babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Misc/performanceMonitor" {
  496. /**
  497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  498. */
  499. export class PerformanceMonitor {
  500. private _enabled;
  501. private _rollingFrameTime;
  502. private _lastFrameTimeMs;
  503. /**
  504. * constructor
  505. * @param frameSampleSize The number of samples required to saturate the sliding window
  506. */
  507. constructor(frameSampleSize?: number);
  508. /**
  509. * Samples current frame
  510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  511. */
  512. sampleFrame(timeMs?: number): void;
  513. /**
  514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  515. */
  516. readonly averageFrameTime: number;
  517. /**
  518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFrameTimeVariance: number;
  521. /**
  522. * Returns the frame time of the most recent frame
  523. */
  524. readonly instantaneousFrameTime: number;
  525. /**
  526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  527. */
  528. readonly averageFPS: number;
  529. /**
  530. * Returns the average framerate in frames per second using the most recent frame time
  531. */
  532. readonly instantaneousFPS: number;
  533. /**
  534. * Returns true if enough samples have been taken to completely fill the sliding window
  535. */
  536. readonly isSaturated: boolean;
  537. /**
  538. * Enables contributions to the sliding window sample set
  539. */
  540. enable(): void;
  541. /**
  542. * Disables contributions to the sliding window sample set
  543. * Samples will not be interpolated over the disabled period
  544. */
  545. disable(): void;
  546. /**
  547. * Returns true if sampling is enabled
  548. */
  549. readonly isEnabled: boolean;
  550. /**
  551. * Resets performance monitor
  552. */
  553. reset(): void;
  554. }
  555. /**
  556. * RollingAverage
  557. *
  558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  559. */
  560. export class RollingAverage {
  561. /**
  562. * Current average
  563. */
  564. average: number;
  565. /**
  566. * Current variance
  567. */
  568. variance: number;
  569. protected _samples: Array<number>;
  570. protected _sampleCount: number;
  571. protected _pos: number;
  572. protected _m2: number;
  573. /**
  574. * constructor
  575. * @param length The number of samples required to saturate the sliding window
  576. */
  577. constructor(length: number);
  578. /**
  579. * Adds a sample to the sample set
  580. * @param v The sample value
  581. */
  582. add(v: number): void;
  583. /**
  584. * Returns previously added values or null if outside of history or outside the sliding window domain
  585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  586. * @return Value previously recorded with add() or null if outside of range
  587. */
  588. history(i: number): number;
  589. /**
  590. * Returns true if enough samples have been taken to completely fill the sliding window
  591. * @return true if sample-set saturated
  592. */
  593. isSaturated(): boolean;
  594. /**
  595. * Resets the rolling average (equivalent to 0 samples taken so far)
  596. */
  597. reset(): void;
  598. /**
  599. * Wraps a value around the sample range boundaries
  600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  601. * @return Wrapped position in sample range
  602. */
  603. protected _wrapPosition(i: number): number;
  604. }
  605. }
  606. declare module "babylonjs/Misc/stringDictionary" {
  607. import { Nullable } from "babylonjs/types";
  608. /**
  609. * This class implement a typical dictionary using a string as key and the generic type T as value.
  610. * The underlying implementation relies on an associative array to ensure the best performances.
  611. * The value can be anything including 'null' but except 'undefined'
  612. */
  613. export class StringDictionary<T> {
  614. /**
  615. * This will clear this dictionary and copy the content from the 'source' one.
  616. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  617. * @param source the dictionary to take the content from and copy to this dictionary
  618. */
  619. copyFrom(source: StringDictionary<T>): void;
  620. /**
  621. * Get a value based from its key
  622. * @param key the given key to get the matching value from
  623. * @return the value if found, otherwise undefined is returned
  624. */
  625. get(key: string): T | undefined;
  626. /**
  627. * Get a value from its key or add it if it doesn't exist.
  628. * This method will ensure you that a given key/data will be present in the dictionary.
  629. * @param key the given key to get the matching value from
  630. * @param factory the factory that will create the value if the key is not present in the dictionary.
  631. * The factory will only be invoked if there's no data for the given key.
  632. * @return the value corresponding to the key.
  633. */
  634. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  635. /**
  636. * Get a value from its key if present in the dictionary otherwise add it
  637. * @param key the key to get the value from
  638. * @param val if there's no such key/value pair in the dictionary add it with this value
  639. * @return the value corresponding to the key
  640. */
  641. getOrAdd(key: string, val: T): T;
  642. /**
  643. * Check if there's a given key in the dictionary
  644. * @param key the key to check for
  645. * @return true if the key is present, false otherwise
  646. */
  647. contains(key: string): boolean;
  648. /**
  649. * Add a new key and its corresponding value
  650. * @param key the key to add
  651. * @param value the value corresponding to the key
  652. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  653. */
  654. add(key: string, value: T): boolean;
  655. /**
  656. * Update a specific value associated to a key
  657. * @param key defines the key to use
  658. * @param value defines the value to store
  659. * @returns true if the value was updated (or false if the key was not found)
  660. */
  661. set(key: string, value: T): boolean;
  662. /**
  663. * Get the element of the given key and remove it from the dictionary
  664. * @param key defines the key to search
  665. * @returns the value associated with the key or null if not found
  666. */
  667. getAndRemove(key: string): Nullable<T>;
  668. /**
  669. * Remove a key/value from the dictionary.
  670. * @param key the key to remove
  671. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  672. */
  673. remove(key: string): boolean;
  674. /**
  675. * Clear the whole content of the dictionary
  676. */
  677. clear(): void;
  678. /**
  679. * Gets the current count
  680. */
  681. readonly count: number;
  682. /**
  683. * Execute a callback on each key/val of the dictionary.
  684. * Note that you can remove any element in this dictionary in the callback implementation
  685. * @param callback the callback to execute on a given key/value pair
  686. */
  687. forEach(callback: (key: string, val: T) => void): void;
  688. /**
  689. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  690. * If the callback returns null or undefined the method will iterate to the next key/value pair
  691. * Note that you can remove any element in this dictionary in the callback implementation
  692. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  693. * @returns the first item
  694. */
  695. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  696. private _count;
  697. private _data;
  698. }
  699. }
  700. declare module "babylonjs/Meshes/dataBuffer" {
  701. /**
  702. * Class used to store gfx data (like WebGLBuffer)
  703. */
  704. export class DataBuffer {
  705. /**
  706. * Gets or sets the number of objects referencing this buffer
  707. */
  708. references: number;
  709. /** Gets or sets the size of the underlying buffer */
  710. capacity: number;
  711. /**
  712. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  713. */
  714. is32Bits: boolean;
  715. /**
  716. * Gets the underlying buffer
  717. */
  718. readonly underlyingResource: any;
  719. }
  720. }
  721. declare module "babylonjs/Meshes/buffer" {
  722. import { Nullable, DataArray } from "babylonjs/types";
  723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  724. /**
  725. * Class used to store data that will be store in GPU memory
  726. */
  727. export class Buffer {
  728. private _engine;
  729. private _buffer;
  730. /** @hidden */
  731. _data: Nullable<DataArray>;
  732. private _updatable;
  733. private _instanced;
  734. /**
  735. * Gets the byte stride.
  736. */
  737. readonly byteStride: number;
  738. /**
  739. * Constructor
  740. * @param engine the engine
  741. * @param data the data to use for this buffer
  742. * @param updatable whether the data is updatable
  743. * @param stride the stride (optional)
  744. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  745. * @param instanced whether the buffer is instanced (optional)
  746. * @param useBytes set to true if the stride in in bytes (optional)
  747. */
  748. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  749. /**
  750. * Create a new VertexBuffer based on the current buffer
  751. * @param kind defines the vertex buffer kind (position, normal, etc.)
  752. * @param offset defines offset in the buffer (0 by default)
  753. * @param size defines the size in floats of attributes (position is 3 for instance)
  754. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  755. * @param instanced defines if the vertex buffer contains indexed data
  756. * @param useBytes defines if the offset and stride are in bytes
  757. * @returns the new vertex buffer
  758. */
  759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  760. /**
  761. * Gets a boolean indicating if the Buffer is updatable?
  762. * @returns true if the buffer is updatable
  763. */
  764. isUpdatable(): boolean;
  765. /**
  766. * Gets current buffer's data
  767. * @returns a DataArray or null
  768. */
  769. getData(): Nullable<DataArray>;
  770. /**
  771. * Gets underlying native buffer
  772. * @returns underlying native buffer
  773. */
  774. getBuffer(): Nullable<DataBuffer>;
  775. /**
  776. * Gets the stride in float32 units (i.e. byte stride / 4).
  777. * May not be an integer if the byte stride is not divisible by 4.
  778. * DEPRECATED. Use byteStride instead.
  779. * @returns the stride in float32 units
  780. */
  781. getStrideSize(): number;
  782. /**
  783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  784. * @param data defines the data to store
  785. */
  786. create(data?: Nullable<DataArray>): void;
  787. /** @hidden */
  788. _rebuild(): void;
  789. /**
  790. * Update current buffer data
  791. * @param data defines the data to store
  792. */
  793. update(data: DataArray): void;
  794. /**
  795. * Updates the data directly.
  796. * @param data the new data
  797. * @param offset the new offset
  798. * @param vertexCount the vertex count (optional)
  799. * @param useBytes set to true if the offset is in bytes
  800. */
  801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  802. /**
  803. * Release all resources
  804. */
  805. dispose(): void;
  806. }
  807. /**
  808. * Specialized buffer used to store vertex data
  809. */
  810. export class VertexBuffer {
  811. /** @hidden */
  812. _buffer: Buffer;
  813. private _kind;
  814. private _size;
  815. private _ownsBuffer;
  816. private _instanced;
  817. private _instanceDivisor;
  818. /**
  819. * The byte type.
  820. */
  821. static readonly BYTE: number;
  822. /**
  823. * The unsigned byte type.
  824. */
  825. static readonly UNSIGNED_BYTE: number;
  826. /**
  827. * The short type.
  828. */
  829. static readonly SHORT: number;
  830. /**
  831. * The unsigned short type.
  832. */
  833. static readonly UNSIGNED_SHORT: number;
  834. /**
  835. * The integer type.
  836. */
  837. static readonly INT: number;
  838. /**
  839. * The unsigned integer type.
  840. */
  841. static readonly UNSIGNED_INT: number;
  842. /**
  843. * The float type.
  844. */
  845. static readonly FLOAT: number;
  846. /**
  847. * Gets or sets the instance divisor when in instanced mode
  848. */
  849. instanceDivisor: number;
  850. /**
  851. * Gets the byte stride.
  852. */
  853. readonly byteStride: number;
  854. /**
  855. * Gets the byte offset.
  856. */
  857. readonly byteOffset: number;
  858. /**
  859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  860. */
  861. readonly normalized: boolean;
  862. /**
  863. * Gets the data type of each component in the array.
  864. */
  865. readonly type: number;
  866. /**
  867. * Constructor
  868. * @param engine the engine
  869. * @param data the data to use for this vertex buffer
  870. * @param kind the vertex buffer kind
  871. * @param updatable whether the data is updatable
  872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  873. * @param stride the stride (optional)
  874. * @param instanced whether the buffer is instanced (optional)
  875. * @param offset the offset of the data (optional)
  876. * @param size the number of components (optional)
  877. * @param type the type of the component (optional)
  878. * @param normalized whether the data contains normalized data (optional)
  879. * @param useBytes set to true if stride and offset are in bytes (optional)
  880. */
  881. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  882. /** @hidden */
  883. _rebuild(): void;
  884. /**
  885. * Returns the kind of the VertexBuffer (string)
  886. * @returns a string
  887. */
  888. getKind(): string;
  889. /**
  890. * Gets a boolean indicating if the VertexBuffer is updatable?
  891. * @returns true if the buffer is updatable
  892. */
  893. isUpdatable(): boolean;
  894. /**
  895. * Gets current buffer's data
  896. * @returns a DataArray or null
  897. */
  898. getData(): Nullable<DataArray>;
  899. /**
  900. * Gets underlying native buffer
  901. * @returns underlying native buffer
  902. */
  903. getBuffer(): Nullable<DataBuffer>;
  904. /**
  905. * Gets the stride in float32 units (i.e. byte stride / 4).
  906. * May not be an integer if the byte stride is not divisible by 4.
  907. * DEPRECATED. Use byteStride instead.
  908. * @returns the stride in float32 units
  909. */
  910. getStrideSize(): number;
  911. /**
  912. * Returns the offset as a multiple of the type byte length.
  913. * DEPRECATED. Use byteOffset instead.
  914. * @returns the offset in bytes
  915. */
  916. getOffset(): number;
  917. /**
  918. * Returns the number of components per vertex attribute (integer)
  919. * @returns the size in float
  920. */
  921. getSize(): number;
  922. /**
  923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  924. * @returns true if this buffer is instanced
  925. */
  926. getIsInstanced(): boolean;
  927. /**
  928. * Returns the instancing divisor, zero for non-instanced (integer).
  929. * @returns a number
  930. */
  931. getInstanceDivisor(): number;
  932. /**
  933. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  934. * @param data defines the data to store
  935. */
  936. create(data?: DataArray): void;
  937. /**
  938. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  939. * This function will create a new buffer if the current one is not updatable
  940. * @param data defines the data to store
  941. */
  942. update(data: DataArray): void;
  943. /**
  944. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  945. * Returns the directly updated WebGLBuffer.
  946. * @param data the new data
  947. * @param offset the new offset
  948. * @param useBytes set to true if the offset is in bytes
  949. */
  950. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  951. /**
  952. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  953. */
  954. dispose(): void;
  955. /**
  956. * Enumerates each value of this vertex buffer as numbers.
  957. * @param count the number of values to enumerate
  958. * @param callback the callback function called for each value
  959. */
  960. forEach(count: number, callback: (value: number, index: number) => void): void;
  961. /**
  962. * Positions
  963. */
  964. static readonly PositionKind: string;
  965. /**
  966. * Normals
  967. */
  968. static readonly NormalKind: string;
  969. /**
  970. * Tangents
  971. */
  972. static readonly TangentKind: string;
  973. /**
  974. * Texture coordinates
  975. */
  976. static readonly UVKind: string;
  977. /**
  978. * Texture coordinates 2
  979. */
  980. static readonly UV2Kind: string;
  981. /**
  982. * Texture coordinates 3
  983. */
  984. static readonly UV3Kind: string;
  985. /**
  986. * Texture coordinates 4
  987. */
  988. static readonly UV4Kind: string;
  989. /**
  990. * Texture coordinates 5
  991. */
  992. static readonly UV5Kind: string;
  993. /**
  994. * Texture coordinates 6
  995. */
  996. static readonly UV6Kind: string;
  997. /**
  998. * Colors
  999. */
  1000. static readonly ColorKind: string;
  1001. /**
  1002. * Matrix indices (for bones)
  1003. */
  1004. static readonly MatricesIndicesKind: string;
  1005. /**
  1006. * Matrix weights (for bones)
  1007. */
  1008. static readonly MatricesWeightsKind: string;
  1009. /**
  1010. * Additional matrix indices (for bones)
  1011. */
  1012. static readonly MatricesIndicesExtraKind: string;
  1013. /**
  1014. * Additional matrix weights (for bones)
  1015. */
  1016. static readonly MatricesWeightsExtraKind: string;
  1017. /**
  1018. * Deduces the stride given a kind.
  1019. * @param kind The kind string to deduce
  1020. * @returns The deduced stride
  1021. */
  1022. static DeduceStride(kind: string): number;
  1023. /**
  1024. * Gets the byte length of the given type.
  1025. * @param type the type
  1026. * @returns the number of bytes
  1027. */
  1028. static GetTypeByteLength(type: number): number;
  1029. /**
  1030. * Enumerates each value of the given parameters as numbers.
  1031. * @param data the data to enumerate
  1032. * @param byteOffset the byte offset of the data
  1033. * @param byteStride the byte stride of the data
  1034. * @param componentCount the number of components per element
  1035. * @param componentType the type of the component
  1036. * @param count the number of values to enumerate
  1037. * @param normalized whether the data is normalized
  1038. * @param callback the callback function called for each value
  1039. */
  1040. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1041. private static _GetFloatValue;
  1042. }
  1043. }
  1044. declare module "babylonjs/Maths/math.scalar" {
  1045. /**
  1046. * Scalar computation library
  1047. */
  1048. export class Scalar {
  1049. /**
  1050. * Two pi constants convenient for computation.
  1051. */
  1052. static TwoPi: number;
  1053. /**
  1054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1055. * @param a number
  1056. * @param b number
  1057. * @param epsilon (default = 1.401298E-45)
  1058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1059. */
  1060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1061. /**
  1062. * Returns a string : the upper case translation of the number i to hexadecimal.
  1063. * @param i number
  1064. * @returns the upper case translation of the number i to hexadecimal.
  1065. */
  1066. static ToHex(i: number): string;
  1067. /**
  1068. * Returns -1 if value is negative and +1 is value is positive.
  1069. * @param value the value
  1070. * @returns the value itself if it's equal to zero.
  1071. */
  1072. static Sign(value: number): number;
  1073. /**
  1074. * Returns the value itself if it's between min and max.
  1075. * Returns min if the value is lower than min.
  1076. * Returns max if the value is greater than max.
  1077. * @param value the value to clmap
  1078. * @param min the min value to clamp to (default: 0)
  1079. * @param max the max value to clamp to (default: 1)
  1080. * @returns the clamped value
  1081. */
  1082. static Clamp(value: number, min?: number, max?: number): number;
  1083. /**
  1084. * the log2 of value.
  1085. * @param value the value to compute log2 of
  1086. * @returns the log2 of value.
  1087. */
  1088. static Log2(value: number): number;
  1089. /**
  1090. * Loops the value, so that it is never larger than length and never smaller than 0.
  1091. *
  1092. * This is similar to the modulo operator but it works with floating point numbers.
  1093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1094. * With t = 5 and length = 2.5, the result would be 0.0.
  1095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1096. * @param value the value
  1097. * @param length the length
  1098. * @returns the looped value
  1099. */
  1100. static Repeat(value: number, length: number): number;
  1101. /**
  1102. * Normalize the value between 0.0 and 1.0 using min and max values
  1103. * @param value value to normalize
  1104. * @param min max to normalize between
  1105. * @param max min to normalize between
  1106. * @returns the normalized value
  1107. */
  1108. static Normalize(value: number, min: number, max: number): number;
  1109. /**
  1110. * Denormalize the value from 0.0 and 1.0 using min and max values
  1111. * @param normalized value to denormalize
  1112. * @param min max to denormalize between
  1113. * @param max min to denormalize between
  1114. * @returns the denormalized value
  1115. */
  1116. static Denormalize(normalized: number, min: number, max: number): number;
  1117. /**
  1118. * Calculates the shortest difference between two given angles given in degrees.
  1119. * @param current current angle in degrees
  1120. * @param target target angle in degrees
  1121. * @returns the delta
  1122. */
  1123. static DeltaAngle(current: number, target: number): number;
  1124. /**
  1125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1126. * @param tx value
  1127. * @param length length
  1128. * @returns The returned value will move back and forth between 0 and length
  1129. */
  1130. static PingPong(tx: number, length: number): number;
  1131. /**
  1132. * Interpolates between min and max with smoothing at the limits.
  1133. *
  1134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1136. * @param from from
  1137. * @param to to
  1138. * @param tx value
  1139. * @returns the smooth stepped value
  1140. */
  1141. static SmoothStep(from: number, to: number, tx: number): number;
  1142. /**
  1143. * Moves a value current towards target.
  1144. *
  1145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1146. * Negative values of maxDelta pushes the value away from target.
  1147. * @param current current value
  1148. * @param target target value
  1149. * @param maxDelta max distance to move
  1150. * @returns resulting value
  1151. */
  1152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1153. /**
  1154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1155. *
  1156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1158. * @param current current value
  1159. * @param target target value
  1160. * @param maxDelta max distance to move
  1161. * @returns resulting angle
  1162. */
  1163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1164. /**
  1165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1166. * @param start start value
  1167. * @param end target value
  1168. * @param amount amount to lerp between
  1169. * @returns the lerped value
  1170. */
  1171. static Lerp(start: number, end: number, amount: number): number;
  1172. /**
  1173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1175. * @param start start value
  1176. * @param end target value
  1177. * @param amount amount to lerp between
  1178. * @returns the lerped value
  1179. */
  1180. static LerpAngle(start: number, end: number, amount: number): number;
  1181. /**
  1182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1183. * @param a start value
  1184. * @param b target value
  1185. * @param value value between a and b
  1186. * @returns the inverseLerp value
  1187. */
  1188. static InverseLerp(a: number, b: number, value: number): number;
  1189. /**
  1190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1192. * @param value1 spline value
  1193. * @param tangent1 spline value
  1194. * @param value2 spline value
  1195. * @param tangent2 spline value
  1196. * @param amount input value
  1197. * @returns hermite result
  1198. */
  1199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1200. /**
  1201. * Returns a random float number between and min and max values
  1202. * @param min min value of random
  1203. * @param max max value of random
  1204. * @returns random value
  1205. */
  1206. static RandomRange(min: number, max: number): number;
  1207. /**
  1208. * This function returns percentage of a number in a given range.
  1209. *
  1210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1212. * @param number to convert to percentage
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the percentage
  1216. */
  1217. static RangeToPercent(number: number, min: number, max: number): number;
  1218. /**
  1219. * This function returns number that corresponds to the percentage in a given range.
  1220. *
  1221. * PercentToRange(0.34,0,100) will return 34.
  1222. * @param percent to convert to number
  1223. * @param min min range
  1224. * @param max max range
  1225. * @returns the number
  1226. */
  1227. static PercentToRange(percent: number, min: number, max: number): number;
  1228. /**
  1229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1230. * @param angle The angle to normalize in radian.
  1231. * @return The converted angle.
  1232. */
  1233. static NormalizeRadians(angle: number): number;
  1234. }
  1235. }
  1236. declare module "babylonjs/Maths/math.constants" {
  1237. /**
  1238. * Constant used to convert a value to gamma space
  1239. * @ignorenaming
  1240. */
  1241. export const ToGammaSpace: number;
  1242. /**
  1243. * Constant used to convert a value to linear space
  1244. * @ignorenaming
  1245. */
  1246. export const ToLinearSpace = 2.2;
  1247. /**
  1248. * Constant used to define the minimal number value in Babylon.js
  1249. * @ignorenaming
  1250. */
  1251. let Epsilon: number;
  1252. export { Epsilon };
  1253. }
  1254. declare module "babylonjs/Maths/math.viewport" {
  1255. /**
  1256. * Class used to represent a viewport on screen
  1257. */
  1258. export class Viewport {
  1259. /** viewport left coordinate */
  1260. x: number;
  1261. /** viewport top coordinate */
  1262. y: number;
  1263. /**viewport width */
  1264. width: number;
  1265. /** viewport height */
  1266. height: number;
  1267. /**
  1268. * Creates a Viewport object located at (x, y) and sized (width, height)
  1269. * @param x defines viewport left coordinate
  1270. * @param y defines viewport top coordinate
  1271. * @param width defines the viewport width
  1272. * @param height defines the viewport height
  1273. */
  1274. constructor(
  1275. /** viewport left coordinate */
  1276. x: number,
  1277. /** viewport top coordinate */
  1278. y: number,
  1279. /**viewport width */
  1280. width: number,
  1281. /** viewport height */
  1282. height: number);
  1283. /**
  1284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1285. * @param renderWidth defines the rendering width
  1286. * @param renderHeight defines the rendering height
  1287. * @returns a new Viewport
  1288. */
  1289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1290. /**
  1291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1292. * @param renderWidth defines the rendering width
  1293. * @param renderHeight defines the rendering height
  1294. * @param ref defines the target viewport
  1295. * @returns the current viewport
  1296. */
  1297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1298. /**
  1299. * Returns a new Viewport copied from the current one
  1300. * @returns a new Viewport
  1301. */
  1302. clone(): Viewport;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/arrayTools" {
  1306. /**
  1307. * Class containing a set of static utilities functions for arrays.
  1308. */
  1309. export class ArrayTools {
  1310. /**
  1311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1312. * @param size the number of element to construct and put in the array
  1313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1314. * @returns a new array filled with new objects
  1315. */
  1316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1317. }
  1318. }
  1319. declare module "babylonjs/Maths/math.like" {
  1320. import { float, int, DeepImmutable } from "babylonjs/types";
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IColor4Like {
  1325. r: float;
  1326. g: float;
  1327. b: float;
  1328. a: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IColor3Like {
  1334. r: float;
  1335. g: float;
  1336. b: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector4Like {
  1342. x: float;
  1343. y: float;
  1344. z: float;
  1345. w: float;
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export interface IVector3Like {
  1351. x: float;
  1352. y: float;
  1353. z: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IVector2Like {
  1359. x: float;
  1360. y: float;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IMatrixLike {
  1366. toArray(): DeepImmutable<Float32Array>;
  1367. updateFlag: int;
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export interface IViewportLike {
  1373. x: float;
  1374. y: float;
  1375. width: float;
  1376. height: float;
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export interface IPlaneLike {
  1382. normal: IVector3Like;
  1383. d: float;
  1384. normalize(): void;
  1385. }
  1386. }
  1387. declare module "babylonjs/Maths/math.vector" {
  1388. import { Viewport } from "babylonjs/Maths/math.viewport";
  1389. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1390. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1391. /**
  1392. * Class representing a vector containing 2 coordinates
  1393. */
  1394. export class Vector2 {
  1395. /** defines the first coordinate */
  1396. x: number;
  1397. /** defines the second coordinate */
  1398. y: number;
  1399. /**
  1400. * Creates a new Vector2 from the given x and y coordinates
  1401. * @param x defines the first coordinate
  1402. * @param y defines the second coordinate
  1403. */
  1404. constructor(
  1405. /** defines the first coordinate */
  1406. x?: number,
  1407. /** defines the second coordinate */
  1408. y?: number);
  1409. /**
  1410. * Gets a string with the Vector2 coordinates
  1411. * @returns a string with the Vector2 coordinates
  1412. */
  1413. toString(): string;
  1414. /**
  1415. * Gets class name
  1416. * @returns the string "Vector2"
  1417. */
  1418. getClassName(): string;
  1419. /**
  1420. * Gets current vector hash code
  1421. * @returns the Vector2 hash code as a number
  1422. */
  1423. getHashCode(): number;
  1424. /**
  1425. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1426. * @param array defines the source array
  1427. * @param index defines the offset in source array
  1428. * @returns the current Vector2
  1429. */
  1430. toArray(array: FloatArray, index?: number): Vector2;
  1431. /**
  1432. * Copy the current vector to an array
  1433. * @returns a new array with 2 elements: the Vector2 coordinates.
  1434. */
  1435. asArray(): number[];
  1436. /**
  1437. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1438. * @param source defines the source Vector2
  1439. * @returns the current updated Vector2
  1440. */
  1441. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the Vector2 coordinates with the given floats
  1444. * @param x defines the first coordinate
  1445. * @param y defines the second coordinate
  1446. * @returns the current updated Vector2
  1447. */
  1448. copyFromFloats(x: number, y: number): Vector2;
  1449. /**
  1450. * Sets the Vector2 coordinates with the given floats
  1451. * @param x defines the first coordinate
  1452. * @param y defines the second coordinate
  1453. * @returns the current updated Vector2
  1454. */
  1455. set(x: number, y: number): Vector2;
  1456. /**
  1457. * Add another vector with the current one
  1458. * @param otherVector defines the other vector
  1459. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1460. */
  1461. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1462. /**
  1463. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1464. * @param otherVector defines the other vector
  1465. * @param result defines the target vector
  1466. * @returns the unmodified current Vector2
  1467. */
  1468. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1469. /**
  1470. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1471. * @param otherVector defines the other vector
  1472. * @returns the current updated Vector2
  1473. */
  1474. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1475. /**
  1476. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1477. * @param otherVector defines the other vector
  1478. * @returns a new Vector2
  1479. */
  1480. addVector3(otherVector: Vector3): Vector2;
  1481. /**
  1482. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1483. * @param otherVector defines the other vector
  1484. * @returns a new Vector2
  1485. */
  1486. subtract(otherVector: Vector2): Vector2;
  1487. /**
  1488. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1489. * @param otherVector defines the other vector
  1490. * @param result defines the target vector
  1491. * @returns the unmodified current Vector2
  1492. */
  1493. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1494. /**
  1495. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1496. * @param otherVector defines the other vector
  1497. * @returns the current updated Vector2
  1498. */
  1499. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1500. /**
  1501. * Multiplies in place the current Vector2 coordinates by the given ones
  1502. * @param otherVector defines the other vector
  1503. * @returns the current updated Vector2
  1504. */
  1505. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1512. /**
  1513. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1521. * @param x defines the first coordinate
  1522. * @param y defines the second coordinate
  1523. * @returns a new Vector2
  1524. */
  1525. multiplyByFloats(x: number, y: number): Vector2;
  1526. /**
  1527. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1528. * @param otherVector defines the other vector
  1529. * @returns a new Vector2
  1530. */
  1531. divide(otherVector: Vector2): Vector2;
  1532. /**
  1533. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1534. * @param otherVector defines the other vector
  1535. * @param result defines the target vector
  1536. * @returns the unmodified current Vector2
  1537. */
  1538. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1539. /**
  1540. * Divides the current Vector2 coordinates by the given ones
  1541. * @param otherVector defines the other vector
  1542. * @returns the current updated Vector2
  1543. */
  1544. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1545. /**
  1546. * Gets a new Vector2 with current Vector2 negated coordinates
  1547. * @returns a new Vector2
  1548. */
  1549. negate(): Vector2;
  1550. /**
  1551. * Multiply the Vector2 coordinates by scale
  1552. * @param scale defines the scaling factor
  1553. * @returns the current updated Vector2
  1554. */
  1555. scaleInPlace(scale: number): Vector2;
  1556. /**
  1557. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1558. * @param scale defines the scaling factor
  1559. * @returns a new Vector2
  1560. */
  1561. scale(scale: number): Vector2;
  1562. /**
  1563. * Scale the current Vector2 values by a factor to a given Vector2
  1564. * @param scale defines the scale factor
  1565. * @param result defines the Vector2 object where to store the result
  1566. * @returns the unmodified current Vector2
  1567. */
  1568. scaleToRef(scale: number, result: Vector2): Vector2;
  1569. /**
  1570. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1571. * @param scale defines the scale factor
  1572. * @param result defines the Vector2 object where to store the result
  1573. * @returns the unmodified current Vector2
  1574. */
  1575. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1576. /**
  1577. * Gets a boolean if two vectors are equals
  1578. * @param otherVector defines the other vector
  1579. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1580. */
  1581. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1582. /**
  1583. * Gets a boolean if two vectors are equals (using an epsilon value)
  1584. * @param otherVector defines the other vector
  1585. * @param epsilon defines the minimal distance to consider equality
  1586. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1587. */
  1588. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. floor(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 from current Vector2 floored values
  1596. * @returns a new Vector2
  1597. */
  1598. fract(): Vector2;
  1599. /**
  1600. * Gets the length of the vector
  1601. * @returns the vector length (float)
  1602. */
  1603. length(): number;
  1604. /**
  1605. * Gets the vector squared length
  1606. * @returns the vector squared length (float)
  1607. */
  1608. lengthSquared(): number;
  1609. /**
  1610. * Normalize the vector
  1611. * @returns the current updated Vector2
  1612. */
  1613. normalize(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 copied from the Vector2
  1616. * @returns a new Vector2
  1617. */
  1618. clone(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(0, 0)
  1621. * @returns a new Vector2
  1622. */
  1623. static Zero(): Vector2;
  1624. /**
  1625. * Gets a new Vector2(1, 1)
  1626. * @returns a new Vector2
  1627. */
  1628. static One(): Vector2;
  1629. /**
  1630. * Gets a new Vector2 set from the given index element of the given array
  1631. * @param array defines the data source
  1632. * @param offset defines the offset in the data source
  1633. * @returns a new Vector2
  1634. */
  1635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1636. /**
  1637. * Sets "result" from the given index element of the given array
  1638. * @param array defines the data source
  1639. * @param offset defines the offset in the data source
  1640. * @param result defines the target vector
  1641. */
  1642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1643. /**
  1644. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1645. * @param value1 defines 1st point of control
  1646. * @param value2 defines 2nd point of control
  1647. * @param value3 defines 3rd point of control
  1648. * @param value4 defines 4th point of control
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1655. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1656. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1657. * @param value defines the value to clamp
  1658. * @param min defines the lower limit
  1659. * @param max defines the upper limit
  1660. * @returns a new Vector2
  1661. */
  1662. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1665. * @param value1 defines the 1st control point
  1666. * @param tangent1 defines the outgoing tangent
  1667. * @param value2 defines the 2nd control point
  1668. * @param tangent2 defines the incoming tangent
  1669. * @param amount defines the interpolation factor
  1670. * @returns a new Vector2
  1671. */
  1672. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1673. /**
  1674. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1675. * @param start defines the start vector
  1676. * @param end defines the end vector
  1677. * @param amount defines the interpolation factor
  1678. * @returns a new Vector2
  1679. */
  1680. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1681. /**
  1682. * Gets the dot product of the vector "left" and the vector "right"
  1683. * @param left defines first vector
  1684. * @param right defines second vector
  1685. * @returns the dot product (float)
  1686. */
  1687. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1688. /**
  1689. * Returns a new Vector2 equal to the normalized given vector
  1690. * @param vector defines the vector to normalize
  1691. * @returns a new Vector2
  1692. */
  1693. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1694. /**
  1695. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1696. * @param left defines 1st vector
  1697. * @param right defines 2nd vector
  1698. * @returns a new Vector2
  1699. */
  1700. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1701. /**
  1702. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1703. * @param left defines 1st vector
  1704. * @param right defines 2nd vector
  1705. * @returns a new Vector2
  1706. */
  1707. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1708. /**
  1709. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1710. * @param vector defines the vector to transform
  1711. * @param transformation defines the matrix to apply
  1712. * @returns a new Vector2
  1713. */
  1714. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1715. /**
  1716. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1717. * @param vector defines the vector to transform
  1718. * @param transformation defines the matrix to apply
  1719. * @param result defines the target vector
  1720. */
  1721. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1722. /**
  1723. * Determines if a given vector is included in a triangle
  1724. * @param p defines the vector to test
  1725. * @param p0 defines 1st triangle point
  1726. * @param p1 defines 2nd triangle point
  1727. * @param p2 defines 3rd triangle point
  1728. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1729. */
  1730. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1731. /**
  1732. * Gets the distance between the vectors "value1" and "value2"
  1733. * @param value1 defines first vector
  1734. * @param value2 defines second vector
  1735. * @returns the distance between vectors
  1736. */
  1737. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1738. /**
  1739. * Returns the squared distance between the vectors "value1" and "value2"
  1740. * @param value1 defines first vector
  1741. * @param value2 defines second vector
  1742. * @returns the squared distance between vectors
  1743. */
  1744. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1745. /**
  1746. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1747. * @param value1 defines first vector
  1748. * @param value2 defines second vector
  1749. * @returns a new Vector2
  1750. */
  1751. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1752. /**
  1753. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1754. * @param p defines the middle point
  1755. * @param segA defines one point of the segment
  1756. * @param segB defines the other point of the segment
  1757. * @returns the shortest distance
  1758. */
  1759. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1760. }
  1761. /**
  1762. * Classed used to store (x,y,z) vector representation
  1763. * A Vector3 is the main object used in 3D geometry
  1764. * It can represent etiher the coordinates of a point the space, either a direction
  1765. * Reminder: js uses a left handed forward facing system
  1766. */
  1767. export class Vector3 {
  1768. /**
  1769. * Defines the first coordinates (on X axis)
  1770. */
  1771. x: number;
  1772. /**
  1773. * Defines the second coordinates (on Y axis)
  1774. */
  1775. y: number;
  1776. /**
  1777. * Defines the third coordinates (on Z axis)
  1778. */
  1779. z: number;
  1780. private static _UpReadOnly;
  1781. private static _ZeroReadOnly;
  1782. /**
  1783. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1784. * @param x defines the first coordinates (on X axis)
  1785. * @param y defines the second coordinates (on Y axis)
  1786. * @param z defines the third coordinates (on Z axis)
  1787. */
  1788. constructor(
  1789. /**
  1790. * Defines the first coordinates (on X axis)
  1791. */
  1792. x?: number,
  1793. /**
  1794. * Defines the second coordinates (on Y axis)
  1795. */
  1796. y?: number,
  1797. /**
  1798. * Defines the third coordinates (on Z axis)
  1799. */
  1800. z?: number);
  1801. /**
  1802. * Creates a string representation of the Vector3
  1803. * @returns a string with the Vector3 coordinates.
  1804. */
  1805. toString(): string;
  1806. /**
  1807. * Gets the class name
  1808. * @returns the string "Vector3"
  1809. */
  1810. getClassName(): string;
  1811. /**
  1812. * Creates the Vector3 hash code
  1813. * @returns a number which tends to be unique between Vector3 instances
  1814. */
  1815. getHashCode(): number;
  1816. /**
  1817. * Creates an array containing three elements : the coordinates of the Vector3
  1818. * @returns a new array of numbers
  1819. */
  1820. asArray(): number[];
  1821. /**
  1822. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1823. * @param array defines the destination array
  1824. * @param index defines the offset in the destination array
  1825. * @returns the current Vector3
  1826. */
  1827. toArray(array: FloatArray, index?: number): Vector3;
  1828. /**
  1829. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1830. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1831. */
  1832. toQuaternion(): Quaternion;
  1833. /**
  1834. * Adds the given vector to the current Vector3
  1835. * @param otherVector defines the second operand
  1836. * @returns the current updated Vector3
  1837. */
  1838. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1839. /**
  1840. * Adds the given coordinates to the current Vector3
  1841. * @param x defines the x coordinate of the operand
  1842. * @param y defines the y coordinate of the operand
  1843. * @param z defines the z coordinate of the operand
  1844. * @returns the current updated Vector3
  1845. */
  1846. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1847. /**
  1848. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1849. * @param otherVector defines the second operand
  1850. * @returns the resulting Vector3
  1851. */
  1852. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1853. /**
  1854. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1855. * @param otherVector defines the second operand
  1856. * @param result defines the Vector3 object where to store the result
  1857. * @returns the current Vector3
  1858. */
  1859. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1860. /**
  1861. * Subtract the given vector from the current Vector3
  1862. * @param otherVector defines the second operand
  1863. * @returns the current updated Vector3
  1864. */
  1865. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1866. /**
  1867. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1868. * @param otherVector defines the second operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1872. /**
  1873. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1874. * @param otherVector defines the second operand
  1875. * @param result defines the Vector3 object where to store the result
  1876. * @returns the current Vector3
  1877. */
  1878. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1879. /**
  1880. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1881. * @param x defines the x coordinate of the operand
  1882. * @param y defines the y coordinate of the operand
  1883. * @param z defines the z coordinate of the operand
  1884. * @returns the resulting Vector3
  1885. */
  1886. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1887. /**
  1888. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1889. * @param x defines the x coordinate of the operand
  1890. * @param y defines the y coordinate of the operand
  1891. * @param z defines the z coordinate of the operand
  1892. * @param result defines the Vector3 object where to store the result
  1893. * @returns the current Vector3
  1894. */
  1895. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1896. /**
  1897. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1898. * @returns a new Vector3
  1899. */
  1900. negate(): Vector3;
  1901. /**
  1902. * Multiplies the Vector3 coordinates by the float "scale"
  1903. * @param scale defines the multiplier factor
  1904. * @returns the current updated Vector3
  1905. */
  1906. scaleInPlace(scale: number): Vector3;
  1907. /**
  1908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1909. * @param scale defines the multiplier factor
  1910. * @returns a new Vector3
  1911. */
  1912. scale(scale: number): Vector3;
  1913. /**
  1914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1915. * @param scale defines the multiplier factor
  1916. * @param result defines the Vector3 object where to store the result
  1917. * @returns the current Vector3
  1918. */
  1919. scaleToRef(scale: number, result: Vector3): Vector3;
  1920. /**
  1921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1922. * @param scale defines the scale factor
  1923. * @param result defines the Vector3 object where to store the result
  1924. * @returns the unmodified current Vector3
  1925. */
  1926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1927. /**
  1928. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1929. * @param otherVector defines the second operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1933. /**
  1934. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1935. * @param otherVector defines the second operand
  1936. * @param epsilon defines the minimal distance to define values as equals
  1937. * @returns true if both vectors are distant less than epsilon
  1938. */
  1939. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1940. /**
  1941. * Returns true if the current Vector3 coordinates equals the given floats
  1942. * @param x defines the x coordinate of the operand
  1943. * @param y defines the y coordinate of the operand
  1944. * @param z defines the z coordinate of the operand
  1945. * @returns true if both vectors are equals
  1946. */
  1947. equalsToFloats(x: number, y: number, z: number): boolean;
  1948. /**
  1949. * Multiplies the current Vector3 coordinates by the given ones
  1950. * @param otherVector defines the second operand
  1951. * @returns the current updated Vector3
  1952. */
  1953. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1956. * @param otherVector defines the second operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1960. /**
  1961. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1962. * @param otherVector defines the second operand
  1963. * @param result defines the Vector3 object where to store the result
  1964. * @returns the current Vector3
  1965. */
  1966. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1967. /**
  1968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1969. * @param x defines the x coordinate of the operand
  1970. * @param y defines the y coordinate of the operand
  1971. * @param z defines the z coordinate of the operand
  1972. * @returns the new Vector3
  1973. */
  1974. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1975. /**
  1976. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1977. * @param otherVector defines the second operand
  1978. * @returns the new Vector3
  1979. */
  1980. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1981. /**
  1982. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1983. * @param otherVector defines the second operand
  1984. * @param result defines the Vector3 object where to store the result
  1985. * @returns the current Vector3
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1988. /**
  1989. * Divides the current Vector3 coordinates by the given ones.
  1990. * @param otherVector defines the second operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. divideInPlace(otherVector: Vector3): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1996. * @param other defines the second operand
  1997. * @returns the current updated Vector3
  1998. */
  1999. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2000. /**
  2001. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2002. * @param other defines the second operand
  2003. * @returns the current updated Vector3
  2004. */
  2005. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2006. /**
  2007. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2008. * @param x defines the x coordinate of the operand
  2009. * @param y defines the y coordinate of the operand
  2010. * @param z defines the z coordinate of the operand
  2011. * @returns the current updated Vector3
  2012. */
  2013. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2014. /**
  2015. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2016. * @param x defines the x coordinate of the operand
  2017. * @param y defines the y coordinate of the operand
  2018. * @param z defines the z coordinate of the operand
  2019. * @returns the current updated Vector3
  2020. */
  2021. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2022. /**
  2023. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2024. * Check if is non uniform within a certain amount of decimal places to account for this
  2025. * @param epsilon the amount the values can differ
  2026. * @returns if the the vector is non uniform to a certain number of decimal places
  2027. */
  2028. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2029. /**
  2030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2031. */
  2032. readonly isNonUniform: boolean;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. floor(): Vector3;
  2038. /**
  2039. * Gets a new Vector3 from current Vector3 floored values
  2040. * @returns a new Vector3
  2041. */
  2042. fract(): Vector3;
  2043. /**
  2044. * Gets the length of the Vector3
  2045. * @returns the length of the Vector3
  2046. */
  2047. length(): number;
  2048. /**
  2049. * Gets the squared length of the Vector3
  2050. * @returns squared length of the Vector3
  2051. */
  2052. lengthSquared(): number;
  2053. /**
  2054. * Normalize the current Vector3.
  2055. * Please note that this is an in place operation.
  2056. * @returns the current updated Vector3
  2057. */
  2058. normalize(): Vector3;
  2059. /**
  2060. * Reorders the x y z properties of the vector in place
  2061. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2062. * @returns the current updated vector
  2063. */
  2064. reorderInPlace(order: string): this;
  2065. /**
  2066. * Rotates the vector around 0,0,0 by a quaternion
  2067. * @param quaternion the rotation quaternion
  2068. * @param result vector to store the result
  2069. * @returns the resulting vector
  2070. */
  2071. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2072. /**
  2073. * Rotates a vector around a given point
  2074. * @param quaternion the rotation quaternion
  2075. * @param point the point to rotate around
  2076. * @param result vector to store the result
  2077. * @returns the resulting vector
  2078. */
  2079. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2080. /**
  2081. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2082. * The cross product is then orthogonal to both current and "other"
  2083. * @param other defines the right operand
  2084. * @returns the cross product
  2085. */
  2086. cross(other: Vector3): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 with the given input length.
  2089. * Please note that this is an in place operation.
  2090. * @param len the length of the vector
  2091. * @returns the current updated Vector3
  2092. */
  2093. normalizeFromLength(len: number): Vector3;
  2094. /**
  2095. * Normalize the current Vector3 to a new vector
  2096. * @returns the new Vector3
  2097. */
  2098. normalizeToNew(): Vector3;
  2099. /**
  2100. * Normalize the current Vector3 to the reference
  2101. * @param reference define the Vector3 to update
  2102. * @returns the updated Vector3
  2103. */
  2104. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2105. /**
  2106. * Creates a new Vector3 copied from the current Vector3
  2107. * @returns the new Vector3
  2108. */
  2109. clone(): Vector3;
  2110. /**
  2111. * Copies the given vector coordinates to the current Vector3 ones
  2112. * @param source defines the source Vector3
  2113. * @returns the current updated Vector3
  2114. */
  2115. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2116. /**
  2117. * Copies the given floats to the current Vector3 coordinates
  2118. * @param x defines the x coordinate of the operand
  2119. * @param y defines the y coordinate of the operand
  2120. * @param z defines the z coordinate of the operand
  2121. * @returns the current updated Vector3
  2122. */
  2123. copyFromFloats(x: number, y: number, z: number): Vector3;
  2124. /**
  2125. * Copies the given floats to the current Vector3 coordinates
  2126. * @param x defines the x coordinate of the operand
  2127. * @param y defines the y coordinate of the operand
  2128. * @param z defines the z coordinate of the operand
  2129. * @returns the current updated Vector3
  2130. */
  2131. set(x: number, y: number, z: number): Vector3;
  2132. /**
  2133. * Copies the given float to the current Vector3 coordinates
  2134. * @param v defines the x, y and z coordinates of the operand
  2135. * @returns the current updated Vector3
  2136. */
  2137. setAll(v: number): Vector3;
  2138. /**
  2139. * Get the clip factor between two vectors
  2140. * @param vector0 defines the first operand
  2141. * @param vector1 defines the second operand
  2142. * @param axis defines the axis to use
  2143. * @param size defines the size along the axis
  2144. * @returns the clip factor
  2145. */
  2146. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2147. /**
  2148. * Get angle between two vectors
  2149. * @param vector0 angle between vector0 and vector1
  2150. * @param vector1 angle between vector0 and vector1
  2151. * @param normal direction of the normal
  2152. * @return the angle between vector0 and vector1
  2153. */
  2154. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2155. /**
  2156. * Returns a new Vector3 set from the index "offset" of the given array
  2157. * @param array defines the source array
  2158. * @param offset defines the offset in the source array
  2159. * @returns the new Vector3
  2160. */
  2161. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2162. /**
  2163. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2164. * This function is deprecated. Use FromArray instead
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @returns the new Vector3
  2168. */
  2169. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2170. /**
  2171. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2172. * @param array defines the source array
  2173. * @param offset defines the offset in the source array
  2174. * @param result defines the Vector3 where to store the result
  2175. */
  2176. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2177. /**
  2178. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2179. * This function is deprecated. Use FromArrayToRef instead.
  2180. * @param array defines the source array
  2181. * @param offset defines the offset in the source array
  2182. * @param result defines the Vector3 where to store the result
  2183. */
  2184. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2185. /**
  2186. * Sets the given vector "result" with the given floats.
  2187. * @param x defines the x coordinate of the source
  2188. * @param y defines the y coordinate of the source
  2189. * @param z defines the z coordinate of the source
  2190. * @param result defines the Vector3 where to store the result
  2191. */
  2192. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2193. /**
  2194. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2195. * @returns a new empty Vector3
  2196. */
  2197. static Zero(): Vector3;
  2198. /**
  2199. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2200. * @returns a new unit Vector3
  2201. */
  2202. static One(): Vector3;
  2203. /**
  2204. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2205. * @returns a new up Vector3
  2206. */
  2207. static Up(): Vector3;
  2208. /**
  2209. * Gets a up Vector3 that must not be updated
  2210. */
  2211. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2212. /**
  2213. * Gets a zero Vector3 that must not be updated
  2214. */
  2215. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2216. /**
  2217. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2218. * @returns a new down Vector3
  2219. */
  2220. static Down(): Vector3;
  2221. /**
  2222. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2223. * @returns a new forward Vector3
  2224. */
  2225. static Forward(): Vector3;
  2226. /**
  2227. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2228. * @returns a new forward Vector3
  2229. */
  2230. static Backward(): Vector3;
  2231. /**
  2232. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2233. * @returns a new right Vector3
  2234. */
  2235. static Right(): Vector3;
  2236. /**
  2237. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2238. * @returns a new left Vector3
  2239. */
  2240. static Left(): Vector3;
  2241. /**
  2242. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2243. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2244. * @param vector defines the Vector3 to transform
  2245. * @param transformation defines the transformation matrix
  2246. * @returns the transformed Vector3
  2247. */
  2248. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2249. /**
  2250. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2251. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2252. * @param vector defines the Vector3 to transform
  2253. * @param transformation defines the transformation matrix
  2254. * @param result defines the Vector3 where to store the result
  2255. */
  2256. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2257. /**
  2258. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2259. * This method computes tranformed coordinates only, not transformed direction vectors
  2260. * @param x define the x coordinate of the source vector
  2261. * @param y define the y coordinate of the source vector
  2262. * @param z define the z coordinate of the source vector
  2263. * @param transformation defines the transformation matrix
  2264. * @param result defines the Vector3 where to store the result
  2265. */
  2266. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2267. /**
  2268. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2269. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2270. * @param vector defines the Vector3 to transform
  2271. * @param transformation defines the transformation matrix
  2272. * @returns the new Vector3
  2273. */
  2274. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2275. /**
  2276. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2277. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2278. * @param vector defines the Vector3 to transform
  2279. * @param transformation defines the transformation matrix
  2280. * @param result defines the Vector3 where to store the result
  2281. */
  2282. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2283. /**
  2284. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2285. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2286. * @param x define the x coordinate of the source vector
  2287. * @param y define the y coordinate of the source vector
  2288. * @param z define the z coordinate of the source vector
  2289. * @param transformation defines the transformation matrix
  2290. * @param result defines the Vector3 where to store the result
  2291. */
  2292. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2293. /**
  2294. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2295. * @param value1 defines the first control point
  2296. * @param value2 defines the second control point
  2297. * @param value3 defines the third control point
  2298. * @param value4 defines the fourth control point
  2299. * @param amount defines the amount on the spline to use
  2300. * @returns the new Vector3
  2301. */
  2302. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2303. /**
  2304. * 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"
  2305. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2306. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2307. * @param value defines the current value
  2308. * @param min defines the lower range value
  2309. * @param max defines the upper range value
  2310. * @returns the new Vector3
  2311. */
  2312. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2313. /**
  2314. * 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"
  2315. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2316. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2317. * @param value defines the current value
  2318. * @param min defines the lower range value
  2319. * @param max defines the upper range value
  2320. * @param result defines the Vector3 where to store the result
  2321. */
  2322. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2323. /**
  2324. * Checks if a given vector is inside a specific range
  2325. * @param v defines the vector to test
  2326. * @param min defines the minimum range
  2327. * @param max defines the maximum range
  2328. */
  2329. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2330. /**
  2331. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2332. * @param value1 defines the first control point
  2333. * @param tangent1 defines the first tangent vector
  2334. * @param value2 defines the second control point
  2335. * @param tangent2 defines the second tangent vector
  2336. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2337. * @returns the new Vector3
  2338. */
  2339. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2340. /**
  2341. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2342. * @param start defines the start value
  2343. * @param end defines the end value
  2344. * @param amount max defines amount between both (between 0 and 1)
  2345. * @returns the new Vector3
  2346. */
  2347. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2348. /**
  2349. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2350. * @param start defines the start value
  2351. * @param end defines the end value
  2352. * @param amount max defines amount between both (between 0 and 1)
  2353. * @param result defines the Vector3 where to store the result
  2354. */
  2355. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2356. /**
  2357. * Returns the dot product (float) between the vectors "left" and "right"
  2358. * @param left defines the left operand
  2359. * @param right defines the right operand
  2360. * @returns the dot product
  2361. */
  2362. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2363. /**
  2364. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2365. * The cross product is then orthogonal to both "left" and "right"
  2366. * @param left defines the left operand
  2367. * @param right defines the right operand
  2368. * @returns the cross product
  2369. */
  2370. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Sets the given vector "result" with the cross product of "left" and "right"
  2373. * The cross product is then orthogonal to both "left" and "right"
  2374. * @param left defines the left operand
  2375. * @param right defines the right operand
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2379. /**
  2380. * Returns a new Vector3 as the normalization of the given vector
  2381. * @param vector defines the Vector3 to normalize
  2382. * @returns the new Vector3
  2383. */
  2384. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2385. /**
  2386. * Sets the given vector "result" with the normalization of the given first vector
  2387. * @param vector defines the Vector3 to normalize
  2388. * @param result defines the Vector3 where to store the result
  2389. */
  2390. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2391. /**
  2392. * Project a Vector3 onto screen space
  2393. * @param vector defines the Vector3 to project
  2394. * @param world defines the world matrix to use
  2395. * @param transform defines the transform (view x projection) matrix to use
  2396. * @param viewport defines the screen viewport to use
  2397. * @returns the new Vector3
  2398. */
  2399. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2400. /** @hidden */
  2401. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2402. /**
  2403. * Unproject from screen space to object space
  2404. * @param source defines the screen space Vector3 to use
  2405. * @param viewportWidth defines the current width of the viewport
  2406. * @param viewportHeight defines the current height of the viewport
  2407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2408. * @param transform defines the transform (view x projection) matrix to use
  2409. * @returns the new Vector3
  2410. */
  2411. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param source defines the screen space Vector3 to use
  2415. * @param viewportWidth defines the current width of the viewport
  2416. * @param viewportHeight defines the current height of the viewport
  2417. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2418. * @param view defines the view matrix to use
  2419. * @param projection defines the projection matrix to use
  2420. * @returns the new Vector3
  2421. */
  2422. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2423. /**
  2424. * Unproject from screen space to object space
  2425. * @param source defines the screen space Vector3 to use
  2426. * @param viewportWidth defines the current width of the viewport
  2427. * @param viewportHeight defines the current height of the viewport
  2428. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2429. * @param view defines the view matrix to use
  2430. * @param projection defines the projection matrix to use
  2431. * @param result defines the Vector3 where to store the result
  2432. */
  2433. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2434. /**
  2435. * Unproject from screen space to object space
  2436. * @param sourceX defines the screen space x coordinate to use
  2437. * @param sourceY defines the screen space y coordinate to use
  2438. * @param sourceZ defines the screen space z coordinate to use
  2439. * @param viewportWidth defines the current width of the viewport
  2440. * @param viewportHeight defines the current height of the viewport
  2441. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2442. * @param view defines the view matrix to use
  2443. * @param projection defines the projection matrix to use
  2444. * @param result defines the Vector3 where to store the result
  2445. */
  2446. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2447. /**
  2448. * Gets the minimal coordinate values between two Vector3
  2449. * @param left defines the first operand
  2450. * @param right defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Gets the maximal coordinate values between two Vector3
  2456. * @param left defines the first operand
  2457. * @param right defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Returns the distance between the vectors "value1" and "value2"
  2463. * @param value1 defines the first operand
  2464. * @param value2 defines the second operand
  2465. * @returns the distance
  2466. */
  2467. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2468. /**
  2469. * Returns the squared distance between the vectors "value1" and "value2"
  2470. * @param value1 defines the first operand
  2471. * @param value2 defines the second operand
  2472. * @returns the squared distance
  2473. */
  2474. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2475. /**
  2476. * Returns a new Vector3 located at the center between "value1" and "value2"
  2477. * @param value1 defines the first operand
  2478. * @param value2 defines the second operand
  2479. * @returns the new Vector3
  2480. */
  2481. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2484. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2485. * to something in order to rotate it from its local system to the given target system
  2486. * Note: axis1, axis2 and axis3 are normalized during this operation
  2487. * @param axis1 defines the first axis
  2488. * @param axis2 defines the second axis
  2489. * @param axis3 defines the third axis
  2490. * @returns a new Vector3
  2491. */
  2492. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2493. /**
  2494. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2495. * @param axis1 defines the first axis
  2496. * @param axis2 defines the second axis
  2497. * @param axis3 defines the third axis
  2498. * @param ref defines the Vector3 where to store the result
  2499. */
  2500. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2501. }
  2502. /**
  2503. * Vector4 class created for EulerAngle class conversion to Quaternion
  2504. */
  2505. export class Vector4 {
  2506. /** x value of the vector */
  2507. x: number;
  2508. /** y value of the vector */
  2509. y: number;
  2510. /** z value of the vector */
  2511. z: number;
  2512. /** w value of the vector */
  2513. w: number;
  2514. /**
  2515. * Creates a Vector4 object from the given floats.
  2516. * @param x x value of the vector
  2517. * @param y y value of the vector
  2518. * @param z z value of the vector
  2519. * @param w w value of the vector
  2520. */
  2521. constructor(
  2522. /** x value of the vector */
  2523. x: number,
  2524. /** y value of the vector */
  2525. y: number,
  2526. /** z value of the vector */
  2527. z: number,
  2528. /** w value of the vector */
  2529. w: number);
  2530. /**
  2531. * Returns the string with the Vector4 coordinates.
  2532. * @returns a string containing all the vector values
  2533. */
  2534. toString(): string;
  2535. /**
  2536. * Returns the string "Vector4".
  2537. * @returns "Vector4"
  2538. */
  2539. getClassName(): string;
  2540. /**
  2541. * Returns the Vector4 hash code.
  2542. * @returns a unique hash code
  2543. */
  2544. getHashCode(): number;
  2545. /**
  2546. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2547. * @returns the resulting array
  2548. */
  2549. asArray(): number[];
  2550. /**
  2551. * Populates the given array from the given index with the Vector4 coordinates.
  2552. * @param array array to populate
  2553. * @param index index of the array to start at (default: 0)
  2554. * @returns the Vector4.
  2555. */
  2556. toArray(array: FloatArray, index?: number): Vector4;
  2557. /**
  2558. * Adds the given vector to the current Vector4.
  2559. * @param otherVector the vector to add
  2560. * @returns the updated Vector4.
  2561. */
  2562. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2563. /**
  2564. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2565. * @param otherVector the vector to add
  2566. * @returns the resulting vector
  2567. */
  2568. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2569. /**
  2570. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2571. * @param otherVector the vector to add
  2572. * @param result the vector to store the result
  2573. * @returns the current Vector4.
  2574. */
  2575. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2576. /**
  2577. * Subtract in place the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @returns the updated Vector4.
  2580. */
  2581. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2582. /**
  2583. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2584. * @param otherVector the vector to add
  2585. * @returns the new vector with the result
  2586. */
  2587. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2588. /**
  2589. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2590. * @param otherVector the vector to subtract
  2591. * @param result the vector to store the result
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. */
  2598. /**
  2599. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2600. * @param x value to subtract
  2601. * @param y value to subtract
  2602. * @param z value to subtract
  2603. * @param w value to subtract
  2604. * @returns new vector containing the result
  2605. */
  2606. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2607. /**
  2608. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2609. * @param x value to subtract
  2610. * @param y value to subtract
  2611. * @param z value to subtract
  2612. * @param w value to subtract
  2613. * @param result the vector to store the result in
  2614. * @returns the current Vector4.
  2615. */
  2616. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2617. /**
  2618. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2619. * @returns a new vector with the negated values
  2620. */
  2621. negate(): Vector4;
  2622. /**
  2623. * Multiplies the current Vector4 coordinates by scale (float).
  2624. * @param scale the number to scale with
  2625. * @returns the updated Vector4.
  2626. */
  2627. scaleInPlace(scale: number): Vector4;
  2628. /**
  2629. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2630. * @param scale the number to scale with
  2631. * @returns a new vector with the result
  2632. */
  2633. scale(scale: number): Vector4;
  2634. /**
  2635. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2636. * @param scale the number to scale with
  2637. * @param result a vector to store the result in
  2638. * @returns the current Vector4.
  2639. */
  2640. scaleToRef(scale: number, result: Vector4): Vector4;
  2641. /**
  2642. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2643. * @param scale defines the scale factor
  2644. * @param result defines the Vector4 object where to store the result
  2645. * @returns the unmodified current Vector4
  2646. */
  2647. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2648. /**
  2649. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2650. * @param otherVector the vector to compare against
  2651. * @returns true if they are equal
  2652. */
  2653. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2654. /**
  2655. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2656. * @param otherVector vector to compare against
  2657. * @param epsilon (Default: very small number)
  2658. * @returns true if they are equal
  2659. */
  2660. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2661. /**
  2662. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2663. * @param x x value to compare against
  2664. * @param y y value to compare against
  2665. * @param z z value to compare against
  2666. * @param w w value to compare against
  2667. * @returns true if equal
  2668. */
  2669. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2670. /**
  2671. * Multiplies in place the current Vector4 by the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @returns the updated Vector4.
  2674. */
  2675. multiplyInPlace(otherVector: Vector4): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2678. * @param otherVector vector to multiple with
  2679. * @returns resulting new vector
  2680. */
  2681. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2684. * @param otherVector vector to multiple with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2691. * @param x x value multiply with
  2692. * @param y y value multiply with
  2693. * @param z z value multiply with
  2694. * @param w w value multiply with
  2695. * @returns resulting new vector
  2696. */
  2697. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2698. /**
  2699. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2700. * @param otherVector vector to devide with
  2701. * @returns resulting new vector
  2702. */
  2703. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2704. /**
  2705. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2706. * @param otherVector vector to devide with
  2707. * @param result vector to store the result
  2708. * @returns the current Vector4.
  2709. */
  2710. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2711. /**
  2712. * Divides the current Vector3 coordinates by the given ones.
  2713. * @param otherVector vector to devide with
  2714. * @returns the updated Vector3.
  2715. */
  2716. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2719. * @param other defines the second operand
  2720. * @returns the current updated Vector4
  2721. */
  2722. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2723. /**
  2724. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2725. * @param other defines the second operand
  2726. * @returns the current updated Vector4
  2727. */
  2728. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2729. /**
  2730. * Gets a new Vector4 from current Vector4 floored values
  2731. * @returns a new Vector4
  2732. */
  2733. floor(): Vector4;
  2734. /**
  2735. * Gets a new Vector4 from current Vector3 floored values
  2736. * @returns a new Vector4
  2737. */
  2738. fract(): Vector4;
  2739. /**
  2740. * Returns the Vector4 length (float).
  2741. * @returns the length
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Returns the Vector4 squared length (float).
  2746. * @returns the length squared
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalizes in place the Vector4.
  2751. * @returns the updated Vector4.
  2752. */
  2753. normalize(): Vector4;
  2754. /**
  2755. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2756. * @returns this converted to a new vector3
  2757. */
  2758. toVector3(): Vector3;
  2759. /**
  2760. * Returns a new Vector4 copied from the current one.
  2761. * @returns the new cloned vector
  2762. */
  2763. clone(): Vector4;
  2764. /**
  2765. * Updates the current Vector4 with the given one coordinates.
  2766. * @param source the source vector to copy from
  2767. * @returns the updated Vector4.
  2768. */
  2769. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2770. /**
  2771. * Updates the current Vector4 coordinates with the given floats.
  2772. * @param x float to copy from
  2773. * @param y float to copy from
  2774. * @param z float to copy from
  2775. * @param w float to copy from
  2776. * @returns the updated Vector4.
  2777. */
  2778. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2779. /**
  2780. * Updates the current Vector4 coordinates with the given floats.
  2781. * @param x float to set from
  2782. * @param y float to set from
  2783. * @param z float to set from
  2784. * @param w float to set from
  2785. * @returns the updated Vector4.
  2786. */
  2787. set(x: number, y: number, z: number, w: number): Vector4;
  2788. /**
  2789. * Copies the given float to the current Vector3 coordinates
  2790. * @param v defines the x, y, z and w coordinates of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. setAll(v: number): Vector4;
  2794. /**
  2795. * Returns a new Vector4 set from the starting index of the given array.
  2796. * @param array the array to pull values from
  2797. * @param offset the offset into the array to start at
  2798. * @returns the new vector
  2799. */
  2800. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2801. /**
  2802. * Updates the given vector "result" from the starting index of the given array.
  2803. * @param array the array to pull values from
  2804. * @param offset the offset into the array to start at
  2805. * @param result the vector to store the result in
  2806. */
  2807. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2808. /**
  2809. * Updates the given vector "result" from the starting index of the given Float32Array.
  2810. * @param array the array to pull values from
  2811. * @param offset the offset into the array to start at
  2812. * @param result the vector to store the result in
  2813. */
  2814. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2815. /**
  2816. * Updates the given vector "result" coordinates from the given floats.
  2817. * @param x float to set from
  2818. * @param y float to set from
  2819. * @param z float to set from
  2820. * @param w float to set from
  2821. * @param result the vector to the floats in
  2822. */
  2823. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2824. /**
  2825. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2826. * @returns the new vector
  2827. */
  2828. static Zero(): Vector4;
  2829. /**
  2830. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2831. * @returns the new vector
  2832. */
  2833. static One(): Vector4;
  2834. /**
  2835. * Returns a new normalized Vector4 from the given one.
  2836. * @param vector the vector to normalize
  2837. * @returns the vector
  2838. */
  2839. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2840. /**
  2841. * Updates the given vector "result" from the normalization of the given one.
  2842. * @param vector the vector to normalize
  2843. * @param result the vector to store the result in
  2844. */
  2845. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2846. /**
  2847. * Returns a vector with the minimum values from the left and right vectors
  2848. * @param left left vector to minimize
  2849. * @param right right vector to minimize
  2850. * @returns a new vector with the minimum of the left and right vector values
  2851. */
  2852. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns a vector with the maximum values from the left and right vectors
  2855. * @param left left vector to maximize
  2856. * @param right right vector to maximize
  2857. * @returns a new vector with the maximum of the left and right vector values
  2858. */
  2859. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2860. /**
  2861. * Returns the distance (float) between the vectors "value1" and "value2".
  2862. * @param value1 value to calulate the distance between
  2863. * @param value2 value to calulate the distance between
  2864. * @return the distance between the two vectors
  2865. */
  2866. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2867. /**
  2868. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2869. * @param value1 value to calulate the distance between
  2870. * @param value2 value to calulate the distance between
  2871. * @return the distance between the two vectors squared
  2872. */
  2873. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2874. /**
  2875. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2876. * @param value1 value to calulate the center between
  2877. * @param value2 value to calulate the center between
  2878. * @return the center between the two vectors
  2879. */
  2880. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2881. /**
  2882. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2883. * This methods computes transformed normalized direction vectors only.
  2884. * @param vector the vector to transform
  2885. * @param transformation the transformation matrix to apply
  2886. * @returns the new vector
  2887. */
  2888. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2889. /**
  2890. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2891. * This methods computes transformed normalized direction vectors only.
  2892. * @param vector the vector to transform
  2893. * @param transformation the transformation matrix to apply
  2894. * @param result the vector to store the result in
  2895. */
  2896. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2897. /**
  2898. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2899. * This methods computes transformed normalized direction vectors only.
  2900. * @param x value to transform
  2901. * @param y value to transform
  2902. * @param z value to transform
  2903. * @param w value to transform
  2904. * @param transformation the transformation matrix to apply
  2905. * @param result the vector to store the results in
  2906. */
  2907. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2908. /**
  2909. * Creates a new Vector4 from a Vector3
  2910. * @param source defines the source data
  2911. * @param w defines the 4th component (default is 0)
  2912. * @returns a new Vector4
  2913. */
  2914. static FromVector3(source: Vector3, w?: number): Vector4;
  2915. }
  2916. /**
  2917. * Class used to store quaternion data
  2918. * @see https://en.wikipedia.org/wiki/Quaternion
  2919. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2920. */
  2921. export class Quaternion {
  2922. /** defines the first component (0 by default) */
  2923. x: number;
  2924. /** defines the second component (0 by default) */
  2925. y: number;
  2926. /** defines the third component (0 by default) */
  2927. z: number;
  2928. /** defines the fourth component (1.0 by default) */
  2929. w: number;
  2930. /**
  2931. * Creates a new Quaternion from the given floats
  2932. * @param x defines the first component (0 by default)
  2933. * @param y defines the second component (0 by default)
  2934. * @param z defines the third component (0 by default)
  2935. * @param w defines the fourth component (1.0 by default)
  2936. */
  2937. constructor(
  2938. /** defines the first component (0 by default) */
  2939. x?: number,
  2940. /** defines the second component (0 by default) */
  2941. y?: number,
  2942. /** defines the third component (0 by default) */
  2943. z?: number,
  2944. /** defines the fourth component (1.0 by default) */
  2945. w?: number);
  2946. /**
  2947. * Gets a string representation for the current quaternion
  2948. * @returns a string with the Quaternion coordinates
  2949. */
  2950. toString(): string;
  2951. /**
  2952. * Gets the class name of the quaternion
  2953. * @returns the string "Quaternion"
  2954. */
  2955. getClassName(): string;
  2956. /**
  2957. * Gets a hash code for this quaternion
  2958. * @returns the quaternion hash code
  2959. */
  2960. getHashCode(): number;
  2961. /**
  2962. * Copy the quaternion to an array
  2963. * @returns a new array populated with 4 elements from the quaternion coordinates
  2964. */
  2965. asArray(): number[];
  2966. /**
  2967. * Check if two quaternions are equals
  2968. * @param otherQuaternion defines the second operand
  2969. * @return true if the current quaternion and the given one coordinates are strictly equals
  2970. */
  2971. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2972. /**
  2973. * Clone the current quaternion
  2974. * @returns a new quaternion copied from the current one
  2975. */
  2976. clone(): Quaternion;
  2977. /**
  2978. * Copy a quaternion to the current one
  2979. * @param other defines the other quaternion
  2980. * @returns the updated current quaternion
  2981. */
  2982. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2983. /**
  2984. * Updates the current quaternion with the given float coordinates
  2985. * @param x defines the x coordinate
  2986. * @param y defines the y coordinate
  2987. * @param z defines the z coordinate
  2988. * @param w defines the w coordinate
  2989. * @returns the updated current quaternion
  2990. */
  2991. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2992. /**
  2993. * Updates the current quaternion from the given float coordinates
  2994. * @param x defines the x coordinate
  2995. * @param y defines the y coordinate
  2996. * @param z defines the z coordinate
  2997. * @param w defines the w coordinate
  2998. * @returns the updated current quaternion
  2999. */
  3000. set(x: number, y: number, z: number, w: number): Quaternion;
  3001. /**
  3002. * Adds two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3005. */
  3006. add(other: DeepImmutable<Quaternion>): Quaternion;
  3007. /**
  3008. * Add a quaternion to the current one
  3009. * @param other defines the quaternion to add
  3010. * @returns the current quaternion
  3011. */
  3012. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3013. /**
  3014. * Subtract two quaternions
  3015. * @param other defines the second operand
  3016. * @returns a new quaternion as the subtraction result of the given one from the current one
  3017. */
  3018. subtract(other: Quaternion): Quaternion;
  3019. /**
  3020. * Multiplies the current quaternion by a scale factor
  3021. * @param value defines the scale factor
  3022. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3023. */
  3024. scale(value: number): Quaternion;
  3025. /**
  3026. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3027. * @param scale defines the scale factor
  3028. * @param result defines the Quaternion object where to store the result
  3029. * @returns the unmodified current quaternion
  3030. */
  3031. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3032. /**
  3033. * Multiplies in place the current quaternion by a scale factor
  3034. * @param value defines the scale factor
  3035. * @returns the current modified quaternion
  3036. */
  3037. scaleInPlace(value: number): Quaternion;
  3038. /**
  3039. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3040. * @param scale defines the scale factor
  3041. * @param result defines the Quaternion object where to store the result
  3042. * @returns the unmodified current quaternion
  3043. */
  3044. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3045. /**
  3046. * Multiplies two quaternions
  3047. * @param q1 defines the second operand
  3048. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3049. */
  3050. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3051. /**
  3052. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3053. * @param q1 defines the second operand
  3054. * @param result defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3058. /**
  3059. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3060. * @param q1 defines the second operand
  3061. * @returns the currentupdated quaternion
  3062. */
  3063. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3064. /**
  3065. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3066. * @param ref defines the target quaternion
  3067. * @returns the current quaternion
  3068. */
  3069. conjugateToRef(ref: Quaternion): Quaternion;
  3070. /**
  3071. * Conjugates in place (1-q) the current quaternion
  3072. * @returns the current updated quaternion
  3073. */
  3074. conjugateInPlace(): Quaternion;
  3075. /**
  3076. * Conjugates in place (1-q) the current quaternion
  3077. * @returns a new quaternion
  3078. */
  3079. conjugate(): Quaternion;
  3080. /**
  3081. * Gets length of current quaternion
  3082. * @returns the quaternion length (float)
  3083. */
  3084. length(): number;
  3085. /**
  3086. * Normalize in place the current quaternion
  3087. * @returns the current updated quaternion
  3088. */
  3089. normalize(): Quaternion;
  3090. /**
  3091. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3092. * @param order is a reserved parameter and is ignore for now
  3093. * @returns a new Vector3 containing the Euler angles
  3094. */
  3095. toEulerAngles(order?: string): Vector3;
  3096. /**
  3097. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3098. * @param result defines the vector which will be filled with the Euler angles
  3099. * @param order is a reserved parameter and is ignore for now
  3100. * @returns the current unchanged quaternion
  3101. */
  3102. toEulerAnglesToRef(result: Vector3): Quaternion;
  3103. /**
  3104. * Updates the given rotation matrix with the current quaternion values
  3105. * @param result defines the target matrix
  3106. * @returns the current unchanged quaternion
  3107. */
  3108. toRotationMatrix(result: Matrix): Quaternion;
  3109. /**
  3110. * Updates the current quaternion from the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @returns the current updated quaternion
  3113. */
  3114. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3115. /**
  3116. * Creates a new quaternion from a rotation matrix
  3117. * @param matrix defines the source matrix
  3118. * @returns a new quaternion created from the given rotation matrix values
  3119. */
  3120. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3121. /**
  3122. * Updates the given quaternion with the given rotation matrix values
  3123. * @param matrix defines the source matrix
  3124. * @param result defines the target quaternion
  3125. */
  3126. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3127. /**
  3128. * Returns the dot product (float) between the quaternions "left" and "right"
  3129. * @param left defines the left operand
  3130. * @param right defines the right operand
  3131. * @returns the dot product
  3132. */
  3133. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3134. /**
  3135. * Checks if the two quaternions are close to each other
  3136. * @param quat0 defines the first quaternion to check
  3137. * @param quat1 defines the second quaternion to check
  3138. * @returns true if the two quaternions are close to each other
  3139. */
  3140. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3141. /**
  3142. * Creates an empty quaternion
  3143. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3144. */
  3145. static Zero(): Quaternion;
  3146. /**
  3147. * Inverse a given quaternion
  3148. * @param q defines the source quaternion
  3149. * @returns a new quaternion as the inverted current quaternion
  3150. */
  3151. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3152. /**
  3153. * Inverse a given quaternion
  3154. * @param q defines the source quaternion
  3155. * @param result the quaternion the result will be stored in
  3156. * @returns the result quaternion
  3157. */
  3158. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3159. /**
  3160. * Creates an identity quaternion
  3161. * @returns the identity quaternion
  3162. */
  3163. static Identity(): Quaternion;
  3164. /**
  3165. * Gets a boolean indicating if the given quaternion is identity
  3166. * @param quaternion defines the quaternion to check
  3167. * @returns true if the quaternion is identity
  3168. */
  3169. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3170. /**
  3171. * Creates a quaternion from a rotation around an axis
  3172. * @param axis defines the axis to use
  3173. * @param angle defines the angle to use
  3174. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3175. */
  3176. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3177. /**
  3178. * Creates a rotation around an axis and stores it into the given quaternion
  3179. * @param axis defines the axis to use
  3180. * @param angle defines the angle to use
  3181. * @param result defines the target quaternion
  3182. * @returns the target quaternion
  3183. */
  3184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3185. /**
  3186. * Creates a new quaternion from data stored into an array
  3187. * @param array defines the data source
  3188. * @param offset defines the offset in the source array where the data starts
  3189. * @returns a new quaternion
  3190. */
  3191. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3192. /**
  3193. * Create a quaternion from Euler rotation angles
  3194. * @param x Pitch
  3195. * @param y Yaw
  3196. * @param z Roll
  3197. * @returns the new Quaternion
  3198. */
  3199. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3200. /**
  3201. * Updates a quaternion from Euler rotation angles
  3202. * @param x Pitch
  3203. * @param y Yaw
  3204. * @param z Roll
  3205. * @param result the quaternion to store the result
  3206. * @returns the updated quaternion
  3207. */
  3208. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3209. /**
  3210. * Create a quaternion from Euler rotation vector
  3211. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3212. * @returns the new Quaternion
  3213. */
  3214. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3215. /**
  3216. * Updates a quaternion from Euler rotation vector
  3217. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3218. * @param result the quaternion to store the result
  3219. * @returns the updated quaternion
  3220. */
  3221. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3222. /**
  3223. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3224. * @param yaw defines the rotation around Y axis
  3225. * @param pitch defines the rotation around X axis
  3226. * @param roll defines the rotation around Z axis
  3227. * @returns the new quaternion
  3228. */
  3229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3230. /**
  3231. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3232. * @param yaw defines the rotation around Y axis
  3233. * @param pitch defines the rotation around X axis
  3234. * @param roll defines the rotation around Z axis
  3235. * @param result defines the target quaternion
  3236. */
  3237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3238. /**
  3239. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3240. * @param alpha defines the rotation around first axis
  3241. * @param beta defines the rotation around second axis
  3242. * @param gamma defines the rotation around third axis
  3243. * @returns the new quaternion
  3244. */
  3245. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3246. /**
  3247. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3248. * @param alpha defines the rotation around first axis
  3249. * @param beta defines the rotation around second axis
  3250. * @param gamma defines the rotation around third axis
  3251. * @param result defines the target quaternion
  3252. */
  3253. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3254. /**
  3255. * 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)
  3256. * @param axis1 defines the first axis
  3257. * @param axis2 defines the second axis
  3258. * @param axis3 defines the third axis
  3259. * @returns the new quaternion
  3260. */
  3261. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3262. /**
  3263. * 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
  3264. * @param axis1 defines the first axis
  3265. * @param axis2 defines the second axis
  3266. * @param axis3 defines the third axis
  3267. * @param ref defines the target quaternion
  3268. */
  3269. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3270. /**
  3271. * Interpolates between two quaternions
  3272. * @param left defines first quaternion
  3273. * @param right defines second quaternion
  3274. * @param amount defines the gradient to use
  3275. * @returns the new interpolated quaternion
  3276. */
  3277. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3278. /**
  3279. * Interpolates between two quaternions and stores it into a target quaternion
  3280. * @param left defines first quaternion
  3281. * @param right defines second quaternion
  3282. * @param amount defines the gradient to use
  3283. * @param result defines the target quaternion
  3284. */
  3285. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3286. /**
  3287. * Interpolate between two quaternions using Hermite interpolation
  3288. * @param value1 defines first quaternion
  3289. * @param tangent1 defines the incoming tangent
  3290. * @param value2 defines second quaternion
  3291. * @param tangent2 defines the outgoing tangent
  3292. * @param amount defines the target quaternion
  3293. * @returns the new interpolated quaternion
  3294. */
  3295. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3296. }
  3297. /**
  3298. * Class used to store matrix data (4x4)
  3299. */
  3300. export class Matrix {
  3301. private static _updateFlagSeed;
  3302. private static _identityReadOnly;
  3303. private _isIdentity;
  3304. private _isIdentityDirty;
  3305. private _isIdentity3x2;
  3306. private _isIdentity3x2Dirty;
  3307. /**
  3308. * Gets the update flag of the matrix which is an unique number for the matrix.
  3309. * It will be incremented every time the matrix data change.
  3310. * You can use it to speed the comparison between two versions of the same matrix.
  3311. */
  3312. updateFlag: number;
  3313. private readonly _m;
  3314. /**
  3315. * Gets the internal data of the matrix
  3316. */
  3317. readonly m: DeepImmutable<Float32Array>;
  3318. /** @hidden */
  3319. _markAsUpdated(): void;
  3320. /** @hidden */
  3321. private _updateIdentityStatus;
  3322. /**
  3323. * Creates an empty matrix (filled with zeros)
  3324. */
  3325. constructor();
  3326. /**
  3327. * Check if the current matrix is identity
  3328. * @returns true is the matrix is the identity matrix
  3329. */
  3330. isIdentity(): boolean;
  3331. /**
  3332. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3333. * @returns true is the matrix is the identity matrix
  3334. */
  3335. isIdentityAs3x2(): boolean;
  3336. /**
  3337. * Gets the determinant of the matrix
  3338. * @returns the matrix determinant
  3339. */
  3340. determinant(): number;
  3341. /**
  3342. * Returns the matrix as a Float32Array
  3343. * @returns the matrix underlying array
  3344. */
  3345. toArray(): DeepImmutable<Float32Array>;
  3346. /**
  3347. * Returns the matrix as a Float32Array
  3348. * @returns the matrix underlying array.
  3349. */
  3350. asArray(): DeepImmutable<Float32Array>;
  3351. /**
  3352. * Inverts the current matrix in place
  3353. * @returns the current inverted matrix
  3354. */
  3355. invert(): Matrix;
  3356. /**
  3357. * Sets all the matrix elements to zero
  3358. * @returns the current matrix
  3359. */
  3360. reset(): Matrix;
  3361. /**
  3362. * Adds the current matrix with a second one
  3363. * @param other defines the matrix to add
  3364. * @returns a new matrix as the addition of the current matrix and the given one
  3365. */
  3366. add(other: DeepImmutable<Matrix>): Matrix;
  3367. /**
  3368. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3369. * @param other defines the matrix to add
  3370. * @param result defines the target matrix
  3371. * @returns the current matrix
  3372. */
  3373. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3374. /**
  3375. * Adds in place the given matrix to the current matrix
  3376. * @param other defines the second operand
  3377. * @returns the current updated matrix
  3378. */
  3379. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3380. /**
  3381. * Sets the given matrix to the current inverted Matrix
  3382. * @param other defines the target matrix
  3383. * @returns the unmodified current matrix
  3384. */
  3385. invertToRef(other: Matrix): Matrix;
  3386. /**
  3387. * add a value at the specified position in the current Matrix
  3388. * @param index the index of the value within the matrix. between 0 and 15.
  3389. * @param value the value to be added
  3390. * @returns the current updated matrix
  3391. */
  3392. addAtIndex(index: number, value: number): Matrix;
  3393. /**
  3394. * mutiply the specified position in the current Matrix by a value
  3395. * @param index the index of the value within the matrix. between 0 and 15.
  3396. * @param value the value to be added
  3397. * @returns the current updated matrix
  3398. */
  3399. multiplyAtIndex(index: number, value: number): Matrix;
  3400. /**
  3401. * Inserts the translation vector (using 3 floats) in the current matrix
  3402. * @param x defines the 1st component of the translation
  3403. * @param y defines the 2nd component of the translation
  3404. * @param z defines the 3rd component of the translation
  3405. * @returns the current updated matrix
  3406. */
  3407. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3408. /**
  3409. * Adds the translation vector (using 3 floats) in the current matrix
  3410. * @param x defines the 1st component of the translation
  3411. * @param y defines the 2nd component of the translation
  3412. * @param z defines the 3rd component of the translation
  3413. * @returns the current updated matrix
  3414. */
  3415. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3416. /**
  3417. * Inserts the translation vector in the current matrix
  3418. * @param vector3 defines the translation to insert
  3419. * @returns the current updated matrix
  3420. */
  3421. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3422. /**
  3423. * Gets the translation value of the current matrix
  3424. * @returns a new Vector3 as the extracted translation from the matrix
  3425. */
  3426. getTranslation(): Vector3;
  3427. /**
  3428. * Fill a Vector3 with the extracted translation from the matrix
  3429. * @param result defines the Vector3 where to store the translation
  3430. * @returns the current matrix
  3431. */
  3432. getTranslationToRef(result: Vector3): Matrix;
  3433. /**
  3434. * Remove rotation and scaling part from the matrix
  3435. * @returns the updated matrix
  3436. */
  3437. removeRotationAndScaling(): Matrix;
  3438. /**
  3439. * Multiply two matrices
  3440. * @param other defines the second operand
  3441. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3442. */
  3443. multiply(other: DeepImmutable<Matrix>): Matrix;
  3444. /**
  3445. * Copy the current matrix from the given one
  3446. * @param other defines the source matrix
  3447. * @returns the current updated matrix
  3448. */
  3449. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3450. /**
  3451. * Populates the given array from the starting index with the current matrix values
  3452. * @param array defines the target array
  3453. * @param offset defines the offset in the target array where to start storing values
  3454. * @returns the current matrix
  3455. */
  3456. copyToArray(array: Float32Array, offset?: number): Matrix;
  3457. /**
  3458. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3459. * @param other defines the second operand
  3460. * @param result defines the matrix where to store the multiplication
  3461. * @returns the current matrix
  3462. */
  3463. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3464. /**
  3465. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3466. * @param other defines the second operand
  3467. * @param result defines the array where to store the multiplication
  3468. * @param offset defines the offset in the target array where to start storing values
  3469. * @returns the current matrix
  3470. */
  3471. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3472. /**
  3473. * Check equality between this matrix and a second one
  3474. * @param value defines the second matrix to compare
  3475. * @returns true is the current matrix and the given one values are strictly equal
  3476. */
  3477. equals(value: DeepImmutable<Matrix>): boolean;
  3478. /**
  3479. * Clone the current matrix
  3480. * @returns a new matrix from the current matrix
  3481. */
  3482. clone(): Matrix;
  3483. /**
  3484. * Returns the name of the current matrix class
  3485. * @returns the string "Matrix"
  3486. */
  3487. getClassName(): string;
  3488. /**
  3489. * Gets the hash code of the current matrix
  3490. * @returns the hash code
  3491. */
  3492. getHashCode(): number;
  3493. /**
  3494. * Decomposes the current Matrix into a translation, rotation and scaling components
  3495. * @param scale defines the scale vector3 given as a reference to update
  3496. * @param rotation defines the rotation quaternion given as a reference to update
  3497. * @param translation defines the translation vector3 given as a reference to update
  3498. * @returns true if operation was successful
  3499. */
  3500. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3501. /**
  3502. * Gets specific row of the matrix
  3503. * @param index defines the number of the row to get
  3504. * @returns the index-th row of the current matrix as a new Vector4
  3505. */
  3506. getRow(index: number): Nullable<Vector4>;
  3507. /**
  3508. * Sets the index-th row of the current matrix to the vector4 values
  3509. * @param index defines the number of the row to set
  3510. * @param row defines the target vector4
  3511. * @returns the updated current matrix
  3512. */
  3513. setRow(index: number, row: Vector4): Matrix;
  3514. /**
  3515. * Compute the transpose of the matrix
  3516. * @returns the new transposed matrix
  3517. */
  3518. transpose(): Matrix;
  3519. /**
  3520. * Compute the transpose of the matrix and store it in a given matrix
  3521. * @param result defines the target matrix
  3522. * @returns the current matrix
  3523. */
  3524. transposeToRef(result: Matrix): Matrix;
  3525. /**
  3526. * Sets the index-th row of the current matrix with the given 4 x float values
  3527. * @param index defines the row index
  3528. * @param x defines the x component to set
  3529. * @param y defines the y component to set
  3530. * @param z defines the z component to set
  3531. * @param w defines the w component to set
  3532. * @returns the updated current matrix
  3533. */
  3534. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3535. /**
  3536. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3537. * @param scale defines the scale factor
  3538. * @returns a new matrix
  3539. */
  3540. scale(scale: number): Matrix;
  3541. /**
  3542. * Scale the current matrix values by a factor to a given result matrix
  3543. * @param scale defines the scale factor
  3544. * @param result defines the matrix to store the result
  3545. * @returns the current matrix
  3546. */
  3547. scaleToRef(scale: number, result: Matrix): Matrix;
  3548. /**
  3549. * Scale the current matrix values by a factor and add the result to a given matrix
  3550. * @param scale defines the scale factor
  3551. * @param result defines the Matrix to store the result
  3552. * @returns the current matrix
  3553. */
  3554. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3555. /**
  3556. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3557. * @param ref matrix to store the result
  3558. */
  3559. toNormalMatrix(ref: Matrix): void;
  3560. /**
  3561. * Gets only rotation part of the current matrix
  3562. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3563. */
  3564. getRotationMatrix(): Matrix;
  3565. /**
  3566. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3567. * @param result defines the target matrix to store data to
  3568. * @returns the current matrix
  3569. */
  3570. getRotationMatrixToRef(result: Matrix): Matrix;
  3571. /**
  3572. * Toggles model matrix from being right handed to left handed in place and vice versa
  3573. */
  3574. toggleModelMatrixHandInPlace(): void;
  3575. /**
  3576. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3577. */
  3578. toggleProjectionMatrixHandInPlace(): void;
  3579. /**
  3580. * Creates a matrix from an array
  3581. * @param array defines the source array
  3582. * @param offset defines an offset in the source array
  3583. * @returns a new Matrix set from the starting index of the given array
  3584. */
  3585. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3586. /**
  3587. * Copy the content of an array into a given matrix
  3588. * @param array defines the source array
  3589. * @param offset defines an offset in the source array
  3590. * @param result defines the target matrix
  3591. */
  3592. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3593. /**
  3594. * Stores an array into a matrix after having multiplied each component by a given factor
  3595. * @param array defines the source array
  3596. * @param offset defines the offset in the source array
  3597. * @param scale defines the scaling factor
  3598. * @param result defines the target matrix
  3599. */
  3600. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3601. /**
  3602. * Gets an identity matrix that must not be updated
  3603. */
  3604. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3605. /**
  3606. * Stores a list of values (16) inside a given matrix
  3607. * @param initialM11 defines 1st value of 1st row
  3608. * @param initialM12 defines 2nd value of 1st row
  3609. * @param initialM13 defines 3rd value of 1st row
  3610. * @param initialM14 defines 4th value of 1st row
  3611. * @param initialM21 defines 1st value of 2nd row
  3612. * @param initialM22 defines 2nd value of 2nd row
  3613. * @param initialM23 defines 3rd value of 2nd row
  3614. * @param initialM24 defines 4th value of 2nd row
  3615. * @param initialM31 defines 1st value of 3rd row
  3616. * @param initialM32 defines 2nd value of 3rd row
  3617. * @param initialM33 defines 3rd value of 3rd row
  3618. * @param initialM34 defines 4th value of 3rd row
  3619. * @param initialM41 defines 1st value of 4th row
  3620. * @param initialM42 defines 2nd value of 4th row
  3621. * @param initialM43 defines 3rd value of 4th row
  3622. * @param initialM44 defines 4th value of 4th row
  3623. * @param result defines the target matrix
  3624. */
  3625. 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;
  3626. /**
  3627. * Creates new matrix from a list of values (16)
  3628. * @param initialM11 defines 1st value of 1st row
  3629. * @param initialM12 defines 2nd value of 1st row
  3630. * @param initialM13 defines 3rd value of 1st row
  3631. * @param initialM14 defines 4th value of 1st row
  3632. * @param initialM21 defines 1st value of 2nd row
  3633. * @param initialM22 defines 2nd value of 2nd row
  3634. * @param initialM23 defines 3rd value of 2nd row
  3635. * @param initialM24 defines 4th value of 2nd row
  3636. * @param initialM31 defines 1st value of 3rd row
  3637. * @param initialM32 defines 2nd value of 3rd row
  3638. * @param initialM33 defines 3rd value of 3rd row
  3639. * @param initialM34 defines 4th value of 3rd row
  3640. * @param initialM41 defines 1st value of 4th row
  3641. * @param initialM42 defines 2nd value of 4th row
  3642. * @param initialM43 defines 3rd value of 4th row
  3643. * @param initialM44 defines 4th value of 4th row
  3644. * @returns the new matrix
  3645. */
  3646. 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;
  3647. /**
  3648. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3649. * @param scale defines the scale vector3
  3650. * @param rotation defines the rotation quaternion
  3651. * @param translation defines the translation vector3
  3652. * @returns a new matrix
  3653. */
  3654. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3655. /**
  3656. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3657. * @param scale defines the scale vector3
  3658. * @param rotation defines the rotation quaternion
  3659. * @param translation defines the translation vector3
  3660. * @param result defines the target matrix
  3661. */
  3662. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3663. /**
  3664. * Creates a new identity matrix
  3665. * @returns a new identity matrix
  3666. */
  3667. static Identity(): Matrix;
  3668. /**
  3669. * Creates a new identity matrix and stores the result in a given matrix
  3670. * @param result defines the target matrix
  3671. */
  3672. static IdentityToRef(result: Matrix): void;
  3673. /**
  3674. * Creates a new zero matrix
  3675. * @returns a new zero matrix
  3676. */
  3677. static Zero(): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis
  3680. * @param angle defines the angle (in radians) to use
  3681. * @return the new matrix
  3682. */
  3683. static RotationX(angle: number): Matrix;
  3684. /**
  3685. * Creates a new matrix as the invert of a given matrix
  3686. * @param source defines the source matrix
  3687. * @returns the new matrix
  3688. */
  3689. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationXToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Y axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationY(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationYToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the Z axis
  3710. * @param angle defines the angle (in radians) to use
  3711. * @return the new matrix
  3712. */
  3713. static RotationZ(angle: number): Matrix;
  3714. /**
  3715. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3716. * @param angle defines the angle (in radians) to use
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationZToRef(angle: number, result: Matrix): void;
  3720. /**
  3721. * Creates a new rotation matrix for "angle" radians around the given axis
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle (in radians) to use
  3724. * @return the new matrix
  3725. */
  3726. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3727. /**
  3728. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3729. * @param axis defines the axis to use
  3730. * @param angle defines the angle (in radians) to use
  3731. * @param result defines the target matrix
  3732. */
  3733. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3734. /**
  3735. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3736. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3737. * @param from defines the vector to align
  3738. * @param to defines the vector to align to
  3739. * @param result defines the target matrix
  3740. */
  3741. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3742. /**
  3743. * Creates a rotation matrix
  3744. * @param yaw defines the yaw angle in radians (Y axis)
  3745. * @param pitch defines the pitch angle in radians (X axis)
  3746. * @param roll defines the roll angle in radians (X axis)
  3747. * @returns the new rotation matrix
  3748. */
  3749. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3750. /**
  3751. * Creates a rotation matrix and stores it in a given matrix
  3752. * @param yaw defines the yaw angle in radians (Y axis)
  3753. * @param pitch defines the pitch angle in radians (X axis)
  3754. * @param roll defines the roll angle in radians (X axis)
  3755. * @param result defines the target matrix
  3756. */
  3757. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3758. /**
  3759. * Creates a scaling matrix
  3760. * @param x defines the scale factor on X axis
  3761. * @param y defines the scale factor on Y axis
  3762. * @param z defines the scale factor on Z axis
  3763. * @returns the new matrix
  3764. */
  3765. static Scaling(x: number, y: number, z: number): Matrix;
  3766. /**
  3767. * Creates a scaling matrix and stores it in a given matrix
  3768. * @param x defines the scale factor on X axis
  3769. * @param y defines the scale factor on Y axis
  3770. * @param z defines the scale factor on Z axis
  3771. * @param result defines the target matrix
  3772. */
  3773. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3774. /**
  3775. * Creates a translation matrix
  3776. * @param x defines the translation on X axis
  3777. * @param y defines the translation on Y axis
  3778. * @param z defines the translationon Z axis
  3779. * @returns the new matrix
  3780. */
  3781. static Translation(x: number, y: number, z: number): Matrix;
  3782. /**
  3783. * Creates a translation matrix and stores it in a given matrix
  3784. * @param x defines the translation on X axis
  3785. * @param y defines the translation on Y axis
  3786. * @param z defines the translationon Z axis
  3787. * @param result defines the target matrix
  3788. */
  3789. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3790. /**
  3791. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3792. * @param startValue defines the start value
  3793. * @param endValue defines the end value
  3794. * @param gradient defines the gradient factor
  3795. * @returns the new matrix
  3796. */
  3797. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3798. /**
  3799. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3800. * @param startValue defines the start value
  3801. * @param endValue defines the end value
  3802. * @param gradient defines the gradient factor
  3803. * @param result defines the Matrix object where to store data
  3804. */
  3805. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * Builds a new matrix whose values are computed by:
  3808. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3809. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3810. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3811. * @param startValue defines the first matrix
  3812. * @param endValue defines the second matrix
  3813. * @param gradient defines the gradient between the two matrices
  3814. * @returns the new matrix
  3815. */
  3816. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3817. /**
  3818. * Update a matrix to values which are computed by:
  3819. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3820. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3821. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3822. * @param startValue defines the first matrix
  3823. * @param endValue defines the second matrix
  3824. * @param gradient defines the gradient between the two matrices
  3825. * @param result defines the target matrix
  3826. */
  3827. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3828. /**
  3829. * 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"
  3830. * This function works in left handed mode
  3831. * @param eye defines the final position of the entity
  3832. * @param target defines where the entity should look at
  3833. * @param up defines the up vector for the entity
  3834. * @returns the new matrix
  3835. */
  3836. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3837. /**
  3838. * 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".
  3839. * This function works in left handed mode
  3840. * @param eye defines the final position of the entity
  3841. * @param target defines where the entity should look at
  3842. * @param up defines the up vector for the entity
  3843. * @param result defines the target matrix
  3844. */
  3845. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3846. /**
  3847. * 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"
  3848. * This function works in right handed mode
  3849. * @param eye defines the final position of the entity
  3850. * @param target defines where the entity should look at
  3851. * @param up defines the up vector for the entity
  3852. * @returns the new matrix
  3853. */
  3854. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3855. /**
  3856. * 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".
  3857. * This function works in right handed mode
  3858. * @param eye defines the final position of the entity
  3859. * @param target defines where the entity should look at
  3860. * @param up defines the up vector for the entity
  3861. * @param result defines the target matrix
  3862. */
  3863. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3864. /**
  3865. * Create a left-handed orthographic projection matrix
  3866. * @param width defines the viewport width
  3867. * @param height defines the viewport height
  3868. * @param znear defines the near clip plane
  3869. * @param zfar defines the far clip plane
  3870. * @returns a new matrix as a left-handed orthographic projection matrix
  3871. */
  3872. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3873. /**
  3874. * Store a left-handed orthographic projection to a given matrix
  3875. * @param width defines the viewport width
  3876. * @param height defines the viewport height
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Create a left-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a left-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a left-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a right-handed orthographic projection matrix
  3906. * @param left defines the viewport left coordinate
  3907. * @param right defines the viewport right coordinate
  3908. * @param bottom defines the viewport bottom coordinate
  3909. * @param top defines the viewport top coordinate
  3910. * @param znear defines the near clip plane
  3911. * @param zfar defines the far clip plane
  3912. * @returns a new matrix as a right-handed orthographic projection matrix
  3913. */
  3914. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3915. /**
  3916. * Stores a right-handed orthographic projection into a given matrix
  3917. * @param left defines the viewport left coordinate
  3918. * @param right defines the viewport right coordinate
  3919. * @param bottom defines the viewport bottom coordinate
  3920. * @param top defines the viewport top coordinate
  3921. * @param znear defines the near clip plane
  3922. * @param zfar defines the far clip plane
  3923. * @param result defines the target matrix
  3924. */
  3925. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3926. /**
  3927. * Creates a left-handed perspective projection matrix
  3928. * @param width defines the viewport width
  3929. * @param height defines the viewport height
  3930. * @param znear defines the near clip plane
  3931. * @param zfar defines the far clip plane
  3932. * @returns a new matrix as a left-handed perspective projection matrix
  3933. */
  3934. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3935. /**
  3936. * Creates a left-handed perspective projection matrix
  3937. * @param fov defines the horizontal field of view
  3938. * @param aspect defines the aspect ratio
  3939. * @param znear defines the near clip plane
  3940. * @param zfar defines the far clip plane
  3941. * @returns a new matrix as a left-handed perspective projection matrix
  3942. */
  3943. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3944. /**
  3945. * Stores a left-handed perspective projection into a given matrix
  3946. * @param fov defines the horizontal field of view
  3947. * @param aspect defines the aspect ratio
  3948. * @param znear defines the near clip plane
  3949. * @param zfar defines the far clip plane
  3950. * @param result defines the target matrix
  3951. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3952. */
  3953. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3954. /**
  3955. * Creates a right-handed perspective projection matrix
  3956. * @param fov defines the horizontal field of view
  3957. * @param aspect defines the aspect ratio
  3958. * @param znear defines the near clip plane
  3959. * @param zfar defines the far clip plane
  3960. * @returns a new matrix as a right-handed perspective projection matrix
  3961. */
  3962. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3963. /**
  3964. * Stores a right-handed perspective projection into a given matrix
  3965. * @param fov defines the horizontal field of view
  3966. * @param aspect defines the aspect ratio
  3967. * @param znear defines the near clip plane
  3968. * @param zfar defines the far clip plane
  3969. * @param result defines the target matrix
  3970. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3971. */
  3972. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3973. /**
  3974. * Stores a perspective projection for WebVR info a given matrix
  3975. * @param fov defines the field of view
  3976. * @param znear defines the near clip plane
  3977. * @param zfar defines the far clip plane
  3978. * @param result defines the target matrix
  3979. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3980. */
  3981. static PerspectiveFovWebVRToRef(fov: {
  3982. upDegrees: number;
  3983. downDegrees: number;
  3984. leftDegrees: number;
  3985. rightDegrees: number;
  3986. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3987. /**
  3988. * Computes a complete transformation matrix
  3989. * @param viewport defines the viewport to use
  3990. * @param world defines the world matrix
  3991. * @param view defines the view matrix
  3992. * @param projection defines the projection matrix
  3993. * @param zmin defines the near clip plane
  3994. * @param zmax defines the far clip plane
  3995. * @returns the transformation matrix
  3996. */
  3997. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3998. /**
  3999. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4000. * @param matrix defines the matrix to use
  4001. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4002. */
  4003. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4004. /**
  4005. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4006. * @param matrix defines the matrix to use
  4007. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4008. */
  4009. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4010. /**
  4011. * Compute the transpose of a given matrix
  4012. * @param matrix defines the matrix to transpose
  4013. * @returns the new matrix
  4014. */
  4015. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4016. /**
  4017. * Compute the transpose of a matrix and store it in a target matrix
  4018. * @param matrix defines the matrix to transpose
  4019. * @param result defines the target matrix
  4020. */
  4021. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4022. /**
  4023. * Computes a reflection matrix from a plane
  4024. * @param plane defines the reflection plane
  4025. * @returns a new matrix
  4026. */
  4027. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4028. /**
  4029. * Computes a reflection matrix from a plane
  4030. * @param plane defines the reflection plane
  4031. * @param result defines the target matrix
  4032. */
  4033. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4034. /**
  4035. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4036. * @param xaxis defines the value of the 1st axis
  4037. * @param yaxis defines the value of the 2nd axis
  4038. * @param zaxis defines the value of the 3rd axis
  4039. * @param result defines the target matrix
  4040. */
  4041. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4042. /**
  4043. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4044. * @param quat defines the quaternion to use
  4045. * @param result defines the target matrix
  4046. */
  4047. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4048. }
  4049. /**
  4050. * @hidden
  4051. */
  4052. export class TmpVectors {
  4053. static Vector2: Vector2[];
  4054. static Vector3: Vector3[];
  4055. static Vector4: Vector4[];
  4056. static Quaternion: Quaternion[];
  4057. static Matrix: Matrix[];
  4058. }
  4059. }
  4060. declare module "babylonjs/Engines/constants" {
  4061. /** Defines the cross module used constants to avoid circular dependncies */
  4062. export class Constants {
  4063. /** Defines that alpha blending is disabled */
  4064. static readonly ALPHA_DISABLE: number;
  4065. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4066. static readonly ALPHA_ADD: number;
  4067. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4068. static readonly ALPHA_COMBINE: number;
  4069. /** Defines that alpha blending to DEST - SRC * DEST */
  4070. static readonly ALPHA_SUBTRACT: number;
  4071. /** Defines that alpha blending to SRC * DEST */
  4072. static readonly ALPHA_MULTIPLY: number;
  4073. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4074. static readonly ALPHA_MAXIMIZED: number;
  4075. /** Defines that alpha blending to SRC + DEST */
  4076. static readonly ALPHA_ONEONE: number;
  4077. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4078. static readonly ALPHA_PREMULTIPLIED: number;
  4079. /**
  4080. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4081. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4082. */
  4083. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4084. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4085. static readonly ALPHA_INTERPOLATE: number;
  4086. /**
  4087. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4088. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4089. */
  4090. static readonly ALPHA_SCREENMODE: number;
  4091. /** Defines that the ressource is not delayed*/
  4092. static readonly DELAYLOADSTATE_NONE: number;
  4093. /** Defines that the ressource was successfully delay loaded */
  4094. static readonly DELAYLOADSTATE_LOADED: number;
  4095. /** Defines that the ressource is currently delay loading */
  4096. static readonly DELAYLOADSTATE_LOADING: number;
  4097. /** Defines that the ressource is delayed and has not started loading */
  4098. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4100. static readonly NEVER: number;
  4101. /** 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 */
  4102. static readonly ALWAYS: number;
  4103. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4104. static readonly LESS: number;
  4105. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4106. static readonly EQUAL: number;
  4107. /** 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 */
  4108. static readonly LEQUAL: number;
  4109. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4110. static readonly GREATER: number;
  4111. /** 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 */
  4112. static readonly GEQUAL: number;
  4113. /** 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 */
  4114. static readonly NOTEQUAL: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be kept */
  4116. static readonly KEEP: number;
  4117. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4118. static readonly REPLACE: number;
  4119. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4120. static readonly INCR: number;
  4121. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4122. static readonly DECR: number;
  4123. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4124. static readonly INVERT: number;
  4125. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4126. static readonly INCR_WRAP: number;
  4127. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4128. static readonly DECR_WRAP: number;
  4129. /** Texture is not repeating outside of 0..1 UVs */
  4130. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4131. /** Texture is repeating outside of 0..1 UVs */
  4132. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4133. /** Texture is repeating and mirrored */
  4134. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4135. /** ALPHA */
  4136. static readonly TEXTUREFORMAT_ALPHA: number;
  4137. /** LUMINANCE */
  4138. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4139. /** LUMINANCE_ALPHA */
  4140. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4141. /** RGB */
  4142. static readonly TEXTUREFORMAT_RGB: number;
  4143. /** RGBA */
  4144. static readonly TEXTUREFORMAT_RGBA: number;
  4145. /** RED */
  4146. static readonly TEXTUREFORMAT_RED: number;
  4147. /** RED (2nd reference) */
  4148. static readonly TEXTUREFORMAT_R: number;
  4149. /** RG */
  4150. static readonly TEXTUREFORMAT_RG: number;
  4151. /** RED_INTEGER */
  4152. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4153. /** RED_INTEGER (2nd reference) */
  4154. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4155. /** RG_INTEGER */
  4156. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4157. /** RGB_INTEGER */
  4158. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4159. /** RGBA_INTEGER */
  4160. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4161. /** UNSIGNED_BYTE */
  4162. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4163. /** UNSIGNED_BYTE (2nd reference) */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4165. /** FLOAT */
  4166. static readonly TEXTURETYPE_FLOAT: number;
  4167. /** HALF_FLOAT */
  4168. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4169. /** BYTE */
  4170. static readonly TEXTURETYPE_BYTE: number;
  4171. /** SHORT */
  4172. static readonly TEXTURETYPE_SHORT: number;
  4173. /** UNSIGNED_SHORT */
  4174. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4175. /** INT */
  4176. static readonly TEXTURETYPE_INT: number;
  4177. /** UNSIGNED_INT */
  4178. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4179. /** UNSIGNED_SHORT_4_4_4_4 */
  4180. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4181. /** UNSIGNED_SHORT_5_5_5_1 */
  4182. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4183. /** UNSIGNED_SHORT_5_6_5 */
  4184. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4185. /** UNSIGNED_INT_2_10_10_10_REV */
  4186. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4187. /** UNSIGNED_INT_24_8 */
  4188. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4189. /** UNSIGNED_INT_10F_11F_11F_REV */
  4190. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4191. /** UNSIGNED_INT_5_9_9_9_REV */
  4192. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4193. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4194. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4195. /** nearest is mag = nearest and min = nearest and mip = linear */
  4196. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4197. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4198. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4199. /** Trilinear is mag = linear and min = linear and mip = linear */
  4200. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4201. /** nearest is mag = nearest and min = nearest and mip = linear */
  4202. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4203. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4204. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4205. /** Trilinear is mag = linear and min = linear and mip = linear */
  4206. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4207. /** mag = nearest and min = nearest and mip = nearest */
  4208. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4209. /** mag = nearest and min = linear and mip = nearest */
  4210. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4211. /** mag = nearest and min = linear and mip = linear */
  4212. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4213. /** mag = nearest and min = linear and mip = none */
  4214. static readonly TEXTURE_NEAREST_LINEAR: number;
  4215. /** mag = nearest and min = nearest and mip = none */
  4216. static readonly TEXTURE_NEAREST_NEAREST: number;
  4217. /** mag = linear and min = nearest and mip = nearest */
  4218. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4219. /** mag = linear and min = nearest and mip = linear */
  4220. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4221. /** mag = linear and min = linear and mip = none */
  4222. static readonly TEXTURE_LINEAR_LINEAR: number;
  4223. /** mag = linear and min = nearest and mip = none */
  4224. static readonly TEXTURE_LINEAR_NEAREST: number;
  4225. /** Explicit coordinates mode */
  4226. static readonly TEXTURE_EXPLICIT_MODE: number;
  4227. /** Spherical coordinates mode */
  4228. static readonly TEXTURE_SPHERICAL_MODE: number;
  4229. /** Planar coordinates mode */
  4230. static readonly TEXTURE_PLANAR_MODE: number;
  4231. /** Cubic coordinates mode */
  4232. static readonly TEXTURE_CUBIC_MODE: number;
  4233. /** Projection coordinates mode */
  4234. static readonly TEXTURE_PROJECTION_MODE: number;
  4235. /** Skybox coordinates mode */
  4236. static readonly TEXTURE_SKYBOX_MODE: number;
  4237. /** Inverse Cubic coordinates mode */
  4238. static readonly TEXTURE_INVCUBIC_MODE: number;
  4239. /** Equirectangular coordinates mode */
  4240. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4241. /** Equirectangular Fixed coordinates mode */
  4242. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4243. /** Equirectangular Fixed Mirrored coordinates mode */
  4244. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4245. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4246. static readonly SCALEMODE_FLOOR: number;
  4247. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4248. static readonly SCALEMODE_NEAREST: number;
  4249. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4250. static readonly SCALEMODE_CEILING: number;
  4251. /**
  4252. * The dirty texture flag value
  4253. */
  4254. static readonly MATERIAL_TextureDirtyFlag: number;
  4255. /**
  4256. * The dirty light flag value
  4257. */
  4258. static readonly MATERIAL_LightDirtyFlag: number;
  4259. /**
  4260. * The dirty fresnel flag value
  4261. */
  4262. static readonly MATERIAL_FresnelDirtyFlag: number;
  4263. /**
  4264. * The dirty attribute flag value
  4265. */
  4266. static readonly MATERIAL_AttributesDirtyFlag: number;
  4267. /**
  4268. * The dirty misc flag value
  4269. */
  4270. static readonly MATERIAL_MiscDirtyFlag: number;
  4271. /**
  4272. * The all dirty flag value
  4273. */
  4274. static readonly MATERIAL_AllDirtyFlag: number;
  4275. /**
  4276. * Returns the triangle fill mode
  4277. */
  4278. static readonly MATERIAL_TriangleFillMode: number;
  4279. /**
  4280. * Returns the wireframe mode
  4281. */
  4282. static readonly MATERIAL_WireFrameFillMode: number;
  4283. /**
  4284. * Returns the point fill mode
  4285. */
  4286. static readonly MATERIAL_PointFillMode: number;
  4287. /**
  4288. * Returns the point list draw mode
  4289. */
  4290. static readonly MATERIAL_PointListDrawMode: number;
  4291. /**
  4292. * Returns the line list draw mode
  4293. */
  4294. static readonly MATERIAL_LineListDrawMode: number;
  4295. /**
  4296. * Returns the line loop draw mode
  4297. */
  4298. static readonly MATERIAL_LineLoopDrawMode: number;
  4299. /**
  4300. * Returns the line strip draw mode
  4301. */
  4302. static readonly MATERIAL_LineStripDrawMode: number;
  4303. /**
  4304. * Returns the triangle strip draw mode
  4305. */
  4306. static readonly MATERIAL_TriangleStripDrawMode: number;
  4307. /**
  4308. * Returns the triangle fan draw mode
  4309. */
  4310. static readonly MATERIAL_TriangleFanDrawMode: number;
  4311. /**
  4312. * Stores the clock-wise side orientation
  4313. */
  4314. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4315. /**
  4316. * Stores the counter clock-wise side orientation
  4317. */
  4318. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4319. /**
  4320. * Nothing
  4321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4322. */
  4323. static readonly ACTION_NothingTrigger: number;
  4324. /**
  4325. * On pick
  4326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4327. */
  4328. static readonly ACTION_OnPickTrigger: number;
  4329. /**
  4330. * On left pick
  4331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4332. */
  4333. static readonly ACTION_OnLeftPickTrigger: number;
  4334. /**
  4335. * On right pick
  4336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4337. */
  4338. static readonly ACTION_OnRightPickTrigger: number;
  4339. /**
  4340. * On center pick
  4341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4342. */
  4343. static readonly ACTION_OnCenterPickTrigger: number;
  4344. /**
  4345. * On pick down
  4346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4347. */
  4348. static readonly ACTION_OnPickDownTrigger: number;
  4349. /**
  4350. * On double pick
  4351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4352. */
  4353. static readonly ACTION_OnDoublePickTrigger: number;
  4354. /**
  4355. * On pick up
  4356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4357. */
  4358. static readonly ACTION_OnPickUpTrigger: number;
  4359. /**
  4360. * On pick out.
  4361. * This trigger will only be raised if you also declared a OnPickDown
  4362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4363. */
  4364. static readonly ACTION_OnPickOutTrigger: number;
  4365. /**
  4366. * On long press
  4367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4368. */
  4369. static readonly ACTION_OnLongPressTrigger: number;
  4370. /**
  4371. * On pointer over
  4372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4373. */
  4374. static readonly ACTION_OnPointerOverTrigger: number;
  4375. /**
  4376. * On pointer out
  4377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4378. */
  4379. static readonly ACTION_OnPointerOutTrigger: number;
  4380. /**
  4381. * On every frame
  4382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4383. */
  4384. static readonly ACTION_OnEveryFrameTrigger: number;
  4385. /**
  4386. * On intersection enter
  4387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4388. */
  4389. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4390. /**
  4391. * On intersection exit
  4392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4393. */
  4394. static readonly ACTION_OnIntersectionExitTrigger: number;
  4395. /**
  4396. * On key down
  4397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4398. */
  4399. static readonly ACTION_OnKeyDownTrigger: number;
  4400. /**
  4401. * On key up
  4402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4403. */
  4404. static readonly ACTION_OnKeyUpTrigger: number;
  4405. /**
  4406. * Billboard mode will only apply to Y axis
  4407. */
  4408. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4409. /**
  4410. * Billboard mode will apply to all axes
  4411. */
  4412. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4413. /**
  4414. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4415. */
  4416. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4417. /**
  4418. * Gets or sets base Assets URL
  4419. */
  4420. static PARTICLES_BaseAssetsUrl: string;
  4421. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4422. * Test order :
  4423. * Is the bounding sphere outside the frustum ?
  4424. * If not, are the bounding box vertices outside the frustum ?
  4425. * It not, then the cullable object is in the frustum.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4428. /** Culling strategy : Bounding Sphere Only.
  4429. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4430. * It's also less accurate than the standard because some not visible objects can still be selected.
  4431. * Test : is the bounding sphere outside the frustum ?
  4432. * If not, then the cullable object is in the frustum.
  4433. */
  4434. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4435. /** Culling strategy : Optimistic Inclusion.
  4436. * This in an inclusion test first, then the standard exclusion test.
  4437. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4438. * 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.
  4439. * Anyway, it's as accurate as the standard strategy.
  4440. * Test :
  4441. * Is the cullable object bounding sphere center in the frustum ?
  4442. * If not, apply the default culling strategy.
  4443. */
  4444. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4445. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4446. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4447. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4448. * 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.
  4449. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4450. * Test :
  4451. * Is the cullable object bounding sphere center in the frustum ?
  4452. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4453. */
  4454. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4455. /**
  4456. * No logging while loading
  4457. */
  4458. static readonly SCENELOADER_NO_LOGGING: number;
  4459. /**
  4460. * Minimal logging while loading
  4461. */
  4462. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4463. /**
  4464. * Summary logging while loading
  4465. */
  4466. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4467. /**
  4468. * Detailled logging while loading
  4469. */
  4470. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4471. }
  4472. }
  4473. declare module "babylonjs/Engines/IPipelineContext" {
  4474. /**
  4475. * Class used to store and describe the pipeline context associated with an effect
  4476. */
  4477. export interface IPipelineContext {
  4478. /**
  4479. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4480. */
  4481. isAsync: boolean;
  4482. /**
  4483. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4484. */
  4485. isReady: boolean;
  4486. /** @hidden */
  4487. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4488. }
  4489. }
  4490. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4491. /** @hidden */
  4492. export interface IShaderProcessor {
  4493. attributeProcessor?: (attribute: string) => string;
  4494. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4495. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4496. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4497. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4498. lineProcessor?: (line: string, isFragment: boolean) => string;
  4499. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4500. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4501. }
  4502. }
  4503. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4504. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4505. /** @hidden */
  4506. export interface ProcessingOptions {
  4507. defines: string[];
  4508. indexParameters: any;
  4509. isFragment: boolean;
  4510. shouldUseHighPrecisionShader: boolean;
  4511. supportsUniformBuffers: boolean;
  4512. shadersRepository: string;
  4513. includesShadersStore: {
  4514. [key: string]: string;
  4515. };
  4516. processor?: IShaderProcessor;
  4517. version: string;
  4518. platformName: string;
  4519. lookForClosingBracketForUniformBuffer?: boolean;
  4520. }
  4521. }
  4522. declare module "babylonjs/Misc/stringTools" {
  4523. /**
  4524. * Helper to manipulate strings
  4525. */
  4526. export class StringTools {
  4527. /**
  4528. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4529. * @param str Source string
  4530. * @param suffix Suffix to search for in the source string
  4531. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4532. */
  4533. static EndsWith(str: string, suffix: string): boolean;
  4534. /**
  4535. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4536. * @param str Source string
  4537. * @param suffix Suffix to search for in the source string
  4538. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4539. */
  4540. static StartsWith(str: string, suffix: string): boolean;
  4541. }
  4542. }
  4543. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4544. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4545. /** @hidden */
  4546. export class ShaderCodeNode {
  4547. line: string;
  4548. children: ShaderCodeNode[];
  4549. additionalDefineKey?: string;
  4550. additionalDefineValue?: string;
  4551. isValid(preprocessors: {
  4552. [key: string]: string;
  4553. }): boolean;
  4554. process(preprocessors: {
  4555. [key: string]: string;
  4556. }, options: ProcessingOptions): string;
  4557. }
  4558. }
  4559. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4560. /** @hidden */
  4561. export class ShaderCodeCursor {
  4562. private _lines;
  4563. lineIndex: number;
  4564. readonly currentLine: string;
  4565. readonly canRead: boolean;
  4566. lines: string[];
  4567. }
  4568. }
  4569. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4570. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4571. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4572. /** @hidden */
  4573. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4574. process(preprocessors: {
  4575. [key: string]: string;
  4576. }, options: ProcessingOptions): string;
  4577. }
  4578. }
  4579. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4580. /** @hidden */
  4581. export class ShaderDefineExpression {
  4582. isTrue(preprocessors: {
  4583. [key: string]: string;
  4584. }): boolean;
  4585. }
  4586. }
  4587. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4588. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4589. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4590. /** @hidden */
  4591. export class ShaderCodeTestNode extends ShaderCodeNode {
  4592. testExpression: ShaderDefineExpression;
  4593. isValid(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4602. define: string;
  4603. not: boolean;
  4604. constructor(define: string, not?: boolean);
  4605. isTrue(preprocessors: {
  4606. [key: string]: string;
  4607. }): boolean;
  4608. }
  4609. }
  4610. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4611. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4612. /** @hidden */
  4613. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4614. leftOperand: ShaderDefineExpression;
  4615. rightOperand: ShaderDefineExpression;
  4616. isTrue(preprocessors: {
  4617. [key: string]: string;
  4618. }): boolean;
  4619. }
  4620. }
  4621. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4622. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4623. /** @hidden */
  4624. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4625. leftOperand: ShaderDefineExpression;
  4626. rightOperand: ShaderDefineExpression;
  4627. isTrue(preprocessors: {
  4628. [key: string]: string;
  4629. }): boolean;
  4630. }
  4631. }
  4632. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4633. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4634. /** @hidden */
  4635. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4636. define: string;
  4637. operand: string;
  4638. testValue: string;
  4639. constructor(define: string, operand: string, testValue: string);
  4640. isTrue(preprocessors: {
  4641. [key: string]: string;
  4642. }): boolean;
  4643. }
  4644. }
  4645. declare module "babylonjs/Misc/loadFileError" {
  4646. import { WebRequest } from "babylonjs/Misc/webRequest";
  4647. /**
  4648. * @ignore
  4649. * Application error to support additional information when loading a file
  4650. */
  4651. export class LoadFileError extends Error {
  4652. /** defines the optional web request */
  4653. request?: WebRequest | undefined;
  4654. private static _setPrototypeOf;
  4655. /**
  4656. * Creates a new LoadFileError
  4657. * @param message defines the message of the error
  4658. * @param request defines the optional web request
  4659. */
  4660. constructor(message: string,
  4661. /** defines the optional web request */
  4662. request?: WebRequest | undefined);
  4663. }
  4664. }
  4665. declare module "babylonjs/Offline/IOfflineProvider" {
  4666. /**
  4667. * Class used to enable access to offline support
  4668. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4669. */
  4670. export interface IOfflineProvider {
  4671. /**
  4672. * Gets a boolean indicating if scene must be saved in the database
  4673. */
  4674. enableSceneOffline: boolean;
  4675. /**
  4676. * Gets a boolean indicating if textures must be saved in the database
  4677. */
  4678. enableTexturesOffline: boolean;
  4679. /**
  4680. * Open the offline support and make it available
  4681. * @param successCallback defines the callback to call on success
  4682. * @param errorCallback defines the callback to call on error
  4683. */
  4684. open(successCallback: () => void, errorCallback: () => void): void;
  4685. /**
  4686. * Loads an image from the offline support
  4687. * @param url defines the url to load from
  4688. * @param image defines the target DOM image
  4689. */
  4690. loadImage(url: string, image: HTMLImageElement): void;
  4691. /**
  4692. * Loads a file from offline support
  4693. * @param url defines the URL to load from
  4694. * @param sceneLoaded defines a callback to call on success
  4695. * @param progressCallBack defines a callback to call when progress changed
  4696. * @param errorCallback defines a callback to call on error
  4697. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4698. */
  4699. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4700. }
  4701. }
  4702. declare module "babylonjs/Misc/filesInputStore" {
  4703. /**
  4704. * Class used to help managing file picking and drag'n'drop
  4705. * File Storage
  4706. */
  4707. export class FilesInputStore {
  4708. /**
  4709. * List of files ready to be loaded
  4710. */
  4711. static FilesToLoad: {
  4712. [key: string]: File;
  4713. };
  4714. }
  4715. }
  4716. declare module "babylonjs/Misc/retryStrategy" {
  4717. import { WebRequest } from "babylonjs/Misc/webRequest";
  4718. /**
  4719. * Class used to define a retry strategy when error happens while loading assets
  4720. */
  4721. export class RetryStrategy {
  4722. /**
  4723. * Function used to defines an exponential back off strategy
  4724. * @param maxRetries defines the maximum number of retries (3 by default)
  4725. * @param baseInterval defines the interval between retries
  4726. * @returns the strategy function to use
  4727. */
  4728. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4729. }
  4730. }
  4731. declare module "babylonjs/Misc/fileTools" {
  4732. import { WebRequest } from "babylonjs/Misc/webRequest";
  4733. import { Nullable } from "babylonjs/types";
  4734. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4735. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4736. /**
  4737. * @hidden
  4738. */
  4739. export class FileTools {
  4740. /**
  4741. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4742. */
  4743. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4744. /**
  4745. * Gets or sets the base URL to use to load assets
  4746. */
  4747. static BaseUrl: string;
  4748. /**
  4749. * Default behaviour for cors in the application.
  4750. * It can be a string if the expected behavior is identical in the entire app.
  4751. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4752. */
  4753. static CorsBehavior: string | ((url: string | string[]) => string);
  4754. /**
  4755. * Gets or sets a function used to pre-process url before using them to load assets
  4756. */
  4757. static PreprocessUrl: (url: string) => string;
  4758. /**
  4759. * Removes unwanted characters from an url
  4760. * @param url defines the url to clean
  4761. * @returns the cleaned url
  4762. */
  4763. private static _CleanUrl;
  4764. /**
  4765. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4766. * @param url define the url we are trying
  4767. * @param element define the dom element where to configure the cors policy
  4768. */
  4769. static SetCorsBehavior(url: string | string[], element: {
  4770. crossOrigin: string | null;
  4771. }): void;
  4772. /**
  4773. * Loads an image as an HTMLImageElement.
  4774. * @param input url string, ArrayBuffer, or Blob to load
  4775. * @param onLoad callback called when the image successfully loads
  4776. * @param onError callback called when the image fails to load
  4777. * @param offlineProvider offline provider for caching
  4778. * @returns the HTMLImageElement of the loaded image
  4779. */
  4780. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4781. /**
  4782. * Loads a file
  4783. * @param fileToLoad defines the file to load
  4784. * @param callback defines the callback to call when data is loaded
  4785. * @param progressCallBack defines the callback to call during loading process
  4786. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4787. * @returns a file request object
  4788. */
  4789. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4790. /**
  4791. * Loads a file
  4792. * @param url url string, ArrayBuffer, or Blob to load
  4793. * @param onSuccess callback called when the file successfully loads
  4794. * @param onProgress callback called while file is loading (if the server supports this mode)
  4795. * @param offlineProvider defines the offline provider for caching
  4796. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4797. * @param onError callback called when the file fails to load
  4798. * @returns a file request object
  4799. */
  4800. 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;
  4801. /**
  4802. * Checks if the loaded document was accessed via `file:`-Protocol.
  4803. * @returns boolean
  4804. */
  4805. static IsFileURL(): boolean;
  4806. }
  4807. }
  4808. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4809. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4810. /** @hidden */
  4811. export class ShaderProcessor {
  4812. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4813. private static _ProcessPrecision;
  4814. private static _ExtractOperation;
  4815. private static _BuildSubExpression;
  4816. private static _BuildExpression;
  4817. private static _MoveCursorWithinIf;
  4818. private static _MoveCursor;
  4819. private static _EvaluatePreProcessors;
  4820. private static _PreparePreProcessors;
  4821. private static _ProcessShaderConversion;
  4822. private static _ProcessIncludes;
  4823. }
  4824. }
  4825. declare module "babylonjs/Maths/math.color" {
  4826. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4827. /**
  4828. * Class used to hold a RBG color
  4829. */
  4830. export class Color3 {
  4831. /**
  4832. * Defines the red component (between 0 and 1, default is 0)
  4833. */
  4834. r: number;
  4835. /**
  4836. * Defines the green component (between 0 and 1, default is 0)
  4837. */
  4838. g: number;
  4839. /**
  4840. * Defines the blue component (between 0 and 1, default is 0)
  4841. */
  4842. b: number;
  4843. /**
  4844. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4845. * @param r defines the red component (between 0 and 1, default is 0)
  4846. * @param g defines the green component (between 0 and 1, default is 0)
  4847. * @param b defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. constructor(
  4850. /**
  4851. * Defines the red component (between 0 and 1, default is 0)
  4852. */
  4853. r?: number,
  4854. /**
  4855. * Defines the green component (between 0 and 1, default is 0)
  4856. */
  4857. g?: number,
  4858. /**
  4859. * Defines the blue component (between 0 and 1, default is 0)
  4860. */
  4861. b?: number);
  4862. /**
  4863. * Creates a string with the Color3 current values
  4864. * @returns the string representation of the Color3 object
  4865. */
  4866. toString(): string;
  4867. /**
  4868. * Returns the string "Color3"
  4869. * @returns "Color3"
  4870. */
  4871. getClassName(): string;
  4872. /**
  4873. * Compute the Color3 hash code
  4874. * @returns an unique number that can be used to hash Color3 objects
  4875. */
  4876. getHashCode(): number;
  4877. /**
  4878. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4879. * @param array defines the array where to store the r,g,b components
  4880. * @param index defines an optional index in the target array to define where to start storing values
  4881. * @returns the current Color3 object
  4882. */
  4883. toArray(array: FloatArray, index?: number): Color3;
  4884. /**
  4885. * Returns a new Color4 object from the current Color3 and the given alpha
  4886. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4887. * @returns a new Color4 object
  4888. */
  4889. toColor4(alpha?: number): Color4;
  4890. /**
  4891. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4892. * @returns the new array
  4893. */
  4894. asArray(): number[];
  4895. /**
  4896. * Returns the luminance value
  4897. * @returns a float value
  4898. */
  4899. toLuminance(): number;
  4900. /**
  4901. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4902. * @param otherColor defines the second operand
  4903. * @returns the new Color3 object
  4904. */
  4905. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4906. /**
  4907. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4908. * @param otherColor defines the second operand
  4909. * @param result defines the Color3 object where to store the result
  4910. * @returns the current Color3
  4911. */
  4912. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4913. /**
  4914. * Determines equality between Color3 objects
  4915. * @param otherColor defines the second operand
  4916. * @returns true if the rgb values are equal to the given ones
  4917. */
  4918. equals(otherColor: DeepImmutable<Color3>): boolean;
  4919. /**
  4920. * Determines equality between the current Color3 object and a set of r,b,g values
  4921. * @param r defines the red component to check
  4922. * @param g defines the green component to check
  4923. * @param b defines the blue component to check
  4924. * @returns true if the rgb values are equal to the given ones
  4925. */
  4926. equalsFloats(r: number, g: number, b: number): boolean;
  4927. /**
  4928. * Multiplies in place each rgb value by scale
  4929. * @param scale defines the scaling factor
  4930. * @returns the updated Color3
  4931. */
  4932. scale(scale: number): Color3;
  4933. /**
  4934. * Multiplies the rgb values by scale and stores the result into "result"
  4935. * @param scale defines the scaling factor
  4936. * @param result defines the Color3 object where to store the result
  4937. * @returns the unmodified current Color3
  4938. */
  4939. scaleToRef(scale: number, result: Color3): Color3;
  4940. /**
  4941. * Scale the current Color3 values by a factor and add the result to a given Color3
  4942. * @param scale defines the scale factor
  4943. * @param result defines color to store the result into
  4944. * @returns the unmodified current Color3
  4945. */
  4946. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4947. /**
  4948. * Clamps the rgb values by the min and max values and stores the result into "result"
  4949. * @param min defines minimum clamping value (default is 0)
  4950. * @param max defines maximum clamping value (default is 1)
  4951. * @param result defines color to store the result into
  4952. * @returns the original Color3
  4953. */
  4954. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4955. /**
  4956. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4957. * @param otherColor defines the second operand
  4958. * @returns the new Color3
  4959. */
  4960. add(otherColor: DeepImmutable<Color3>): Color3;
  4961. /**
  4962. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4963. * @param otherColor defines the second operand
  4964. * @param result defines Color3 object to store the result into
  4965. * @returns the unmodified current Color3
  4966. */
  4967. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4968. /**
  4969. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4970. * @param otherColor defines the second operand
  4971. * @returns the new Color3
  4972. */
  4973. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4974. /**
  4975. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4976. * @param otherColor defines the second operand
  4977. * @param result defines Color3 object to store the result into
  4978. * @returns the unmodified current Color3
  4979. */
  4980. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4981. /**
  4982. * Copy the current object
  4983. * @returns a new Color3 copied the current one
  4984. */
  4985. clone(): Color3;
  4986. /**
  4987. * Copies the rgb values from the source in the current Color3
  4988. * @param source defines the source Color3 object
  4989. * @returns the updated Color3 object
  4990. */
  4991. copyFrom(source: DeepImmutable<Color3>): Color3;
  4992. /**
  4993. * Updates the Color3 rgb values from the given floats
  4994. * @param r defines the red component to read from
  4995. * @param g defines the green component to read from
  4996. * @param b defines the blue component to read from
  4997. * @returns the current Color3 object
  4998. */
  4999. copyFromFloats(r: number, g: number, b: number): Color3;
  5000. /**
  5001. * Updates the Color3 rgb values from the given floats
  5002. * @param r defines the red component to read from
  5003. * @param g defines the green component to read from
  5004. * @param b defines the blue component to read from
  5005. * @returns the current Color3 object
  5006. */
  5007. set(r: number, g: number, b: number): Color3;
  5008. /**
  5009. * Compute the Color3 hexadecimal code as a string
  5010. * @returns a string containing the hexadecimal representation of the Color3 object
  5011. */
  5012. toHexString(): string;
  5013. /**
  5014. * Computes a new Color3 converted from the current one to linear space
  5015. * @returns a new Color3 object
  5016. */
  5017. toLinearSpace(): Color3;
  5018. /**
  5019. * Converts current color in rgb space to HSV values
  5020. * @returns a new color3 representing the HSV values
  5021. */
  5022. toHSV(): Color3;
  5023. /**
  5024. * Converts current color in rgb space to HSV values
  5025. * @param result defines the Color3 where to store the HSV values
  5026. */
  5027. toHSVToRef(result: Color3): void;
  5028. /**
  5029. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5030. * @param convertedColor defines the Color3 object where to store the linear space version
  5031. * @returns the unmodified Color3
  5032. */
  5033. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5034. /**
  5035. * Computes a new Color3 converted from the current one to gamma space
  5036. * @returns a new Color3 object
  5037. */
  5038. toGammaSpace(): Color3;
  5039. /**
  5040. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5041. * @param convertedColor defines the Color3 object where to store the gamma space version
  5042. * @returns the unmodified Color3
  5043. */
  5044. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5045. private static _BlackReadOnly;
  5046. /**
  5047. * Convert Hue, saturation and value to a Color3 (RGB)
  5048. * @param hue defines the hue
  5049. * @param saturation defines the saturation
  5050. * @param value defines the value
  5051. * @param result defines the Color3 where to store the RGB values
  5052. */
  5053. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5054. /**
  5055. * Creates a new Color3 from the string containing valid hexadecimal values
  5056. * @param hex defines a string containing valid hexadecimal values
  5057. * @returns a new Color3 object
  5058. */
  5059. static FromHexString(hex: string): Color3;
  5060. /**
  5061. * Creates a new Color3 from the starting index of the given array
  5062. * @param array defines the source array
  5063. * @param offset defines an offset in the source array
  5064. * @returns a new Color3 object
  5065. */
  5066. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5067. /**
  5068. * Creates a new Color3 from integer values (< 256)
  5069. * @param r defines the red component to read from (value between 0 and 255)
  5070. * @param g defines the green component to read from (value between 0 and 255)
  5071. * @param b defines the blue component to read from (value between 0 and 255)
  5072. * @returns a new Color3 object
  5073. */
  5074. static FromInts(r: number, g: number, b: number): Color3;
  5075. /**
  5076. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5077. * @param start defines the start Color3 value
  5078. * @param end defines the end Color3 value
  5079. * @param amount defines the gradient value between start and end
  5080. * @returns a new Color3 object
  5081. */
  5082. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5083. /**
  5084. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5085. * @param left defines the start value
  5086. * @param right defines the end value
  5087. * @param amount defines the gradient factor
  5088. * @param result defines the Color3 object where to store the result
  5089. */
  5090. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5091. /**
  5092. * Returns a Color3 value containing a red color
  5093. * @returns a new Color3 object
  5094. */
  5095. static Red(): Color3;
  5096. /**
  5097. * Returns a Color3 value containing a green color
  5098. * @returns a new Color3 object
  5099. */
  5100. static Green(): Color3;
  5101. /**
  5102. * Returns a Color3 value containing a blue color
  5103. * @returns a new Color3 object
  5104. */
  5105. static Blue(): Color3;
  5106. /**
  5107. * Returns a Color3 value containing a black color
  5108. * @returns a new Color3 object
  5109. */
  5110. static Black(): Color3;
  5111. /**
  5112. * Gets a Color3 value containing a black color that must not be updated
  5113. */
  5114. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5115. /**
  5116. * Returns a Color3 value containing a white color
  5117. * @returns a new Color3 object
  5118. */
  5119. static White(): Color3;
  5120. /**
  5121. * Returns a Color3 value containing a purple color
  5122. * @returns a new Color3 object
  5123. */
  5124. static Purple(): Color3;
  5125. /**
  5126. * Returns a Color3 value containing a magenta color
  5127. * @returns a new Color3 object
  5128. */
  5129. static Magenta(): Color3;
  5130. /**
  5131. * Returns a Color3 value containing a yellow color
  5132. * @returns a new Color3 object
  5133. */
  5134. static Yellow(): Color3;
  5135. /**
  5136. * Returns a Color3 value containing a gray color
  5137. * @returns a new Color3 object
  5138. */
  5139. static Gray(): Color3;
  5140. /**
  5141. * Returns a Color3 value containing a teal color
  5142. * @returns a new Color3 object
  5143. */
  5144. static Teal(): Color3;
  5145. /**
  5146. * Returns a Color3 value containing a random color
  5147. * @returns a new Color3 object
  5148. */
  5149. static Random(): Color3;
  5150. }
  5151. /**
  5152. * Class used to hold a RBGA color
  5153. */
  5154. export class Color4 {
  5155. /**
  5156. * Defines the red component (between 0 and 1, default is 0)
  5157. */
  5158. r: number;
  5159. /**
  5160. * Defines the green component (between 0 and 1, default is 0)
  5161. */
  5162. g: number;
  5163. /**
  5164. * Defines the blue component (between 0 and 1, default is 0)
  5165. */
  5166. b: number;
  5167. /**
  5168. * Defines the alpha component (between 0 and 1, default is 1)
  5169. */
  5170. a: number;
  5171. /**
  5172. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5173. * @param r defines the red component (between 0 and 1, default is 0)
  5174. * @param g defines the green component (between 0 and 1, default is 0)
  5175. * @param b defines the blue component (between 0 and 1, default is 0)
  5176. * @param a defines the alpha component (between 0 and 1, default is 1)
  5177. */
  5178. constructor(
  5179. /**
  5180. * Defines the red component (between 0 and 1, default is 0)
  5181. */
  5182. r?: number,
  5183. /**
  5184. * Defines the green component (between 0 and 1, default is 0)
  5185. */
  5186. g?: number,
  5187. /**
  5188. * Defines the blue component (between 0 and 1, default is 0)
  5189. */
  5190. b?: number,
  5191. /**
  5192. * Defines the alpha component (between 0 and 1, default is 1)
  5193. */
  5194. a?: number);
  5195. /**
  5196. * Adds in place the given Color4 values to the current Color4 object
  5197. * @param right defines the second operand
  5198. * @returns the current updated Color4 object
  5199. */
  5200. addInPlace(right: DeepImmutable<Color4>): Color4;
  5201. /**
  5202. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5203. * @returns the new array
  5204. */
  5205. asArray(): number[];
  5206. /**
  5207. * Stores from the starting index in the given array the Color4 successive values
  5208. * @param array defines the array where to store the r,g,b components
  5209. * @param index defines an optional index in the target array to define where to start storing values
  5210. * @returns the current Color4 object
  5211. */
  5212. toArray(array: number[], index?: number): Color4;
  5213. /**
  5214. * Determines equality between Color4 objects
  5215. * @param otherColor defines the second operand
  5216. * @returns true if the rgba values are equal to the given ones
  5217. */
  5218. equals(otherColor: DeepImmutable<Color4>): boolean;
  5219. /**
  5220. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5221. * @param right defines the second operand
  5222. * @returns a new Color4 object
  5223. */
  5224. add(right: DeepImmutable<Color4>): Color4;
  5225. /**
  5226. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5227. * @param right defines the second operand
  5228. * @returns a new Color4 object
  5229. */
  5230. subtract(right: DeepImmutable<Color4>): Color4;
  5231. /**
  5232. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5233. * @param right defines the second operand
  5234. * @param result defines the Color4 object where to store the result
  5235. * @returns the current Color4 object
  5236. */
  5237. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5238. /**
  5239. * Creates a new Color4 with the current Color4 values multiplied by scale
  5240. * @param scale defines the scaling factor to apply
  5241. * @returns a new Color4 object
  5242. */
  5243. scale(scale: number): Color4;
  5244. /**
  5245. * Multiplies the current Color4 values by scale and stores the result in "result"
  5246. * @param scale defines the scaling factor to apply
  5247. * @param result defines the Color4 object where to store the result
  5248. * @returns the current unmodified Color4
  5249. */
  5250. scaleToRef(scale: number, result: Color4): Color4;
  5251. /**
  5252. * Scale the current Color4 values by a factor and add the result to a given Color4
  5253. * @param scale defines the scale factor
  5254. * @param result defines the Color4 object where to store the result
  5255. * @returns the unmodified current Color4
  5256. */
  5257. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5258. /**
  5259. * Clamps the rgb values by the min and max values and stores the result into "result"
  5260. * @param min defines minimum clamping value (default is 0)
  5261. * @param max defines maximum clamping value (default is 1)
  5262. * @param result defines color to store the result into.
  5263. * @returns the cuurent Color4
  5264. */
  5265. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5266. /**
  5267. * Multipy an Color4 value by another and return a new Color4 object
  5268. * @param color defines the Color4 value to multiply by
  5269. * @returns a new Color4 object
  5270. */
  5271. multiply(color: Color4): Color4;
  5272. /**
  5273. * Multipy a Color4 value by another and push the result in a reference value
  5274. * @param color defines the Color4 value to multiply by
  5275. * @param result defines the Color4 to fill the result in
  5276. * @returns the result Color4
  5277. */
  5278. multiplyToRef(color: Color4, result: Color4): Color4;
  5279. /**
  5280. * Creates a string with the Color4 current values
  5281. * @returns the string representation of the Color4 object
  5282. */
  5283. toString(): string;
  5284. /**
  5285. * Returns the string "Color4"
  5286. * @returns "Color4"
  5287. */
  5288. getClassName(): string;
  5289. /**
  5290. * Compute the Color4 hash code
  5291. * @returns an unique number that can be used to hash Color4 objects
  5292. */
  5293. getHashCode(): number;
  5294. /**
  5295. * Creates a new Color4 copied from the current one
  5296. * @returns a new Color4 object
  5297. */
  5298. clone(): Color4;
  5299. /**
  5300. * Copies the given Color4 values into the current one
  5301. * @param source defines the source Color4 object
  5302. * @returns the current updated Color4 object
  5303. */
  5304. copyFrom(source: Color4): Color4;
  5305. /**
  5306. * Copies the given float values into the current one
  5307. * @param r defines the red component to read from
  5308. * @param g defines the green component to read from
  5309. * @param b defines the blue component to read from
  5310. * @param a defines the alpha component to read from
  5311. * @returns the current updated Color4 object
  5312. */
  5313. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5314. /**
  5315. * Copies the given float values into the current one
  5316. * @param r defines the red component to read from
  5317. * @param g defines the green component to read from
  5318. * @param b defines the blue component to read from
  5319. * @param a defines the alpha component to read from
  5320. * @returns the current updated Color4 object
  5321. */
  5322. set(r: number, g: number, b: number, a: number): Color4;
  5323. /**
  5324. * Compute the Color4 hexadecimal code as a string
  5325. * @returns a string containing the hexadecimal representation of the Color4 object
  5326. */
  5327. toHexString(): string;
  5328. /**
  5329. * Computes a new Color4 converted from the current one to linear space
  5330. * @returns a new Color4 object
  5331. */
  5332. toLinearSpace(): Color4;
  5333. /**
  5334. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5335. * @param convertedColor defines the Color4 object where to store the linear space version
  5336. * @returns the unmodified Color4
  5337. */
  5338. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5339. /**
  5340. * Computes a new Color4 converted from the current one to gamma space
  5341. * @returns a new Color4 object
  5342. */
  5343. toGammaSpace(): Color4;
  5344. /**
  5345. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5346. * @param convertedColor defines the Color4 object where to store the gamma space version
  5347. * @returns the unmodified Color4
  5348. */
  5349. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5350. /**
  5351. * Creates a new Color4 from the string containing valid hexadecimal values
  5352. * @param hex defines a string containing valid hexadecimal values
  5353. * @returns a new Color4 object
  5354. */
  5355. static FromHexString(hex: string): Color4;
  5356. /**
  5357. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5358. * @param left defines the start value
  5359. * @param right defines the end value
  5360. * @param amount defines the gradient factor
  5361. * @returns a new Color4 object
  5362. */
  5363. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5364. /**
  5365. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5366. * @param left defines the start value
  5367. * @param right defines the end value
  5368. * @param amount defines the gradient factor
  5369. * @param result defines the Color4 object where to store data
  5370. */
  5371. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5372. /**
  5373. * Creates a new Color4 from a Color3 and an alpha value
  5374. * @param color3 defines the source Color3 to read from
  5375. * @param alpha defines the alpha component (1.0 by default)
  5376. * @returns a new Color4 object
  5377. */
  5378. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5379. /**
  5380. * Creates a new Color4 from the starting index element of the given array
  5381. * @param array defines the source array to read from
  5382. * @param offset defines the offset in the source array
  5383. * @returns a new Color4 object
  5384. */
  5385. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5386. /**
  5387. * Creates a new Color3 from integer values (< 256)
  5388. * @param r defines the red component to read from (value between 0 and 255)
  5389. * @param g defines the green component to read from (value between 0 and 255)
  5390. * @param b defines the blue component to read from (value between 0 and 255)
  5391. * @param a defines the alpha component to read from (value between 0 and 255)
  5392. * @returns a new Color3 object
  5393. */
  5394. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5395. /**
  5396. * Check the content of a given array and convert it to an array containing RGBA data
  5397. * If the original array was already containing count * 4 values then it is returned directly
  5398. * @param colors defines the array to check
  5399. * @param count defines the number of RGBA data to expect
  5400. * @returns an array containing count * 4 values (RGBA)
  5401. */
  5402. static CheckColors4(colors: number[], count: number): number[];
  5403. }
  5404. /**
  5405. * @hidden
  5406. */
  5407. export class TmpColors {
  5408. static Color3: Color3[];
  5409. static Color4: Color4[];
  5410. }
  5411. }
  5412. declare module "babylonjs/Maths/sphericalPolynomial" {
  5413. import { Vector3 } from "babylonjs/Maths/math.vector";
  5414. import { Color3 } from "babylonjs/Maths/math.color";
  5415. /**
  5416. * Class representing spherical harmonics coefficients to the 3rd degree
  5417. */
  5418. export class SphericalHarmonics {
  5419. /**
  5420. * Defines whether or not the harmonics have been prescaled for rendering.
  5421. */
  5422. preScaled: boolean;
  5423. /**
  5424. * The l0,0 coefficients of the spherical harmonics
  5425. */
  5426. l00: Vector3;
  5427. /**
  5428. * The l1,-1 coefficients of the spherical harmonics
  5429. */
  5430. l1_1: Vector3;
  5431. /**
  5432. * The l1,0 coefficients of the spherical harmonics
  5433. */
  5434. l10: Vector3;
  5435. /**
  5436. * The l1,1 coefficients of the spherical harmonics
  5437. */
  5438. l11: Vector3;
  5439. /**
  5440. * The l2,-2 coefficients of the spherical harmonics
  5441. */
  5442. l2_2: Vector3;
  5443. /**
  5444. * The l2,-1 coefficients of the spherical harmonics
  5445. */
  5446. l2_1: Vector3;
  5447. /**
  5448. * The l2,0 coefficients of the spherical harmonics
  5449. */
  5450. l20: Vector3;
  5451. /**
  5452. * The l2,1 coefficients of the spherical harmonics
  5453. */
  5454. l21: Vector3;
  5455. /**
  5456. * The l2,2 coefficients of the spherical harmonics
  5457. */
  5458. l22: Vector3;
  5459. /**
  5460. * Adds a light to the spherical harmonics
  5461. * @param direction the direction of the light
  5462. * @param color the color of the light
  5463. * @param deltaSolidAngle the delta solid angle of the light
  5464. */
  5465. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5466. /**
  5467. * Scales the spherical harmonics by the given amount
  5468. * @param scale the amount to scale
  5469. */
  5470. scaleInPlace(scale: number): void;
  5471. /**
  5472. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5473. *
  5474. * ```
  5475. * E_lm = A_l * L_lm
  5476. * ```
  5477. *
  5478. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5479. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5480. * the scaling factors are given in equation 9.
  5481. */
  5482. convertIncidentRadianceToIrradiance(): void;
  5483. /**
  5484. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5485. *
  5486. * ```
  5487. * L = (1/pi) * E * rho
  5488. * ```
  5489. *
  5490. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5491. */
  5492. convertIrradianceToLambertianRadiance(): void;
  5493. /**
  5494. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5495. * required operations at run time.
  5496. *
  5497. * This is simply done by scaling back the SH with Ylm constants parameter.
  5498. * The trigonometric part being applied by the shader at run time.
  5499. */
  5500. preScaleForRendering(): void;
  5501. /**
  5502. * Constructs a spherical harmonics from an array.
  5503. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5504. * @returns the spherical harmonics
  5505. */
  5506. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5507. /**
  5508. * Gets the spherical harmonics from polynomial
  5509. * @param polynomial the spherical polynomial
  5510. * @returns the spherical harmonics
  5511. */
  5512. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5513. }
  5514. /**
  5515. * Class representing spherical polynomial coefficients to the 3rd degree
  5516. */
  5517. export class SphericalPolynomial {
  5518. private _harmonics;
  5519. /**
  5520. * The spherical harmonics used to create the polynomials.
  5521. */
  5522. readonly preScaledHarmonics: SphericalHarmonics;
  5523. /**
  5524. * The x coefficients of the spherical polynomial
  5525. */
  5526. x: Vector3;
  5527. /**
  5528. * The y coefficients of the spherical polynomial
  5529. */
  5530. y: Vector3;
  5531. /**
  5532. * The z coefficients of the spherical polynomial
  5533. */
  5534. z: Vector3;
  5535. /**
  5536. * The xx coefficients of the spherical polynomial
  5537. */
  5538. xx: Vector3;
  5539. /**
  5540. * The yy coefficients of the spherical polynomial
  5541. */
  5542. yy: Vector3;
  5543. /**
  5544. * The zz coefficients of the spherical polynomial
  5545. */
  5546. zz: Vector3;
  5547. /**
  5548. * The xy coefficients of the spherical polynomial
  5549. */
  5550. xy: Vector3;
  5551. /**
  5552. * The yz coefficients of the spherical polynomial
  5553. */
  5554. yz: Vector3;
  5555. /**
  5556. * The zx coefficients of the spherical polynomial
  5557. */
  5558. zx: Vector3;
  5559. /**
  5560. * Adds an ambient color to the spherical polynomial
  5561. * @param color the color to add
  5562. */
  5563. addAmbient(color: Color3): void;
  5564. /**
  5565. * Scales the spherical polynomial by the given amount
  5566. * @param scale the amount to scale
  5567. */
  5568. scaleInPlace(scale: number): void;
  5569. /**
  5570. * Gets the spherical polynomial from harmonics
  5571. * @param harmonics the spherical harmonics
  5572. * @returns the spherical polynomial
  5573. */
  5574. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5575. /**
  5576. * Constructs a spherical polynomial from an array.
  5577. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5578. * @returns the spherical polynomial
  5579. */
  5580. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5581. }
  5582. }
  5583. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5584. /**
  5585. * Define options used to create a render target texture
  5586. */
  5587. export class RenderTargetCreationOptions {
  5588. /**
  5589. * Specifies is mipmaps must be generated
  5590. */
  5591. generateMipMaps?: boolean;
  5592. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5593. generateDepthBuffer?: boolean;
  5594. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5595. generateStencilBuffer?: boolean;
  5596. /** Defines texture type (int by default) */
  5597. type?: number;
  5598. /** Defines sampling mode (trilinear by default) */
  5599. samplingMode?: number;
  5600. /** Defines format (RGBA by default) */
  5601. format?: number;
  5602. }
  5603. }
  5604. declare module "babylonjs/States/alphaCullingState" {
  5605. /**
  5606. * @hidden
  5607. **/
  5608. export class _AlphaState {
  5609. private _isAlphaBlendDirty;
  5610. private _isBlendFunctionParametersDirty;
  5611. private _isBlendEquationParametersDirty;
  5612. private _isBlendConstantsDirty;
  5613. private _alphaBlend;
  5614. private _blendFunctionParameters;
  5615. private _blendEquationParameters;
  5616. private _blendConstants;
  5617. /**
  5618. * Initializes the state.
  5619. */
  5620. constructor();
  5621. readonly isDirty: boolean;
  5622. alphaBlend: boolean;
  5623. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5624. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5625. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5626. reset(): void;
  5627. apply(gl: WebGLRenderingContext): void;
  5628. }
  5629. }
  5630. declare module "babylonjs/States/depthCullingState" {
  5631. import { Nullable } from "babylonjs/types";
  5632. /**
  5633. * @hidden
  5634. **/
  5635. export class _DepthCullingState {
  5636. private _isDepthTestDirty;
  5637. private _isDepthMaskDirty;
  5638. private _isDepthFuncDirty;
  5639. private _isCullFaceDirty;
  5640. private _isCullDirty;
  5641. private _isZOffsetDirty;
  5642. private _isFrontFaceDirty;
  5643. private _depthTest;
  5644. private _depthMask;
  5645. private _depthFunc;
  5646. private _cull;
  5647. private _cullFace;
  5648. private _zOffset;
  5649. private _frontFace;
  5650. /**
  5651. * Initializes the state.
  5652. */
  5653. constructor();
  5654. readonly isDirty: boolean;
  5655. zOffset: number;
  5656. cullFace: Nullable<number>;
  5657. cull: Nullable<boolean>;
  5658. depthFunc: Nullable<number>;
  5659. depthMask: boolean;
  5660. depthTest: boolean;
  5661. frontFace: Nullable<number>;
  5662. reset(): void;
  5663. apply(gl: WebGLRenderingContext): void;
  5664. }
  5665. }
  5666. declare module "babylonjs/States/stencilState" {
  5667. /**
  5668. * @hidden
  5669. **/
  5670. export class _StencilState {
  5671. /** 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 */
  5672. static readonly ALWAYS: number;
  5673. /** Passed to stencilOperation to specify that stencil value must be kept */
  5674. static readonly KEEP: number;
  5675. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5676. static readonly REPLACE: number;
  5677. private _isStencilTestDirty;
  5678. private _isStencilMaskDirty;
  5679. private _isStencilFuncDirty;
  5680. private _isStencilOpDirty;
  5681. private _stencilTest;
  5682. private _stencilMask;
  5683. private _stencilFunc;
  5684. private _stencilFuncRef;
  5685. private _stencilFuncMask;
  5686. private _stencilOpStencilFail;
  5687. private _stencilOpDepthFail;
  5688. private _stencilOpStencilDepthPass;
  5689. readonly isDirty: boolean;
  5690. stencilFunc: number;
  5691. stencilFuncRef: number;
  5692. stencilFuncMask: number;
  5693. stencilOpStencilFail: number;
  5694. stencilOpDepthFail: number;
  5695. stencilOpStencilDepthPass: number;
  5696. stencilMask: number;
  5697. stencilTest: boolean;
  5698. constructor();
  5699. reset(): void;
  5700. apply(gl: WebGLRenderingContext): void;
  5701. }
  5702. }
  5703. declare module "babylonjs/States/index" {
  5704. export * from "babylonjs/States/alphaCullingState";
  5705. export * from "babylonjs/States/depthCullingState";
  5706. export * from "babylonjs/States/stencilState";
  5707. }
  5708. declare module "babylonjs/Instrumentation/timeToken" {
  5709. import { Nullable } from "babylonjs/types";
  5710. /**
  5711. * @hidden
  5712. **/
  5713. export class _TimeToken {
  5714. _startTimeQuery: Nullable<WebGLQuery>;
  5715. _endTimeQuery: Nullable<WebGLQuery>;
  5716. _timeElapsedQuery: Nullable<WebGLQuery>;
  5717. _timeElapsedQueryEnded: boolean;
  5718. }
  5719. }
  5720. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5721. /**
  5722. * Class used to evalaute queries containing `and` and `or` operators
  5723. */
  5724. export class AndOrNotEvaluator {
  5725. /**
  5726. * Evaluate a query
  5727. * @param query defines the query to evaluate
  5728. * @param evaluateCallback defines the callback used to filter result
  5729. * @returns true if the query matches
  5730. */
  5731. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5732. private static _HandleParenthesisContent;
  5733. private static _SimplifyNegation;
  5734. }
  5735. }
  5736. declare module "babylonjs/Misc/tags" {
  5737. /**
  5738. * Class used to store custom tags
  5739. */
  5740. export class Tags {
  5741. /**
  5742. * Adds support for tags on the given object
  5743. * @param obj defines the object to use
  5744. */
  5745. static EnableFor(obj: any): void;
  5746. /**
  5747. * Removes tags support
  5748. * @param obj defines the object to use
  5749. */
  5750. static DisableFor(obj: any): void;
  5751. /**
  5752. * Gets a boolean indicating if the given object has tags
  5753. * @param obj defines the object to use
  5754. * @returns a boolean
  5755. */
  5756. static HasTags(obj: any): boolean;
  5757. /**
  5758. * Gets the tags available on a given object
  5759. * @param obj defines the object to use
  5760. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5761. * @returns the tags
  5762. */
  5763. static GetTags(obj: any, asString?: boolean): any;
  5764. /**
  5765. * Adds tags to an object
  5766. * @param obj defines the object to use
  5767. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5768. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5769. */
  5770. static AddTagsTo(obj: any, tagsString: string): void;
  5771. /**
  5772. * @hidden
  5773. */
  5774. static _AddTagTo(obj: any, tag: string): void;
  5775. /**
  5776. * Removes specific tags from a specific object
  5777. * @param obj defines the object to use
  5778. * @param tagsString defines the tags to remove
  5779. */
  5780. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5781. /**
  5782. * @hidden
  5783. */
  5784. static _RemoveTagFrom(obj: any, tag: string): void;
  5785. /**
  5786. * Defines if tags hosted on an object match a given query
  5787. * @param obj defines the object to use
  5788. * @param tagsQuery defines the tag query
  5789. * @returns a boolean
  5790. */
  5791. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5792. }
  5793. }
  5794. declare module "babylonjs/Maths/math.path" {
  5795. import { DeepImmutable, Nullable } from "babylonjs/types";
  5796. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5797. /**
  5798. * Defines potential orientation for back face culling
  5799. */
  5800. export enum Orientation {
  5801. /**
  5802. * Clockwise
  5803. */
  5804. CW = 0,
  5805. /** Counter clockwise */
  5806. CCW = 1
  5807. }
  5808. /** Class used to represent a Bezier curve */
  5809. export class BezierCurve {
  5810. /**
  5811. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5812. * @param t defines the time
  5813. * @param x1 defines the left coordinate on X axis
  5814. * @param y1 defines the left coordinate on Y axis
  5815. * @param x2 defines the right coordinate on X axis
  5816. * @param y2 defines the right coordinate on Y axis
  5817. * @returns the interpolated value
  5818. */
  5819. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5820. }
  5821. /**
  5822. * Defines angle representation
  5823. */
  5824. export class Angle {
  5825. private _radians;
  5826. /**
  5827. * Creates an Angle object of "radians" radians (float).
  5828. * @param radians the angle in radians
  5829. */
  5830. constructor(radians: number);
  5831. /**
  5832. * Get value in degrees
  5833. * @returns the Angle value in degrees (float)
  5834. */
  5835. degrees(): number;
  5836. /**
  5837. * Get value in radians
  5838. * @returns the Angle value in radians (float)
  5839. */
  5840. radians(): number;
  5841. /**
  5842. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5843. * @param a defines first vector
  5844. * @param b defines second vector
  5845. * @returns a new Angle
  5846. */
  5847. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5848. /**
  5849. * Gets a new Angle object from the given float in radians
  5850. * @param radians defines the angle value in radians
  5851. * @returns a new Angle
  5852. */
  5853. static FromRadians(radians: number): Angle;
  5854. /**
  5855. * Gets a new Angle object from the given float in degrees
  5856. * @param degrees defines the angle value in degrees
  5857. * @returns a new Angle
  5858. */
  5859. static FromDegrees(degrees: number): Angle;
  5860. }
  5861. /**
  5862. * This represents an arc in a 2d space.
  5863. */
  5864. export class Arc2 {
  5865. /** Defines the start point of the arc */
  5866. startPoint: Vector2;
  5867. /** Defines the mid point of the arc */
  5868. midPoint: Vector2;
  5869. /** Defines the end point of the arc */
  5870. endPoint: Vector2;
  5871. /**
  5872. * Defines the center point of the arc.
  5873. */
  5874. centerPoint: Vector2;
  5875. /**
  5876. * Defines the radius of the arc.
  5877. */
  5878. radius: number;
  5879. /**
  5880. * Defines the angle of the arc (from mid point to end point).
  5881. */
  5882. angle: Angle;
  5883. /**
  5884. * Defines the start angle of the arc (from start point to middle point).
  5885. */
  5886. startAngle: Angle;
  5887. /**
  5888. * Defines the orientation of the arc (clock wise/counter clock wise).
  5889. */
  5890. orientation: Orientation;
  5891. /**
  5892. * Creates an Arc object from the three given points : start, middle and end.
  5893. * @param startPoint Defines the start point of the arc
  5894. * @param midPoint Defines the midlle point of the arc
  5895. * @param endPoint Defines the end point of the arc
  5896. */
  5897. constructor(
  5898. /** Defines the start point of the arc */
  5899. startPoint: Vector2,
  5900. /** Defines the mid point of the arc */
  5901. midPoint: Vector2,
  5902. /** Defines the end point of the arc */
  5903. endPoint: Vector2);
  5904. }
  5905. /**
  5906. * Represents a 2D path made up of multiple 2D points
  5907. */
  5908. export class Path2 {
  5909. private _points;
  5910. private _length;
  5911. /**
  5912. * If the path start and end point are the same
  5913. */
  5914. closed: boolean;
  5915. /**
  5916. * Creates a Path2 object from the starting 2D coordinates x and y.
  5917. * @param x the starting points x value
  5918. * @param y the starting points y value
  5919. */
  5920. constructor(x: number, y: number);
  5921. /**
  5922. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5923. * @param x the added points x value
  5924. * @param y the added points y value
  5925. * @returns the updated Path2.
  5926. */
  5927. addLineTo(x: number, y: number): Path2;
  5928. /**
  5929. * 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.
  5930. * @param midX middle point x value
  5931. * @param midY middle point y value
  5932. * @param endX end point x value
  5933. * @param endY end point y value
  5934. * @param numberOfSegments (default: 36)
  5935. * @returns the updated Path2.
  5936. */
  5937. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5938. /**
  5939. * Closes the Path2.
  5940. * @returns the Path2.
  5941. */
  5942. close(): Path2;
  5943. /**
  5944. * Gets the sum of the distance between each sequential point in the path
  5945. * @returns the Path2 total length (float).
  5946. */
  5947. length(): number;
  5948. /**
  5949. * Gets the points which construct the path
  5950. * @returns the Path2 internal array of points.
  5951. */
  5952. getPoints(): Vector2[];
  5953. /**
  5954. * Retreives the point at the distance aways from the starting point
  5955. * @param normalizedLengthPosition the length along the path to retreive the point from
  5956. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5957. */
  5958. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5959. /**
  5960. * Creates a new path starting from an x and y position
  5961. * @param x starting x value
  5962. * @param y starting y value
  5963. * @returns a new Path2 starting at the coordinates (x, y).
  5964. */
  5965. static StartingAt(x: number, y: number): Path2;
  5966. }
  5967. /**
  5968. * Represents a 3D path made up of multiple 3D points
  5969. */
  5970. export class Path3D {
  5971. /**
  5972. * an array of Vector3, the curve axis of the Path3D
  5973. */
  5974. path: Vector3[];
  5975. private _curve;
  5976. private _distances;
  5977. private _tangents;
  5978. private _normals;
  5979. private _binormals;
  5980. private _raw;
  5981. /**
  5982. * new Path3D(path, normal, raw)
  5983. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5984. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5985. * @param path an array of Vector3, the curve axis of the Path3D
  5986. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5987. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5988. */
  5989. constructor(
  5990. /**
  5991. * an array of Vector3, the curve axis of the Path3D
  5992. */
  5993. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5994. /**
  5995. * Returns the Path3D array of successive Vector3 designing its curve.
  5996. * @returns the Path3D array of successive Vector3 designing its curve.
  5997. */
  5998. getCurve(): Vector3[];
  5999. /**
  6000. * Returns an array populated with tangent vectors on each Path3D curve point.
  6001. * @returns an array populated with tangent vectors on each Path3D curve point.
  6002. */
  6003. getTangents(): Vector3[];
  6004. /**
  6005. * Returns an array populated with normal vectors on each Path3D curve point.
  6006. * @returns an array populated with normal vectors on each Path3D curve point.
  6007. */
  6008. getNormals(): Vector3[];
  6009. /**
  6010. * Returns an array populated with binormal vectors on each Path3D curve point.
  6011. * @returns an array populated with binormal vectors on each Path3D curve point.
  6012. */
  6013. getBinormals(): Vector3[];
  6014. /**
  6015. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6016. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6017. */
  6018. getDistances(): number[];
  6019. /**
  6020. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6021. * @param path path which all values are copied into the curves points
  6022. * @param firstNormal which should be projected onto the curve
  6023. * @returns the same object updated.
  6024. */
  6025. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6026. private _compute;
  6027. private _getFirstNonNullVector;
  6028. private _getLastNonNullVector;
  6029. private _normalVector;
  6030. }
  6031. /**
  6032. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6033. * A Curve3 is designed from a series of successive Vector3.
  6034. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6035. */
  6036. export class Curve3 {
  6037. private _points;
  6038. private _length;
  6039. /**
  6040. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6041. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6042. * @param v1 (Vector3) the control point
  6043. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6044. * @param nbPoints (integer) the wanted number of points in the curve
  6045. * @returns the created Curve3
  6046. */
  6047. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6048. /**
  6049. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6050. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6051. * @param v1 (Vector3) the first control point
  6052. * @param v2 (Vector3) the second control point
  6053. * @param v3 (Vector3) the end point of the Cubic Bezier
  6054. * @param nbPoints (integer) the wanted number of points in the curve
  6055. * @returns the created Curve3
  6056. */
  6057. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6058. /**
  6059. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6060. * @param p1 (Vector3) the origin point of the Hermite Spline
  6061. * @param t1 (Vector3) the tangent vector at the origin point
  6062. * @param p2 (Vector3) the end point of the Hermite Spline
  6063. * @param t2 (Vector3) the tangent vector at the end point
  6064. * @param nbPoints (integer) the wanted number of points in the curve
  6065. * @returns the created Curve3
  6066. */
  6067. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6068. /**
  6069. * Returns a Curve3 object along a CatmullRom Spline curve :
  6070. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6071. * @param nbPoints (integer) the wanted number of points between each curve control points
  6072. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6073. * @returns the created Curve3
  6074. */
  6075. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6076. /**
  6077. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6078. * A Curve3 is designed from a series of successive Vector3.
  6079. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6080. * @param points points which make up the curve
  6081. */
  6082. constructor(points: Vector3[]);
  6083. /**
  6084. * @returns the Curve3 stored array of successive Vector3
  6085. */
  6086. getPoints(): Vector3[];
  6087. /**
  6088. * @returns the computed length (float) of the curve.
  6089. */
  6090. length(): number;
  6091. /**
  6092. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6093. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6094. * curveA and curveB keep unchanged.
  6095. * @param curve the curve to continue from this curve
  6096. * @returns the newly constructed curve
  6097. */
  6098. continue(curve: DeepImmutable<Curve3>): Curve3;
  6099. private _computeLength;
  6100. }
  6101. }
  6102. declare module "babylonjs/Animations/easing" {
  6103. /**
  6104. * This represents the main contract an easing function should follow.
  6105. * Easing functions are used throughout the animation system.
  6106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6107. */
  6108. export interface IEasingFunction {
  6109. /**
  6110. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6111. * of the easing function.
  6112. * The link below provides some of the most common examples of easing functions.
  6113. * @see https://easings.net/
  6114. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6115. * @returns the corresponding value on the curve defined by the easing function
  6116. */
  6117. ease(gradient: number): number;
  6118. }
  6119. /**
  6120. * Base class used for every default easing function.
  6121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6122. */
  6123. export class EasingFunction implements IEasingFunction {
  6124. /**
  6125. * Interpolation follows the mathematical formula associated with the easing function.
  6126. */
  6127. static readonly EASINGMODE_EASEIN: number;
  6128. /**
  6129. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6130. */
  6131. static readonly EASINGMODE_EASEOUT: number;
  6132. /**
  6133. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6134. */
  6135. static readonly EASINGMODE_EASEINOUT: number;
  6136. private _easingMode;
  6137. /**
  6138. * Sets the easing mode of the current function.
  6139. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6140. */
  6141. setEasingMode(easingMode: number): void;
  6142. /**
  6143. * Gets the current easing mode.
  6144. * @returns the easing mode
  6145. */
  6146. getEasingMode(): number;
  6147. /**
  6148. * @hidden
  6149. */
  6150. easeInCore(gradient: number): number;
  6151. /**
  6152. * Given an input gradient between 0 and 1, this returns the corresponding value
  6153. * of the easing function.
  6154. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6155. * @returns the corresponding value on the curve defined by the easing function
  6156. */
  6157. ease(gradient: number): number;
  6158. }
  6159. /**
  6160. * Easing function with a circle shape (see link below).
  6161. * @see https://easings.net/#easeInCirc
  6162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6163. */
  6164. export class CircleEase extends EasingFunction implements IEasingFunction {
  6165. /** @hidden */
  6166. easeInCore(gradient: number): number;
  6167. }
  6168. /**
  6169. * Easing function with a ease back shape (see link below).
  6170. * @see https://easings.net/#easeInBack
  6171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6172. */
  6173. export class BackEase extends EasingFunction implements IEasingFunction {
  6174. /** Defines the amplitude of the function */
  6175. amplitude: number;
  6176. /**
  6177. * Instantiates a back ease easing
  6178. * @see https://easings.net/#easeInBack
  6179. * @param amplitude Defines the amplitude of the function
  6180. */
  6181. constructor(
  6182. /** Defines the amplitude of the function */
  6183. amplitude?: number);
  6184. /** @hidden */
  6185. easeInCore(gradient: number): number;
  6186. }
  6187. /**
  6188. * Easing function with a bouncing shape (see link below).
  6189. * @see https://easings.net/#easeInBounce
  6190. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6191. */
  6192. export class BounceEase extends EasingFunction implements IEasingFunction {
  6193. /** Defines the number of bounces */
  6194. bounces: number;
  6195. /** Defines the amplitude of the bounce */
  6196. bounciness: number;
  6197. /**
  6198. * Instantiates a bounce easing
  6199. * @see https://easings.net/#easeInBounce
  6200. * @param bounces Defines the number of bounces
  6201. * @param bounciness Defines the amplitude of the bounce
  6202. */
  6203. constructor(
  6204. /** Defines the number of bounces */
  6205. bounces?: number,
  6206. /** Defines the amplitude of the bounce */
  6207. bounciness?: number);
  6208. /** @hidden */
  6209. easeInCore(gradient: number): number;
  6210. }
  6211. /**
  6212. * Easing function with a power of 3 shape (see link below).
  6213. * @see https://easings.net/#easeInCubic
  6214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6215. */
  6216. export class CubicEase extends EasingFunction implements IEasingFunction {
  6217. /** @hidden */
  6218. easeInCore(gradient: number): number;
  6219. }
  6220. /**
  6221. * Easing function with an elastic shape (see link below).
  6222. * @see https://easings.net/#easeInElastic
  6223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6224. */
  6225. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6226. /** Defines the number of oscillations*/
  6227. oscillations: number;
  6228. /** Defines the amplitude of the oscillations*/
  6229. springiness: number;
  6230. /**
  6231. * Instantiates an elastic easing function
  6232. * @see https://easings.net/#easeInElastic
  6233. * @param oscillations Defines the number of oscillations
  6234. * @param springiness Defines the amplitude of the oscillations
  6235. */
  6236. constructor(
  6237. /** Defines the number of oscillations*/
  6238. oscillations?: number,
  6239. /** Defines the amplitude of the oscillations*/
  6240. springiness?: number);
  6241. /** @hidden */
  6242. easeInCore(gradient: number): number;
  6243. }
  6244. /**
  6245. * Easing function with an exponential shape (see link below).
  6246. * @see https://easings.net/#easeInExpo
  6247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6248. */
  6249. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6250. /** Defines the exponent of the function */
  6251. exponent: number;
  6252. /**
  6253. * Instantiates an exponential easing function
  6254. * @see https://easings.net/#easeInExpo
  6255. * @param exponent Defines the exponent of the function
  6256. */
  6257. constructor(
  6258. /** Defines the exponent of the function */
  6259. exponent?: number);
  6260. /** @hidden */
  6261. easeInCore(gradient: number): number;
  6262. }
  6263. /**
  6264. * Easing function with a power shape (see link below).
  6265. * @see https://easings.net/#easeInQuad
  6266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6267. */
  6268. export class PowerEase extends EasingFunction implements IEasingFunction {
  6269. /** Defines the power of the function */
  6270. power: number;
  6271. /**
  6272. * Instantiates an power base easing function
  6273. * @see https://easings.net/#easeInQuad
  6274. * @param power Defines the power of the function
  6275. */
  6276. constructor(
  6277. /** Defines the power of the function */
  6278. power?: number);
  6279. /** @hidden */
  6280. easeInCore(gradient: number): number;
  6281. }
  6282. /**
  6283. * Easing function with a power of 2 shape (see link below).
  6284. * @see https://easings.net/#easeInQuad
  6285. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6286. */
  6287. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6288. /** @hidden */
  6289. easeInCore(gradient: number): number;
  6290. }
  6291. /**
  6292. * Easing function with a power of 4 shape (see link below).
  6293. * @see https://easings.net/#easeInQuart
  6294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6295. */
  6296. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6297. /** @hidden */
  6298. easeInCore(gradient: number): number;
  6299. }
  6300. /**
  6301. * Easing function with a power of 5 shape (see link below).
  6302. * @see https://easings.net/#easeInQuint
  6303. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6304. */
  6305. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6306. /** @hidden */
  6307. easeInCore(gradient: number): number;
  6308. }
  6309. /**
  6310. * Easing function with a sin shape (see link below).
  6311. * @see https://easings.net/#easeInSine
  6312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6313. */
  6314. export class SineEase extends EasingFunction implements IEasingFunction {
  6315. /** @hidden */
  6316. easeInCore(gradient: number): number;
  6317. }
  6318. /**
  6319. * Easing function with a bezier shape (see link below).
  6320. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6322. */
  6323. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6324. /** Defines the x component of the start tangent in the bezier curve */
  6325. x1: number;
  6326. /** Defines the y component of the start tangent in the bezier curve */
  6327. y1: number;
  6328. /** Defines the x component of the end tangent in the bezier curve */
  6329. x2: number;
  6330. /** Defines the y component of the end tangent in the bezier curve */
  6331. y2: number;
  6332. /**
  6333. * Instantiates a bezier function
  6334. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6335. * @param x1 Defines the x component of the start tangent in the bezier curve
  6336. * @param y1 Defines the y component of the start tangent in the bezier curve
  6337. * @param x2 Defines the x component of the end tangent in the bezier curve
  6338. * @param y2 Defines the y component of the end tangent in the bezier curve
  6339. */
  6340. constructor(
  6341. /** Defines the x component of the start tangent in the bezier curve */
  6342. x1?: number,
  6343. /** Defines the y component of the start tangent in the bezier curve */
  6344. y1?: number,
  6345. /** Defines the x component of the end tangent in the bezier curve */
  6346. x2?: number,
  6347. /** Defines the y component of the end tangent in the bezier curve */
  6348. y2?: number);
  6349. /** @hidden */
  6350. easeInCore(gradient: number): number;
  6351. }
  6352. }
  6353. declare module "babylonjs/Animations/animationKey" {
  6354. /**
  6355. * Defines an interface which represents an animation key frame
  6356. */
  6357. export interface IAnimationKey {
  6358. /**
  6359. * Frame of the key frame
  6360. */
  6361. frame: number;
  6362. /**
  6363. * Value at the specifies key frame
  6364. */
  6365. value: any;
  6366. /**
  6367. * The input tangent for the cubic hermite spline
  6368. */
  6369. inTangent?: any;
  6370. /**
  6371. * The output tangent for the cubic hermite spline
  6372. */
  6373. outTangent?: any;
  6374. /**
  6375. * The animation interpolation type
  6376. */
  6377. interpolation?: AnimationKeyInterpolation;
  6378. }
  6379. /**
  6380. * Enum for the animation key frame interpolation type
  6381. */
  6382. export enum AnimationKeyInterpolation {
  6383. /**
  6384. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6385. */
  6386. STEP = 1
  6387. }
  6388. }
  6389. declare module "babylonjs/Animations/animationRange" {
  6390. /**
  6391. * Represents the range of an animation
  6392. */
  6393. export class AnimationRange {
  6394. /**The name of the animation range**/
  6395. name: string;
  6396. /**The starting frame of the animation */
  6397. from: number;
  6398. /**The ending frame of the animation*/
  6399. to: number;
  6400. /**
  6401. * Initializes the range of an animation
  6402. * @param name The name of the animation range
  6403. * @param from The starting frame of the animation
  6404. * @param to The ending frame of the animation
  6405. */
  6406. constructor(
  6407. /**The name of the animation range**/
  6408. name: string,
  6409. /**The starting frame of the animation */
  6410. from: number,
  6411. /**The ending frame of the animation*/
  6412. to: number);
  6413. /**
  6414. * Makes a copy of the animation range
  6415. * @returns A copy of the animation range
  6416. */
  6417. clone(): AnimationRange;
  6418. }
  6419. }
  6420. declare module "babylonjs/Animations/animationEvent" {
  6421. /**
  6422. * Composed of a frame, and an action function
  6423. */
  6424. export class AnimationEvent {
  6425. /** The frame for which the event is triggered **/
  6426. frame: number;
  6427. /** The event to perform when triggered **/
  6428. action: (currentFrame: number) => void;
  6429. /** Specifies if the event should be triggered only once**/
  6430. onlyOnce?: boolean | undefined;
  6431. /**
  6432. * Specifies if the animation event is done
  6433. */
  6434. isDone: boolean;
  6435. /**
  6436. * Initializes the animation event
  6437. * @param frame The frame for which the event is triggered
  6438. * @param action The event to perform when triggered
  6439. * @param onlyOnce Specifies if the event should be triggered only once
  6440. */
  6441. constructor(
  6442. /** The frame for which the event is triggered **/
  6443. frame: number,
  6444. /** The event to perform when triggered **/
  6445. action: (currentFrame: number) => void,
  6446. /** Specifies if the event should be triggered only once**/
  6447. onlyOnce?: boolean | undefined);
  6448. /** @hidden */
  6449. _clone(): AnimationEvent;
  6450. }
  6451. }
  6452. declare module "babylonjs/Behaviors/behavior" {
  6453. import { Nullable } from "babylonjs/types";
  6454. /**
  6455. * Interface used to define a behavior
  6456. */
  6457. export interface Behavior<T> {
  6458. /** gets or sets behavior's name */
  6459. name: string;
  6460. /**
  6461. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6462. */
  6463. init(): void;
  6464. /**
  6465. * Called when the behavior is attached to a target
  6466. * @param target defines the target where the behavior is attached to
  6467. */
  6468. attach(target: T): void;
  6469. /**
  6470. * Called when the behavior is detached from its target
  6471. */
  6472. detach(): void;
  6473. }
  6474. /**
  6475. * Interface implemented by classes supporting behaviors
  6476. */
  6477. export interface IBehaviorAware<T> {
  6478. /**
  6479. * Attach a behavior
  6480. * @param behavior defines the behavior to attach
  6481. * @returns the current host
  6482. */
  6483. addBehavior(behavior: Behavior<T>): T;
  6484. /**
  6485. * Remove a behavior from the current object
  6486. * @param behavior defines the behavior to detach
  6487. * @returns the current host
  6488. */
  6489. removeBehavior(behavior: Behavior<T>): T;
  6490. /**
  6491. * Gets a behavior using its name to search
  6492. * @param name defines the name to search
  6493. * @returns the behavior or null if not found
  6494. */
  6495. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6496. }
  6497. }
  6498. declare module "babylonjs/Misc/smartArray" {
  6499. /**
  6500. * Defines an array and its length.
  6501. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6502. */
  6503. export interface ISmartArrayLike<T> {
  6504. /**
  6505. * The data of the array.
  6506. */
  6507. data: Array<T>;
  6508. /**
  6509. * The active length of the array.
  6510. */
  6511. length: number;
  6512. }
  6513. /**
  6514. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6515. */
  6516. export class SmartArray<T> implements ISmartArrayLike<T> {
  6517. /**
  6518. * The full set of data from the array.
  6519. */
  6520. data: Array<T>;
  6521. /**
  6522. * The active length of the array.
  6523. */
  6524. length: number;
  6525. protected _id: number;
  6526. /**
  6527. * Instantiates a Smart Array.
  6528. * @param capacity defines the default capacity of the array.
  6529. */
  6530. constructor(capacity: number);
  6531. /**
  6532. * Pushes a value at the end of the active data.
  6533. * @param value defines the object to push in the array.
  6534. */
  6535. push(value: T): void;
  6536. /**
  6537. * Iterates over the active data and apply the lambda to them.
  6538. * @param func defines the action to apply on each value.
  6539. */
  6540. forEach(func: (content: T) => void): void;
  6541. /**
  6542. * Sorts the full sets of data.
  6543. * @param compareFn defines the comparison function to apply.
  6544. */
  6545. sort(compareFn: (a: T, b: T) => number): void;
  6546. /**
  6547. * Resets the active data to an empty array.
  6548. */
  6549. reset(): void;
  6550. /**
  6551. * Releases all the data from the array as well as the array.
  6552. */
  6553. dispose(): void;
  6554. /**
  6555. * Concats the active data with a given array.
  6556. * @param array defines the data to concatenate with.
  6557. */
  6558. concat(array: any): void;
  6559. /**
  6560. * Returns the position of a value in the active data.
  6561. * @param value defines the value to find the index for
  6562. * @returns the index if found in the active data otherwise -1
  6563. */
  6564. indexOf(value: T): number;
  6565. /**
  6566. * Returns whether an element is part of the active data.
  6567. * @param value defines the value to look for
  6568. * @returns true if found in the active data otherwise false
  6569. */
  6570. contains(value: T): boolean;
  6571. private static _GlobalId;
  6572. }
  6573. /**
  6574. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6575. * The data in this array can only be present once
  6576. */
  6577. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6578. private _duplicateId;
  6579. /**
  6580. * Pushes a value at the end of the active data.
  6581. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6582. * @param value defines the object to push in the array.
  6583. */
  6584. push(value: T): void;
  6585. /**
  6586. * Pushes a value at the end of the active data.
  6587. * If the data is already present, it won t be added again
  6588. * @param value defines the object to push in the array.
  6589. * @returns true if added false if it was already present
  6590. */
  6591. pushNoDuplicate(value: T): boolean;
  6592. /**
  6593. * Resets the active data to an empty array.
  6594. */
  6595. reset(): void;
  6596. /**
  6597. * Concats the active data with a given array.
  6598. * This ensures no dupplicate will be present in the result.
  6599. * @param array defines the data to concatenate with.
  6600. */
  6601. concatWithNoDuplicate(array: any): void;
  6602. }
  6603. }
  6604. declare module "babylonjs/Cameras/cameraInputsManager" {
  6605. import { Nullable } from "babylonjs/types";
  6606. import { Camera } from "babylonjs/Cameras/camera";
  6607. /**
  6608. * @ignore
  6609. * This is a list of all the different input types that are available in the application.
  6610. * Fo instance: ArcRotateCameraGamepadInput...
  6611. */
  6612. export var CameraInputTypes: {};
  6613. /**
  6614. * This is the contract to implement in order to create a new input class.
  6615. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6616. */
  6617. export interface ICameraInput<TCamera extends Camera> {
  6618. /**
  6619. * Defines the camera the input is attached to.
  6620. */
  6621. camera: Nullable<TCamera>;
  6622. /**
  6623. * Gets the class name of the current intput.
  6624. * @returns the class name
  6625. */
  6626. getClassName(): string;
  6627. /**
  6628. * Get the friendly name associated with the input class.
  6629. * @returns the input friendly name
  6630. */
  6631. getSimpleName(): string;
  6632. /**
  6633. * Attach the input controls to a specific dom element to get the input from.
  6634. * @param element Defines the element the controls should be listened from
  6635. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6636. */
  6637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6638. /**
  6639. * Detach the current controls from the specified dom element.
  6640. * @param element Defines the element to stop listening the inputs from
  6641. */
  6642. detachControl(element: Nullable<HTMLElement>): void;
  6643. /**
  6644. * Update the current camera state depending on the inputs that have been used this frame.
  6645. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6646. */
  6647. checkInputs?: () => void;
  6648. }
  6649. /**
  6650. * Represents a map of input types to input instance or input index to input instance.
  6651. */
  6652. export interface CameraInputsMap<TCamera extends Camera> {
  6653. /**
  6654. * Accessor to the input by input type.
  6655. */
  6656. [name: string]: ICameraInput<TCamera>;
  6657. /**
  6658. * Accessor to the input by input index.
  6659. */
  6660. [idx: number]: ICameraInput<TCamera>;
  6661. }
  6662. /**
  6663. * This represents the input manager used within a camera.
  6664. * It helps dealing with all the different kind of input attached to a camera.
  6665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6666. */
  6667. export class CameraInputsManager<TCamera extends Camera> {
  6668. /**
  6669. * Defines the list of inputs attahed to the camera.
  6670. */
  6671. attached: CameraInputsMap<TCamera>;
  6672. /**
  6673. * Defines the dom element the camera is collecting inputs from.
  6674. * This is null if the controls have not been attached.
  6675. */
  6676. attachedElement: Nullable<HTMLElement>;
  6677. /**
  6678. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6679. */
  6680. noPreventDefault: boolean;
  6681. /**
  6682. * Defined the camera the input manager belongs to.
  6683. */
  6684. camera: TCamera;
  6685. /**
  6686. * Update the current camera state depending on the inputs that have been used this frame.
  6687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6688. */
  6689. checkInputs: () => void;
  6690. /**
  6691. * Instantiate a new Camera Input Manager.
  6692. * @param camera Defines the camera the input manager blongs to
  6693. */
  6694. constructor(camera: TCamera);
  6695. /**
  6696. * Add an input method to a camera
  6697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6698. * @param input camera input method
  6699. */
  6700. add(input: ICameraInput<TCamera>): void;
  6701. /**
  6702. * Remove a specific input method from a camera
  6703. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6704. * @param inputToRemove camera input method
  6705. */
  6706. remove(inputToRemove: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Remove a specific input type from a camera
  6709. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6710. * @param inputType the type of the input to remove
  6711. */
  6712. removeByType(inputType: string): void;
  6713. private _addCheckInputs;
  6714. /**
  6715. * Attach the input controls to the currently attached dom element to listen the events from.
  6716. * @param input Defines the input to attach
  6717. */
  6718. attachInput(input: ICameraInput<TCamera>): void;
  6719. /**
  6720. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6721. * @param element Defines the dom element to collect the events from
  6722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6723. */
  6724. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6725. /**
  6726. * Detach the current manager inputs controls from a specific dom element.
  6727. * @param element Defines the dom element to collect the events from
  6728. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6729. */
  6730. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6731. /**
  6732. * Rebuild the dynamic inputCheck function from the current list of
  6733. * defined inputs in the manager.
  6734. */
  6735. rebuildInputCheck(): void;
  6736. /**
  6737. * Remove all attached input methods from a camera
  6738. */
  6739. clear(): void;
  6740. /**
  6741. * Serialize the current input manager attached to a camera.
  6742. * This ensures than once parsed,
  6743. * the input associated to the camera will be identical to the current ones
  6744. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6745. */
  6746. serialize(serializedCamera: any): void;
  6747. /**
  6748. * Parses an input manager serialized JSON to restore the previous list of inputs
  6749. * and states associated to a camera.
  6750. * @param parsedCamera Defines the JSON to parse
  6751. */
  6752. parse(parsedCamera: any): void;
  6753. }
  6754. }
  6755. declare module "babylonjs/Collisions/intersectionInfo" {
  6756. import { Nullable } from "babylonjs/types";
  6757. /**
  6758. * @hidden
  6759. */
  6760. export class IntersectionInfo {
  6761. bu: Nullable<number>;
  6762. bv: Nullable<number>;
  6763. distance: number;
  6764. faceId: number;
  6765. subMeshId: number;
  6766. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6767. }
  6768. }
  6769. declare module "babylonjs/Maths/math.plane" {
  6770. import { DeepImmutable } from "babylonjs/types";
  6771. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6772. /**
  6773. * Represens a plane by the equation ax + by + cz + d = 0
  6774. */
  6775. export class Plane {
  6776. private static _TmpMatrix;
  6777. /**
  6778. * Normal of the plane (a,b,c)
  6779. */
  6780. normal: Vector3;
  6781. /**
  6782. * d component of the plane
  6783. */
  6784. d: number;
  6785. /**
  6786. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6787. * @param a a component of the plane
  6788. * @param b b component of the plane
  6789. * @param c c component of the plane
  6790. * @param d d component of the plane
  6791. */
  6792. constructor(a: number, b: number, c: number, d: number);
  6793. /**
  6794. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6795. */
  6796. asArray(): number[];
  6797. /**
  6798. * @returns a new plane copied from the current Plane.
  6799. */
  6800. clone(): Plane;
  6801. /**
  6802. * @returns the string "Plane".
  6803. */
  6804. getClassName(): string;
  6805. /**
  6806. * @returns the Plane hash code.
  6807. */
  6808. getHashCode(): number;
  6809. /**
  6810. * Normalize the current Plane in place.
  6811. * @returns the updated Plane.
  6812. */
  6813. normalize(): Plane;
  6814. /**
  6815. * Applies a transformation the plane and returns the result
  6816. * @param transformation the transformation matrix to be applied to the plane
  6817. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6818. */
  6819. transform(transformation: DeepImmutable<Matrix>): Plane;
  6820. /**
  6821. * Calcualtte the dot product between the point and the plane normal
  6822. * @param point point to calculate the dot product with
  6823. * @returns the dot product (float) of the point coordinates and the plane normal.
  6824. */
  6825. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6826. /**
  6827. * Updates the current Plane from the plane defined by the three given points.
  6828. * @param point1 one of the points used to contruct the plane
  6829. * @param point2 one of the points used to contruct the plane
  6830. * @param point3 one of the points used to contruct the plane
  6831. * @returns the updated Plane.
  6832. */
  6833. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6834. /**
  6835. * Checks if the plane is facing a given direction
  6836. * @param direction the direction to check if the plane is facing
  6837. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6838. * @returns True is the vector "direction" is the same side than the plane normal.
  6839. */
  6840. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6841. /**
  6842. * Calculates the distance to a point
  6843. * @param point point to calculate distance to
  6844. * @returns the signed distance (float) from the given point to the Plane.
  6845. */
  6846. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6847. /**
  6848. * Creates a plane from an array
  6849. * @param array the array to create a plane from
  6850. * @returns a new Plane from the given array.
  6851. */
  6852. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6853. /**
  6854. * Creates a plane from three points
  6855. * @param point1 point used to create the plane
  6856. * @param point2 point used to create the plane
  6857. * @param point3 point used to create the plane
  6858. * @returns a new Plane defined by the three given points.
  6859. */
  6860. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6861. /**
  6862. * Creates a plane from an origin point and a normal
  6863. * @param origin origin of the plane to be constructed
  6864. * @param normal normal of the plane to be constructed
  6865. * @returns a new Plane the normal vector to this plane at the given origin point.
  6866. * Note : the vector "normal" is updated because normalized.
  6867. */
  6868. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6869. /**
  6870. * Calculates the distance from a plane and a point
  6871. * @param origin origin of the plane to be constructed
  6872. * @param normal normal of the plane to be constructed
  6873. * @param point point to calculate distance to
  6874. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6875. */
  6876. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingSphere" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6882. import { Plane } from "babylonjs/Maths/math.plane";
  6883. /**
  6884. * Class used to store bounding sphere information
  6885. */
  6886. export class BoundingSphere {
  6887. /**
  6888. * Gets the center of the bounding sphere in local space
  6889. */
  6890. readonly center: Vector3;
  6891. /**
  6892. * Radius of the bounding sphere in local space
  6893. */
  6894. radius: number;
  6895. /**
  6896. * Gets the center of the bounding sphere in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Radius of the bounding sphere in world space
  6901. */
  6902. radiusWorld: number;
  6903. /**
  6904. * Gets the minimum vector in local space
  6905. */
  6906. readonly minimum: Vector3;
  6907. /**
  6908. * Gets the maximum vector in local space
  6909. */
  6910. readonly maximum: Vector3;
  6911. private _worldMatrix;
  6912. private static readonly TmpVector3;
  6913. /**
  6914. * Creates a new bounding sphere
  6915. * @param min defines the minimum vector (in local space)
  6916. * @param max defines the maximum vector (in local space)
  6917. * @param worldMatrix defines the new world matrix
  6918. */
  6919. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6920. /**
  6921. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6922. * @param min defines the new minimum vector (in local space)
  6923. * @param max defines the new maximum vector (in local space)
  6924. * @param worldMatrix defines the new world matrix
  6925. */
  6926. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6927. /**
  6928. * Scale the current bounding sphere by applying a scale factor
  6929. * @param factor defines the scale factor to apply
  6930. * @returns the current bounding box
  6931. */
  6932. scale(factor: number): BoundingSphere;
  6933. /**
  6934. * Gets the world matrix of the bounding box
  6935. * @returns a matrix
  6936. */
  6937. getWorldMatrix(): DeepImmutable<Matrix>;
  6938. /** @hidden */
  6939. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6940. /**
  6941. * Tests if the bounding sphere is intersecting the frustum planes
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @returns true if there is an intersection
  6944. */
  6945. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. /**
  6947. * Tests if the bounding sphere center is in between the frustum planes.
  6948. * Used for optimistic fast inclusion.
  6949. * @param frustumPlanes defines the frustum planes to test
  6950. * @returns true if the sphere center is in between the frustum planes
  6951. */
  6952. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6953. /**
  6954. * Tests if a point is inside the bounding sphere
  6955. * @param point defines the point to test
  6956. * @returns true if the point is inside the bounding sphere
  6957. */
  6958. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6959. /**
  6960. * Checks if two sphere intersct
  6961. * @param sphere0 sphere 0
  6962. * @param sphere1 sphere 1
  6963. * @returns true if the speres intersect
  6964. */
  6965. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6966. }
  6967. }
  6968. declare module "babylonjs/Culling/boundingBox" {
  6969. import { DeepImmutable } from "babylonjs/types";
  6970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6971. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6972. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6973. import { Plane } from "babylonjs/Maths/math.plane";
  6974. /**
  6975. * Class used to store bounding box information
  6976. */
  6977. export class BoundingBox implements ICullable {
  6978. /**
  6979. * Gets the 8 vectors representing the bounding box in local space
  6980. */
  6981. readonly vectors: Vector3[];
  6982. /**
  6983. * Gets the center of the bounding box in local space
  6984. */
  6985. readonly center: Vector3;
  6986. /**
  6987. * Gets the center of the bounding box in world space
  6988. */
  6989. readonly centerWorld: Vector3;
  6990. /**
  6991. * Gets the extend size in local space
  6992. */
  6993. readonly extendSize: Vector3;
  6994. /**
  6995. * Gets the extend size in world space
  6996. */
  6997. readonly extendSizeWorld: Vector3;
  6998. /**
  6999. * Gets the OBB (object bounding box) directions
  7000. */
  7001. readonly directions: Vector3[];
  7002. /**
  7003. * Gets the 8 vectors representing the bounding box in world space
  7004. */
  7005. readonly vectorsWorld: Vector3[];
  7006. /**
  7007. * Gets the minimum vector in world space
  7008. */
  7009. readonly minimumWorld: Vector3;
  7010. /**
  7011. * Gets the maximum vector in world space
  7012. */
  7013. readonly maximumWorld: Vector3;
  7014. /**
  7015. * Gets the minimum vector in local space
  7016. */
  7017. readonly minimum: Vector3;
  7018. /**
  7019. * Gets the maximum vector in local space
  7020. */
  7021. readonly maximum: Vector3;
  7022. private _worldMatrix;
  7023. private static readonly TmpVector3;
  7024. /**
  7025. * @hidden
  7026. */
  7027. _tag: number;
  7028. /**
  7029. * Creates a new bounding box
  7030. * @param min defines the minimum vector (in local space)
  7031. * @param max defines the maximum vector (in local space)
  7032. * @param worldMatrix defines the new world matrix
  7033. */
  7034. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7035. /**
  7036. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7037. * @param min defines the new minimum vector (in local space)
  7038. * @param max defines the new maximum vector (in local space)
  7039. * @param worldMatrix defines the new world matrix
  7040. */
  7041. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7042. /**
  7043. * Scale the current bounding box by applying a scale factor
  7044. * @param factor defines the scale factor to apply
  7045. * @returns the current bounding box
  7046. */
  7047. scale(factor: number): BoundingBox;
  7048. /**
  7049. * Gets the world matrix of the bounding box
  7050. * @returns a matrix
  7051. */
  7052. getWorldMatrix(): DeepImmutable<Matrix>;
  7053. /** @hidden */
  7054. _update(world: DeepImmutable<Matrix>): void;
  7055. /**
  7056. * Tests if the bounding box is intersecting the frustum planes
  7057. * @param frustumPlanes defines the frustum planes to test
  7058. * @returns true if there is an intersection
  7059. */
  7060. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7061. /**
  7062. * Tests if the bounding box is entirely inside the frustum planes
  7063. * @param frustumPlanes defines the frustum planes to test
  7064. * @returns true if there is an inclusion
  7065. */
  7066. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7067. /**
  7068. * Tests if a point is inside the bounding box
  7069. * @param point defines the point to test
  7070. * @returns true if the point is inside the bounding box
  7071. */
  7072. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7073. /**
  7074. * Tests if the bounding box intersects with a bounding sphere
  7075. * @param sphere defines the sphere to test
  7076. * @returns true if there is an intersection
  7077. */
  7078. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7079. /**
  7080. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7081. * @param min defines the min vector to use
  7082. * @param max defines the max vector to use
  7083. * @returns true if there is an intersection
  7084. */
  7085. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7086. /**
  7087. * Tests if two bounding boxes are intersections
  7088. * @param box0 defines the first box to test
  7089. * @param box1 defines the second box to test
  7090. * @returns true if there is an intersection
  7091. */
  7092. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7093. /**
  7094. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7095. * @param minPoint defines the minimum vector of the bounding box
  7096. * @param maxPoint defines the maximum vector of the bounding box
  7097. * @param sphereCenter defines the sphere center
  7098. * @param sphereRadius defines the sphere radius
  7099. * @returns true if there is an intersection
  7100. */
  7101. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7102. /**
  7103. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7104. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7105. * @param frustumPlanes defines the frustum planes to test
  7106. * @return true if there is an inclusion
  7107. */
  7108. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7109. /**
  7110. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7111. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7112. * @param frustumPlanes defines the frustum planes to test
  7113. * @return true if there is an intersection
  7114. */
  7115. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7116. }
  7117. }
  7118. declare module "babylonjs/Collisions/collider" {
  7119. import { Nullable, IndicesArray } from "babylonjs/types";
  7120. import { Vector3 } from "babylonjs/Maths/math.vector";
  7121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7122. import { Plane } from "babylonjs/Maths/math.plane";
  7123. /** @hidden */
  7124. export class Collider {
  7125. /** Define if a collision was found */
  7126. collisionFound: boolean;
  7127. /**
  7128. * Define last intersection point in local space
  7129. */
  7130. intersectionPoint: Vector3;
  7131. /**
  7132. * Define last collided mesh
  7133. */
  7134. collidedMesh: Nullable<AbstractMesh>;
  7135. private _collisionPoint;
  7136. private _planeIntersectionPoint;
  7137. private _tempVector;
  7138. private _tempVector2;
  7139. private _tempVector3;
  7140. private _tempVector4;
  7141. private _edge;
  7142. private _baseToVertex;
  7143. private _destinationPoint;
  7144. private _slidePlaneNormal;
  7145. private _displacementVector;
  7146. /** @hidden */
  7147. _radius: Vector3;
  7148. /** @hidden */
  7149. _retry: number;
  7150. private _velocity;
  7151. private _basePoint;
  7152. private _epsilon;
  7153. /** @hidden */
  7154. _velocityWorldLength: number;
  7155. /** @hidden */
  7156. _basePointWorld: Vector3;
  7157. private _velocityWorld;
  7158. private _normalizedVelocity;
  7159. /** @hidden */
  7160. _initialVelocity: Vector3;
  7161. /** @hidden */
  7162. _initialPosition: Vector3;
  7163. private _nearestDistance;
  7164. private _collisionMask;
  7165. collisionMask: number;
  7166. /**
  7167. * Gets the plane normal used to compute the sliding response (in local space)
  7168. */
  7169. readonly slidePlaneNormal: Vector3;
  7170. /** @hidden */
  7171. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7172. /** @hidden */
  7173. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7174. /** @hidden */
  7175. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7176. /** @hidden */
  7177. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7178. /** @hidden */
  7179. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7180. /** @hidden */
  7181. _getResponse(pos: Vector3, vel: Vector3): void;
  7182. }
  7183. }
  7184. declare module "babylonjs/Culling/boundingInfo" {
  7185. import { DeepImmutable } from "babylonjs/types";
  7186. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7187. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7188. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7189. import { Plane } from "babylonjs/Maths/math.plane";
  7190. import { Collider } from "babylonjs/Collisions/collider";
  7191. /**
  7192. * Interface for cullable objects
  7193. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7194. */
  7195. export interface ICullable {
  7196. /**
  7197. * Checks if the object or part of the object is in the frustum
  7198. * @param frustumPlanes Camera near/planes
  7199. * @returns true if the object is in frustum otherwise false
  7200. */
  7201. isInFrustum(frustumPlanes: Plane[]): boolean;
  7202. /**
  7203. * Checks if a cullable object (mesh...) is in the camera frustum
  7204. * Unlike isInFrustum this cheks the full bounding box
  7205. * @param frustumPlanes Camera near/planes
  7206. * @returns true if the object is in frustum otherwise false
  7207. */
  7208. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7209. }
  7210. /**
  7211. * Info for a bounding data of a mesh
  7212. */
  7213. export class BoundingInfo implements ICullable {
  7214. /**
  7215. * Bounding box for the mesh
  7216. */
  7217. readonly boundingBox: BoundingBox;
  7218. /**
  7219. * Bounding sphere for the mesh
  7220. */
  7221. readonly boundingSphere: BoundingSphere;
  7222. private _isLocked;
  7223. private static readonly TmpVector3;
  7224. /**
  7225. * Constructs bounding info
  7226. * @param minimum min vector of the bounding box/sphere
  7227. * @param maximum max vector of the bounding box/sphere
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7231. /**
  7232. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7233. * @param min defines the new minimum vector (in local space)
  7234. * @param max defines the new maximum vector (in local space)
  7235. * @param worldMatrix defines the new world matrix
  7236. */
  7237. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7238. /**
  7239. * min vector of the bounding box/sphere
  7240. */
  7241. readonly minimum: Vector3;
  7242. /**
  7243. * max vector of the bounding box/sphere
  7244. */
  7245. readonly maximum: Vector3;
  7246. /**
  7247. * If the info is locked and won't be updated to avoid perf overhead
  7248. */
  7249. isLocked: boolean;
  7250. /**
  7251. * Updates the bounding sphere and box
  7252. * @param world world matrix to be used to update
  7253. */
  7254. update(world: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7257. * @param center New center of the bounding info
  7258. * @param extend New extend of the bounding info
  7259. * @returns the current bounding info
  7260. */
  7261. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7262. /**
  7263. * Scale the current bounding info by applying a scale factor
  7264. * @param factor defines the scale factor to apply
  7265. * @returns the current bounding info
  7266. */
  7267. scale(factor: number): BoundingInfo;
  7268. /**
  7269. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7270. * @param frustumPlanes defines the frustum to test
  7271. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7272. * @returns true if the bounding info is in the frustum planes
  7273. */
  7274. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7275. /**
  7276. * Gets the world distance between the min and max points of the bounding box
  7277. */
  7278. readonly diagonalLength: number;
  7279. /**
  7280. * Checks if a cullable object (mesh...) is in the camera frustum
  7281. * Unlike isInFrustum this cheks the full bounding box
  7282. * @param frustumPlanes Camera near/planes
  7283. * @returns true if the object is in frustum otherwise false
  7284. */
  7285. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7286. /** @hidden */
  7287. _checkCollision(collider: Collider): boolean;
  7288. /**
  7289. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7290. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7291. * @param point the point to check intersection with
  7292. * @returns if the point intersects
  7293. */
  7294. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7295. /**
  7296. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7297. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7298. * @param boundingInfo the bounding info to check intersection with
  7299. * @param precise if the intersection should be done using OBB
  7300. * @returns if the bounding info intersects
  7301. */
  7302. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7303. }
  7304. }
  7305. declare module "babylonjs/Maths/math.functions" {
  7306. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7307. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7308. /**
  7309. * Extracts minimum and maximum values from a list of indexed positions
  7310. * @param positions defines the positions to use
  7311. * @param indices defines the indices to the positions
  7312. * @param indexStart defines the start index
  7313. * @param indexCount defines the end index
  7314. * @param bias defines bias value to add to the result
  7315. * @return minimum and maximum values
  7316. */
  7317. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7318. minimum: Vector3;
  7319. maximum: Vector3;
  7320. };
  7321. /**
  7322. * Extracts minimum and maximum values from a list of positions
  7323. * @param positions defines the positions to use
  7324. * @param start defines the start index in the positions array
  7325. * @param count defines the number of positions to handle
  7326. * @param bias defines bias value to add to the result
  7327. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7328. * @return minimum and maximum values
  7329. */
  7330. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7331. minimum: Vector3;
  7332. maximum: Vector3;
  7333. };
  7334. }
  7335. declare module "babylonjs/Misc/iInspectable" {
  7336. /**
  7337. * Enum that determines the text-wrapping mode to use.
  7338. */
  7339. export enum InspectableType {
  7340. /**
  7341. * Checkbox for booleans
  7342. */
  7343. Checkbox = 0,
  7344. /**
  7345. * Sliders for numbers
  7346. */
  7347. Slider = 1,
  7348. /**
  7349. * Vector3
  7350. */
  7351. Vector3 = 2,
  7352. /**
  7353. * Quaternions
  7354. */
  7355. Quaternion = 3,
  7356. /**
  7357. * Color3
  7358. */
  7359. Color3 = 4,
  7360. /**
  7361. * String
  7362. */
  7363. String = 5
  7364. }
  7365. /**
  7366. * Interface used to define custom inspectable properties.
  7367. * This interface is used by the inspector to display custom property grids
  7368. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7369. */
  7370. export interface IInspectable {
  7371. /**
  7372. * Gets the label to display
  7373. */
  7374. label: string;
  7375. /**
  7376. * Gets the name of the property to edit
  7377. */
  7378. propertyName: string;
  7379. /**
  7380. * Gets the type of the editor to use
  7381. */
  7382. type: InspectableType;
  7383. /**
  7384. * Gets the minimum value of the property when using in "slider" mode
  7385. */
  7386. min?: number;
  7387. /**
  7388. * Gets the maximum value of the property when using in "slider" mode
  7389. */
  7390. max?: number;
  7391. /**
  7392. * Gets the setp to use when using in "slider" mode
  7393. */
  7394. step?: number;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/timingTools" {
  7398. /**
  7399. * Class used to provide helper for timing
  7400. */
  7401. export class TimingTools {
  7402. /**
  7403. * Polyfill for setImmediate
  7404. * @param action defines the action to execute after the current execution block
  7405. */
  7406. static SetImmediate(action: () => void): void;
  7407. }
  7408. }
  7409. declare module "babylonjs/Misc/instantiationTools" {
  7410. /**
  7411. * Class used to enable instatition of objects by class name
  7412. */
  7413. export class InstantiationTools {
  7414. /**
  7415. * Use this object to register external classes like custom textures or material
  7416. * to allow the laoders to instantiate them
  7417. */
  7418. static RegisteredExternalClasses: {
  7419. [key: string]: Object;
  7420. };
  7421. /**
  7422. * Tries to instantiate a new object from a given class name
  7423. * @param className defines the class name to instantiate
  7424. * @returns the new object or null if the system was not able to do the instantiation
  7425. */
  7426. static Instantiate(className: string): any;
  7427. }
  7428. }
  7429. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7430. import { Nullable } from "babylonjs/types";
  7431. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7432. /**
  7433. * This represents the required contract to create a new type of texture loader.
  7434. */
  7435. export interface IInternalTextureLoader {
  7436. /**
  7437. * Defines wether the loader supports cascade loading the different faces.
  7438. */
  7439. supportCascades: boolean;
  7440. /**
  7441. * This returns if the loader support the current file information.
  7442. * @param extension defines the file extension of the file being loaded
  7443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7444. * @param fallback defines the fallback internal texture if any
  7445. * @param isBase64 defines whether the texture is encoded as a base64
  7446. * @param isBuffer defines whether the texture data are stored as a buffer
  7447. * @returns true if the loader can load the specified file
  7448. */
  7449. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7450. /**
  7451. * Transform the url before loading if required.
  7452. * @param rootUrl the url of the texture
  7453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7454. * @returns the transformed texture
  7455. */
  7456. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7457. /**
  7458. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7459. * @param rootUrl the url of the texture
  7460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7461. * @returns the fallback texture
  7462. */
  7463. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7464. /**
  7465. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7466. * @param data contains the texture data
  7467. * @param texture defines the BabylonJS internal texture
  7468. * @param createPolynomials will be true if polynomials have been requested
  7469. * @param onLoad defines the callback to trigger once the texture is ready
  7470. * @param onError defines the callback to trigger in case of error
  7471. */
  7472. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7473. /**
  7474. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7475. * @param data contains the texture data
  7476. * @param texture defines the BabylonJS internal texture
  7477. * @param callback defines the method to call once ready to upload
  7478. */
  7479. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7480. }
  7481. }
  7482. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7483. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7484. import { Nullable } from "babylonjs/types";
  7485. import { Scene } from "babylonjs/scene";
  7486. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7487. module "babylonjs/Engines/engine" {
  7488. interface Engine {
  7489. /**
  7490. * Creates a depth stencil cube texture.
  7491. * This is only available in WebGL 2.
  7492. * @param size The size of face edge in the cube texture.
  7493. * @param options The options defining the cube texture.
  7494. * @returns The cube texture
  7495. */
  7496. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7497. /**
  7498. * Creates a cube texture
  7499. * @param rootUrl defines the url where the files to load is located
  7500. * @param scene defines the current scene
  7501. * @param files defines the list of files to load (1 per face)
  7502. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7503. * @param onLoad defines an optional callback raised when the texture is loaded
  7504. * @param onError defines an optional callback raised if there is an issue to load the texture
  7505. * @param format defines the format of the data
  7506. * @param forcedExtension defines the extension to use to pick the right loader
  7507. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7508. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7509. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7510. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7511. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7512. * @returns the cube texture as an InternalTexture
  7513. */
  7514. 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;
  7515. /**
  7516. * Creates a cube texture
  7517. * @param rootUrl defines the url where the files to load is located
  7518. * @param scene defines the current scene
  7519. * @param files defines the list of files to load (1 per face)
  7520. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7521. * @param onLoad defines an optional callback raised when the texture is loaded
  7522. * @param onError defines an optional callback raised if there is an issue to load the texture
  7523. * @param format defines the format of the data
  7524. * @param forcedExtension defines the extension to use to pick the right loader
  7525. * @returns the cube texture as an InternalTexture
  7526. */
  7527. 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;
  7528. /**
  7529. * Creates a cube texture
  7530. * @param rootUrl defines the url where the files to load is located
  7531. * @param scene defines the current scene
  7532. * @param files defines the list of files to load (1 per face)
  7533. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7534. * @param onLoad defines an optional callback raised when the texture is loaded
  7535. * @param onError defines an optional callback raised if there is an issue to load the texture
  7536. * @param format defines the format of the data
  7537. * @param forcedExtension defines the extension to use to pick the right loader
  7538. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7539. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7540. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7541. * @returns the cube texture as an InternalTexture
  7542. */
  7543. 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;
  7544. /** @hidden */
  7545. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7546. /** @hidden */
  7547. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7548. /** @hidden */
  7549. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7550. /** @hidden */
  7551. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7552. }
  7553. }
  7554. }
  7555. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7556. import { Nullable } from "babylonjs/types";
  7557. import { Scene } from "babylonjs/scene";
  7558. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7560. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7561. /**
  7562. * Class for creating a cube texture
  7563. */
  7564. export class CubeTexture extends BaseTexture {
  7565. private _delayedOnLoad;
  7566. /**
  7567. * The url of the texture
  7568. */
  7569. url: string;
  7570. /**
  7571. * Gets or sets the center of the bounding box associated with the cube texture.
  7572. * It must define where the camera used to render the texture was set
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxPosition: Vector3;
  7576. private _boundingBoxSize;
  7577. /**
  7578. * Gets or sets the size of the bounding box associated with the cube texture
  7579. * When defined, the cubemap will switch to local mode
  7580. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7581. * @example https://www.babylonjs-playground.com/#RNASML
  7582. */
  7583. /**
  7584. * Returns the bounding box size
  7585. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7586. */
  7587. boundingBoxSize: Vector3;
  7588. protected _rotationY: number;
  7589. /**
  7590. * Sets texture matrix rotation angle around Y axis in radians.
  7591. */
  7592. /**
  7593. * Gets texture matrix rotation angle around Y axis radians.
  7594. */
  7595. rotationY: number;
  7596. /**
  7597. * Are mip maps generated for this texture or not.
  7598. */
  7599. readonly noMipmap: boolean;
  7600. private _noMipmap;
  7601. private _files;
  7602. private _extensions;
  7603. private _textureMatrix;
  7604. private _format;
  7605. private _createPolynomials;
  7606. /** @hidden */
  7607. _prefiltered: boolean;
  7608. /**
  7609. * Creates a cube texture from an array of image urls
  7610. * @param files defines an array of image urls
  7611. * @param scene defines the hosting scene
  7612. * @param noMipmap specifies if mip maps are not used
  7613. * @returns a cube texture
  7614. */
  7615. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7616. /**
  7617. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7618. * @param url defines the url of the prefiltered texture
  7619. * @param scene defines the scene the texture is attached to
  7620. * @param forcedExtension defines the extension of the file if different from the url
  7621. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7622. * @return the prefiltered texture
  7623. */
  7624. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7625. /**
  7626. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7627. * as prefiltered data.
  7628. * @param rootUrl defines the url of the texture or the root name of the six images
  7629. * @param scene defines the scene the texture is attached to
  7630. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7631. * @param noMipmap defines if mipmaps should be created or not
  7632. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7633. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7634. * @param onError defines a callback triggered in case of error during load
  7635. * @param format defines the internal format to use for the texture once loaded
  7636. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7637. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7638. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7639. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7640. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7641. * @return the cube texture
  7642. */
  7643. 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);
  7644. /**
  7645. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7646. */
  7647. readonly isPrefiltered: boolean;
  7648. /**
  7649. * Get the current class name of the texture useful for serialization or dynamic coding.
  7650. * @returns "CubeTexture"
  7651. */
  7652. getClassName(): string;
  7653. /**
  7654. * Update the url (and optional buffer) of this texture if url was null during construction.
  7655. * @param url the url of the texture
  7656. * @param forcedExtension defines the extension to use
  7657. * @param onLoad callback called when the texture is loaded (defaults to null)
  7658. */
  7659. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7660. /**
  7661. * Delays loading of the cube texture
  7662. * @param forcedExtension defines the extension to use
  7663. */
  7664. delayLoad(forcedExtension?: string): void;
  7665. /**
  7666. * Returns the reflection texture matrix
  7667. * @returns the reflection texture matrix
  7668. */
  7669. getReflectionTextureMatrix(): Matrix;
  7670. /**
  7671. * Sets the reflection texture matrix
  7672. * @param value Reflection texture matrix
  7673. */
  7674. setReflectionTextureMatrix(value: Matrix): void;
  7675. /**
  7676. * Parses text to create a cube texture
  7677. * @param parsedTexture define the serialized text to read from
  7678. * @param scene defines the hosting scene
  7679. * @param rootUrl defines the root url of the cube texture
  7680. * @returns a cube texture
  7681. */
  7682. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7683. /**
  7684. * Makes a clone, or deep copy, of the cube texture
  7685. * @returns a new cube texture
  7686. */
  7687. clone(): CubeTexture;
  7688. }
  7689. }
  7690. declare module "babylonjs/Materials/materialDefines" {
  7691. /**
  7692. * Manages the defines for the Material
  7693. */
  7694. export class MaterialDefines {
  7695. /** @hidden */
  7696. protected _keys: string[];
  7697. private _isDirty;
  7698. /** @hidden */
  7699. _renderId: number;
  7700. /** @hidden */
  7701. _areLightsDirty: boolean;
  7702. /** @hidden */
  7703. _areLightsDisposed: boolean;
  7704. /** @hidden */
  7705. _areAttributesDirty: boolean;
  7706. /** @hidden */
  7707. _areTexturesDirty: boolean;
  7708. /** @hidden */
  7709. _areFresnelDirty: boolean;
  7710. /** @hidden */
  7711. _areMiscDirty: boolean;
  7712. /** @hidden */
  7713. _areImageProcessingDirty: boolean;
  7714. /** @hidden */
  7715. _normals: boolean;
  7716. /** @hidden */
  7717. _uvs: boolean;
  7718. /** @hidden */
  7719. _needNormals: boolean;
  7720. /** @hidden */
  7721. _needUVs: boolean;
  7722. [id: string]: any;
  7723. /**
  7724. * Specifies if the material needs to be re-calculated
  7725. */
  7726. readonly isDirty: boolean;
  7727. /**
  7728. * Marks the material to indicate that it has been re-calculated
  7729. */
  7730. markAsProcessed(): void;
  7731. /**
  7732. * Marks the material to indicate that it needs to be re-calculated
  7733. */
  7734. markAsUnprocessed(): void;
  7735. /**
  7736. * Marks the material to indicate all of its defines need to be re-calculated
  7737. */
  7738. markAllAsDirty(): void;
  7739. /**
  7740. * Marks the material to indicate that image processing needs to be re-calculated
  7741. */
  7742. markAsImageProcessingDirty(): void;
  7743. /**
  7744. * Marks the material to indicate the lights need to be re-calculated
  7745. * @param disposed Defines whether the light is dirty due to dispose or not
  7746. */
  7747. markAsLightDirty(disposed?: boolean): void;
  7748. /**
  7749. * Marks the attribute state as changed
  7750. */
  7751. markAsAttributesDirty(): void;
  7752. /**
  7753. * Marks the texture state as changed
  7754. */
  7755. markAsTexturesDirty(): void;
  7756. /**
  7757. * Marks the fresnel state as changed
  7758. */
  7759. markAsFresnelDirty(): void;
  7760. /**
  7761. * Marks the misc state as changed
  7762. */
  7763. markAsMiscDirty(): void;
  7764. /**
  7765. * Rebuilds the material defines
  7766. */
  7767. rebuild(): void;
  7768. /**
  7769. * Specifies if two material defines are equal
  7770. * @param other - A material define instance to compare to
  7771. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7772. */
  7773. isEqual(other: MaterialDefines): boolean;
  7774. /**
  7775. * Clones this instance's defines to another instance
  7776. * @param other - material defines to clone values to
  7777. */
  7778. cloneTo(other: MaterialDefines): void;
  7779. /**
  7780. * Resets the material define values
  7781. */
  7782. reset(): void;
  7783. /**
  7784. * Converts the material define values to a string
  7785. * @returns - String of material define information
  7786. */
  7787. toString(): string;
  7788. }
  7789. }
  7790. declare module "babylonjs/Materials/colorCurves" {
  7791. import { Effect } from "babylonjs/Materials/effect";
  7792. /**
  7793. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7794. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7795. * 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;
  7796. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7797. */
  7798. export class ColorCurves {
  7799. private _dirty;
  7800. private _tempColor;
  7801. private _globalCurve;
  7802. private _highlightsCurve;
  7803. private _midtonesCurve;
  7804. private _shadowsCurve;
  7805. private _positiveCurve;
  7806. private _negativeCurve;
  7807. private _globalHue;
  7808. private _globalDensity;
  7809. private _globalSaturation;
  7810. private _globalExposure;
  7811. /**
  7812. * Gets the global Hue value.
  7813. * 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).
  7814. */
  7815. /**
  7816. * Sets the global Hue value.
  7817. * 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).
  7818. */
  7819. globalHue: number;
  7820. /**
  7821. * Gets the global Density value.
  7822. * 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.
  7823. * Values less than zero provide a filter of opposite hue.
  7824. */
  7825. /**
  7826. * Sets the global Density value.
  7827. * 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.
  7828. * Values less than zero provide a filter of opposite hue.
  7829. */
  7830. globalDensity: number;
  7831. /**
  7832. * Gets the global Saturation value.
  7833. * 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.
  7834. */
  7835. /**
  7836. * Sets the global Saturation value.
  7837. * 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.
  7838. */
  7839. globalSaturation: number;
  7840. /**
  7841. * Gets the global Exposure value.
  7842. * 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.
  7843. */
  7844. /**
  7845. * Sets the global Exposure value.
  7846. * 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.
  7847. */
  7848. globalExposure: number;
  7849. private _highlightsHue;
  7850. private _highlightsDensity;
  7851. private _highlightsSaturation;
  7852. private _highlightsExposure;
  7853. /**
  7854. * Gets the highlights Hue value.
  7855. * 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).
  7856. */
  7857. /**
  7858. * Sets the highlights Hue value.
  7859. * 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).
  7860. */
  7861. highlightsHue: number;
  7862. /**
  7863. * Gets the highlights Density value.
  7864. * 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.
  7865. * Values less than zero provide a filter of opposite hue.
  7866. */
  7867. /**
  7868. * Sets the highlights Density value.
  7869. * 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.
  7870. * Values less than zero provide a filter of opposite hue.
  7871. */
  7872. highlightsDensity: number;
  7873. /**
  7874. * Gets the highlights Saturation value.
  7875. * 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.
  7876. */
  7877. /**
  7878. * Sets the highlights Saturation value.
  7879. * 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.
  7880. */
  7881. highlightsSaturation: number;
  7882. /**
  7883. * Gets the highlights Exposure value.
  7884. * 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.
  7885. */
  7886. /**
  7887. * Sets the highlights Exposure value.
  7888. * 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.
  7889. */
  7890. highlightsExposure: number;
  7891. private _midtonesHue;
  7892. private _midtonesDensity;
  7893. private _midtonesSaturation;
  7894. private _midtonesExposure;
  7895. /**
  7896. * Gets the midtones Hue value.
  7897. * 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).
  7898. */
  7899. /**
  7900. * Sets the midtones Hue value.
  7901. * 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).
  7902. */
  7903. midtonesHue: number;
  7904. /**
  7905. * Gets the midtones Density value.
  7906. * 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.
  7907. * Values less than zero provide a filter of opposite hue.
  7908. */
  7909. /**
  7910. * Sets the midtones Density value.
  7911. * 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.
  7912. * Values less than zero provide a filter of opposite hue.
  7913. */
  7914. midtonesDensity: number;
  7915. /**
  7916. * Gets the midtones Saturation value.
  7917. * 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.
  7918. */
  7919. /**
  7920. * Sets the midtones Saturation value.
  7921. * 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.
  7922. */
  7923. midtonesSaturation: number;
  7924. /**
  7925. * Gets the midtones Exposure value.
  7926. * 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.
  7927. */
  7928. /**
  7929. * Sets the midtones Exposure value.
  7930. * 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.
  7931. */
  7932. midtonesExposure: number;
  7933. private _shadowsHue;
  7934. private _shadowsDensity;
  7935. private _shadowsSaturation;
  7936. private _shadowsExposure;
  7937. /**
  7938. * Gets the shadows Hue value.
  7939. * 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).
  7940. */
  7941. /**
  7942. * Sets the shadows Hue value.
  7943. * 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).
  7944. */
  7945. shadowsHue: number;
  7946. /**
  7947. * Gets the shadows Density value.
  7948. * 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.
  7949. * Values less than zero provide a filter of opposite hue.
  7950. */
  7951. /**
  7952. * Sets the shadows Density value.
  7953. * 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.
  7954. * Values less than zero provide a filter of opposite hue.
  7955. */
  7956. shadowsDensity: number;
  7957. /**
  7958. * Gets the shadows Saturation value.
  7959. * 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.
  7960. */
  7961. /**
  7962. * Sets the shadows Saturation value.
  7963. * 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.
  7964. */
  7965. shadowsSaturation: number;
  7966. /**
  7967. * Gets the shadows Exposure value.
  7968. * 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.
  7969. */
  7970. /**
  7971. * Sets the shadows Exposure value.
  7972. * 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.
  7973. */
  7974. shadowsExposure: number;
  7975. /**
  7976. * Returns the class name
  7977. * @returns The class name
  7978. */
  7979. getClassName(): string;
  7980. /**
  7981. * Binds the color curves to the shader.
  7982. * @param colorCurves The color curve to bind
  7983. * @param effect The effect to bind to
  7984. * @param positiveUniform The positive uniform shader parameter
  7985. * @param neutralUniform The neutral uniform shader parameter
  7986. * @param negativeUniform The negative uniform shader parameter
  7987. */
  7988. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7989. /**
  7990. * Prepare the list of uniforms associated with the ColorCurves effects.
  7991. * @param uniformsList The list of uniforms used in the effect
  7992. */
  7993. static PrepareUniforms(uniformsList: string[]): void;
  7994. /**
  7995. * Returns color grading data based on a hue, density, saturation and exposure value.
  7996. * @param filterHue The hue of the color filter.
  7997. * @param filterDensity The density of the color filter.
  7998. * @param saturation The saturation.
  7999. * @param exposure The exposure.
  8000. * @param result The result data container.
  8001. */
  8002. private getColorGradingDataToRef;
  8003. /**
  8004. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8005. * @param value The input slider value in range [-100,100].
  8006. * @returns Adjusted value.
  8007. */
  8008. private static applyColorGradingSliderNonlinear;
  8009. /**
  8010. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8011. * @param hue The hue (H) input.
  8012. * @param saturation The saturation (S) input.
  8013. * @param brightness The brightness (B) input.
  8014. * @result An RGBA color represented as Vector4.
  8015. */
  8016. private static fromHSBToRef;
  8017. /**
  8018. * Returns a value clamped between min and max
  8019. * @param value The value to clamp
  8020. * @param min The minimum of value
  8021. * @param max The maximum of value
  8022. * @returns The clamped value.
  8023. */
  8024. private static clamp;
  8025. /**
  8026. * Clones the current color curve instance.
  8027. * @return The cloned curves
  8028. */
  8029. clone(): ColorCurves;
  8030. /**
  8031. * Serializes the current color curve instance to a json representation.
  8032. * @return a JSON representation
  8033. */
  8034. serialize(): any;
  8035. /**
  8036. * Parses the color curve from a json representation.
  8037. * @param source the JSON source to parse
  8038. * @return The parsed curves
  8039. */
  8040. static Parse(source: any): ColorCurves;
  8041. }
  8042. }
  8043. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8044. import { Observable } from "babylonjs/Misc/observable";
  8045. import { Nullable } from "babylonjs/types";
  8046. import { Color4 } from "babylonjs/Maths/math.color";
  8047. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8048. import { Effect } from "babylonjs/Materials/effect";
  8049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8050. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8051. /**
  8052. * Interface to follow in your material defines to integrate easily the
  8053. * Image proccessing functions.
  8054. * @hidden
  8055. */
  8056. export interface IImageProcessingConfigurationDefines {
  8057. IMAGEPROCESSING: boolean;
  8058. VIGNETTE: boolean;
  8059. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8060. VIGNETTEBLENDMODEOPAQUE: boolean;
  8061. TONEMAPPING: boolean;
  8062. TONEMAPPING_ACES: boolean;
  8063. CONTRAST: boolean;
  8064. EXPOSURE: boolean;
  8065. COLORCURVES: boolean;
  8066. COLORGRADING: boolean;
  8067. COLORGRADING3D: boolean;
  8068. SAMPLER3DGREENDEPTH: boolean;
  8069. SAMPLER3DBGRMAP: boolean;
  8070. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8071. }
  8072. /**
  8073. * @hidden
  8074. */
  8075. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8076. IMAGEPROCESSING: boolean;
  8077. VIGNETTE: boolean;
  8078. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8079. VIGNETTEBLENDMODEOPAQUE: boolean;
  8080. TONEMAPPING: boolean;
  8081. TONEMAPPING_ACES: boolean;
  8082. CONTRAST: boolean;
  8083. COLORCURVES: boolean;
  8084. COLORGRADING: boolean;
  8085. COLORGRADING3D: boolean;
  8086. SAMPLER3DGREENDEPTH: boolean;
  8087. SAMPLER3DBGRMAP: boolean;
  8088. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8089. EXPOSURE: boolean;
  8090. constructor();
  8091. }
  8092. /**
  8093. * This groups together the common properties used for image processing either in direct forward pass
  8094. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8095. * or not.
  8096. */
  8097. export class ImageProcessingConfiguration {
  8098. /**
  8099. * Default tone mapping applied in BabylonJS.
  8100. */
  8101. static readonly TONEMAPPING_STANDARD: number;
  8102. /**
  8103. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8104. * to other engines rendering to increase portability.
  8105. */
  8106. static readonly TONEMAPPING_ACES: number;
  8107. /**
  8108. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8109. */
  8110. colorCurves: Nullable<ColorCurves>;
  8111. private _colorCurvesEnabled;
  8112. /**
  8113. * Gets wether the color curves effect is enabled.
  8114. */
  8115. /**
  8116. * Sets wether the color curves effect is enabled.
  8117. */
  8118. colorCurvesEnabled: boolean;
  8119. private _colorGradingTexture;
  8120. /**
  8121. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8122. */
  8123. /**
  8124. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8125. */
  8126. colorGradingTexture: Nullable<BaseTexture>;
  8127. private _colorGradingEnabled;
  8128. /**
  8129. * Gets wether the color grading effect is enabled.
  8130. */
  8131. /**
  8132. * Sets wether the color grading effect is enabled.
  8133. */
  8134. colorGradingEnabled: boolean;
  8135. private _colorGradingWithGreenDepth;
  8136. /**
  8137. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8138. */
  8139. /**
  8140. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8141. */
  8142. colorGradingWithGreenDepth: boolean;
  8143. private _colorGradingBGR;
  8144. /**
  8145. * Gets wether the color grading texture contains BGR values.
  8146. */
  8147. /**
  8148. * Sets wether the color grading texture contains BGR values.
  8149. */
  8150. colorGradingBGR: boolean;
  8151. /** @hidden */
  8152. _exposure: number;
  8153. /**
  8154. * Gets the Exposure used in the effect.
  8155. */
  8156. /**
  8157. * Sets the Exposure used in the effect.
  8158. */
  8159. exposure: number;
  8160. private _toneMappingEnabled;
  8161. /**
  8162. * Gets wether the tone mapping effect is enabled.
  8163. */
  8164. /**
  8165. * Sets wether the tone mapping effect is enabled.
  8166. */
  8167. toneMappingEnabled: boolean;
  8168. private _toneMappingType;
  8169. /**
  8170. * Gets the type of tone mapping effect.
  8171. */
  8172. /**
  8173. * Sets the type of tone mapping effect used in BabylonJS.
  8174. */
  8175. toneMappingType: number;
  8176. protected _contrast: number;
  8177. /**
  8178. * Gets the contrast used in the effect.
  8179. */
  8180. /**
  8181. * Sets the contrast used in the effect.
  8182. */
  8183. contrast: number;
  8184. /**
  8185. * Vignette stretch size.
  8186. */
  8187. vignetteStretch: number;
  8188. /**
  8189. * Vignette centre X Offset.
  8190. */
  8191. vignetteCentreX: number;
  8192. /**
  8193. * Vignette centre Y Offset.
  8194. */
  8195. vignetteCentreY: number;
  8196. /**
  8197. * Vignette weight or intensity of the vignette effect.
  8198. */
  8199. vignetteWeight: number;
  8200. /**
  8201. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8202. * if vignetteEnabled is set to true.
  8203. */
  8204. vignetteColor: Color4;
  8205. /**
  8206. * Camera field of view used by the Vignette effect.
  8207. */
  8208. vignetteCameraFov: number;
  8209. private _vignetteBlendMode;
  8210. /**
  8211. * Gets the vignette blend mode allowing different kind of effect.
  8212. */
  8213. /**
  8214. * Sets the vignette blend mode allowing different kind of effect.
  8215. */
  8216. vignetteBlendMode: number;
  8217. private _vignetteEnabled;
  8218. /**
  8219. * Gets wether the vignette effect is enabled.
  8220. */
  8221. /**
  8222. * Sets wether the vignette effect is enabled.
  8223. */
  8224. vignetteEnabled: boolean;
  8225. private _applyByPostProcess;
  8226. /**
  8227. * Gets wether the image processing is applied through a post process or not.
  8228. */
  8229. /**
  8230. * Sets wether the image processing is applied through a post process or not.
  8231. */
  8232. applyByPostProcess: boolean;
  8233. private _isEnabled;
  8234. /**
  8235. * Gets wether the image processing is enabled or not.
  8236. */
  8237. /**
  8238. * Sets wether the image processing is enabled or not.
  8239. */
  8240. isEnabled: boolean;
  8241. /**
  8242. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8243. */
  8244. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8245. /**
  8246. * Method called each time the image processing information changes requires to recompile the effect.
  8247. */
  8248. protected _updateParameters(): void;
  8249. /**
  8250. * Gets the current class name.
  8251. * @return "ImageProcessingConfiguration"
  8252. */
  8253. getClassName(): string;
  8254. /**
  8255. * Prepare the list of uniforms associated with the Image Processing effects.
  8256. * @param uniforms The list of uniforms used in the effect
  8257. * @param defines the list of defines currently in use
  8258. */
  8259. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8260. /**
  8261. * Prepare the list of samplers associated with the Image Processing effects.
  8262. * @param samplersList The list of uniforms used in the effect
  8263. * @param defines the list of defines currently in use
  8264. */
  8265. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8266. /**
  8267. * Prepare the list of defines associated to the shader.
  8268. * @param defines the list of defines to complete
  8269. * @param forPostProcess Define if we are currently in post process mode or not
  8270. */
  8271. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8272. /**
  8273. * Returns true if all the image processing information are ready.
  8274. * @returns True if ready, otherwise, false
  8275. */
  8276. isReady(): boolean;
  8277. /**
  8278. * Binds the image processing to the shader.
  8279. * @param effect The effect to bind to
  8280. * @param aspectRatio Define the current aspect ratio of the effect
  8281. */
  8282. bind(effect: Effect, aspectRatio?: number): void;
  8283. /**
  8284. * Clones the current image processing instance.
  8285. * @return The cloned image processing
  8286. */
  8287. clone(): ImageProcessingConfiguration;
  8288. /**
  8289. * Serializes the current image processing instance to a json representation.
  8290. * @return a JSON representation
  8291. */
  8292. serialize(): any;
  8293. /**
  8294. * Parses the image processing from a json representation.
  8295. * @param source the JSON source to parse
  8296. * @return The parsed image processing
  8297. */
  8298. static Parse(source: any): ImageProcessingConfiguration;
  8299. private static _VIGNETTEMODE_MULTIPLY;
  8300. private static _VIGNETTEMODE_OPAQUE;
  8301. /**
  8302. * Used to apply the vignette as a mix with the pixel color.
  8303. */
  8304. static readonly VIGNETTEMODE_MULTIPLY: number;
  8305. /**
  8306. * Used to apply the vignette as a replacement of the pixel color.
  8307. */
  8308. static readonly VIGNETTEMODE_OPAQUE: number;
  8309. }
  8310. }
  8311. declare module "babylonjs/Shaders/postprocess.vertex" {
  8312. /** @hidden */
  8313. export var postprocessVertexShader: {
  8314. name: string;
  8315. shader: string;
  8316. };
  8317. }
  8318. declare module "babylonjs/Maths/math.axis" {
  8319. import { Vector3 } from "babylonjs/Maths/math.vector";
  8320. /** Defines supported spaces */
  8321. export enum Space {
  8322. /** Local (object) space */
  8323. LOCAL = 0,
  8324. /** World space */
  8325. WORLD = 1,
  8326. /** Bone space */
  8327. BONE = 2
  8328. }
  8329. /** Defines the 3 main axes */
  8330. export class Axis {
  8331. /** X axis */
  8332. static X: Vector3;
  8333. /** Y axis */
  8334. static Y: Vector3;
  8335. /** Z axis */
  8336. static Z: Vector3;
  8337. }
  8338. }
  8339. declare module "babylonjs/Cameras/targetCamera" {
  8340. import { Nullable } from "babylonjs/types";
  8341. import { Camera } from "babylonjs/Cameras/camera";
  8342. import { Scene } from "babylonjs/scene";
  8343. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8344. /**
  8345. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8346. * This is the base of the follow, arc rotate cameras and Free camera
  8347. * @see http://doc.babylonjs.com/features/cameras
  8348. */
  8349. export class TargetCamera extends Camera {
  8350. private static _RigCamTransformMatrix;
  8351. private static _TargetTransformMatrix;
  8352. private static _TargetFocalPoint;
  8353. /**
  8354. * Define the current direction the camera is moving to
  8355. */
  8356. cameraDirection: Vector3;
  8357. /**
  8358. * Define the current rotation the camera is rotating to
  8359. */
  8360. cameraRotation: Vector2;
  8361. /**
  8362. * When set, the up vector of the camera will be updated by the rotation of the camera
  8363. */
  8364. updateUpVectorFromRotation: boolean;
  8365. private _tmpQuaternion;
  8366. /**
  8367. * Define the current rotation of the camera
  8368. */
  8369. rotation: Vector3;
  8370. /**
  8371. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8372. */
  8373. rotationQuaternion: Quaternion;
  8374. /**
  8375. * Define the current speed of the camera
  8376. */
  8377. speed: number;
  8378. /**
  8379. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8380. * around all axis.
  8381. */
  8382. noRotationConstraint: boolean;
  8383. /**
  8384. * Define the current target of the camera as an object or a position.
  8385. */
  8386. lockedTarget: any;
  8387. /** @hidden */
  8388. _currentTarget: Vector3;
  8389. /** @hidden */
  8390. _initialFocalDistance: number;
  8391. /** @hidden */
  8392. _viewMatrix: Matrix;
  8393. /** @hidden */
  8394. _camMatrix: Matrix;
  8395. /** @hidden */
  8396. _cameraTransformMatrix: Matrix;
  8397. /** @hidden */
  8398. _cameraRotationMatrix: Matrix;
  8399. /** @hidden */
  8400. _referencePoint: Vector3;
  8401. /** @hidden */
  8402. _transformedReferencePoint: Vector3;
  8403. protected _globalCurrentTarget: Vector3;
  8404. protected _globalCurrentUpVector: Vector3;
  8405. /** @hidden */
  8406. _reset: () => void;
  8407. private _defaultUp;
  8408. /**
  8409. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8410. * This is the base of the follow, arc rotate cameras and Free camera
  8411. * @see http://doc.babylonjs.com/features/cameras
  8412. * @param name Defines the name of the camera in the scene
  8413. * @param position Defines the start position of the camera in the scene
  8414. * @param scene Defines the scene the camera belongs to
  8415. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8416. */
  8417. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8418. /**
  8419. * Gets the position in front of the camera at a given distance.
  8420. * @param distance The distance from the camera we want the position to be
  8421. * @returns the position
  8422. */
  8423. getFrontPosition(distance: number): Vector3;
  8424. /** @hidden */
  8425. _getLockedTargetPosition(): Nullable<Vector3>;
  8426. private _storedPosition;
  8427. private _storedRotation;
  8428. private _storedRotationQuaternion;
  8429. /**
  8430. * Store current camera state of the camera (fov, position, rotation, etc..)
  8431. * @returns the camera
  8432. */
  8433. storeState(): Camera;
  8434. /**
  8435. * Restored camera state. You must call storeState() first
  8436. * @returns whether it was successful or not
  8437. * @hidden
  8438. */
  8439. _restoreStateValues(): boolean;
  8440. /** @hidden */
  8441. _initCache(): void;
  8442. /** @hidden */
  8443. _updateCache(ignoreParentClass?: boolean): void;
  8444. /** @hidden */
  8445. _isSynchronizedViewMatrix(): boolean;
  8446. /** @hidden */
  8447. _computeLocalCameraSpeed(): number;
  8448. /**
  8449. * Defines the target the camera should look at.
  8450. * @param target Defines the new target as a Vector or a mesh
  8451. */
  8452. setTarget(target: Vector3): void;
  8453. /**
  8454. * Return the current target position of the camera. This value is expressed in local space.
  8455. * @returns the target position
  8456. */
  8457. getTarget(): Vector3;
  8458. /** @hidden */
  8459. _decideIfNeedsToMove(): boolean;
  8460. /** @hidden */
  8461. _updatePosition(): void;
  8462. /** @hidden */
  8463. _checkInputs(): void;
  8464. protected _updateCameraRotationMatrix(): void;
  8465. /**
  8466. * 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)
  8467. * @returns the current camera
  8468. */
  8469. private _rotateUpVectorWithCameraRotationMatrix;
  8470. private _cachedRotationZ;
  8471. private _cachedQuaternionRotationZ;
  8472. /** @hidden */
  8473. _getViewMatrix(): Matrix;
  8474. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8475. /**
  8476. * @hidden
  8477. */
  8478. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8479. /**
  8480. * @hidden
  8481. */
  8482. _updateRigCameras(): void;
  8483. private _getRigCamPositionAndTarget;
  8484. /**
  8485. * Gets the current object class name.
  8486. * @return the class name
  8487. */
  8488. getClassName(): string;
  8489. }
  8490. }
  8491. declare module "babylonjs/Events/keyboardEvents" {
  8492. /**
  8493. * Gather the list of keyboard event types as constants.
  8494. */
  8495. export class KeyboardEventTypes {
  8496. /**
  8497. * The keydown event is fired when a key becomes active (pressed).
  8498. */
  8499. static readonly KEYDOWN: number;
  8500. /**
  8501. * The keyup event is fired when a key has been released.
  8502. */
  8503. static readonly KEYUP: number;
  8504. }
  8505. /**
  8506. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8507. */
  8508. export class KeyboardInfo {
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number;
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent;
  8517. /**
  8518. * Instantiates a new keyboard info.
  8519. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8520. * @param type Defines the type of event (KeyboardEventTypes)
  8521. * @param event Defines the related dom event
  8522. */
  8523. constructor(
  8524. /**
  8525. * Defines the type of event (KeyboardEventTypes)
  8526. */
  8527. type: number,
  8528. /**
  8529. * Defines the related dom event
  8530. */
  8531. event: KeyboardEvent);
  8532. }
  8533. /**
  8534. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8535. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8536. */
  8537. export class KeyboardInfoPre extends KeyboardInfo {
  8538. /**
  8539. * Defines the type of event (KeyboardEventTypes)
  8540. */
  8541. type: number;
  8542. /**
  8543. * Defines the related dom event
  8544. */
  8545. event: KeyboardEvent;
  8546. /**
  8547. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8548. */
  8549. skipOnPointerObservable: boolean;
  8550. /**
  8551. * Instantiates a new keyboard pre info.
  8552. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8553. * @param type Defines the type of event (KeyboardEventTypes)
  8554. * @param event Defines the related dom event
  8555. */
  8556. constructor(
  8557. /**
  8558. * Defines the type of event (KeyboardEventTypes)
  8559. */
  8560. type: number,
  8561. /**
  8562. * Defines the related dom event
  8563. */
  8564. event: KeyboardEvent);
  8565. }
  8566. }
  8567. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8568. import { Nullable } from "babylonjs/types";
  8569. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8570. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8571. /**
  8572. * Manage the keyboard inputs to control the movement of a free camera.
  8573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8574. */
  8575. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8576. /**
  8577. * Defines the camera the input is attached to.
  8578. */
  8579. camera: FreeCamera;
  8580. /**
  8581. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8582. */
  8583. keysUp: number[];
  8584. /**
  8585. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8586. */
  8587. keysDown: number[];
  8588. /**
  8589. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8590. */
  8591. keysLeft: number[];
  8592. /**
  8593. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8594. */
  8595. keysRight: number[];
  8596. private _keys;
  8597. private _onCanvasBlurObserver;
  8598. private _onKeyboardObserver;
  8599. private _engine;
  8600. private _scene;
  8601. /**
  8602. * Attach the input controls to a specific dom element to get the input from.
  8603. * @param element Defines the element the controls should be listened from
  8604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8605. */
  8606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8607. /**
  8608. * Detach the current controls from the specified dom element.
  8609. * @param element Defines the element to stop listening the inputs from
  8610. */
  8611. detachControl(element: Nullable<HTMLElement>): void;
  8612. /**
  8613. * Update the current camera state depending on the inputs that have been used this frame.
  8614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8615. */
  8616. checkInputs(): void;
  8617. /**
  8618. * Gets the class name of the current intput.
  8619. * @returns the class name
  8620. */
  8621. getClassName(): string;
  8622. /** @hidden */
  8623. _onLostFocus(): void;
  8624. /**
  8625. * Get the friendly name associated with the input class.
  8626. * @returns the input friendly name
  8627. */
  8628. getSimpleName(): string;
  8629. }
  8630. }
  8631. declare module "babylonjs/Lights/shadowLight" {
  8632. import { Camera } from "babylonjs/Cameras/camera";
  8633. import { Scene } from "babylonjs/scene";
  8634. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8636. import { Light } from "babylonjs/Lights/light";
  8637. /**
  8638. * Interface describing all the common properties and methods a shadow light needs to implement.
  8639. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8640. * as well as binding the different shadow properties to the effects.
  8641. */
  8642. export interface IShadowLight extends Light {
  8643. /**
  8644. * The light id in the scene (used in scene.findLighById for instance)
  8645. */
  8646. id: string;
  8647. /**
  8648. * The position the shdow will be casted from.
  8649. */
  8650. position: Vector3;
  8651. /**
  8652. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8653. */
  8654. direction: Vector3;
  8655. /**
  8656. * The transformed position. Position of the light in world space taking parenting in account.
  8657. */
  8658. transformedPosition: Vector3;
  8659. /**
  8660. * The transformed direction. Direction of the light in world space taking parenting in account.
  8661. */
  8662. transformedDirection: Vector3;
  8663. /**
  8664. * The friendly name of the light in the scene.
  8665. */
  8666. name: string;
  8667. /**
  8668. * Defines the shadow projection clipping minimum z value.
  8669. */
  8670. shadowMinZ: number;
  8671. /**
  8672. * Defines the shadow projection clipping maximum z value.
  8673. */
  8674. shadowMaxZ: number;
  8675. /**
  8676. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8677. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8678. */
  8679. computeTransformedInformation(): boolean;
  8680. /**
  8681. * Gets the scene the light belongs to.
  8682. * @returns The scene
  8683. */
  8684. getScene(): Scene;
  8685. /**
  8686. * Callback defining a custom Projection Matrix Builder.
  8687. * This can be used to override the default projection matrix computation.
  8688. */
  8689. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8690. /**
  8691. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8692. * @param matrix The materix to updated with the projection information
  8693. * @param viewMatrix The transform matrix of the light
  8694. * @param renderList The list of mesh to render in the map
  8695. * @returns The current light
  8696. */
  8697. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8698. /**
  8699. * Gets the current depth scale used in ESM.
  8700. * @returns The scale
  8701. */
  8702. getDepthScale(): number;
  8703. /**
  8704. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8705. * @returns true if a cube texture needs to be use
  8706. */
  8707. needCube(): boolean;
  8708. /**
  8709. * Detects if the projection matrix requires to be recomputed this frame.
  8710. * @returns true if it requires to be recomputed otherwise, false.
  8711. */
  8712. needProjectionMatrixCompute(): boolean;
  8713. /**
  8714. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8715. */
  8716. forceProjectionMatrixCompute(): void;
  8717. /**
  8718. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8719. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8720. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8721. */
  8722. getShadowDirection(faceIndex?: number): Vector3;
  8723. /**
  8724. * Gets the minZ used for shadow according to both the scene and the light.
  8725. * @param activeCamera The camera we are returning the min for
  8726. * @returns the depth min z
  8727. */
  8728. getDepthMinZ(activeCamera: Camera): number;
  8729. /**
  8730. * Gets the maxZ used for shadow according to both the scene and the light.
  8731. * @param activeCamera The camera we are returning the max for
  8732. * @returns the depth max z
  8733. */
  8734. getDepthMaxZ(activeCamera: Camera): number;
  8735. }
  8736. /**
  8737. * Base implementation IShadowLight
  8738. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8739. */
  8740. export abstract class ShadowLight extends Light implements IShadowLight {
  8741. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8742. protected _position: Vector3;
  8743. protected _setPosition(value: Vector3): void;
  8744. /**
  8745. * Sets the position the shadow will be casted from. Also use as the light position for both
  8746. * point and spot lights.
  8747. */
  8748. /**
  8749. * Sets the position the shadow will be casted from. Also use as the light position for both
  8750. * point and spot lights.
  8751. */
  8752. position: Vector3;
  8753. protected _direction: Vector3;
  8754. protected _setDirection(value: Vector3): void;
  8755. /**
  8756. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8757. * Also use as the light direction on spot and directional lights.
  8758. */
  8759. /**
  8760. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8761. * Also use as the light direction on spot and directional lights.
  8762. */
  8763. direction: Vector3;
  8764. private _shadowMinZ;
  8765. /**
  8766. * Gets the shadow projection clipping minimum z value.
  8767. */
  8768. /**
  8769. * Sets the shadow projection clipping minimum z value.
  8770. */
  8771. shadowMinZ: number;
  8772. private _shadowMaxZ;
  8773. /**
  8774. * Sets the shadow projection clipping maximum z value.
  8775. */
  8776. /**
  8777. * Gets the shadow projection clipping maximum z value.
  8778. */
  8779. shadowMaxZ: number;
  8780. /**
  8781. * Callback defining a custom Projection Matrix Builder.
  8782. * This can be used to override the default projection matrix computation.
  8783. */
  8784. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8785. /**
  8786. * The transformed position. Position of the light in world space taking parenting in account.
  8787. */
  8788. transformedPosition: Vector3;
  8789. /**
  8790. * The transformed direction. Direction of the light in world space taking parenting in account.
  8791. */
  8792. transformedDirection: Vector3;
  8793. private _needProjectionMatrixCompute;
  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. * Return the depth scale used for the shadow map.
  8801. * @returns the depth scale.
  8802. */
  8803. getDepthScale(): number;
  8804. /**
  8805. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8806. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8807. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8808. */
  8809. getShadowDirection(faceIndex?: number): Vector3;
  8810. /**
  8811. * Returns the ShadowLight absolute position in the World.
  8812. * @returns the position vector in world space
  8813. */
  8814. getAbsolutePosition(): Vector3;
  8815. /**
  8816. * Sets the ShadowLight direction toward the passed target.
  8817. * @param target The point to target in local space
  8818. * @returns the updated ShadowLight direction
  8819. */
  8820. setDirectionToTarget(target: Vector3): Vector3;
  8821. /**
  8822. * Returns the light rotation in euler definition.
  8823. * @returns the x y z rotation in local space.
  8824. */
  8825. getRotation(): Vector3;
  8826. /**
  8827. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8828. * @returns true if a cube texture needs to be use
  8829. */
  8830. needCube(): boolean;
  8831. /**
  8832. * Detects if the projection matrix requires to be recomputed this frame.
  8833. * @returns true if it requires to be recomputed otherwise, false.
  8834. */
  8835. needProjectionMatrixCompute(): boolean;
  8836. /**
  8837. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8838. */
  8839. forceProjectionMatrixCompute(): void;
  8840. /** @hidden */
  8841. _initCache(): void;
  8842. /** @hidden */
  8843. _isSynchronized(): boolean;
  8844. /**
  8845. * Computes the world matrix of the node
  8846. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8847. * @returns the world matrix
  8848. */
  8849. computeWorldMatrix(force?: boolean): Matrix;
  8850. /**
  8851. * Gets the minZ used for shadow according to both the scene and the light.
  8852. * @param activeCamera The camera we are returning the min for
  8853. * @returns the depth min z
  8854. */
  8855. getDepthMinZ(activeCamera: Camera): number;
  8856. /**
  8857. * Gets the maxZ used for shadow according to both the scene and the light.
  8858. * @param activeCamera The camera we are returning the max for
  8859. * @returns the depth max z
  8860. */
  8861. getDepthMaxZ(activeCamera: Camera): number;
  8862. /**
  8863. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8864. * @param matrix The materix to updated with the projection information
  8865. * @param viewMatrix The transform matrix of the light
  8866. * @param renderList The list of mesh to render in the map
  8867. * @returns The current light
  8868. */
  8869. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8870. }
  8871. }
  8872. declare module "babylonjs/Materials/materialHelper" {
  8873. import { Nullable } from "babylonjs/types";
  8874. import { Scene } from "babylonjs/scene";
  8875. import { Engine } from "babylonjs/Engines/engine";
  8876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8877. import { Light } from "babylonjs/Lights/light";
  8878. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8879. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8881. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8882. /**
  8883. * "Static Class" containing the most commonly used helper while dealing with material for
  8884. * rendering purpose.
  8885. *
  8886. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8887. *
  8888. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8889. */
  8890. export class MaterialHelper {
  8891. /**
  8892. * Bind the current view position to an effect.
  8893. * @param effect The effect to be bound
  8894. * @param scene The scene the eyes position is used from
  8895. */
  8896. static BindEyePosition(effect: Effect, scene: Scene): void;
  8897. /**
  8898. * Helps preparing the defines values about the UVs in used in the effect.
  8899. * UVs are shared as much as we can accross channels in the shaders.
  8900. * @param texture The texture we are preparing the UVs for
  8901. * @param defines The defines to update
  8902. * @param key The channel key "diffuse", "specular"... used in the shader
  8903. */
  8904. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8905. /**
  8906. * Binds a texture matrix value to its corrsponding uniform
  8907. * @param texture The texture to bind the matrix for
  8908. * @param uniformBuffer The uniform buffer receivin the data
  8909. * @param key The channel key "diffuse", "specular"... used in the shader
  8910. */
  8911. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8912. /**
  8913. * Gets the current status of the fog (should it be enabled?)
  8914. * @param mesh defines the mesh to evaluate for fog support
  8915. * @param scene defines the hosting scene
  8916. * @returns true if fog must be enabled
  8917. */
  8918. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8919. /**
  8920. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8921. * @param mesh defines the current mesh
  8922. * @param scene defines the current scene
  8923. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8924. * @param pointsCloud defines if point cloud rendering has to be turned on
  8925. * @param fogEnabled defines if fog has to be turned on
  8926. * @param alphaTest defines if alpha testing has to be turned on
  8927. * @param defines defines the current list of defines
  8928. */
  8929. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8930. /**
  8931. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8932. * @param scene defines the current scene
  8933. * @param engine defines the current engine
  8934. * @param defines specifies the list of active defines
  8935. * @param useInstances defines if instances have to be turned on
  8936. * @param useClipPlane defines if clip plane have to be turned on
  8937. */
  8938. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8939. /**
  8940. * Prepares the defines for bones
  8941. * @param mesh The mesh containing the geometry data we will draw
  8942. * @param defines The defines to update
  8943. */
  8944. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8945. /**
  8946. * Prepares the defines for morph targets
  8947. * @param mesh The mesh containing the geometry data we will draw
  8948. * @param defines The defines to update
  8949. */
  8950. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8951. /**
  8952. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8953. * @param mesh The mesh containing the geometry data we will draw
  8954. * @param defines The defines to update
  8955. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8956. * @param useBones Precise whether bones should be used or not (override mesh info)
  8957. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8958. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8959. * @returns false if defines are considered not dirty and have not been checked
  8960. */
  8961. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8962. /**
  8963. * Prepares the defines related to multiview
  8964. * @param scene The scene we are intending to draw
  8965. * @param defines The defines to update
  8966. */
  8967. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8968. /**
  8969. * Prepares the defines related to the light information passed in parameter
  8970. * @param scene The scene we are intending to draw
  8971. * @param mesh The mesh the effect is compiling for
  8972. * @param light The light the effect is compiling for
  8973. * @param lightIndex The index of the light
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param state Defines the current state regarding what is needed (normals, etc...)
  8977. */
  8978. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8979. needNormals: boolean;
  8980. needRebuild: boolean;
  8981. shadowEnabled: boolean;
  8982. specularEnabled: boolean;
  8983. lightmapMode: boolean;
  8984. }): void;
  8985. /**
  8986. * Prepares the defines related to the light information passed in parameter
  8987. * @param scene The scene we are intending to draw
  8988. * @param mesh The mesh the effect is compiling for
  8989. * @param defines The defines to update
  8990. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8991. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8992. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8993. * @returns true if normals will be required for the rest of the effect
  8994. */
  8995. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8996. /**
  8997. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8998. * @param lightIndex defines the light index
  8999. * @param uniformsList The uniform list
  9000. * @param samplersList The sampler list
  9001. * @param projectedLightTexture defines if projected texture must be used
  9002. * @param uniformBuffersList defines an optional list of uniform buffers
  9003. */
  9004. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9005. /**
  9006. * Prepares the uniforms and samplers list to be used in the effect
  9007. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9008. * @param samplersList The sampler list
  9009. * @param defines The defines helping in the list generation
  9010. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9011. */
  9012. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9013. /**
  9014. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9015. * @param defines The defines to update while falling back
  9016. * @param fallbacks The authorized effect fallbacks
  9017. * @param maxSimultaneousLights The maximum number of lights allowed
  9018. * @param rank the current rank of the Effect
  9019. * @returns The newly affected rank
  9020. */
  9021. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9022. private static _TmpMorphInfluencers;
  9023. /**
  9024. * Prepares the list of attributes required for morph targets according to the effect defines.
  9025. * @param attribs The current list of supported attribs
  9026. * @param mesh The mesh to prepare the morph targets attributes for
  9027. * @param influencers The number of influencers
  9028. */
  9029. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9030. /**
  9031. * Prepares the list of attributes required for morph targets according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param mesh The mesh to prepare the morph targets attributes for
  9034. * @param defines The current Defines of the effect
  9035. */
  9036. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9037. /**
  9038. * Prepares the list of attributes required for bones according to the effect defines.
  9039. * @param attribs The current list of supported attribs
  9040. * @param mesh The mesh to prepare the bones attributes for
  9041. * @param defines The current Defines of the effect
  9042. * @param fallbacks The current efffect fallback strategy
  9043. */
  9044. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9045. /**
  9046. * Check and prepare the list of attributes required for instances according to the effect defines.
  9047. * @param attribs The current list of supported attribs
  9048. * @param defines The current MaterialDefines of the effect
  9049. */
  9050. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9051. /**
  9052. * Add the list of attributes required for instances to the attribs array.
  9053. * @param attribs The current list of supported attribs
  9054. */
  9055. static PushAttributesForInstances(attribs: string[]): void;
  9056. /**
  9057. * Binds the light shadow information to the effect for the given mesh.
  9058. * @param light The light containing the generator
  9059. * @param scene The scene the lights belongs to
  9060. * @param mesh The mesh we are binding the information to render
  9061. * @param lightIndex The light index in the effect used to render the mesh
  9062. * @param effect The effect we are binding the data to
  9063. */
  9064. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9065. /**
  9066. * Binds the light information to the effect.
  9067. * @param light The light containing the generator
  9068. * @param effect The effect we are binding the data to
  9069. * @param lightIndex The light index in the effect used to render
  9070. */
  9071. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9072. /**
  9073. * Binds the lights information from the scene to the effect for the given mesh.
  9074. * @param light Light to bind
  9075. * @param lightIndex Light index
  9076. * @param scene The scene where the light belongs to
  9077. * @param mesh The mesh we are binding the information to render
  9078. * @param effect The effect we are binding the data to
  9079. * @param useSpecular Defines if specular is supported
  9080. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9081. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9082. */
  9083. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9084. /**
  9085. * Binds the lights information from the scene to the effect for the given mesh.
  9086. * @param scene The scene the lights belongs to
  9087. * @param mesh The mesh we are binding the information to render
  9088. * @param effect The effect we are binding the data to
  9089. * @param defines The generated defines for the effect
  9090. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9091. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9092. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9093. */
  9094. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9095. private static _tempFogColor;
  9096. /**
  9097. * Binds the fog information from the scene to the effect for the given mesh.
  9098. * @param scene The scene the lights belongs to
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param effect The effect we are binding the data to
  9101. * @param linearSpace Defines if the fog effect is applied in linear space
  9102. */
  9103. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9104. /**
  9105. * Binds the bones information from the mesh to the effect.
  9106. * @param mesh The mesh we are binding the information to render
  9107. * @param effect The effect we are binding the data to
  9108. */
  9109. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9110. /**
  9111. * Binds the morph targets information from the mesh to the effect.
  9112. * @param abstractMesh The mesh we are binding the information to render
  9113. * @param effect The effect we are binding the data to
  9114. */
  9115. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9116. /**
  9117. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9118. * @param defines The generated defines used in the effect
  9119. * @param effect The effect we are binding the data to
  9120. * @param scene The scene we are willing to render with logarithmic scale for
  9121. */
  9122. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9123. /**
  9124. * Binds the clip plane information from the scene to the effect.
  9125. * @param scene The scene the clip plane information are extracted from
  9126. * @param effect The effect we are binding the data to
  9127. */
  9128. static BindClipPlane(effect: Effect, scene: Scene): void;
  9129. }
  9130. }
  9131. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9132. /** @hidden */
  9133. export var packingFunctions: {
  9134. name: string;
  9135. shader: string;
  9136. };
  9137. }
  9138. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9139. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9140. /** @hidden */
  9141. export var shadowMapPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9147. /** @hidden */
  9148. export var bonesDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9154. /** @hidden */
  9155. export var morphTargetsVertexGlobalDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9161. /** @hidden */
  9162. export var morphTargetsVertexDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9168. /** @hidden */
  9169. export var instancesDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9175. /** @hidden */
  9176. export var helperFunctions: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9182. /** @hidden */
  9183. export var morphTargetsVertex: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9189. /** @hidden */
  9190. export var instancesVertex: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9196. /** @hidden */
  9197. export var bonesVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9203. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9204. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9205. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9206. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9207. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9208. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9209. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9210. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9211. /** @hidden */
  9212. export var shadowMapVertexShader: {
  9213. name: string;
  9214. shader: string;
  9215. };
  9216. }
  9217. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9218. /** @hidden */
  9219. export var depthBoxBlurPixelShader: {
  9220. name: string;
  9221. shader: string;
  9222. };
  9223. }
  9224. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9225. import { Nullable } from "babylonjs/types";
  9226. import { Scene } from "babylonjs/scene";
  9227. import { Matrix } from "babylonjs/Maths/math.vector";
  9228. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9230. import { Mesh } from "babylonjs/Meshes/mesh";
  9231. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9232. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9233. import { Effect } from "babylonjs/Materials/effect";
  9234. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9235. import "babylonjs/Shaders/shadowMap.fragment";
  9236. import "babylonjs/Shaders/shadowMap.vertex";
  9237. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9238. import { Observable } from "babylonjs/Misc/observable";
  9239. /**
  9240. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9241. */
  9242. export interface ICustomShaderOptions {
  9243. /**
  9244. * Gets or sets the custom shader name to use
  9245. */
  9246. shaderName: string;
  9247. /**
  9248. * The list of attribute names used in the shader
  9249. */
  9250. attributes?: string[];
  9251. /**
  9252. * The list of unifrom names used in the shader
  9253. */
  9254. uniforms?: string[];
  9255. /**
  9256. * The list of sampler names used in the shader
  9257. */
  9258. samplers?: string[];
  9259. /**
  9260. * The list of defines used in the shader
  9261. */
  9262. defines?: string[];
  9263. }
  9264. /**
  9265. * Interface to implement to create a shadow generator compatible with BJS.
  9266. */
  9267. export interface IShadowGenerator {
  9268. /**
  9269. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9270. * @returns The render target texture if present otherwise, null
  9271. */
  9272. getShadowMap(): Nullable<RenderTargetTexture>;
  9273. /**
  9274. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9275. * @returns The render target texture if the shadow map is present otherwise, null
  9276. */
  9277. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9278. /**
  9279. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9280. * @param subMesh The submesh we want to render in the shadow map
  9281. * @param useInstances Defines wether will draw in the map using instances
  9282. * @returns true if ready otherwise, false
  9283. */
  9284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9285. /**
  9286. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9287. * @param defines Defines of the material we want to update
  9288. * @param lightIndex Index of the light in the enabled light list of the material
  9289. */
  9290. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9291. /**
  9292. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9293. * defined in the generator but impacting the effect).
  9294. * It implies the unifroms available on the materials are the standard BJS ones.
  9295. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9296. * @param effect The effect we are binfing the information for
  9297. */
  9298. bindShadowLight(lightIndex: string, effect: Effect): void;
  9299. /**
  9300. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9301. * (eq to shadow prjection matrix * light transform matrix)
  9302. * @returns The transform matrix used to create the shadow map
  9303. */
  9304. getTransformMatrix(): Matrix;
  9305. /**
  9306. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9307. * Cube and 2D textures for instance.
  9308. */
  9309. recreateShadowMap(): void;
  9310. /**
  9311. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9312. * @param onCompiled Callback triggered at the and of the effects compilation
  9313. * @param options Sets of optional options forcing the compilation with different modes
  9314. */
  9315. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9316. useInstances: boolean;
  9317. }>): void;
  9318. /**
  9319. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9320. * @param options Sets of optional options forcing the compilation with different modes
  9321. * @returns A promise that resolves when the compilation completes
  9322. */
  9323. forceCompilationAsync(options?: Partial<{
  9324. useInstances: boolean;
  9325. }>): Promise<void>;
  9326. /**
  9327. * Serializes the shadow generator setup to a json object.
  9328. * @returns The serialized JSON object
  9329. */
  9330. serialize(): any;
  9331. /**
  9332. * Disposes the Shadow map and related Textures and effects.
  9333. */
  9334. dispose(): void;
  9335. }
  9336. /**
  9337. * Default implementation IShadowGenerator.
  9338. * This is the main object responsible of generating shadows in the framework.
  9339. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9340. */
  9341. export class ShadowGenerator implements IShadowGenerator {
  9342. /**
  9343. * Shadow generator mode None: no filtering applied.
  9344. */
  9345. static readonly FILTER_NONE: number;
  9346. /**
  9347. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9348. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9349. */
  9350. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9351. /**
  9352. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9353. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9354. */
  9355. static readonly FILTER_POISSONSAMPLING: number;
  9356. /**
  9357. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9359. */
  9360. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9361. /**
  9362. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9363. * edge artifacts on steep falloff.
  9364. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9365. */
  9366. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9367. /**
  9368. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9369. * edge artifacts on steep falloff.
  9370. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9371. */
  9372. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9373. /**
  9374. * Shadow generator mode PCF: Percentage Closer Filtering
  9375. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9376. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9377. */
  9378. static readonly FILTER_PCF: number;
  9379. /**
  9380. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9381. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9382. * Contact Hardening
  9383. */
  9384. static readonly FILTER_PCSS: number;
  9385. /**
  9386. * Reserved for PCF and PCSS
  9387. * Highest Quality.
  9388. *
  9389. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9390. *
  9391. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9392. */
  9393. static readonly QUALITY_HIGH: number;
  9394. /**
  9395. * Reserved for PCF and PCSS
  9396. * Good tradeoff for quality/perf cross devices
  9397. *
  9398. * Execute PCF on a 3*3 kernel.
  9399. *
  9400. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9401. */
  9402. static readonly QUALITY_MEDIUM: number;
  9403. /**
  9404. * Reserved for PCF and PCSS
  9405. * The lowest quality but the fastest.
  9406. *
  9407. * Execute PCF on a 1*1 kernel.
  9408. *
  9409. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9410. */
  9411. static readonly QUALITY_LOW: number;
  9412. /** Gets or sets the custom shader name to use */
  9413. customShaderOptions: ICustomShaderOptions;
  9414. /**
  9415. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9416. */
  9417. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9418. /**
  9419. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9420. */
  9421. onAfterShadowMapRenderObservable: Observable<Effect>;
  9422. /**
  9423. * Observable triggered before a mesh is rendered in the shadow map.
  9424. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9425. */
  9426. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9427. /**
  9428. * Observable triggered after a mesh is rendered in the shadow map.
  9429. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9430. */
  9431. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9432. private _bias;
  9433. /**
  9434. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9435. */
  9436. /**
  9437. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9438. */
  9439. bias: number;
  9440. private _normalBias;
  9441. /**
  9442. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9443. */
  9444. /**
  9445. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9446. */
  9447. normalBias: number;
  9448. private _blurBoxOffset;
  9449. /**
  9450. * Gets the blur box offset: offset applied during the blur pass.
  9451. * Only useful if useKernelBlur = false
  9452. */
  9453. /**
  9454. * Sets the blur box offset: offset applied during the blur pass.
  9455. * Only useful if useKernelBlur = false
  9456. */
  9457. blurBoxOffset: number;
  9458. private _blurScale;
  9459. /**
  9460. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9461. * 2 means half of the size.
  9462. */
  9463. /**
  9464. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9465. * 2 means half of the size.
  9466. */
  9467. blurScale: number;
  9468. private _blurKernel;
  9469. /**
  9470. * Gets the blur kernel: kernel size of the blur pass.
  9471. * Only useful if useKernelBlur = true
  9472. */
  9473. /**
  9474. * Sets the blur kernel: kernel size of the blur pass.
  9475. * Only useful if useKernelBlur = true
  9476. */
  9477. blurKernel: number;
  9478. private _useKernelBlur;
  9479. /**
  9480. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9481. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9482. */
  9483. /**
  9484. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9485. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9486. */
  9487. useKernelBlur: boolean;
  9488. private _depthScale;
  9489. /**
  9490. * Gets the depth scale used in ESM mode.
  9491. */
  9492. /**
  9493. * Sets the depth scale used in ESM mode.
  9494. * This can override the scale stored on the light.
  9495. */
  9496. depthScale: number;
  9497. private _filter;
  9498. /**
  9499. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9500. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9501. */
  9502. /**
  9503. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9504. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9505. */
  9506. filter: number;
  9507. /**
  9508. * Gets if the current filter is set to Poisson Sampling.
  9509. */
  9510. /**
  9511. * Sets the current filter to Poisson Sampling.
  9512. */
  9513. usePoissonSampling: boolean;
  9514. /**
  9515. * Gets if the current filter is set to ESM.
  9516. */
  9517. /**
  9518. * Sets the current filter is to ESM.
  9519. */
  9520. useExponentialShadowMap: boolean;
  9521. /**
  9522. * Gets if the current filter is set to filtered ESM.
  9523. */
  9524. /**
  9525. * Gets if the current filter is set to filtered ESM.
  9526. */
  9527. useBlurExponentialShadowMap: boolean;
  9528. /**
  9529. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9530. * exponential to prevent steep falloff artifacts).
  9531. */
  9532. /**
  9533. * Sets the current filter to "close ESM" (using the inverse of the
  9534. * exponential to prevent steep falloff artifacts).
  9535. */
  9536. useCloseExponentialShadowMap: boolean;
  9537. /**
  9538. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9539. * exponential to prevent steep falloff artifacts).
  9540. */
  9541. /**
  9542. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9543. * exponential to prevent steep falloff artifacts).
  9544. */
  9545. useBlurCloseExponentialShadowMap: boolean;
  9546. /**
  9547. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCF" (percentage closer filtering).
  9551. */
  9552. usePercentageCloserFiltering: boolean;
  9553. private _filteringQuality;
  9554. /**
  9555. * Gets the PCF or PCSS Quality.
  9556. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9557. */
  9558. /**
  9559. * Sets the PCF or PCSS Quality.
  9560. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9561. */
  9562. filteringQuality: number;
  9563. /**
  9564. * Gets if the current filter is set to "PCSS" (contact hardening).
  9565. */
  9566. /**
  9567. * Sets the current filter to "PCSS" (contact hardening).
  9568. */
  9569. useContactHardeningShadow: boolean;
  9570. private _contactHardeningLightSizeUVRatio;
  9571. /**
  9572. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9573. * Using a ratio helps keeping shape stability independently of the map size.
  9574. *
  9575. * It does not account for the light projection as it was having too much
  9576. * instability during the light setup or during light position changes.
  9577. *
  9578. * Only valid if useContactHardeningShadow is true.
  9579. */
  9580. /**
  9581. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9582. * Using a ratio helps keeping shape stability independently of the map size.
  9583. *
  9584. * It does not account for the light projection as it was having too much
  9585. * instability during the light setup or during light position changes.
  9586. *
  9587. * Only valid if useContactHardeningShadow is true.
  9588. */
  9589. contactHardeningLightSizeUVRatio: number;
  9590. private _darkness;
  9591. /** Gets or sets the actual darkness of a shadow */
  9592. darkness: number;
  9593. /**
  9594. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9595. * 0 means strongest and 1 would means no shadow.
  9596. * @returns the darkness.
  9597. */
  9598. getDarkness(): number;
  9599. /**
  9600. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9601. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9602. * @returns the shadow generator allowing fluent coding.
  9603. */
  9604. setDarkness(darkness: number): ShadowGenerator;
  9605. private _transparencyShadow;
  9606. /** Gets or sets the ability to have transparent shadow */
  9607. transparencyShadow: boolean;
  9608. /**
  9609. * Sets the ability to have transparent shadow (boolean).
  9610. * @param transparent True if transparent else False
  9611. * @returns the shadow generator allowing fluent coding
  9612. */
  9613. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9614. private _shadowMap;
  9615. private _shadowMap2;
  9616. /**
  9617. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9618. * @returns The render target texture if present otherwise, null
  9619. */
  9620. getShadowMap(): Nullable<RenderTargetTexture>;
  9621. /**
  9622. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9623. * @returns The render target texture if the shadow map is present otherwise, null
  9624. */
  9625. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9626. /**
  9627. * Gets the class name of that object
  9628. * @returns "ShadowGenerator"
  9629. */
  9630. getClassName(): string;
  9631. /**
  9632. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9633. * @param mesh Mesh to add
  9634. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9635. * @returns the Shadow Generator itself
  9636. */
  9637. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9638. /**
  9639. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9640. * @param mesh Mesh to remove
  9641. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9642. * @returns the Shadow Generator itself
  9643. */
  9644. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9645. /**
  9646. * Controls the extent to which the shadows fade out at the edge of the frustum
  9647. * Used only by directionals and spots
  9648. */
  9649. frustumEdgeFalloff: number;
  9650. private _light;
  9651. /**
  9652. * Returns the associated light object.
  9653. * @returns the light generating the shadow
  9654. */
  9655. getLight(): IShadowLight;
  9656. /**
  9657. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9658. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9659. * It might on the other hand introduce peter panning.
  9660. */
  9661. forceBackFacesOnly: boolean;
  9662. private _scene;
  9663. private _lightDirection;
  9664. private _effect;
  9665. private _viewMatrix;
  9666. private _projectionMatrix;
  9667. private _transformMatrix;
  9668. private _cachedPosition;
  9669. private _cachedDirection;
  9670. private _cachedDefines;
  9671. private _currentRenderID;
  9672. private _boxBlurPostprocess;
  9673. private _kernelBlurXPostprocess;
  9674. private _kernelBlurYPostprocess;
  9675. private _blurPostProcesses;
  9676. private _mapSize;
  9677. private _currentFaceIndex;
  9678. private _currentFaceIndexCache;
  9679. private _textureType;
  9680. private _defaultTextureMatrix;
  9681. /** @hidden */
  9682. static _SceneComponentInitialization: (scene: Scene) => void;
  9683. /**
  9684. * Creates a ShadowGenerator object.
  9685. * A ShadowGenerator is the required tool to use the shadows.
  9686. * Each light casting shadows needs to use its own ShadowGenerator.
  9687. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9688. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9689. * @param light The light object generating the shadows.
  9690. * @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.
  9691. */
  9692. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9693. private _initializeGenerator;
  9694. private _initializeShadowMap;
  9695. private _initializeBlurRTTAndPostProcesses;
  9696. private _renderForShadowMap;
  9697. private _renderSubMeshForShadowMap;
  9698. private _applyFilterValues;
  9699. /**
  9700. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9701. * @param onCompiled Callback triggered at the and of the effects compilation
  9702. * @param options Sets of optional options forcing the compilation with different modes
  9703. */
  9704. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9705. useInstances: boolean;
  9706. }>): void;
  9707. /**
  9708. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9709. * @param options Sets of optional options forcing the compilation with different modes
  9710. * @returns A promise that resolves when the compilation completes
  9711. */
  9712. forceCompilationAsync(options?: Partial<{
  9713. useInstances: boolean;
  9714. }>): Promise<void>;
  9715. /**
  9716. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9717. * @param subMesh The submesh we want to render in the shadow map
  9718. * @param useInstances Defines wether will draw in the map using instances
  9719. * @returns true if ready otherwise, false
  9720. */
  9721. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9722. /**
  9723. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9724. * @param defines Defines of the material we want to update
  9725. * @param lightIndex Index of the light in the enabled light list of the material
  9726. */
  9727. prepareDefines(defines: any, lightIndex: number): void;
  9728. /**
  9729. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9730. * defined in the generator but impacting the effect).
  9731. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9732. * @param effect The effect we are binfing the information for
  9733. */
  9734. bindShadowLight(lightIndex: string, effect: Effect): void;
  9735. /**
  9736. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9737. * (eq to shadow prjection matrix * light transform matrix)
  9738. * @returns The transform matrix used to create the shadow map
  9739. */
  9740. getTransformMatrix(): Matrix;
  9741. /**
  9742. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9743. * Cube and 2D textures for instance.
  9744. */
  9745. recreateShadowMap(): void;
  9746. private _disposeBlurPostProcesses;
  9747. private _disposeRTTandPostProcesses;
  9748. /**
  9749. * Disposes the ShadowGenerator.
  9750. * Returns nothing.
  9751. */
  9752. dispose(): void;
  9753. /**
  9754. * Serializes the shadow generator setup to a json object.
  9755. * @returns The serialized JSON object
  9756. */
  9757. serialize(): any;
  9758. /**
  9759. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9760. * @param parsedShadowGenerator The JSON object to parse
  9761. * @param scene The scene to create the shadow map for
  9762. * @returns The parsed shadow generator
  9763. */
  9764. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9765. }
  9766. }
  9767. declare module "babylonjs/Lights/light" {
  9768. import { Nullable } from "babylonjs/types";
  9769. import { Scene } from "babylonjs/scene";
  9770. import { Vector3 } from "babylonjs/Maths/math.vector";
  9771. import { Color3 } from "babylonjs/Maths/math.color";
  9772. import { Node } from "babylonjs/node";
  9773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9774. import { Effect } from "babylonjs/Materials/effect";
  9775. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9776. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9777. /**
  9778. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9779. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9780. * 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.
  9781. */
  9782. export abstract class Light extends Node {
  9783. /**
  9784. * Falloff Default: light is falling off following the material specification:
  9785. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9786. */
  9787. static readonly FALLOFF_DEFAULT: number;
  9788. /**
  9789. * Falloff Physical: light is falling off following the inverse squared distance law.
  9790. */
  9791. static readonly FALLOFF_PHYSICAL: number;
  9792. /**
  9793. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9794. * to enhance interoperability with other engines.
  9795. */
  9796. static readonly FALLOFF_GLTF: number;
  9797. /**
  9798. * Falloff Standard: light is falling off like in the standard material
  9799. * to enhance interoperability with other materials.
  9800. */
  9801. static readonly FALLOFF_STANDARD: number;
  9802. /**
  9803. * If every light affecting the material is in this lightmapMode,
  9804. * material.lightmapTexture adds or multiplies
  9805. * (depends on material.useLightmapAsShadowmap)
  9806. * after every other light calculations.
  9807. */
  9808. static readonly LIGHTMAP_DEFAULT: number;
  9809. /**
  9810. * material.lightmapTexture as only diffuse lighting from this light
  9811. * adds only specular lighting from this light
  9812. * adds dynamic shadows
  9813. */
  9814. static readonly LIGHTMAP_SPECULAR: number;
  9815. /**
  9816. * material.lightmapTexture as only lighting
  9817. * no light calculation from this light
  9818. * only adds dynamic shadows from this light
  9819. */
  9820. static readonly LIGHTMAP_SHADOWSONLY: number;
  9821. /**
  9822. * Each light type uses the default quantity according to its type:
  9823. * point/spot lights use luminous intensity
  9824. * directional lights use illuminance
  9825. */
  9826. static readonly INTENSITYMODE_AUTOMATIC: number;
  9827. /**
  9828. * lumen (lm)
  9829. */
  9830. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9831. /**
  9832. * candela (lm/sr)
  9833. */
  9834. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9835. /**
  9836. * lux (lm/m^2)
  9837. */
  9838. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9839. /**
  9840. * nit (cd/m^2)
  9841. */
  9842. static readonly INTENSITYMODE_LUMINANCE: number;
  9843. /**
  9844. * Light type const id of the point light.
  9845. */
  9846. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9847. /**
  9848. * Light type const id of the directional light.
  9849. */
  9850. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9851. /**
  9852. * Light type const id of the spot light.
  9853. */
  9854. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9855. /**
  9856. * Light type const id of the hemispheric light.
  9857. */
  9858. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9859. /**
  9860. * Diffuse gives the basic color to an object.
  9861. */
  9862. diffuse: Color3;
  9863. /**
  9864. * Specular produces a highlight color on an object.
  9865. * Note: This is note affecting PBR materials.
  9866. */
  9867. specular: Color3;
  9868. /**
  9869. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9870. * falling off base on range or angle.
  9871. * This can be set to any values in Light.FALLOFF_x.
  9872. *
  9873. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9874. * other types of materials.
  9875. */
  9876. falloffType: number;
  9877. /**
  9878. * Strength of the light.
  9879. * Note: By default it is define in the framework own unit.
  9880. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9881. */
  9882. intensity: number;
  9883. private _range;
  9884. protected _inverseSquaredRange: number;
  9885. /**
  9886. * Defines how far from the source the light is impacting in scene units.
  9887. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9888. */
  9889. /**
  9890. * Defines how far from the source the light is impacting in scene units.
  9891. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9892. */
  9893. range: number;
  9894. /**
  9895. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9896. * of light.
  9897. */
  9898. private _photometricScale;
  9899. private _intensityMode;
  9900. /**
  9901. * Gets the photometric scale used to interpret the intensity.
  9902. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9903. */
  9904. /**
  9905. * Sets the photometric scale used to interpret the intensity.
  9906. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9907. */
  9908. intensityMode: number;
  9909. private _radius;
  9910. /**
  9911. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9912. */
  9913. /**
  9914. * sets the light radius used by PBR Materials to simulate soft area lights.
  9915. */
  9916. radius: number;
  9917. private _renderPriority;
  9918. /**
  9919. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9920. * exceeding the number allowed of the materials.
  9921. */
  9922. renderPriority: number;
  9923. private _shadowEnabled;
  9924. /**
  9925. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9926. * the current shadow generator.
  9927. */
  9928. /**
  9929. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9930. * the current shadow generator.
  9931. */
  9932. shadowEnabled: boolean;
  9933. private _includedOnlyMeshes;
  9934. /**
  9935. * Gets the only meshes impacted by this light.
  9936. */
  9937. /**
  9938. * Sets the only meshes impacted by this light.
  9939. */
  9940. includedOnlyMeshes: AbstractMesh[];
  9941. private _excludedMeshes;
  9942. /**
  9943. * Gets the meshes not impacted by this light.
  9944. */
  9945. /**
  9946. * Sets the meshes not impacted by this light.
  9947. */
  9948. excludedMeshes: AbstractMesh[];
  9949. private _excludeWithLayerMask;
  9950. /**
  9951. * Gets the layer id use to find what meshes are not impacted by the light.
  9952. * Inactive if 0
  9953. */
  9954. /**
  9955. * Sets the layer id use to find what meshes are not impacted by the light.
  9956. * Inactive if 0
  9957. */
  9958. excludeWithLayerMask: number;
  9959. private _includeOnlyWithLayerMask;
  9960. /**
  9961. * Gets the layer id use to find what meshes are impacted by the light.
  9962. * Inactive if 0
  9963. */
  9964. /**
  9965. * Sets the layer id use to find what meshes are impacted by the light.
  9966. * Inactive if 0
  9967. */
  9968. includeOnlyWithLayerMask: number;
  9969. private _lightmapMode;
  9970. /**
  9971. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9972. */
  9973. /**
  9974. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9975. */
  9976. lightmapMode: number;
  9977. /**
  9978. * Shadow generator associted to the light.
  9979. * @hidden Internal use only.
  9980. */
  9981. _shadowGenerator: Nullable<IShadowGenerator>;
  9982. /**
  9983. * @hidden Internal use only.
  9984. */
  9985. _excludedMeshesIds: string[];
  9986. /**
  9987. * @hidden Internal use only.
  9988. */
  9989. _includedOnlyMeshesIds: string[];
  9990. /**
  9991. * The current light unifom buffer.
  9992. * @hidden Internal use only.
  9993. */
  9994. _uniformBuffer: UniformBuffer;
  9995. /**
  9996. * Creates a Light object in the scene.
  9997. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9998. * @param name The firendly name of the light
  9999. * @param scene The scene the light belongs too
  10000. */
  10001. constructor(name: string, scene: Scene);
  10002. protected abstract _buildUniformLayout(): void;
  10003. /**
  10004. * Sets the passed Effect "effect" with the Light information.
  10005. * @param effect The effect to update
  10006. * @param lightIndex The index of the light in the effect to update
  10007. * @returns The light
  10008. */
  10009. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10010. /**
  10011. * Sets the passed Effect "effect" with the Light information.
  10012. * @param effect The effect to update
  10013. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10014. * @returns The light
  10015. */
  10016. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10017. /**
  10018. * Returns the string "Light".
  10019. * @returns the class name
  10020. */
  10021. getClassName(): string;
  10022. /** @hidden */
  10023. readonly _isLight: boolean;
  10024. /**
  10025. * Converts the light information to a readable string for debug purpose.
  10026. * @param fullDetails Supports for multiple levels of logging within scene loading
  10027. * @returns the human readable light info
  10028. */
  10029. toString(fullDetails?: boolean): string;
  10030. /** @hidden */
  10031. protected _syncParentEnabledState(): void;
  10032. /**
  10033. * Set the enabled state of this node.
  10034. * @param value - the new enabled state
  10035. */
  10036. setEnabled(value: boolean): void;
  10037. /**
  10038. * Returns the Light associated shadow generator if any.
  10039. * @return the associated shadow generator.
  10040. */
  10041. getShadowGenerator(): Nullable<IShadowGenerator>;
  10042. /**
  10043. * Returns a Vector3, the absolute light position in the World.
  10044. * @returns the world space position of the light
  10045. */
  10046. getAbsolutePosition(): Vector3;
  10047. /**
  10048. * Specifies if the light will affect the passed mesh.
  10049. * @param mesh The mesh to test against the light
  10050. * @return true the mesh is affected otherwise, false.
  10051. */
  10052. canAffectMesh(mesh: AbstractMesh): boolean;
  10053. /**
  10054. * Sort function to order lights for rendering.
  10055. * @param a First Light object to compare to second.
  10056. * @param b Second Light object to compare first.
  10057. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10058. */
  10059. static CompareLightsPriority(a: Light, b: Light): number;
  10060. /**
  10061. * Releases resources associated with this node.
  10062. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10063. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10064. */
  10065. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10066. /**
  10067. * Returns the light type ID (integer).
  10068. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10069. */
  10070. getTypeID(): number;
  10071. /**
  10072. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10073. * @returns the scaled intensity in intensity mode unit
  10074. */
  10075. getScaledIntensity(): number;
  10076. /**
  10077. * Returns a new Light object, named "name", from the current one.
  10078. * @param name The name of the cloned light
  10079. * @returns the new created light
  10080. */
  10081. clone(name: string): Nullable<Light>;
  10082. /**
  10083. * Serializes the current light into a Serialization object.
  10084. * @returns the serialized object.
  10085. */
  10086. serialize(): any;
  10087. /**
  10088. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10089. * This new light is named "name" and added to the passed scene.
  10090. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10091. * @param name The friendly name of the light
  10092. * @param scene The scene the new light will belong to
  10093. * @returns the constructor function
  10094. */
  10095. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10096. /**
  10097. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10098. * @param parsedLight The JSON representation of the light
  10099. * @param scene The scene to create the parsed light in
  10100. * @returns the created light after parsing
  10101. */
  10102. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10103. private _hookArrayForExcluded;
  10104. private _hookArrayForIncludedOnly;
  10105. private _resyncMeshes;
  10106. /**
  10107. * Forces the meshes to update their light related information in their rendering used effects
  10108. * @hidden Internal Use Only
  10109. */
  10110. _markMeshesAsLightDirty(): void;
  10111. /**
  10112. * Recomputes the cached photometric scale if needed.
  10113. */
  10114. private _computePhotometricScale;
  10115. /**
  10116. * Returns the Photometric Scale according to the light type and intensity mode.
  10117. */
  10118. private _getPhotometricScale;
  10119. /**
  10120. * Reorder the light in the scene according to their defined priority.
  10121. * @hidden Internal Use Only
  10122. */
  10123. _reorderLightsInScene(): void;
  10124. /**
  10125. * Prepares the list of defines specific to the light type.
  10126. * @param defines the list of defines
  10127. * @param lightIndex defines the index of the light for the effect
  10128. */
  10129. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10130. }
  10131. }
  10132. declare module "babylonjs/Actions/action" {
  10133. import { Observable } from "babylonjs/Misc/observable";
  10134. import { Condition } from "babylonjs/Actions/condition";
  10135. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10136. import { ActionManager } from "babylonjs/Actions/actionManager";
  10137. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10138. /**
  10139. * Interface used to define Action
  10140. */
  10141. export interface IAction {
  10142. /**
  10143. * Trigger for the action
  10144. */
  10145. trigger: number;
  10146. /** Options of the trigger */
  10147. triggerOptions: any;
  10148. /**
  10149. * Gets the trigger parameters
  10150. * @returns the trigger parameters
  10151. */
  10152. getTriggerParameter(): any;
  10153. /**
  10154. * Internal only - executes current action event
  10155. * @hidden
  10156. */
  10157. _executeCurrent(evt?: ActionEvent): void;
  10158. /**
  10159. * Serialize placeholder for child classes
  10160. * @param parent of child
  10161. * @returns the serialized object
  10162. */
  10163. serialize(parent: any): any;
  10164. /**
  10165. * Internal only
  10166. * @hidden
  10167. */
  10168. _prepare(): void;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: AbstractActionManager;
  10174. /**
  10175. * Adds action to chain of actions, may be a DoNothingAction
  10176. * @param action defines the next action to execute
  10177. * @returns The action passed in
  10178. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10179. */
  10180. then(action: IAction): IAction;
  10181. }
  10182. /**
  10183. * The action to be carried out following a trigger
  10184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10185. */
  10186. export class Action implements IAction {
  10187. /** the trigger, with or without parameters, for the action */
  10188. triggerOptions: any;
  10189. /**
  10190. * Trigger for the action
  10191. */
  10192. trigger: number;
  10193. /**
  10194. * Internal only - manager for action
  10195. * @hidden
  10196. */
  10197. _actionManager: ActionManager;
  10198. private _nextActiveAction;
  10199. private _child;
  10200. private _condition?;
  10201. private _triggerParameter;
  10202. /**
  10203. * An event triggered prior to action being executed.
  10204. */
  10205. onBeforeExecuteObservable: Observable<Action>;
  10206. /**
  10207. * Creates a new Action
  10208. * @param triggerOptions the trigger, with or without parameters, for the action
  10209. * @param condition an optional determinant of action
  10210. */
  10211. constructor(
  10212. /** the trigger, with or without parameters, for the action */
  10213. triggerOptions: any, condition?: Condition);
  10214. /**
  10215. * Internal only
  10216. * @hidden
  10217. */
  10218. _prepare(): void;
  10219. /**
  10220. * Gets the trigger parameters
  10221. * @returns the trigger parameters
  10222. */
  10223. getTriggerParameter(): any;
  10224. /**
  10225. * Internal only - executes current action event
  10226. * @hidden
  10227. */
  10228. _executeCurrent(evt?: ActionEvent): void;
  10229. /**
  10230. * Execute placeholder for child classes
  10231. * @param evt optional action event
  10232. */
  10233. execute(evt?: ActionEvent): void;
  10234. /**
  10235. * Skips to next active action
  10236. */
  10237. skipToNextActiveAction(): void;
  10238. /**
  10239. * Adds action to chain of actions, may be a DoNothingAction
  10240. * @param action defines the next action to execute
  10241. * @returns The action passed in
  10242. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10243. */
  10244. then(action: Action): Action;
  10245. /**
  10246. * Internal only
  10247. * @hidden
  10248. */
  10249. _getProperty(propertyPath: string): string;
  10250. /**
  10251. * Internal only
  10252. * @hidden
  10253. */
  10254. _getEffectiveTarget(target: any, propertyPath: string): any;
  10255. /**
  10256. * Serialize placeholder for child classes
  10257. * @param parent of child
  10258. * @returns the serialized object
  10259. */
  10260. serialize(parent: any): any;
  10261. /**
  10262. * Internal only called by serialize
  10263. * @hidden
  10264. */
  10265. protected _serialize(serializedAction: any, parent?: any): any;
  10266. /**
  10267. * Internal only
  10268. * @hidden
  10269. */
  10270. static _SerializeValueAsString: (value: any) => string;
  10271. /**
  10272. * Internal only
  10273. * @hidden
  10274. */
  10275. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10276. name: string;
  10277. targetType: string;
  10278. value: string;
  10279. };
  10280. }
  10281. }
  10282. declare module "babylonjs/Actions/condition" {
  10283. import { ActionManager } from "babylonjs/Actions/actionManager";
  10284. /**
  10285. * A Condition applied to an Action
  10286. */
  10287. export class Condition {
  10288. /**
  10289. * Internal only - manager for action
  10290. * @hidden
  10291. */
  10292. _actionManager: ActionManager;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. _evaluationId: number;
  10298. /**
  10299. * Internal only
  10300. * @hidden
  10301. */
  10302. _currentResult: boolean;
  10303. /**
  10304. * Creates a new Condition
  10305. * @param actionManager the manager of the action the condition is applied to
  10306. */
  10307. constructor(actionManager: ActionManager);
  10308. /**
  10309. * Check if the current condition is valid
  10310. * @returns a boolean
  10311. */
  10312. isValid(): boolean;
  10313. /**
  10314. * Internal only
  10315. * @hidden
  10316. */
  10317. _getProperty(propertyPath: string): string;
  10318. /**
  10319. * Internal only
  10320. * @hidden
  10321. */
  10322. _getEffectiveTarget(target: any, propertyPath: string): any;
  10323. /**
  10324. * Serialize placeholder for child classes
  10325. * @returns the serialized object
  10326. */
  10327. serialize(): any;
  10328. /**
  10329. * Internal only
  10330. * @hidden
  10331. */
  10332. protected _serialize(serializedCondition: any): any;
  10333. }
  10334. /**
  10335. * Defines specific conditional operators as extensions of Condition
  10336. */
  10337. export class ValueCondition extends Condition {
  10338. /** path to specify the property of the target the conditional operator uses */
  10339. propertyPath: string;
  10340. /** the value compared by the conditional operator against the current value of the property */
  10341. value: any;
  10342. /** the conditional operator, default ValueCondition.IsEqual */
  10343. operator: number;
  10344. /**
  10345. * Internal only
  10346. * @hidden
  10347. */
  10348. private static _IsEqual;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. private static _IsDifferent;
  10354. /**
  10355. * Internal only
  10356. * @hidden
  10357. */
  10358. private static _IsGreater;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. private static _IsLesser;
  10364. /**
  10365. * returns the number for IsEqual
  10366. */
  10367. static readonly IsEqual: number;
  10368. /**
  10369. * Returns the number for IsDifferent
  10370. */
  10371. static readonly IsDifferent: number;
  10372. /**
  10373. * Returns the number for IsGreater
  10374. */
  10375. static readonly IsGreater: number;
  10376. /**
  10377. * Returns the number for IsLesser
  10378. */
  10379. static readonly IsLesser: number;
  10380. /**
  10381. * Internal only The action manager for the condition
  10382. * @hidden
  10383. */
  10384. _actionManager: ActionManager;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private _target;
  10390. /**
  10391. * Internal only
  10392. * @hidden
  10393. */
  10394. private _effectiveTarget;
  10395. /**
  10396. * Internal only
  10397. * @hidden
  10398. */
  10399. private _property;
  10400. /**
  10401. * Creates a new ValueCondition
  10402. * @param actionManager manager for the action the condition applies to
  10403. * @param target for the action
  10404. * @param propertyPath path to specify the property of the target the conditional operator uses
  10405. * @param value the value compared by the conditional operator against the current value of the property
  10406. * @param operator the conditional operator, default ValueCondition.IsEqual
  10407. */
  10408. constructor(actionManager: ActionManager, target: any,
  10409. /** path to specify the property of the target the conditional operator uses */
  10410. propertyPath: string,
  10411. /** the value compared by the conditional operator against the current value of the property */
  10412. value: any,
  10413. /** the conditional operator, default ValueCondition.IsEqual */
  10414. operator?: number);
  10415. /**
  10416. * Compares the given value with the property value for the specified conditional operator
  10417. * @returns the result of the comparison
  10418. */
  10419. isValid(): boolean;
  10420. /**
  10421. * Serialize the ValueCondition into a JSON compatible object
  10422. * @returns serialization object
  10423. */
  10424. serialize(): any;
  10425. /**
  10426. * Gets the name of the conditional operator for the ValueCondition
  10427. * @param operator the conditional operator
  10428. * @returns the name
  10429. */
  10430. static GetOperatorName(operator: number): string;
  10431. }
  10432. /**
  10433. * Defines a predicate condition as an extension of Condition
  10434. */
  10435. export class PredicateCondition extends Condition {
  10436. /** defines the predicate function used to validate the condition */
  10437. predicate: () => boolean;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Creates a new PredicateCondition
  10445. * @param actionManager manager for the action the condition applies to
  10446. * @param predicate defines the predicate function used to validate the condition
  10447. */
  10448. constructor(actionManager: ActionManager,
  10449. /** defines the predicate function used to validate the condition */
  10450. predicate: () => boolean);
  10451. /**
  10452. * @returns the validity of the predicate condition
  10453. */
  10454. isValid(): boolean;
  10455. }
  10456. /**
  10457. * Defines a state condition as an extension of Condition
  10458. */
  10459. export class StateCondition extends Condition {
  10460. /** Value to compare with target state */
  10461. value: string;
  10462. /**
  10463. * Internal only - manager for action
  10464. * @hidden
  10465. */
  10466. _actionManager: ActionManager;
  10467. /**
  10468. * Internal only
  10469. * @hidden
  10470. */
  10471. private _target;
  10472. /**
  10473. * Creates a new StateCondition
  10474. * @param actionManager manager for the action the condition applies to
  10475. * @param target of the condition
  10476. * @param value to compare with target state
  10477. */
  10478. constructor(actionManager: ActionManager, target: any,
  10479. /** Value to compare with target state */
  10480. value: string);
  10481. /**
  10482. * Gets a boolean indicating if the current condition is met
  10483. * @returns the validity of the state
  10484. */
  10485. isValid(): boolean;
  10486. /**
  10487. * Serialize the StateCondition into a JSON compatible object
  10488. * @returns serialization object
  10489. */
  10490. serialize(): any;
  10491. }
  10492. }
  10493. declare module "babylonjs/Actions/directActions" {
  10494. import { Action } from "babylonjs/Actions/action";
  10495. import { Condition } from "babylonjs/Actions/condition";
  10496. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10497. /**
  10498. * This defines an action responsible to toggle a boolean once triggered.
  10499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10500. */
  10501. export class SwitchBooleanAction extends Action {
  10502. /**
  10503. * The path to the boolean property in the target object
  10504. */
  10505. propertyPath: string;
  10506. private _target;
  10507. private _effectiveTarget;
  10508. private _property;
  10509. /**
  10510. * Instantiate the action
  10511. * @param triggerOptions defines the trigger options
  10512. * @param target defines the object containing the boolean
  10513. * @param propertyPath defines the path to the boolean property in the target object
  10514. * @param condition defines the trigger related conditions
  10515. */
  10516. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10517. /** @hidden */
  10518. _prepare(): void;
  10519. /**
  10520. * Execute the action toggle the boolean value.
  10521. */
  10522. execute(): void;
  10523. /**
  10524. * Serializes the actions and its related information.
  10525. * @param parent defines the object to serialize in
  10526. * @returns the serialized object
  10527. */
  10528. serialize(parent: any): any;
  10529. }
  10530. /**
  10531. * This defines an action responsible to set a the state field of the target
  10532. * to a desired value once triggered.
  10533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10534. */
  10535. export class SetStateAction extends Action {
  10536. /**
  10537. * The value to store in the state field.
  10538. */
  10539. value: string;
  10540. private _target;
  10541. /**
  10542. * Instantiate the action
  10543. * @param triggerOptions defines the trigger options
  10544. * @param target defines the object containing the state property
  10545. * @param value defines the value to store in the state field
  10546. * @param condition defines the trigger related conditions
  10547. */
  10548. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10549. /**
  10550. * Execute the action and store the value on the target state property.
  10551. */
  10552. execute(): void;
  10553. /**
  10554. * Serializes the actions and its related information.
  10555. * @param parent defines the object to serialize in
  10556. * @returns the serialized object
  10557. */
  10558. serialize(parent: any): any;
  10559. }
  10560. /**
  10561. * This defines an action responsible to set a property of the target
  10562. * to a desired value once triggered.
  10563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10564. */
  10565. export class SetValueAction extends Action {
  10566. /**
  10567. * The path of the property to set in the target.
  10568. */
  10569. propertyPath: string;
  10570. /**
  10571. * The value to set in the property
  10572. */
  10573. value: any;
  10574. private _target;
  10575. private _effectiveTarget;
  10576. private _property;
  10577. /**
  10578. * Instantiate the action
  10579. * @param triggerOptions defines the trigger options
  10580. * @param target defines the object containing the property
  10581. * @param propertyPath defines the path of the property to set in the target
  10582. * @param value defines the value to set in the property
  10583. * @param condition defines the trigger related conditions
  10584. */
  10585. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10586. /** @hidden */
  10587. _prepare(): void;
  10588. /**
  10589. * Execute the action and set the targetted property to the desired value.
  10590. */
  10591. execute(): void;
  10592. /**
  10593. * Serializes the actions and its related information.
  10594. * @param parent defines the object to serialize in
  10595. * @returns the serialized object
  10596. */
  10597. serialize(parent: any): any;
  10598. }
  10599. /**
  10600. * This defines an action responsible to increment the target value
  10601. * to a desired value once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class IncrementValueAction extends Action {
  10605. /**
  10606. * The path of the property to increment in the target.
  10607. */
  10608. propertyPath: string;
  10609. /**
  10610. * The value we should increment the property by.
  10611. */
  10612. value: any;
  10613. private _target;
  10614. private _effectiveTarget;
  10615. private _property;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param target defines the object containing the property
  10620. * @param propertyPath defines the path of the property to increment in the target
  10621. * @param value defines the value value we should increment the property by
  10622. * @param condition defines the trigger related conditions
  10623. */
  10624. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10625. /** @hidden */
  10626. _prepare(): void;
  10627. /**
  10628. * Execute the action and increment the target of the value amount.
  10629. */
  10630. execute(): void;
  10631. /**
  10632. * Serializes the actions and its related information.
  10633. * @param parent defines the object to serialize in
  10634. * @returns the serialized object
  10635. */
  10636. serialize(parent: any): any;
  10637. }
  10638. /**
  10639. * This defines an action responsible to start an animation once triggered.
  10640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10641. */
  10642. export class PlayAnimationAction extends Action {
  10643. /**
  10644. * Where the animation should start (animation frame)
  10645. */
  10646. from: number;
  10647. /**
  10648. * Where the animation should stop (animation frame)
  10649. */
  10650. to: number;
  10651. /**
  10652. * Define if the animation should loop or stop after the first play.
  10653. */
  10654. loop?: boolean;
  10655. private _target;
  10656. /**
  10657. * Instantiate the action
  10658. * @param triggerOptions defines the trigger options
  10659. * @param target defines the target animation or animation name
  10660. * @param from defines from where the animation should start (animation frame)
  10661. * @param end defines where the animation should stop (animation frame)
  10662. * @param loop defines if the animation should loop or stop after the first play
  10663. * @param condition defines the trigger related conditions
  10664. */
  10665. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10666. /** @hidden */
  10667. _prepare(): void;
  10668. /**
  10669. * Execute the action and play the animation.
  10670. */
  10671. execute(): void;
  10672. /**
  10673. * Serializes the actions and its related information.
  10674. * @param parent defines the object to serialize in
  10675. * @returns the serialized object
  10676. */
  10677. serialize(parent: any): any;
  10678. }
  10679. /**
  10680. * This defines an action responsible to stop an animation once triggered.
  10681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10682. */
  10683. export class StopAnimationAction extends Action {
  10684. private _target;
  10685. /**
  10686. * Instantiate the action
  10687. * @param triggerOptions defines the trigger options
  10688. * @param target defines the target animation or animation name
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and stop the animation.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible that does nothing once triggered.
  10707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10708. */
  10709. export class DoNothingAction extends Action {
  10710. /**
  10711. * Instantiate the action
  10712. * @param triggerOptions defines the trigger options
  10713. * @param condition defines the trigger related conditions
  10714. */
  10715. constructor(triggerOptions?: any, condition?: Condition);
  10716. /**
  10717. * Execute the action and do nothing.
  10718. */
  10719. execute(): void;
  10720. /**
  10721. * Serializes the actions and its related information.
  10722. * @param parent defines the object to serialize in
  10723. * @returns the serialized object
  10724. */
  10725. serialize(parent: any): any;
  10726. }
  10727. /**
  10728. * This defines an action responsible to trigger several actions once triggered.
  10729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10730. */
  10731. export class CombineAction extends Action {
  10732. /**
  10733. * The list of aggregated animations to run.
  10734. */
  10735. children: Action[];
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param children defines the list of aggregated animations to run
  10740. * @param condition defines the trigger related conditions
  10741. */
  10742. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10743. /** @hidden */
  10744. _prepare(): void;
  10745. /**
  10746. * Execute the action and executes all the aggregated actions.
  10747. */
  10748. execute(evt: ActionEvent): void;
  10749. /**
  10750. * Serializes the actions and its related information.
  10751. * @param parent defines the object to serialize in
  10752. * @returns the serialized object
  10753. */
  10754. serialize(parent: any): any;
  10755. }
  10756. /**
  10757. * This defines an action responsible to run code (external event) once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class ExecuteCodeAction extends Action {
  10761. /**
  10762. * The callback function to run.
  10763. */
  10764. func: (evt: ActionEvent) => void;
  10765. /**
  10766. * Instantiate the action
  10767. * @param triggerOptions defines the trigger options
  10768. * @param func defines the callback function to run
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10772. /**
  10773. * Execute the action and run the attached code.
  10774. */
  10775. execute(evt: ActionEvent): void;
  10776. }
  10777. /**
  10778. * This defines an action responsible to set the parent property of the target once triggered.
  10779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10780. */
  10781. export class SetParentAction extends Action {
  10782. private _parent;
  10783. private _target;
  10784. /**
  10785. * Instantiate the action
  10786. * @param triggerOptions defines the trigger options
  10787. * @param target defines the target containing the parent property
  10788. * @param parent defines from where the animation should start (animation frame)
  10789. * @param condition defines the trigger related conditions
  10790. */
  10791. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10792. /** @hidden */
  10793. _prepare(): void;
  10794. /**
  10795. * Execute the action and set the parent property.
  10796. */
  10797. execute(): void;
  10798. /**
  10799. * Serializes the actions and its related information.
  10800. * @param parent defines the object to serialize in
  10801. * @returns the serialized object
  10802. */
  10803. serialize(parent: any): any;
  10804. }
  10805. }
  10806. declare module "babylonjs/Actions/actionManager" {
  10807. import { Nullable } from "babylonjs/types";
  10808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10809. import { Scene } from "babylonjs/scene";
  10810. import { IAction } from "babylonjs/Actions/action";
  10811. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10812. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10813. /**
  10814. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10815. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10817. */
  10818. export class ActionManager extends AbstractActionManager {
  10819. /**
  10820. * Nothing
  10821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10822. */
  10823. static readonly NothingTrigger: number;
  10824. /**
  10825. * On pick
  10826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10827. */
  10828. static readonly OnPickTrigger: number;
  10829. /**
  10830. * On left pick
  10831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10832. */
  10833. static readonly OnLeftPickTrigger: number;
  10834. /**
  10835. * On right pick
  10836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10837. */
  10838. static readonly OnRightPickTrigger: number;
  10839. /**
  10840. * On center pick
  10841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10842. */
  10843. static readonly OnCenterPickTrigger: number;
  10844. /**
  10845. * On pick down
  10846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10847. */
  10848. static readonly OnPickDownTrigger: number;
  10849. /**
  10850. * On double pick
  10851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10852. */
  10853. static readonly OnDoublePickTrigger: number;
  10854. /**
  10855. * On pick up
  10856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10857. */
  10858. static readonly OnPickUpTrigger: number;
  10859. /**
  10860. * On pick out.
  10861. * This trigger will only be raised if you also declared a OnPickDown
  10862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10863. */
  10864. static readonly OnPickOutTrigger: number;
  10865. /**
  10866. * On long press
  10867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10868. */
  10869. static readonly OnLongPressTrigger: number;
  10870. /**
  10871. * On pointer over
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10873. */
  10874. static readonly OnPointerOverTrigger: number;
  10875. /**
  10876. * On pointer out
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10878. */
  10879. static readonly OnPointerOutTrigger: number;
  10880. /**
  10881. * On every frame
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly OnEveryFrameTrigger: number;
  10885. /**
  10886. * On intersection enter
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnIntersectionEnterTrigger: number;
  10890. /**
  10891. * On intersection exit
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10893. */
  10894. static readonly OnIntersectionExitTrigger: number;
  10895. /**
  10896. * On key down
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10898. */
  10899. static readonly OnKeyDownTrigger: number;
  10900. /**
  10901. * On key up
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10903. */
  10904. static readonly OnKeyUpTrigger: number;
  10905. private _scene;
  10906. /**
  10907. * Creates a new action manager
  10908. * @param scene defines the hosting scene
  10909. */
  10910. constructor(scene: Scene);
  10911. /**
  10912. * Releases all associated resources
  10913. */
  10914. dispose(): void;
  10915. /**
  10916. * Gets hosting scene
  10917. * @returns the hosting scene
  10918. */
  10919. getScene(): Scene;
  10920. /**
  10921. * Does this action manager handles actions of any of the given triggers
  10922. * @param triggers defines the triggers to be tested
  10923. * @return a boolean indicating whether one (or more) of the triggers is handled
  10924. */
  10925. hasSpecificTriggers(triggers: number[]): boolean;
  10926. /**
  10927. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10928. * speed.
  10929. * @param triggerA defines the trigger to be tested
  10930. * @param triggerB defines the trigger to be tested
  10931. * @return a boolean indicating whether one (or more) of the triggers is handled
  10932. */
  10933. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10934. /**
  10935. * Does this action manager handles actions of a given trigger
  10936. * @param trigger defines the trigger to be tested
  10937. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10938. * @return whether the trigger is handled
  10939. */
  10940. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10941. /**
  10942. * Does this action manager has pointer triggers
  10943. */
  10944. readonly hasPointerTriggers: boolean;
  10945. /**
  10946. * Does this action manager has pick triggers
  10947. */
  10948. readonly hasPickTriggers: boolean;
  10949. /**
  10950. * Registers an action to this action manager
  10951. * @param action defines the action to be registered
  10952. * @return the action amended (prepared) after registration
  10953. */
  10954. registerAction(action: IAction): Nullable<IAction>;
  10955. /**
  10956. * Unregisters an action to this action manager
  10957. * @param action defines the action to be unregistered
  10958. * @return a boolean indicating whether the action has been unregistered
  10959. */
  10960. unregisterAction(action: IAction): Boolean;
  10961. /**
  10962. * Process a specific trigger
  10963. * @param trigger defines the trigger to process
  10964. * @param evt defines the event details to be processed
  10965. */
  10966. processTrigger(trigger: number, evt?: IActionEvent): void;
  10967. /** @hidden */
  10968. _getEffectiveTarget(target: any, propertyPath: string): any;
  10969. /** @hidden */
  10970. _getProperty(propertyPath: string): string;
  10971. /**
  10972. * Serialize this manager to a JSON object
  10973. * @param name defines the property name to store this manager
  10974. * @returns a JSON representation of this manager
  10975. */
  10976. serialize(name: string): any;
  10977. /**
  10978. * Creates a new ActionManager from a JSON data
  10979. * @param parsedActions defines the JSON data to read from
  10980. * @param object defines the hosting mesh
  10981. * @param scene defines the hosting scene
  10982. */
  10983. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10984. /**
  10985. * Get a trigger name by index
  10986. * @param trigger defines the trigger index
  10987. * @returns a trigger name
  10988. */
  10989. static GetTriggerName(trigger: number): string;
  10990. }
  10991. }
  10992. declare module "babylonjs/Culling/ray" {
  10993. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10994. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10996. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10997. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10998. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10999. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11000. import { Plane } from "babylonjs/Maths/math.plane";
  11001. /**
  11002. * Class representing a ray with position and direction
  11003. */
  11004. export class Ray {
  11005. /** origin point */
  11006. origin: Vector3;
  11007. /** direction */
  11008. direction: Vector3;
  11009. /** length of the ray */
  11010. length: number;
  11011. private static readonly TmpVector3;
  11012. private _tmpRay;
  11013. /**
  11014. * Creates a new ray
  11015. * @param origin origin point
  11016. * @param direction direction
  11017. * @param length length of the ray
  11018. */
  11019. constructor(
  11020. /** origin point */
  11021. origin: Vector3,
  11022. /** direction */
  11023. direction: Vector3,
  11024. /** length of the ray */
  11025. length?: number);
  11026. /**
  11027. * Checks if the ray intersects a box
  11028. * @param minimum bound of the box
  11029. * @param maximum bound of the box
  11030. * @param intersectionTreshold extra extend to be added to the box in all direction
  11031. * @returns if the box was hit
  11032. */
  11033. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11034. /**
  11035. * Checks if the ray intersects a box
  11036. * @param box the bounding box to check
  11037. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11038. * @returns if the box was hit
  11039. */
  11040. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11041. /**
  11042. * If the ray hits a sphere
  11043. * @param sphere the bounding sphere to check
  11044. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11045. * @returns true if it hits the sphere
  11046. */
  11047. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11048. /**
  11049. * If the ray hits a triange
  11050. * @param vertex0 triangle vertex
  11051. * @param vertex1 triangle vertex
  11052. * @param vertex2 triangle vertex
  11053. * @returns intersection information if hit
  11054. */
  11055. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11056. /**
  11057. * Checks if ray intersects a plane
  11058. * @param plane the plane to check
  11059. * @returns the distance away it was hit
  11060. */
  11061. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11062. /**
  11063. * Calculate the intercept of a ray on a given axis
  11064. * @param axis to check 'x' | 'y' | 'z'
  11065. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11066. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11067. */
  11068. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11069. /**
  11070. * Checks if ray intersects a mesh
  11071. * @param mesh the mesh to check
  11072. * @param fastCheck if only the bounding box should checked
  11073. * @returns picking info of the intersecton
  11074. */
  11075. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11076. /**
  11077. * Checks if ray intersects a mesh
  11078. * @param meshes the meshes to check
  11079. * @param fastCheck if only the bounding box should checked
  11080. * @param results array to store result in
  11081. * @returns Array of picking infos
  11082. */
  11083. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11084. private _comparePickingInfo;
  11085. private static smallnum;
  11086. private static rayl;
  11087. /**
  11088. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11089. * @param sega the first point of the segment to test the intersection against
  11090. * @param segb the second point of the segment to test the intersection against
  11091. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11092. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11093. */
  11094. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11095. /**
  11096. * Update the ray from viewport position
  11097. * @param x position
  11098. * @param y y position
  11099. * @param viewportWidth viewport width
  11100. * @param viewportHeight viewport height
  11101. * @param world world matrix
  11102. * @param view view matrix
  11103. * @param projection projection matrix
  11104. * @returns this ray updated
  11105. */
  11106. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11107. /**
  11108. * Creates a ray with origin and direction of 0,0,0
  11109. * @returns the new ray
  11110. */
  11111. static Zero(): Ray;
  11112. /**
  11113. * Creates a new ray from screen space and viewport
  11114. * @param x position
  11115. * @param y y position
  11116. * @param viewportWidth viewport width
  11117. * @param viewportHeight viewport height
  11118. * @param world world matrix
  11119. * @param view view matrix
  11120. * @param projection projection matrix
  11121. * @returns new ray
  11122. */
  11123. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11124. /**
  11125. * 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
  11126. * transformed to the given world matrix.
  11127. * @param origin The origin point
  11128. * @param end The end point
  11129. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11130. * @returns the new ray
  11131. */
  11132. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11133. /**
  11134. * Transforms a ray by a matrix
  11135. * @param ray ray to transform
  11136. * @param matrix matrix to apply
  11137. * @returns the resulting new ray
  11138. */
  11139. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11140. /**
  11141. * Transforms a ray by a matrix
  11142. * @param ray ray to transform
  11143. * @param matrix matrix to apply
  11144. * @param result ray to store result in
  11145. */
  11146. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11147. /**
  11148. * Unproject a ray from screen space to object space
  11149. * @param sourceX defines the screen space x coordinate to use
  11150. * @param sourceY defines the screen space y coordinate to use
  11151. * @param viewportWidth defines the current width of the viewport
  11152. * @param viewportHeight defines the current height of the viewport
  11153. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11154. * @param view defines the view matrix to use
  11155. * @param projection defines the projection matrix to use
  11156. */
  11157. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11158. }
  11159. /**
  11160. * Type used to define predicate used to select faces when a mesh intersection is detected
  11161. */
  11162. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11163. module "babylonjs/scene" {
  11164. interface Scene {
  11165. /** @hidden */
  11166. _tempPickingRay: Nullable<Ray>;
  11167. /** @hidden */
  11168. _cachedRayForTransform: Ray;
  11169. /** @hidden */
  11170. _pickWithRayInverseMatrix: Matrix;
  11171. /** @hidden */
  11172. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11173. /** @hidden */
  11174. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11175. }
  11176. }
  11177. }
  11178. declare module "babylonjs/sceneComponent" {
  11179. import { Scene } from "babylonjs/scene";
  11180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11181. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11182. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11183. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11184. import { Nullable } from "babylonjs/types";
  11185. import { Camera } from "babylonjs/Cameras/camera";
  11186. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11187. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11188. import { AbstractScene } from "babylonjs/abstractScene";
  11189. /**
  11190. * Groups all the scene component constants in one place to ease maintenance.
  11191. * @hidden
  11192. */
  11193. export class SceneComponentConstants {
  11194. static readonly NAME_EFFECTLAYER: string;
  11195. static readonly NAME_LAYER: string;
  11196. static readonly NAME_LENSFLARESYSTEM: string;
  11197. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11198. static readonly NAME_PARTICLESYSTEM: string;
  11199. static readonly NAME_GAMEPAD: string;
  11200. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11201. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11202. static readonly NAME_DEPTHRENDERER: string;
  11203. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11204. static readonly NAME_SPRITE: string;
  11205. static readonly NAME_OUTLINERENDERER: string;
  11206. static readonly NAME_PROCEDURALTEXTURE: string;
  11207. static readonly NAME_SHADOWGENERATOR: string;
  11208. static readonly NAME_OCTREE: string;
  11209. static readonly NAME_PHYSICSENGINE: string;
  11210. static readonly NAME_AUDIO: string;
  11211. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11212. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11213. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11214. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11215. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11216. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11217. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11218. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11219. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11220. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11221. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11222. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11223. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11224. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11225. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11226. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11227. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11228. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11229. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11230. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11231. static readonly STEP_AFTERRENDER_AUDIO: number;
  11232. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11233. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11234. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11235. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11236. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11237. static readonly STEP_POINTERMOVE_SPRITE: number;
  11238. static readonly STEP_POINTERDOWN_SPRITE: number;
  11239. static readonly STEP_POINTERUP_SPRITE: number;
  11240. }
  11241. /**
  11242. * This represents a scene component.
  11243. *
  11244. * This is used to decouple the dependency the scene is having on the different workloads like
  11245. * layers, post processes...
  11246. */
  11247. export interface ISceneComponent {
  11248. /**
  11249. * The name of the component. Each component must have a unique name.
  11250. */
  11251. name: string;
  11252. /**
  11253. * The scene the component belongs to.
  11254. */
  11255. scene: Scene;
  11256. /**
  11257. * Register the component to one instance of a scene.
  11258. */
  11259. register(): void;
  11260. /**
  11261. * Rebuilds the elements related to this component in case of
  11262. * context lost for instance.
  11263. */
  11264. rebuild(): void;
  11265. /**
  11266. * Disposes the component and the associated ressources.
  11267. */
  11268. dispose(): void;
  11269. }
  11270. /**
  11271. * This represents a SERIALIZABLE scene component.
  11272. *
  11273. * This extends Scene Component to add Serialization methods on top.
  11274. */
  11275. export interface ISceneSerializableComponent extends ISceneComponent {
  11276. /**
  11277. * Adds all the elements from the container to the scene
  11278. * @param container the container holding the elements
  11279. */
  11280. addFromContainer(container: AbstractScene): void;
  11281. /**
  11282. * Removes all the elements in the container from the scene
  11283. * @param container contains the elements to remove
  11284. * @param dispose if the removed element should be disposed (default: false)
  11285. */
  11286. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11287. /**
  11288. * Serializes the component data to the specified json object
  11289. * @param serializationObject The object to serialize to
  11290. */
  11291. serialize(serializationObject: any): void;
  11292. }
  11293. /**
  11294. * Strong typing of a Mesh related stage step action
  11295. */
  11296. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11297. /**
  11298. * Strong typing of a Evaluate Sub Mesh related stage step action
  11299. */
  11300. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11301. /**
  11302. * Strong typing of a Active Mesh related stage step action
  11303. */
  11304. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11305. /**
  11306. * Strong typing of a Camera related stage step action
  11307. */
  11308. export type CameraStageAction = (camera: Camera) => void;
  11309. /**
  11310. * Strong typing of a Camera Frame buffer related stage step action
  11311. */
  11312. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11313. /**
  11314. * Strong typing of a Render Target related stage step action
  11315. */
  11316. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11317. /**
  11318. * Strong typing of a RenderingGroup related stage step action
  11319. */
  11320. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11321. /**
  11322. * Strong typing of a Mesh Render related stage step action
  11323. */
  11324. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11325. /**
  11326. * Strong typing of a simple stage step action
  11327. */
  11328. export type SimpleStageAction = () => void;
  11329. /**
  11330. * Strong typing of a render target action.
  11331. */
  11332. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11333. /**
  11334. * Strong typing of a pointer move action.
  11335. */
  11336. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11337. /**
  11338. * Strong typing of a pointer up/down action.
  11339. */
  11340. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11341. /**
  11342. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11343. * @hidden
  11344. */
  11345. export class Stage<T extends Function> extends Array<{
  11346. index: number;
  11347. component: ISceneComponent;
  11348. action: T;
  11349. }> {
  11350. /**
  11351. * Hide ctor from the rest of the world.
  11352. * @param items The items to add.
  11353. */
  11354. private constructor();
  11355. /**
  11356. * Creates a new Stage.
  11357. * @returns A new instance of a Stage
  11358. */
  11359. static Create<T extends Function>(): Stage<T>;
  11360. /**
  11361. * Registers a step in an ordered way in the targeted stage.
  11362. * @param index Defines the position to register the step in
  11363. * @param component Defines the component attached to the step
  11364. * @param action Defines the action to launch during the step
  11365. */
  11366. registerStep(index: number, component: ISceneComponent, action: T): void;
  11367. /**
  11368. * Clears all the steps from the stage.
  11369. */
  11370. clear(): void;
  11371. }
  11372. }
  11373. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11374. import { Nullable } from "babylonjs/types";
  11375. import { Observable } from "babylonjs/Misc/observable";
  11376. import { Scene } from "babylonjs/scene";
  11377. import { Sprite } from "babylonjs/Sprites/sprite";
  11378. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11379. import { Ray } from "babylonjs/Culling/ray";
  11380. import { Camera } from "babylonjs/Cameras/camera";
  11381. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11382. import { ISceneComponent } from "babylonjs/sceneComponent";
  11383. module "babylonjs/scene" {
  11384. interface Scene {
  11385. /** @hidden */
  11386. _pointerOverSprite: Nullable<Sprite>;
  11387. /** @hidden */
  11388. _pickedDownSprite: Nullable<Sprite>;
  11389. /** @hidden */
  11390. _tempSpritePickingRay: Nullable<Ray>;
  11391. /**
  11392. * All of the sprite managers added to this scene
  11393. * @see http://doc.babylonjs.com/babylon101/sprites
  11394. */
  11395. spriteManagers: Array<ISpriteManager>;
  11396. /**
  11397. * An event triggered when sprites rendering is about to start
  11398. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11399. */
  11400. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11401. /**
  11402. * An event triggered when sprites rendering is done
  11403. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11404. */
  11405. onAfterSpritesRenderingObservable: Observable<Scene>;
  11406. /** @hidden */
  11407. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11408. /** Launch a ray to try to pick a sprite in the scene
  11409. * @param x position on screen
  11410. * @param y position on screen
  11411. * @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
  11412. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11413. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11414. * @returns a PickingInfo
  11415. */
  11416. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11417. /** Use the given ray to pick a sprite in the scene
  11418. * @param ray The ray (in world space) to use to pick meshes
  11419. * @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
  11420. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11421. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11422. * @returns a PickingInfo
  11423. */
  11424. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11425. /** @hidden */
  11426. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11427. /** Launch a ray to try to pick sprites in the scene
  11428. * @param x position on screen
  11429. * @param y position on screen
  11430. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11431. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11432. * @returns a PickingInfo array
  11433. */
  11434. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11435. /** Use the given ray to pick sprites in the scene
  11436. * @param ray The ray (in world space) to use to pick meshes
  11437. * @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
  11438. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11439. * @returns a PickingInfo array
  11440. */
  11441. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11442. /**
  11443. * Force the sprite under the pointer
  11444. * @param sprite defines the sprite to use
  11445. */
  11446. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11447. /**
  11448. * Gets the sprite under the pointer
  11449. * @returns a Sprite or null if no sprite is under the pointer
  11450. */
  11451. getPointerOverSprite(): Nullable<Sprite>;
  11452. }
  11453. }
  11454. /**
  11455. * Defines the sprite scene component responsible to manage sprites
  11456. * in a given scene.
  11457. */
  11458. export class SpriteSceneComponent implements ISceneComponent {
  11459. /**
  11460. * The component name helpfull to identify the component in the list of scene components.
  11461. */
  11462. readonly name: string;
  11463. /**
  11464. * The scene the component belongs to.
  11465. */
  11466. scene: Scene;
  11467. /** @hidden */
  11468. private _spritePredicate;
  11469. /**
  11470. * Creates a new instance of the component for the given scene
  11471. * @param scene Defines the scene to register the component in
  11472. */
  11473. constructor(scene: Scene);
  11474. /**
  11475. * Registers the component in a given scene
  11476. */
  11477. register(): void;
  11478. /**
  11479. * Rebuilds the elements related to this component in case of
  11480. * context lost for instance.
  11481. */
  11482. rebuild(): void;
  11483. /**
  11484. * Disposes the component and the associated ressources.
  11485. */
  11486. dispose(): void;
  11487. private _pickSpriteButKeepRay;
  11488. private _pointerMove;
  11489. private _pointerDown;
  11490. private _pointerUp;
  11491. }
  11492. }
  11493. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11494. /** @hidden */
  11495. export var fogFragmentDeclaration: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11501. /** @hidden */
  11502. export var fogFragment: {
  11503. name: string;
  11504. shader: string;
  11505. };
  11506. }
  11507. declare module "babylonjs/Shaders/sprites.fragment" {
  11508. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11509. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11510. /** @hidden */
  11511. export var spritesPixelShader: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11517. /** @hidden */
  11518. export var fogVertexDeclaration: {
  11519. name: string;
  11520. shader: string;
  11521. };
  11522. }
  11523. declare module "babylonjs/Shaders/sprites.vertex" {
  11524. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11525. /** @hidden */
  11526. export var spritesVertexShader: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module "babylonjs/Sprites/spriteManager" {
  11532. import { IDisposable, Scene } from "babylonjs/scene";
  11533. import { Nullable } from "babylonjs/types";
  11534. import { Observable } from "babylonjs/Misc/observable";
  11535. import { Sprite } from "babylonjs/Sprites/sprite";
  11536. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11537. import { Camera } from "babylonjs/Cameras/camera";
  11538. import { Texture } from "babylonjs/Materials/Textures/texture";
  11539. import "babylonjs/Shaders/sprites.fragment";
  11540. import "babylonjs/Shaders/sprites.vertex";
  11541. import { Ray } from "babylonjs/Culling/ray";
  11542. /**
  11543. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11544. */
  11545. export interface ISpriteManager extends IDisposable {
  11546. /**
  11547. * Restricts the camera to viewing objects with the same layerMask.
  11548. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11549. */
  11550. layerMask: number;
  11551. /**
  11552. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11553. */
  11554. isPickable: boolean;
  11555. /**
  11556. * Specifies the rendering group id for this mesh (0 by default)
  11557. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11558. */
  11559. renderingGroupId: number;
  11560. /**
  11561. * Defines the list of sprites managed by the manager.
  11562. */
  11563. sprites: Array<Sprite>;
  11564. /**
  11565. * Tests the intersection of a sprite with a specific ray.
  11566. * @param ray The ray we are sending to test the collision
  11567. * @param camera The camera space we are sending rays in
  11568. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11569. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11570. * @returns picking info or null.
  11571. */
  11572. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11573. /**
  11574. * Intersects the sprites with a ray
  11575. * @param ray defines the ray to intersect with
  11576. * @param camera defines the current active camera
  11577. * @param predicate defines a predicate used to select candidate sprites
  11578. * @returns null if no hit or a PickingInfo array
  11579. */
  11580. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11581. /**
  11582. * Renders the list of sprites on screen.
  11583. */
  11584. render(): void;
  11585. }
  11586. /**
  11587. * Class used to manage multiple sprites on the same spritesheet
  11588. * @see http://doc.babylonjs.com/babylon101/sprites
  11589. */
  11590. export class SpriteManager implements ISpriteManager {
  11591. /** defines the manager's name */
  11592. name: string;
  11593. /** Gets the list of sprites */
  11594. sprites: Sprite[];
  11595. /** Gets or sets the rendering group id (0 by default) */
  11596. renderingGroupId: number;
  11597. /** Gets or sets camera layer mask */
  11598. layerMask: number;
  11599. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11600. fogEnabled: boolean;
  11601. /** Gets or sets a boolean indicating if the sprites are pickable */
  11602. isPickable: boolean;
  11603. /** Defines the default width of a cell in the spritesheet */
  11604. cellWidth: number;
  11605. /** Defines the default height of a cell in the spritesheet */
  11606. cellHeight: number;
  11607. /** Associative array from JSON sprite data file */
  11608. private _cellData;
  11609. /** Array of sprite names from JSON sprite data file */
  11610. private _spriteMap;
  11611. /** True when packed cell data from JSON file is ready*/
  11612. private _packedAndReady;
  11613. /**
  11614. * An event triggered when the manager is disposed.
  11615. */
  11616. onDisposeObservable: Observable<SpriteManager>;
  11617. private _onDisposeObserver;
  11618. /**
  11619. * Callback called when the manager is disposed
  11620. */
  11621. onDispose: () => void;
  11622. private _capacity;
  11623. private _fromPacked;
  11624. private _spriteTexture;
  11625. private _epsilon;
  11626. private _scene;
  11627. private _vertexData;
  11628. private _buffer;
  11629. private _vertexBuffers;
  11630. private _indexBuffer;
  11631. private _effectBase;
  11632. private _effectFog;
  11633. /**
  11634. * Gets or sets the spritesheet texture
  11635. */
  11636. texture: Texture;
  11637. /**
  11638. * Creates a new sprite manager
  11639. * @param name defines the manager's name
  11640. * @param imgUrl defines the sprite sheet url
  11641. * @param capacity defines the maximum allowed number of sprites
  11642. * @param cellSize defines the size of a sprite cell
  11643. * @param scene defines the hosting scene
  11644. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11645. * @param samplingMode defines the smapling mode to use with spritesheet
  11646. * @param fromPacked set to false; do not alter
  11647. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11648. */
  11649. constructor(
  11650. /** defines the manager's name */
  11651. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11652. private _makePacked;
  11653. private _appendSpriteVertex;
  11654. /**
  11655. * Intersects the sprites with a ray
  11656. * @param ray defines the ray to intersect with
  11657. * @param camera defines the current active camera
  11658. * @param predicate defines a predicate used to select candidate sprites
  11659. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11660. * @returns null if no hit or a PickingInfo
  11661. */
  11662. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11663. /**
  11664. * Intersects the sprites with a ray
  11665. * @param ray defines the ray to intersect with
  11666. * @param camera defines the current active camera
  11667. * @param predicate defines a predicate used to select candidate sprites
  11668. * @returns null if no hit or a PickingInfo array
  11669. */
  11670. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11671. /**
  11672. * Render all child sprites
  11673. */
  11674. render(): void;
  11675. /**
  11676. * Release associated resources
  11677. */
  11678. dispose(): void;
  11679. }
  11680. }
  11681. declare module "babylonjs/Sprites/sprite" {
  11682. import { Vector3 } from "babylonjs/Maths/math.vector";
  11683. import { Nullable } from "babylonjs/types";
  11684. import { ActionManager } from "babylonjs/Actions/actionManager";
  11685. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11686. import { Color4 } from "babylonjs/Maths/math.color";
  11687. /**
  11688. * Class used to represent a sprite
  11689. * @see http://doc.babylonjs.com/babylon101/sprites
  11690. */
  11691. export class Sprite {
  11692. /** defines the name */
  11693. name: string;
  11694. /** Gets or sets the current world position */
  11695. position: Vector3;
  11696. /** Gets or sets the main color */
  11697. color: Color4;
  11698. /** Gets or sets the width */
  11699. width: number;
  11700. /** Gets or sets the height */
  11701. height: number;
  11702. /** Gets or sets rotation angle */
  11703. angle: number;
  11704. /** Gets or sets the cell index in the sprite sheet */
  11705. cellIndex: number;
  11706. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11707. cellRef: string;
  11708. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11709. invertU: number;
  11710. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11711. invertV: number;
  11712. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11713. disposeWhenFinishedAnimating: boolean;
  11714. /** Gets the list of attached animations */
  11715. animations: Animation[];
  11716. /** Gets or sets a boolean indicating if the sprite can be picked */
  11717. isPickable: boolean;
  11718. /**
  11719. * Gets or sets the associated action manager
  11720. */
  11721. actionManager: Nullable<ActionManager>;
  11722. private _animationStarted;
  11723. private _loopAnimation;
  11724. private _fromIndex;
  11725. private _toIndex;
  11726. private _delay;
  11727. private _direction;
  11728. private _manager;
  11729. private _time;
  11730. private _onAnimationEnd;
  11731. /**
  11732. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11733. */
  11734. isVisible: boolean;
  11735. /**
  11736. * Gets or sets the sprite size
  11737. */
  11738. size: number;
  11739. /**
  11740. * Creates a new Sprite
  11741. * @param name defines the name
  11742. * @param manager defines the manager
  11743. */
  11744. constructor(
  11745. /** defines the name */
  11746. name: string, manager: ISpriteManager);
  11747. /**
  11748. * Starts an animation
  11749. * @param from defines the initial key
  11750. * @param to defines the end key
  11751. * @param loop defines if the animation must loop
  11752. * @param delay defines the start delay (in ms)
  11753. * @param onAnimationEnd defines a callback to call when animation ends
  11754. */
  11755. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11756. /** Stops current animation (if any) */
  11757. stopAnimation(): void;
  11758. /** @hidden */
  11759. _animate(deltaTime: number): void;
  11760. /** Release associated resources */
  11761. dispose(): void;
  11762. }
  11763. }
  11764. declare module "babylonjs/Collisions/pickingInfo" {
  11765. import { Nullable } from "babylonjs/types";
  11766. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11768. import { Sprite } from "babylonjs/Sprites/sprite";
  11769. import { Ray } from "babylonjs/Culling/ray";
  11770. /**
  11771. * Information about the result of picking within a scene
  11772. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11773. */
  11774. export class PickingInfo {
  11775. /** @hidden */
  11776. _pickingUnavailable: boolean;
  11777. /**
  11778. * If the pick collided with an object
  11779. */
  11780. hit: boolean;
  11781. /**
  11782. * Distance away where the pick collided
  11783. */
  11784. distance: number;
  11785. /**
  11786. * The location of pick collision
  11787. */
  11788. pickedPoint: Nullable<Vector3>;
  11789. /**
  11790. * The mesh corresponding the the pick collision
  11791. */
  11792. pickedMesh: Nullable<AbstractMesh>;
  11793. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11794. bu: number;
  11795. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11796. bv: number;
  11797. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11798. faceId: number;
  11799. /** Id of the the submesh that was picked */
  11800. subMeshId: number;
  11801. /** If a sprite was picked, this will be the sprite the pick collided with */
  11802. pickedSprite: Nullable<Sprite>;
  11803. /**
  11804. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11805. */
  11806. originMesh: Nullable<AbstractMesh>;
  11807. /**
  11808. * The ray that was used to perform the picking.
  11809. */
  11810. ray: Nullable<Ray>;
  11811. /**
  11812. * Gets the normal correspodning to the face the pick collided with
  11813. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11814. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11815. * @returns The normal correspodning to the face the pick collided with
  11816. */
  11817. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11818. /**
  11819. * Gets the texture coordinates of where the pick occured
  11820. * @returns the vector containing the coordnates of the texture
  11821. */
  11822. getTextureCoordinates(): Nullable<Vector2>;
  11823. }
  11824. }
  11825. declare module "babylonjs/Events/pointerEvents" {
  11826. import { Nullable } from "babylonjs/types";
  11827. import { Vector2 } from "babylonjs/Maths/math.vector";
  11828. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11829. import { Ray } from "babylonjs/Culling/ray";
  11830. /**
  11831. * Gather the list of pointer event types as constants.
  11832. */
  11833. export class PointerEventTypes {
  11834. /**
  11835. * 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.
  11836. */
  11837. static readonly POINTERDOWN: number;
  11838. /**
  11839. * The pointerup event is fired when a pointer is no longer active.
  11840. */
  11841. static readonly POINTERUP: number;
  11842. /**
  11843. * The pointermove event is fired when a pointer changes coordinates.
  11844. */
  11845. static readonly POINTERMOVE: number;
  11846. /**
  11847. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11848. */
  11849. static readonly POINTERWHEEL: number;
  11850. /**
  11851. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11852. */
  11853. static readonly POINTERPICK: number;
  11854. /**
  11855. * The pointertap event is fired when a the object has been touched and released without drag.
  11856. */
  11857. static readonly POINTERTAP: number;
  11858. /**
  11859. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11860. */
  11861. static readonly POINTERDOUBLETAP: number;
  11862. }
  11863. /**
  11864. * Base class of pointer info types.
  11865. */
  11866. export class PointerInfoBase {
  11867. /**
  11868. * Defines the type of event (PointerEventTypes)
  11869. */
  11870. type: number;
  11871. /**
  11872. * Defines the related dom event
  11873. */
  11874. event: PointerEvent | MouseWheelEvent;
  11875. /**
  11876. * Instantiates the base class of pointers info.
  11877. * @param type Defines the type of event (PointerEventTypes)
  11878. * @param event Defines the related dom event
  11879. */
  11880. constructor(
  11881. /**
  11882. * Defines the type of event (PointerEventTypes)
  11883. */
  11884. type: number,
  11885. /**
  11886. * Defines the related dom event
  11887. */
  11888. event: PointerEvent | MouseWheelEvent);
  11889. }
  11890. /**
  11891. * This class is used to store pointer related info for the onPrePointerObservable event.
  11892. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11893. */
  11894. export class PointerInfoPre extends PointerInfoBase {
  11895. /**
  11896. * Ray from a pointer if availible (eg. 6dof controller)
  11897. */
  11898. ray: Nullable<Ray>;
  11899. /**
  11900. * Defines the local position of the pointer on the canvas.
  11901. */
  11902. localPosition: Vector2;
  11903. /**
  11904. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11905. */
  11906. skipOnPointerObservable: boolean;
  11907. /**
  11908. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11909. * @param type Defines the type of event (PointerEventTypes)
  11910. * @param event Defines the related dom event
  11911. * @param localX Defines the local x coordinates of the pointer when the event occured
  11912. * @param localY Defines the local y coordinates of the pointer when the event occured
  11913. */
  11914. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11915. }
  11916. /**
  11917. * This type contains all the data related to a pointer event in Babylon.js.
  11918. * 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.
  11919. */
  11920. export class PointerInfo extends PointerInfoBase {
  11921. /**
  11922. * Defines the picking info associated to the info (if any)\
  11923. */
  11924. pickInfo: Nullable<PickingInfo>;
  11925. /**
  11926. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11927. * @param type Defines the type of event (PointerEventTypes)
  11928. * @param event Defines the related dom event
  11929. * @param pickInfo Defines the picking info associated to the info (if any)\
  11930. */
  11931. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11932. /**
  11933. * Defines the picking info associated to the info (if any)\
  11934. */
  11935. pickInfo: Nullable<PickingInfo>);
  11936. }
  11937. /**
  11938. * Data relating to a touch event on the screen.
  11939. */
  11940. export interface PointerTouch {
  11941. /**
  11942. * X coordinate of touch.
  11943. */
  11944. x: number;
  11945. /**
  11946. * Y coordinate of touch.
  11947. */
  11948. y: number;
  11949. /**
  11950. * Id of touch. Unique for each finger.
  11951. */
  11952. pointerId: number;
  11953. /**
  11954. * Event type passed from DOM.
  11955. */
  11956. type: any;
  11957. }
  11958. }
  11959. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11960. import { Observable } from "babylonjs/Misc/observable";
  11961. import { Nullable } from "babylonjs/types";
  11962. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11963. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11964. /**
  11965. * Manage the mouse inputs to control the movement of a free camera.
  11966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11967. */
  11968. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11969. /**
  11970. * Define if touch is enabled in the mouse input
  11971. */
  11972. touchEnabled: boolean;
  11973. /**
  11974. * Defines the camera the input is attached to.
  11975. */
  11976. camera: FreeCamera;
  11977. /**
  11978. * Defines the buttons associated with the input to handle camera move.
  11979. */
  11980. buttons: number[];
  11981. /**
  11982. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11983. */
  11984. angularSensibility: number;
  11985. private _pointerInput;
  11986. private _onMouseMove;
  11987. private _observer;
  11988. private previousPosition;
  11989. /**
  11990. * Observable for when a pointer move event occurs containing the move offset
  11991. */
  11992. onPointerMovedObservable: Observable<{
  11993. offsetX: number;
  11994. offsetY: number;
  11995. }>;
  11996. /**
  11997. * @hidden
  11998. * If the camera should be rotated automatically based on pointer movement
  11999. */
  12000. _allowCameraRotation: boolean;
  12001. /**
  12002. * Manage the mouse inputs to control the movement of a free camera.
  12003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12004. * @param touchEnabled Defines if touch is enabled or not
  12005. */
  12006. constructor(
  12007. /**
  12008. * Define if touch is enabled in the mouse input
  12009. */
  12010. touchEnabled?: boolean);
  12011. /**
  12012. * Attach the input controls to a specific dom element to get the input from.
  12013. * @param element Defines the element the controls should be listened from
  12014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12015. */
  12016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12017. /**
  12018. * Called on JS contextmenu event.
  12019. * Override this method to provide functionality.
  12020. */
  12021. protected onContextMenu(evt: PointerEvent): void;
  12022. /**
  12023. * Detach the current controls from the specified dom element.
  12024. * @param element Defines the element to stop listening the inputs from
  12025. */
  12026. detachControl(element: Nullable<HTMLElement>): void;
  12027. /**
  12028. * Gets the class name of the current intput.
  12029. * @returns the class name
  12030. */
  12031. getClassName(): string;
  12032. /**
  12033. * Get the friendly name associated with the input class.
  12034. * @returns the input friendly name
  12035. */
  12036. getSimpleName(): string;
  12037. }
  12038. }
  12039. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12040. import { Nullable } from "babylonjs/types";
  12041. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12042. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12043. /**
  12044. * Manage the touch inputs to control the movement of a free camera.
  12045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12046. */
  12047. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12048. /**
  12049. * Defines the camera the input is attached to.
  12050. */
  12051. camera: FreeCamera;
  12052. /**
  12053. * Defines the touch sensibility for rotation.
  12054. * The higher the faster.
  12055. */
  12056. touchAngularSensibility: number;
  12057. /**
  12058. * Defines the touch sensibility for move.
  12059. * The higher the faster.
  12060. */
  12061. touchMoveSensibility: number;
  12062. private _offsetX;
  12063. private _offsetY;
  12064. private _pointerPressed;
  12065. private _pointerInput;
  12066. private _observer;
  12067. private _onLostFocus;
  12068. /**
  12069. * Attach the input controls to a specific dom element to get the input from.
  12070. * @param element Defines the element the controls should be listened from
  12071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12072. */
  12073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12074. /**
  12075. * Detach the current controls from the specified dom element.
  12076. * @param element Defines the element to stop listening the inputs from
  12077. */
  12078. detachControl(element: Nullable<HTMLElement>): void;
  12079. /**
  12080. * Update the current camera state depending on the inputs that have been used this frame.
  12081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12082. */
  12083. checkInputs(): void;
  12084. /**
  12085. * Gets the class name of the current intput.
  12086. * @returns the class name
  12087. */
  12088. getClassName(): string;
  12089. /**
  12090. * Get the friendly name associated with the input class.
  12091. * @returns the input friendly name
  12092. */
  12093. getSimpleName(): string;
  12094. }
  12095. }
  12096. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12097. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12098. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12099. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12100. import { Nullable } from "babylonjs/types";
  12101. /**
  12102. * Default Inputs manager for the FreeCamera.
  12103. * It groups all the default supported inputs for ease of use.
  12104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12105. */
  12106. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12107. /**
  12108. * @hidden
  12109. */
  12110. _mouseInput: Nullable<FreeCameraMouseInput>;
  12111. /**
  12112. * Instantiates a new FreeCameraInputsManager.
  12113. * @param camera Defines the camera the inputs belong to
  12114. */
  12115. constructor(camera: FreeCamera);
  12116. /**
  12117. * Add keyboard input support to the input manager.
  12118. * @returns the current input manager
  12119. */
  12120. addKeyboard(): FreeCameraInputsManager;
  12121. /**
  12122. * Add mouse input support to the input manager.
  12123. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12124. * @returns the current input manager
  12125. */
  12126. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12127. /**
  12128. * Removes the mouse input support from the manager
  12129. * @returns the current input manager
  12130. */
  12131. removeMouse(): FreeCameraInputsManager;
  12132. /**
  12133. * Add touch input support to the input manager.
  12134. * @returns the current input manager
  12135. */
  12136. addTouch(): FreeCameraInputsManager;
  12137. /**
  12138. * Remove all attached input methods from a camera
  12139. */
  12140. clear(): void;
  12141. }
  12142. }
  12143. declare module "babylonjs/Cameras/freeCamera" {
  12144. import { Vector3 } from "babylonjs/Maths/math.vector";
  12145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12146. import { Scene } from "babylonjs/scene";
  12147. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12148. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12149. /**
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. */
  12154. export class FreeCamera extends TargetCamera {
  12155. /**
  12156. * Define the collision ellipsoid of the camera.
  12157. * This is helpful to simulate a camera body like the player body around the camera
  12158. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12159. */
  12160. ellipsoid: Vector3;
  12161. /**
  12162. * Define an offset for the position of the ellipsoid around the camera.
  12163. * This can be helpful to determine the center of the body near the gravity center of the body
  12164. * instead of its head.
  12165. */
  12166. ellipsoidOffset: Vector3;
  12167. /**
  12168. * Enable or disable collisions of the camera with the rest of the scene objects.
  12169. */
  12170. checkCollisions: boolean;
  12171. /**
  12172. * Enable or disable gravity on the camera.
  12173. */
  12174. applyGravity: boolean;
  12175. /**
  12176. * Define the input manager associated to the camera.
  12177. */
  12178. inputs: FreeCameraInputsManager;
  12179. /**
  12180. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12181. * Higher values reduce sensitivity.
  12182. */
  12183. /**
  12184. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12185. * Higher values reduce sensitivity.
  12186. */
  12187. angularSensibility: number;
  12188. /**
  12189. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12190. */
  12191. keysUp: number[];
  12192. /**
  12193. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12194. */
  12195. keysDown: number[];
  12196. /**
  12197. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12198. */
  12199. keysLeft: number[];
  12200. /**
  12201. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12202. */
  12203. keysRight: number[];
  12204. /**
  12205. * Event raised when the camera collide with a mesh in the scene.
  12206. */
  12207. onCollide: (collidedMesh: AbstractMesh) => void;
  12208. private _collider;
  12209. private _needMoveForGravity;
  12210. private _oldPosition;
  12211. private _diffPosition;
  12212. private _newPosition;
  12213. /** @hidden */
  12214. _localDirection: Vector3;
  12215. /** @hidden */
  12216. _transformedDirection: Vector3;
  12217. /**
  12218. * Instantiates a Free Camera.
  12219. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12220. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12221. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12222. * @param name Define the name of the camera in the scene
  12223. * @param position Define the start position of the camera in the scene
  12224. * @param scene Define the scene the camera belongs to
  12225. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12226. */
  12227. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12228. /**
  12229. * Attached controls to the current camera.
  12230. * @param element Defines the element the controls should be listened from
  12231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12232. */
  12233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12234. /**
  12235. * Detach the current controls from the camera.
  12236. * The camera will stop reacting to inputs.
  12237. * @param element Defines the element to stop listening the inputs from
  12238. */
  12239. detachControl(element: HTMLElement): void;
  12240. private _collisionMask;
  12241. /**
  12242. * Define a collision mask to limit the list of object the camera can collide with
  12243. */
  12244. collisionMask: number;
  12245. /** @hidden */
  12246. _collideWithWorld(displacement: Vector3): void;
  12247. private _onCollisionPositionChange;
  12248. /** @hidden */
  12249. _checkInputs(): void;
  12250. /** @hidden */
  12251. _decideIfNeedsToMove(): boolean;
  12252. /** @hidden */
  12253. _updatePosition(): void;
  12254. /**
  12255. * Destroy the camera and release the current resources hold by it.
  12256. */
  12257. dispose(): void;
  12258. /**
  12259. * Gets the current object class name.
  12260. * @return the class name
  12261. */
  12262. getClassName(): string;
  12263. }
  12264. }
  12265. declare module "babylonjs/Gamepads/gamepad" {
  12266. import { Observable } from "babylonjs/Misc/observable";
  12267. /**
  12268. * Represents a gamepad control stick position
  12269. */
  12270. export class StickValues {
  12271. /**
  12272. * The x component of the control stick
  12273. */
  12274. x: number;
  12275. /**
  12276. * The y component of the control stick
  12277. */
  12278. y: number;
  12279. /**
  12280. * Initializes the gamepad x and y control stick values
  12281. * @param x The x component of the gamepad control stick value
  12282. * @param y The y component of the gamepad control stick value
  12283. */
  12284. constructor(
  12285. /**
  12286. * The x component of the control stick
  12287. */
  12288. x: number,
  12289. /**
  12290. * The y component of the control stick
  12291. */
  12292. y: number);
  12293. }
  12294. /**
  12295. * An interface which manages callbacks for gamepad button changes
  12296. */
  12297. export interface GamepadButtonChanges {
  12298. /**
  12299. * Called when a gamepad has been changed
  12300. */
  12301. changed: boolean;
  12302. /**
  12303. * Called when a gamepad press event has been triggered
  12304. */
  12305. pressChanged: boolean;
  12306. /**
  12307. * Called when a touch event has been triggered
  12308. */
  12309. touchChanged: boolean;
  12310. /**
  12311. * Called when a value has changed
  12312. */
  12313. valueChanged: boolean;
  12314. }
  12315. /**
  12316. * Represents a gamepad
  12317. */
  12318. export class Gamepad {
  12319. /**
  12320. * The id of the gamepad
  12321. */
  12322. id: string;
  12323. /**
  12324. * The index of the gamepad
  12325. */
  12326. index: number;
  12327. /**
  12328. * The browser gamepad
  12329. */
  12330. browserGamepad: any;
  12331. /**
  12332. * Specifies what type of gamepad this represents
  12333. */
  12334. type: number;
  12335. private _leftStick;
  12336. private _rightStick;
  12337. /** @hidden */
  12338. _isConnected: boolean;
  12339. private _leftStickAxisX;
  12340. private _leftStickAxisY;
  12341. private _rightStickAxisX;
  12342. private _rightStickAxisY;
  12343. /**
  12344. * Triggered when the left control stick has been changed
  12345. */
  12346. private _onleftstickchanged;
  12347. /**
  12348. * Triggered when the right control stick has been changed
  12349. */
  12350. private _onrightstickchanged;
  12351. /**
  12352. * Represents a gamepad controller
  12353. */
  12354. static GAMEPAD: number;
  12355. /**
  12356. * Represents a generic controller
  12357. */
  12358. static GENERIC: number;
  12359. /**
  12360. * Represents an XBox controller
  12361. */
  12362. static XBOX: number;
  12363. /**
  12364. * Represents a pose-enabled controller
  12365. */
  12366. static POSE_ENABLED: number;
  12367. /**
  12368. * Represents an Dual Shock controller
  12369. */
  12370. static DUALSHOCK: number;
  12371. /**
  12372. * Specifies whether the left control stick should be Y-inverted
  12373. */
  12374. protected _invertLeftStickY: boolean;
  12375. /**
  12376. * Specifies if the gamepad has been connected
  12377. */
  12378. readonly isConnected: boolean;
  12379. /**
  12380. * Initializes the gamepad
  12381. * @param id The id of the gamepad
  12382. * @param index The index of the gamepad
  12383. * @param browserGamepad The browser gamepad
  12384. * @param leftStickX The x component of the left joystick
  12385. * @param leftStickY The y component of the left joystick
  12386. * @param rightStickX The x component of the right joystick
  12387. * @param rightStickY The y component of the right joystick
  12388. */
  12389. constructor(
  12390. /**
  12391. * The id of the gamepad
  12392. */
  12393. id: string,
  12394. /**
  12395. * The index of the gamepad
  12396. */
  12397. index: number,
  12398. /**
  12399. * The browser gamepad
  12400. */
  12401. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12402. /**
  12403. * Callback triggered when the left joystick has changed
  12404. * @param callback
  12405. */
  12406. onleftstickchanged(callback: (values: StickValues) => void): void;
  12407. /**
  12408. * Callback triggered when the right joystick has changed
  12409. * @param callback
  12410. */
  12411. onrightstickchanged(callback: (values: StickValues) => void): void;
  12412. /**
  12413. * Gets the left joystick
  12414. */
  12415. /**
  12416. * Sets the left joystick values
  12417. */
  12418. leftStick: StickValues;
  12419. /**
  12420. * Gets the right joystick
  12421. */
  12422. /**
  12423. * Sets the right joystick value
  12424. */
  12425. rightStick: StickValues;
  12426. /**
  12427. * Updates the gamepad joystick positions
  12428. */
  12429. update(): void;
  12430. /**
  12431. * Disposes the gamepad
  12432. */
  12433. dispose(): void;
  12434. }
  12435. /**
  12436. * Represents a generic gamepad
  12437. */
  12438. export class GenericPad extends Gamepad {
  12439. private _buttons;
  12440. private _onbuttondown;
  12441. private _onbuttonup;
  12442. /**
  12443. * Observable triggered when a button has been pressed
  12444. */
  12445. onButtonDownObservable: Observable<number>;
  12446. /**
  12447. * Observable triggered when a button has been released
  12448. */
  12449. onButtonUpObservable: Observable<number>;
  12450. /**
  12451. * Callback triggered when a button has been pressed
  12452. * @param callback Called when a button has been pressed
  12453. */
  12454. onbuttondown(callback: (buttonPressed: number) => void): void;
  12455. /**
  12456. * Callback triggered when a button has been released
  12457. * @param callback Called when a button has been released
  12458. */
  12459. onbuttonup(callback: (buttonReleased: number) => void): void;
  12460. /**
  12461. * Initializes the generic gamepad
  12462. * @param id The id of the generic gamepad
  12463. * @param index The index of the generic gamepad
  12464. * @param browserGamepad The browser gamepad
  12465. */
  12466. constructor(id: string, index: number, browserGamepad: any);
  12467. private _setButtonValue;
  12468. /**
  12469. * Updates the generic gamepad
  12470. */
  12471. update(): void;
  12472. /**
  12473. * Disposes the generic gamepad
  12474. */
  12475. dispose(): void;
  12476. }
  12477. }
  12478. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12479. import { Nullable } from "babylonjs/types";
  12480. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12481. import { Scene } from "babylonjs/scene";
  12482. module "babylonjs/Engines/engine" {
  12483. interface Engine {
  12484. /**
  12485. * Creates a raw texture
  12486. * @param data defines the data to store in the texture
  12487. * @param width defines the width of the texture
  12488. * @param height defines the height of the texture
  12489. * @param format defines the format of the data
  12490. * @param generateMipMaps defines if the engine should generate the mip levels
  12491. * @param invertY defines if data must be stored with Y axis inverted
  12492. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12493. * @param compression defines the compression used (null by default)
  12494. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12495. * @returns the raw texture inside an InternalTexture
  12496. */
  12497. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12498. /**
  12499. * Update a raw texture
  12500. * @param texture defines the texture to update
  12501. * @param data defines the data to store in the texture
  12502. * @param format defines the format of the data
  12503. * @param invertY defines if data must be stored with Y axis inverted
  12504. */
  12505. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12506. /**
  12507. * Update a raw texture
  12508. * @param texture defines the texture to update
  12509. * @param data defines the data to store in the texture
  12510. * @param format defines the format of the data
  12511. * @param invertY defines if data must be stored with Y axis inverted
  12512. * @param compression defines the compression used (null by default)
  12513. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12514. */
  12515. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12516. /**
  12517. * Creates a new raw cube texture
  12518. * @param data defines the array of data to use to create each face
  12519. * @param size defines the size of the textures
  12520. * @param format defines the format of the data
  12521. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12522. * @param generateMipMaps defines if the engine should generate the mip levels
  12523. * @param invertY defines if data must be stored with Y axis inverted
  12524. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12525. * @param compression defines the compression used (null by default)
  12526. * @returns the cube texture as an InternalTexture
  12527. */
  12528. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12529. /**
  12530. * Update a raw cube texture
  12531. * @param texture defines the texture to udpdate
  12532. * @param data defines the data to store
  12533. * @param format defines the data format
  12534. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12535. * @param invertY defines if data must be stored with Y axis inverted
  12536. */
  12537. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12538. /**
  12539. * Update a raw cube texture
  12540. * @param texture defines the texture to udpdate
  12541. * @param data defines the data to store
  12542. * @param format defines the data format
  12543. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12544. * @param invertY defines if data must be stored with Y axis inverted
  12545. * @param compression defines the compression used (null by default)
  12546. */
  12547. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12548. /**
  12549. * Update a raw cube texture
  12550. * @param texture defines the texture to udpdate
  12551. * @param data defines the data to store
  12552. * @param format defines the data format
  12553. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12554. * @param invertY defines if data must be stored with Y axis inverted
  12555. * @param compression defines the compression used (null by default)
  12556. * @param level defines which level of the texture to update
  12557. */
  12558. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12559. /**
  12560. * Creates a new raw cube texture from a specified url
  12561. * @param url defines the url where the data is located
  12562. * @param scene defines the current scene
  12563. * @param size defines the size of the textures
  12564. * @param format defines the format of the data
  12565. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12566. * @param noMipmap defines if the engine should avoid generating the mip levels
  12567. * @param callback defines a callback used to extract texture data from loaded data
  12568. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12569. * @param onLoad defines a callback called when texture is loaded
  12570. * @param onError defines a callback called if there is an error
  12571. * @returns the cube texture as an InternalTexture
  12572. */
  12573. 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;
  12574. /**
  12575. * Creates a new raw cube texture from a specified url
  12576. * @param url defines the url where the data is located
  12577. * @param scene defines the current scene
  12578. * @param size defines the size of the textures
  12579. * @param format defines the format of the data
  12580. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12581. * @param noMipmap defines if the engine should avoid generating the mip levels
  12582. * @param callback defines a callback used to extract texture data from loaded data
  12583. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12584. * @param onLoad defines a callback called when texture is loaded
  12585. * @param onError defines a callback called if there is an error
  12586. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. * @returns the cube texture as an InternalTexture
  12589. */
  12590. 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;
  12591. /**
  12592. * Creates a new raw 3D texture
  12593. * @param data defines the data used to create the texture
  12594. * @param width defines the width of the texture
  12595. * @param height defines the height of the texture
  12596. * @param depth defines the depth of the texture
  12597. * @param format defines the format of the texture
  12598. * @param generateMipMaps defines if the engine must generate mip levels
  12599. * @param invertY defines if data must be stored with Y axis inverted
  12600. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12601. * @param compression defines the compressed used (can be null)
  12602. * @param textureType defines the compressed used (can be null)
  12603. * @returns a new raw 3D texture (stored in an InternalTexture)
  12604. */
  12605. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12606. /**
  12607. * Update a raw 3D texture
  12608. * @param texture defines the texture to update
  12609. * @param data defines the data to store
  12610. * @param format defines the data format
  12611. * @param invertY defines if data must be stored with Y axis inverted
  12612. */
  12613. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12614. /**
  12615. * Update a raw 3D texture
  12616. * @param texture defines the texture to update
  12617. * @param data defines the data to store
  12618. * @param format defines the data format
  12619. * @param invertY defines if data must be stored with Y axis inverted
  12620. * @param compression defines the used compression (can be null)
  12621. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12622. */
  12623. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12624. }
  12625. }
  12626. }
  12627. declare module "babylonjs/Materials/Textures/rawTexture" {
  12628. import { Scene } from "babylonjs/scene";
  12629. import { Texture } from "babylonjs/Materials/Textures/texture";
  12630. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12631. /**
  12632. * Raw texture can help creating a texture directly from an array of data.
  12633. * This can be super useful if you either get the data from an uncompressed source or
  12634. * if you wish to create your texture pixel by pixel.
  12635. */
  12636. export class RawTexture extends Texture {
  12637. /**
  12638. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12639. */
  12640. format: number;
  12641. private _engine;
  12642. /**
  12643. * Instantiates a new RawTexture.
  12644. * Raw texture can help creating a texture directly from an array of data.
  12645. * This can be super useful if you either get the data from an uncompressed source or
  12646. * if you wish to create your texture pixel by pixel.
  12647. * @param data define the array of data to use to create the texture
  12648. * @param width define the width of the texture
  12649. * @param height define the height of the texture
  12650. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12651. * @param scene define the scene the texture belongs to
  12652. * @param generateMipMaps define whether mip maps should be generated or not
  12653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12655. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12656. */
  12657. constructor(data: ArrayBufferView, width: number, height: number,
  12658. /**
  12659. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12660. */
  12661. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12662. /**
  12663. * Updates the texture underlying data.
  12664. * @param data Define the new data of the texture
  12665. */
  12666. update(data: ArrayBufferView): void;
  12667. /**
  12668. * Creates a luminance texture from some data.
  12669. * @param data Define the texture data
  12670. * @param width Define the width of the texture
  12671. * @param height Define the height of the texture
  12672. * @param scene Define the scene the texture belongs to
  12673. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12674. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12675. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12676. * @returns the luminance texture
  12677. */
  12678. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12679. /**
  12680. * Creates a luminance alpha texture from some data.
  12681. * @param data Define the texture data
  12682. * @param width Define the width of the texture
  12683. * @param height Define the height of the texture
  12684. * @param scene Define the scene the texture belongs to
  12685. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12686. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12687. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12688. * @returns the luminance alpha texture
  12689. */
  12690. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12691. /**
  12692. * Creates an alpha texture from some data.
  12693. * @param data Define the texture data
  12694. * @param width Define the width of the texture
  12695. * @param height Define the height of the texture
  12696. * @param scene Define the scene the texture belongs to
  12697. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12698. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12699. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12700. * @returns the alpha texture
  12701. */
  12702. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12703. /**
  12704. * Creates a RGB texture from some data.
  12705. * @param data Define the texture data
  12706. * @param width Define the width of the texture
  12707. * @param height Define the height of the texture
  12708. * @param scene Define the scene the texture belongs to
  12709. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12710. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12711. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12712. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12713. * @returns the RGB alpha texture
  12714. */
  12715. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12716. /**
  12717. * Creates a RGBA texture from some data.
  12718. * @param data Define the texture data
  12719. * @param width Define the width of the texture
  12720. * @param height Define the height of the texture
  12721. * @param scene Define the scene the texture belongs to
  12722. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12723. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12724. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12725. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12726. * @returns the RGBA texture
  12727. */
  12728. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12729. /**
  12730. * Creates a R texture from some data.
  12731. * @param data Define the texture data
  12732. * @param width Define the width of the texture
  12733. * @param height Define the height of the texture
  12734. * @param scene Define the scene the texture belongs to
  12735. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12736. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12737. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12738. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12739. * @returns the R texture
  12740. */
  12741. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12742. }
  12743. }
  12744. declare module "babylonjs/Maths/math.size" {
  12745. /**
  12746. * Interface for the size containing width and height
  12747. */
  12748. export interface ISize {
  12749. /**
  12750. * Width
  12751. */
  12752. width: number;
  12753. /**
  12754. * Heighht
  12755. */
  12756. height: number;
  12757. }
  12758. /**
  12759. * Size containing widht and height
  12760. */
  12761. export class Size implements ISize {
  12762. /**
  12763. * Width
  12764. */
  12765. width: number;
  12766. /**
  12767. * Height
  12768. */
  12769. height: number;
  12770. /**
  12771. * Creates a Size object from the given width and height (floats).
  12772. * @param width width of the new size
  12773. * @param height height of the new size
  12774. */
  12775. constructor(width: number, height: number);
  12776. /**
  12777. * Returns a string with the Size width and height
  12778. * @returns a string with the Size width and height
  12779. */
  12780. toString(): string;
  12781. /**
  12782. * "Size"
  12783. * @returns the string "Size"
  12784. */
  12785. getClassName(): string;
  12786. /**
  12787. * Returns the Size hash code.
  12788. * @returns a hash code for a unique width and height
  12789. */
  12790. getHashCode(): number;
  12791. /**
  12792. * Updates the current size from the given one.
  12793. * @param src the given size
  12794. */
  12795. copyFrom(src: Size): void;
  12796. /**
  12797. * Updates in place the current Size from the given floats.
  12798. * @param width width of the new size
  12799. * @param height height of the new size
  12800. * @returns the updated Size.
  12801. */
  12802. copyFromFloats(width: number, height: number): Size;
  12803. /**
  12804. * Updates in place the current Size from the given floats.
  12805. * @param width width to set
  12806. * @param height height to set
  12807. * @returns the updated Size.
  12808. */
  12809. set(width: number, height: number): Size;
  12810. /**
  12811. * Multiplies the width and height by numbers
  12812. * @param w factor to multiple the width by
  12813. * @param h factor to multiple the height by
  12814. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12815. */
  12816. multiplyByFloats(w: number, h: number): Size;
  12817. /**
  12818. * Clones the size
  12819. * @returns a new Size copied from the given one.
  12820. */
  12821. clone(): Size;
  12822. /**
  12823. * True if the current Size and the given one width and height are strictly equal.
  12824. * @param other the other size to compare against
  12825. * @returns True if the current Size and the given one width and height are strictly equal.
  12826. */
  12827. equals(other: Size): boolean;
  12828. /**
  12829. * The surface of the Size : width * height (float).
  12830. */
  12831. readonly surface: number;
  12832. /**
  12833. * Create a new size of zero
  12834. * @returns a new Size set to (0.0, 0.0)
  12835. */
  12836. static Zero(): Size;
  12837. /**
  12838. * Sums the width and height of two sizes
  12839. * @param otherSize size to add to this size
  12840. * @returns a new Size set as the addition result of the current Size and the given one.
  12841. */
  12842. add(otherSize: Size): Size;
  12843. /**
  12844. * Subtracts the width and height of two
  12845. * @param otherSize size to subtract to this size
  12846. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12847. */
  12848. subtract(otherSize: Size): Size;
  12849. /**
  12850. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12851. * @param start starting size to lerp between
  12852. * @param end end size to lerp between
  12853. * @param amount amount to lerp between the start and end values
  12854. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12855. */
  12856. static Lerp(start: Size, end: Size, amount: number): Size;
  12857. }
  12858. }
  12859. declare module "babylonjs/Animations/runtimeAnimation" {
  12860. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12861. import { Animatable } from "babylonjs/Animations/animatable";
  12862. import { Scene } from "babylonjs/scene";
  12863. /**
  12864. * Defines a runtime animation
  12865. */
  12866. export class RuntimeAnimation {
  12867. private _events;
  12868. /**
  12869. * The current frame of the runtime animation
  12870. */
  12871. private _currentFrame;
  12872. /**
  12873. * The animation used by the runtime animation
  12874. */
  12875. private _animation;
  12876. /**
  12877. * The target of the runtime animation
  12878. */
  12879. private _target;
  12880. /**
  12881. * The initiating animatable
  12882. */
  12883. private _host;
  12884. /**
  12885. * The original value of the runtime animation
  12886. */
  12887. private _originalValue;
  12888. /**
  12889. * The original blend value of the runtime animation
  12890. */
  12891. private _originalBlendValue;
  12892. /**
  12893. * The offsets cache of the runtime animation
  12894. */
  12895. private _offsetsCache;
  12896. /**
  12897. * The high limits cache of the runtime animation
  12898. */
  12899. private _highLimitsCache;
  12900. /**
  12901. * Specifies if the runtime animation has been stopped
  12902. */
  12903. private _stopped;
  12904. /**
  12905. * The blending factor of the runtime animation
  12906. */
  12907. private _blendingFactor;
  12908. /**
  12909. * The BabylonJS scene
  12910. */
  12911. private _scene;
  12912. /**
  12913. * The current value of the runtime animation
  12914. */
  12915. private _currentValue;
  12916. /** @hidden */
  12917. _animationState: _IAnimationState;
  12918. /**
  12919. * The active target of the runtime animation
  12920. */
  12921. private _activeTargets;
  12922. private _currentActiveTarget;
  12923. private _directTarget;
  12924. /**
  12925. * The target path of the runtime animation
  12926. */
  12927. private _targetPath;
  12928. /**
  12929. * The weight of the runtime animation
  12930. */
  12931. private _weight;
  12932. /**
  12933. * The ratio offset of the runtime animation
  12934. */
  12935. private _ratioOffset;
  12936. /**
  12937. * The previous delay of the runtime animation
  12938. */
  12939. private _previousDelay;
  12940. /**
  12941. * The previous ratio of the runtime animation
  12942. */
  12943. private _previousRatio;
  12944. private _enableBlending;
  12945. private _keys;
  12946. private _minFrame;
  12947. private _maxFrame;
  12948. private _minValue;
  12949. private _maxValue;
  12950. private _targetIsArray;
  12951. /**
  12952. * Gets the current frame of the runtime animation
  12953. */
  12954. readonly currentFrame: number;
  12955. /**
  12956. * Gets the weight of the runtime animation
  12957. */
  12958. readonly weight: number;
  12959. /**
  12960. * Gets the current value of the runtime animation
  12961. */
  12962. readonly currentValue: any;
  12963. /**
  12964. * Gets the target path of the runtime animation
  12965. */
  12966. readonly targetPath: string;
  12967. /**
  12968. * Gets the actual target of the runtime animation
  12969. */
  12970. readonly target: any;
  12971. /** @hidden */
  12972. _onLoop: () => void;
  12973. /**
  12974. * Create a new RuntimeAnimation object
  12975. * @param target defines the target of the animation
  12976. * @param animation defines the source animation object
  12977. * @param scene defines the hosting scene
  12978. * @param host defines the initiating Animatable
  12979. */
  12980. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12981. private _preparePath;
  12982. /**
  12983. * Gets the animation from the runtime animation
  12984. */
  12985. readonly animation: Animation;
  12986. /**
  12987. * Resets the runtime animation to the beginning
  12988. * @param restoreOriginal defines whether to restore the target property to the original value
  12989. */
  12990. reset(restoreOriginal?: boolean): void;
  12991. /**
  12992. * Specifies if the runtime animation is stopped
  12993. * @returns Boolean specifying if the runtime animation is stopped
  12994. */
  12995. isStopped(): boolean;
  12996. /**
  12997. * Disposes of the runtime animation
  12998. */
  12999. dispose(): void;
  13000. /**
  13001. * Apply the interpolated value to the target
  13002. * @param currentValue defines the value computed by the animation
  13003. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13004. */
  13005. setValue(currentValue: any, weight: number): void;
  13006. private _getOriginalValues;
  13007. private _setValue;
  13008. /**
  13009. * Gets the loop pmode of the runtime animation
  13010. * @returns Loop Mode
  13011. */
  13012. private _getCorrectLoopMode;
  13013. /**
  13014. * Move the current animation to a given frame
  13015. * @param frame defines the frame to move to
  13016. */
  13017. goToFrame(frame: number): void;
  13018. /**
  13019. * @hidden Internal use only
  13020. */
  13021. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13022. /**
  13023. * Execute the current animation
  13024. * @param delay defines the delay to add to the current frame
  13025. * @param from defines the lower bound of the animation range
  13026. * @param to defines the upper bound of the animation range
  13027. * @param loop defines if the current animation must loop
  13028. * @param speedRatio defines the current speed ratio
  13029. * @param weight defines the weight of the animation (default is -1 so no weight)
  13030. * @param onLoop optional callback called when animation loops
  13031. * @returns a boolean indicating if the animation is running
  13032. */
  13033. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13034. }
  13035. }
  13036. declare module "babylonjs/Animations/animatable" {
  13037. import { Animation } from "babylonjs/Animations/animation";
  13038. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13039. import { Nullable } from "babylonjs/types";
  13040. import { Observable } from "babylonjs/Misc/observable";
  13041. import { Scene } from "babylonjs/scene";
  13042. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13043. import { Node } from "babylonjs/node";
  13044. /**
  13045. * Class used to store an actual running animation
  13046. */
  13047. export class Animatable {
  13048. /** defines the target object */
  13049. target: any;
  13050. /** defines the starting frame number (default is 0) */
  13051. fromFrame: number;
  13052. /** defines the ending frame number (default is 100) */
  13053. toFrame: number;
  13054. /** defines if the animation must loop (default is false) */
  13055. loopAnimation: boolean;
  13056. /** defines a callback to call when animation ends if it is not looping */
  13057. onAnimationEnd?: (() => void) | null | undefined;
  13058. /** defines a callback to call when animation loops */
  13059. onAnimationLoop?: (() => void) | null | undefined;
  13060. private _localDelayOffset;
  13061. private _pausedDelay;
  13062. private _runtimeAnimations;
  13063. private _paused;
  13064. private _scene;
  13065. private _speedRatio;
  13066. private _weight;
  13067. private _syncRoot;
  13068. /**
  13069. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13070. * This will only apply for non looping animation (default is true)
  13071. */
  13072. disposeOnEnd: boolean;
  13073. /**
  13074. * Gets a boolean indicating if the animation has started
  13075. */
  13076. animationStarted: boolean;
  13077. /**
  13078. * Observer raised when the animation ends
  13079. */
  13080. onAnimationEndObservable: Observable<Animatable>;
  13081. /**
  13082. * Observer raised when the animation loops
  13083. */
  13084. onAnimationLoopObservable: Observable<Animatable>;
  13085. /**
  13086. * Gets the root Animatable used to synchronize and normalize animations
  13087. */
  13088. readonly syncRoot: Nullable<Animatable>;
  13089. /**
  13090. * Gets the current frame of the first RuntimeAnimation
  13091. * Used to synchronize Animatables
  13092. */
  13093. readonly masterFrame: number;
  13094. /**
  13095. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13096. */
  13097. weight: number;
  13098. /**
  13099. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13100. */
  13101. speedRatio: number;
  13102. /**
  13103. * Creates a new Animatable
  13104. * @param scene defines the hosting scene
  13105. * @param target defines the target object
  13106. * @param fromFrame defines the starting frame number (default is 0)
  13107. * @param toFrame defines the ending frame number (default is 100)
  13108. * @param loopAnimation defines if the animation must loop (default is false)
  13109. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13110. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13111. * @param animations defines a group of animation to add to the new Animatable
  13112. * @param onAnimationLoop defines a callback to call when animation loops
  13113. */
  13114. constructor(scene: Scene,
  13115. /** defines the target object */
  13116. target: any,
  13117. /** defines the starting frame number (default is 0) */
  13118. fromFrame?: number,
  13119. /** defines the ending frame number (default is 100) */
  13120. toFrame?: number,
  13121. /** defines if the animation must loop (default is false) */
  13122. loopAnimation?: boolean, speedRatio?: number,
  13123. /** defines a callback to call when animation ends if it is not looping */
  13124. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13125. /** defines a callback to call when animation loops */
  13126. onAnimationLoop?: (() => void) | null | undefined);
  13127. /**
  13128. * Synchronize and normalize current Animatable with a source Animatable
  13129. * This is useful when using animation weights and when animations are not of the same length
  13130. * @param root defines the root Animatable to synchronize with
  13131. * @returns the current Animatable
  13132. */
  13133. syncWith(root: Animatable): Animatable;
  13134. /**
  13135. * Gets the list of runtime animations
  13136. * @returns an array of RuntimeAnimation
  13137. */
  13138. getAnimations(): RuntimeAnimation[];
  13139. /**
  13140. * Adds more animations to the current animatable
  13141. * @param target defines the target of the animations
  13142. * @param animations defines the new animations to add
  13143. */
  13144. appendAnimations(target: any, animations: Animation[]): void;
  13145. /**
  13146. * Gets the source animation for a specific property
  13147. * @param property defines the propertyu to look for
  13148. * @returns null or the source animation for the given property
  13149. */
  13150. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13151. /**
  13152. * Gets the runtime animation for a specific property
  13153. * @param property defines the propertyu to look for
  13154. * @returns null or the runtime animation for the given property
  13155. */
  13156. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13157. /**
  13158. * Resets the animatable to its original state
  13159. */
  13160. reset(): void;
  13161. /**
  13162. * Allows the animatable to blend with current running animations
  13163. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13164. * @param blendingSpeed defines the blending speed to use
  13165. */
  13166. enableBlending(blendingSpeed: number): void;
  13167. /**
  13168. * Disable animation blending
  13169. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13170. */
  13171. disableBlending(): void;
  13172. /**
  13173. * Jump directly to a given frame
  13174. * @param frame defines the frame to jump to
  13175. */
  13176. goToFrame(frame: number): void;
  13177. /**
  13178. * Pause the animation
  13179. */
  13180. pause(): void;
  13181. /**
  13182. * Restart the animation
  13183. */
  13184. restart(): void;
  13185. private _raiseOnAnimationEnd;
  13186. /**
  13187. * Stop and delete the current animation
  13188. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13189. * @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)
  13190. */
  13191. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13192. /**
  13193. * Wait asynchronously for the animation to end
  13194. * @returns a promise which will be fullfilled when the animation ends
  13195. */
  13196. waitAsync(): Promise<Animatable>;
  13197. /** @hidden */
  13198. _animate(delay: number): boolean;
  13199. }
  13200. module "babylonjs/scene" {
  13201. interface Scene {
  13202. /** @hidden */
  13203. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13204. /** @hidden */
  13205. _processLateAnimationBindingsForMatrices(holder: {
  13206. totalWeight: number;
  13207. animations: RuntimeAnimation[];
  13208. originalValue: Matrix;
  13209. }): any;
  13210. /** @hidden */
  13211. _processLateAnimationBindingsForQuaternions(holder: {
  13212. totalWeight: number;
  13213. animations: RuntimeAnimation[];
  13214. originalValue: Quaternion;
  13215. }, refQuaternion: Quaternion): Quaternion;
  13216. /** @hidden */
  13217. _processLateAnimationBindings(): void;
  13218. /**
  13219. * Will start the animation sequence of a given target
  13220. * @param target defines the target
  13221. * @param from defines from which frame should animation start
  13222. * @param to defines until which frame should animation run.
  13223. * @param weight defines the weight to apply to the animation (1.0 by default)
  13224. * @param loop defines if the animation loops
  13225. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13226. * @param onAnimationEnd defines the function to be executed when the animation ends
  13227. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13228. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13229. * @param onAnimationLoop defines the callback to call when an animation loops
  13230. * @returns the animatable object created for this animation
  13231. */
  13232. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13233. /**
  13234. * Will start the animation sequence of a given target
  13235. * @param target defines the target
  13236. * @param from defines from which frame should animation start
  13237. * @param to defines until which frame should animation run.
  13238. * @param loop defines if the animation loops
  13239. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13240. * @param onAnimationEnd defines the function to be executed when the animation ends
  13241. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13242. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13243. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13244. * @param onAnimationLoop defines the callback to call when an animation loops
  13245. * @returns the animatable object created for this animation
  13246. */
  13247. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13248. /**
  13249. * Will start the animation sequence of a given target and its hierarchy
  13250. * @param target defines the target
  13251. * @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.
  13252. * @param from defines from which frame should animation start
  13253. * @param to defines until which frame should animation run.
  13254. * @param loop defines if the animation loops
  13255. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13256. * @param onAnimationEnd defines the function to be executed when the animation ends
  13257. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13258. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13260. * @param onAnimationLoop defines the callback to call when an animation loops
  13261. * @returns the list of created animatables
  13262. */
  13263. 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[];
  13264. /**
  13265. * Begin a new animation on a given node
  13266. * @param target defines the target where the animation will take place
  13267. * @param animations defines the list of animations to start
  13268. * @param from defines the initial value
  13269. * @param to defines the final value
  13270. * @param loop defines if you want animation to loop (off by default)
  13271. * @param speedRatio defines the speed ratio to apply to all animations
  13272. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13273. * @param onAnimationLoop defines the callback to call when an animation loops
  13274. * @returns the list of created animatables
  13275. */
  13276. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13277. /**
  13278. * Begin a new animation on a given node and its hierarchy
  13279. * @param target defines the root node where the animation will take place
  13280. * @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.
  13281. * @param animations defines the list of animations to start
  13282. * @param from defines the initial value
  13283. * @param to defines the final value
  13284. * @param loop defines if you want animation to loop (off by default)
  13285. * @param speedRatio defines the speed ratio to apply to all animations
  13286. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13287. * @param onAnimationLoop defines the callback to call when an animation loops
  13288. * @returns the list of animatables created for all nodes
  13289. */
  13290. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13291. /**
  13292. * Gets the animatable associated with a specific target
  13293. * @param target defines the target of the animatable
  13294. * @returns the required animatable if found
  13295. */
  13296. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13297. /**
  13298. * Gets all animatables associated with a given target
  13299. * @param target defines the target to look animatables for
  13300. * @returns an array of Animatables
  13301. */
  13302. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13303. /**
  13304. * Stops and removes all animations that have been applied to the scene
  13305. */
  13306. stopAllAnimations(): void;
  13307. }
  13308. }
  13309. module "babylonjs/Bones/bone" {
  13310. interface Bone {
  13311. /**
  13312. * Copy an animation range from another bone
  13313. * @param source defines the source bone
  13314. * @param rangeName defines the range name to copy
  13315. * @param frameOffset defines the frame offset
  13316. * @param rescaleAsRequired defines if rescaling must be applied if required
  13317. * @param skelDimensionsRatio defines the scaling ratio
  13318. * @returns true if operation was successful
  13319. */
  13320. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13321. }
  13322. }
  13323. }
  13324. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13325. /**
  13326. * Class used to override all child animations of a given target
  13327. */
  13328. export class AnimationPropertiesOverride {
  13329. /**
  13330. * Gets or sets a value indicating if animation blending must be used
  13331. */
  13332. enableBlending: boolean;
  13333. /**
  13334. * Gets or sets the blending speed to use when enableBlending is true
  13335. */
  13336. blendingSpeed: number;
  13337. /**
  13338. * Gets or sets the default loop mode to use
  13339. */
  13340. loopMode: number;
  13341. }
  13342. }
  13343. declare module "babylonjs/Bones/skeleton" {
  13344. import { Bone } from "babylonjs/Bones/bone";
  13345. import { Observable } from "babylonjs/Misc/observable";
  13346. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13347. import { Scene } from "babylonjs/scene";
  13348. import { Nullable } from "babylonjs/types";
  13349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13350. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13351. import { Animatable } from "babylonjs/Animations/animatable";
  13352. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13353. import { Animation } from "babylonjs/Animations/animation";
  13354. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13355. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13356. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13357. /**
  13358. * Class used to handle skinning animations
  13359. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13360. */
  13361. export class Skeleton implements IAnimatable {
  13362. /** defines the skeleton name */
  13363. name: string;
  13364. /** defines the skeleton Id */
  13365. id: string;
  13366. /**
  13367. * Defines the list of child bones
  13368. */
  13369. bones: Bone[];
  13370. /**
  13371. * Defines an estimate of the dimension of the skeleton at rest
  13372. */
  13373. dimensionsAtRest: Vector3;
  13374. /**
  13375. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13376. */
  13377. needInitialSkinMatrix: boolean;
  13378. /**
  13379. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13380. */
  13381. overrideMesh: Nullable<AbstractMesh>;
  13382. /**
  13383. * Gets the list of animations attached to this skeleton
  13384. */
  13385. animations: Array<Animation>;
  13386. private _scene;
  13387. private _isDirty;
  13388. private _transformMatrices;
  13389. private _transformMatrixTexture;
  13390. private _meshesWithPoseMatrix;
  13391. private _animatables;
  13392. private _identity;
  13393. private _synchronizedWithMesh;
  13394. private _ranges;
  13395. private _lastAbsoluteTransformsUpdateId;
  13396. private _canUseTextureForBones;
  13397. private _uniqueId;
  13398. /** @hidden */
  13399. _numBonesWithLinkedTransformNode: number;
  13400. /** @hidden */
  13401. _hasWaitingData: Nullable<boolean>;
  13402. /**
  13403. * Specifies if the skeleton should be serialized
  13404. */
  13405. doNotSerialize: boolean;
  13406. private _useTextureToStoreBoneMatrices;
  13407. /**
  13408. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13409. * Please note that this option is not available if the hardware does not support it
  13410. */
  13411. useTextureToStoreBoneMatrices: boolean;
  13412. private _animationPropertiesOverride;
  13413. /**
  13414. * Gets or sets the animation properties override
  13415. */
  13416. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13417. /**
  13418. * List of inspectable custom properties (used by the Inspector)
  13419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13420. */
  13421. inspectableCustomProperties: IInspectable[];
  13422. /**
  13423. * An observable triggered before computing the skeleton's matrices
  13424. */
  13425. onBeforeComputeObservable: Observable<Skeleton>;
  13426. /**
  13427. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13428. */
  13429. readonly isUsingTextureForMatrices: boolean;
  13430. /**
  13431. * Gets the unique ID of this skeleton
  13432. */
  13433. readonly uniqueId: number;
  13434. /**
  13435. * Creates a new skeleton
  13436. * @param name defines the skeleton name
  13437. * @param id defines the skeleton Id
  13438. * @param scene defines the hosting scene
  13439. */
  13440. constructor(
  13441. /** defines the skeleton name */
  13442. name: string,
  13443. /** defines the skeleton Id */
  13444. id: string, scene: Scene);
  13445. /**
  13446. * Gets the current object class name.
  13447. * @return the class name
  13448. */
  13449. getClassName(): string;
  13450. /**
  13451. * Returns an array containing the root bones
  13452. * @returns an array containing the root bones
  13453. */
  13454. getChildren(): Array<Bone>;
  13455. /**
  13456. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13457. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13458. * @returns a Float32Array containing matrices data
  13459. */
  13460. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13461. /**
  13462. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13463. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13464. * @returns a raw texture containing the data
  13465. */
  13466. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13467. /**
  13468. * Gets the current hosting scene
  13469. * @returns a scene object
  13470. */
  13471. getScene(): Scene;
  13472. /**
  13473. * Gets a string representing the current skeleton data
  13474. * @param fullDetails defines a boolean indicating if we want a verbose version
  13475. * @returns a string representing the current skeleton data
  13476. */
  13477. toString(fullDetails?: boolean): string;
  13478. /**
  13479. * Get bone's index searching by name
  13480. * @param name defines bone's name to search for
  13481. * @return the indice of the bone. Returns -1 if not found
  13482. */
  13483. getBoneIndexByName(name: string): number;
  13484. /**
  13485. * Creater a new animation range
  13486. * @param name defines the name of the range
  13487. * @param from defines the start key
  13488. * @param to defines the end key
  13489. */
  13490. createAnimationRange(name: string, from: number, to: number): void;
  13491. /**
  13492. * Delete a specific animation range
  13493. * @param name defines the name of the range
  13494. * @param deleteFrames defines if frames must be removed as well
  13495. */
  13496. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13497. /**
  13498. * Gets a specific animation range
  13499. * @param name defines the name of the range to look for
  13500. * @returns the requested animation range or null if not found
  13501. */
  13502. getAnimationRange(name: string): Nullable<AnimationRange>;
  13503. /**
  13504. * Gets the list of all animation ranges defined on this skeleton
  13505. * @returns an array
  13506. */
  13507. getAnimationRanges(): Nullable<AnimationRange>[];
  13508. /**
  13509. * Copy animation range from a source skeleton.
  13510. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13511. * @param source defines the source skeleton
  13512. * @param name defines the name of the range to copy
  13513. * @param rescaleAsRequired defines if rescaling must be applied if required
  13514. * @returns true if operation was successful
  13515. */
  13516. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13517. /**
  13518. * Forces the skeleton to go to rest pose
  13519. */
  13520. returnToRest(): void;
  13521. private _getHighestAnimationFrame;
  13522. /**
  13523. * Begin a specific animation range
  13524. * @param name defines the name of the range to start
  13525. * @param loop defines if looping must be turned on (false by default)
  13526. * @param speedRatio defines the speed ratio to apply (1 by default)
  13527. * @param onAnimationEnd defines a callback which will be called when animation will end
  13528. * @returns a new animatable
  13529. */
  13530. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13531. /** @hidden */
  13532. _markAsDirty(): void;
  13533. /** @hidden */
  13534. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13535. /** @hidden */
  13536. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13537. private _computeTransformMatrices;
  13538. /**
  13539. * Build all resources required to render a skeleton
  13540. */
  13541. prepare(): void;
  13542. /**
  13543. * Gets the list of animatables currently running for this skeleton
  13544. * @returns an array of animatables
  13545. */
  13546. getAnimatables(): IAnimatable[];
  13547. /**
  13548. * Clone the current skeleton
  13549. * @param name defines the name of the new skeleton
  13550. * @param id defines the id of the new skeleton
  13551. * @returns the new skeleton
  13552. */
  13553. clone(name: string, id: string): Skeleton;
  13554. /**
  13555. * Enable animation blending for this skeleton
  13556. * @param blendingSpeed defines the blending speed to apply
  13557. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13558. */
  13559. enableBlending(blendingSpeed?: number): void;
  13560. /**
  13561. * Releases all resources associated with the current skeleton
  13562. */
  13563. dispose(): void;
  13564. /**
  13565. * Serialize the skeleton in a JSON object
  13566. * @returns a JSON object
  13567. */
  13568. serialize(): any;
  13569. /**
  13570. * Creates a new skeleton from serialized data
  13571. * @param parsedSkeleton defines the serialized data
  13572. * @param scene defines the hosting scene
  13573. * @returns a new skeleton
  13574. */
  13575. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13576. /**
  13577. * Compute all node absolute transforms
  13578. * @param forceUpdate defines if computation must be done even if cache is up to date
  13579. */
  13580. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13581. /**
  13582. * Gets the root pose matrix
  13583. * @returns a matrix
  13584. */
  13585. getPoseMatrix(): Nullable<Matrix>;
  13586. /**
  13587. * Sorts bones per internal index
  13588. */
  13589. sortBones(): void;
  13590. private _sortBones;
  13591. }
  13592. }
  13593. declare module "babylonjs/Bones/bone" {
  13594. import { Skeleton } from "babylonjs/Bones/skeleton";
  13595. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13596. import { Nullable } from "babylonjs/types";
  13597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13599. import { Node } from "babylonjs/node";
  13600. import { Space } from "babylonjs/Maths/math.axis";
  13601. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13602. /**
  13603. * Class used to store bone information
  13604. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13605. */
  13606. export class Bone extends Node {
  13607. /**
  13608. * defines the bone name
  13609. */
  13610. name: string;
  13611. private static _tmpVecs;
  13612. private static _tmpQuat;
  13613. private static _tmpMats;
  13614. /**
  13615. * Gets the list of child bones
  13616. */
  13617. children: Bone[];
  13618. /** Gets the animations associated with this bone */
  13619. animations: import("babylonjs/Animations/animation").Animation[];
  13620. /**
  13621. * Gets or sets bone length
  13622. */
  13623. length: number;
  13624. /**
  13625. * @hidden Internal only
  13626. * Set this value to map this bone to a different index in the transform matrices
  13627. * Set this value to -1 to exclude the bone from the transform matrices
  13628. */
  13629. _index: Nullable<number>;
  13630. private _skeleton;
  13631. private _localMatrix;
  13632. private _restPose;
  13633. private _baseMatrix;
  13634. private _absoluteTransform;
  13635. private _invertedAbsoluteTransform;
  13636. private _parent;
  13637. private _scalingDeterminant;
  13638. private _worldTransform;
  13639. private _localScaling;
  13640. private _localRotation;
  13641. private _localPosition;
  13642. private _needToDecompose;
  13643. private _needToCompose;
  13644. /** @hidden */
  13645. _linkedTransformNode: Nullable<TransformNode>;
  13646. /** @hidden */
  13647. _waitingTransformNodeId: Nullable<string>;
  13648. /** @hidden */
  13649. /** @hidden */
  13650. _matrix: Matrix;
  13651. /**
  13652. * Create a new bone
  13653. * @param name defines the bone name
  13654. * @param skeleton defines the parent skeleton
  13655. * @param parentBone defines the parent (can be null if the bone is the root)
  13656. * @param localMatrix defines the local matrix
  13657. * @param restPose defines the rest pose matrix
  13658. * @param baseMatrix defines the base matrix
  13659. * @param index defines index of the bone in the hiearchy
  13660. */
  13661. constructor(
  13662. /**
  13663. * defines the bone name
  13664. */
  13665. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13666. /**
  13667. * Gets the current object class name.
  13668. * @return the class name
  13669. */
  13670. getClassName(): string;
  13671. /**
  13672. * Gets the parent skeleton
  13673. * @returns a skeleton
  13674. */
  13675. getSkeleton(): Skeleton;
  13676. /**
  13677. * Gets parent bone
  13678. * @returns a bone or null if the bone is the root of the bone hierarchy
  13679. */
  13680. getParent(): Nullable<Bone>;
  13681. /**
  13682. * Returns an array containing the root bones
  13683. * @returns an array containing the root bones
  13684. */
  13685. getChildren(): Array<Bone>;
  13686. /**
  13687. * Sets the parent bone
  13688. * @param parent defines the parent (can be null if the bone is the root)
  13689. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13690. */
  13691. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13692. /**
  13693. * Gets the local matrix
  13694. * @returns a matrix
  13695. */
  13696. getLocalMatrix(): Matrix;
  13697. /**
  13698. * Gets the base matrix (initial matrix which remains unchanged)
  13699. * @returns a matrix
  13700. */
  13701. getBaseMatrix(): Matrix;
  13702. /**
  13703. * Gets the rest pose matrix
  13704. * @returns a matrix
  13705. */
  13706. getRestPose(): Matrix;
  13707. /**
  13708. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13709. */
  13710. getWorldMatrix(): Matrix;
  13711. /**
  13712. * Sets the local matrix to rest pose matrix
  13713. */
  13714. returnToRest(): void;
  13715. /**
  13716. * Gets the inverse of the absolute transform matrix.
  13717. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13718. * @returns a matrix
  13719. */
  13720. getInvertedAbsoluteTransform(): Matrix;
  13721. /**
  13722. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13723. * @returns a matrix
  13724. */
  13725. getAbsoluteTransform(): Matrix;
  13726. /**
  13727. * Links with the given transform node.
  13728. * The local matrix of this bone is copied from the transform node every frame.
  13729. * @param transformNode defines the transform node to link to
  13730. */
  13731. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13732. /**
  13733. * Gets the node used to drive the bone's transformation
  13734. * @returns a transform node or null
  13735. */
  13736. getTransformNode(): Nullable<TransformNode>;
  13737. /** Gets or sets current position (in local space) */
  13738. position: Vector3;
  13739. /** Gets or sets current rotation (in local space) */
  13740. rotation: Vector3;
  13741. /** Gets or sets current rotation quaternion (in local space) */
  13742. rotationQuaternion: Quaternion;
  13743. /** Gets or sets current scaling (in local space) */
  13744. scaling: Vector3;
  13745. /**
  13746. * Gets the animation properties override
  13747. */
  13748. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13749. private _decompose;
  13750. private _compose;
  13751. /**
  13752. * Update the base and local matrices
  13753. * @param matrix defines the new base or local matrix
  13754. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13755. * @param updateLocalMatrix defines if the local matrix should be updated
  13756. */
  13757. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13758. /** @hidden */
  13759. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13760. /**
  13761. * Flag the bone as dirty (Forcing it to update everything)
  13762. */
  13763. markAsDirty(): void;
  13764. /** @hidden */
  13765. _markAsDirtyAndCompose(): void;
  13766. private _markAsDirtyAndDecompose;
  13767. /**
  13768. * Translate the bone in local or world space
  13769. * @param vec The amount to translate the bone
  13770. * @param space The space that the translation is in
  13771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13772. */
  13773. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13774. /**
  13775. * Set the postion of the bone in local or world space
  13776. * @param position The position to set the bone
  13777. * @param space The space that the position is in
  13778. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13779. */
  13780. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13781. /**
  13782. * Set the absolute position of the bone (world space)
  13783. * @param position The position to set the bone
  13784. * @param mesh The mesh that this bone is attached to
  13785. */
  13786. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13787. /**
  13788. * Scale the bone on the x, y and z axes (in local space)
  13789. * @param x The amount to scale the bone on the x axis
  13790. * @param y The amount to scale the bone on the y axis
  13791. * @param z The amount to scale the bone on the z axis
  13792. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13793. */
  13794. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13795. /**
  13796. * Set the bone scaling in local space
  13797. * @param scale defines the scaling vector
  13798. */
  13799. setScale(scale: Vector3): void;
  13800. /**
  13801. * Gets the current scaling in local space
  13802. * @returns the current scaling vector
  13803. */
  13804. getScale(): Vector3;
  13805. /**
  13806. * Gets the current scaling in local space and stores it in a target vector
  13807. * @param result defines the target vector
  13808. */
  13809. getScaleToRef(result: Vector3): void;
  13810. /**
  13811. * Set the yaw, pitch, and roll of the bone in local or world space
  13812. * @param yaw The rotation of the bone on the y axis
  13813. * @param pitch The rotation of the bone on the x axis
  13814. * @param roll The rotation of the bone on the z axis
  13815. * @param space The space that the axes of rotation are in
  13816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13817. */
  13818. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13819. /**
  13820. * Add a rotation to the bone on an axis in local or world space
  13821. * @param axis The axis to rotate the bone on
  13822. * @param amount The amount to rotate the bone
  13823. * @param space The space that the axis is in
  13824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13825. */
  13826. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13827. /**
  13828. * Set the rotation of the bone to a particular axis angle in local or world space
  13829. * @param axis The axis to rotate the bone on
  13830. * @param angle The angle that the bone should be rotated to
  13831. * @param space The space that the axis is in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. */
  13834. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13835. /**
  13836. * Set the euler rotation of the bone in local of world space
  13837. * @param rotation The euler rotation that the bone should be set to
  13838. * @param space The space that the rotation is in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. */
  13841. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13842. /**
  13843. * Set the quaternion rotation of the bone in local of world space
  13844. * @param quat The quaternion rotation that the bone should be set to
  13845. * @param space The space that the rotation is in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. */
  13848. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13849. /**
  13850. * Set the rotation matrix of the bone in local of world space
  13851. * @param rotMat The rotation matrix that the bone should be set to
  13852. * @param space The space that the rotation is in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. */
  13855. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13856. private _rotateWithMatrix;
  13857. private _getNegativeRotationToRef;
  13858. /**
  13859. * Get the position of the bone in local or world space
  13860. * @param space The space that the returned position is in
  13861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13862. * @returns The position of the bone
  13863. */
  13864. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13865. /**
  13866. * Copy the position of the bone to a vector3 in local or world space
  13867. * @param space The space that the returned position is in
  13868. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13869. * @param result The vector3 to copy the position to
  13870. */
  13871. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13872. /**
  13873. * Get the absolute position of the bone (world space)
  13874. * @param mesh The mesh that this bone is attached to
  13875. * @returns The absolute position of the bone
  13876. */
  13877. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13878. /**
  13879. * Copy the absolute position of the bone (world space) to the result param
  13880. * @param mesh The mesh that this bone is attached to
  13881. * @param result The vector3 to copy the absolute position to
  13882. */
  13883. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13884. /**
  13885. * Compute the absolute transforms of this bone and its children
  13886. */
  13887. computeAbsoluteTransforms(): void;
  13888. /**
  13889. * Get the world direction from an axis that is in the local space of the bone
  13890. * @param localAxis The local direction that is used to compute the world direction
  13891. * @param mesh The mesh that this bone is attached to
  13892. * @returns The world direction
  13893. */
  13894. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13895. /**
  13896. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13897. * @param localAxis The local direction that is used to compute the world direction
  13898. * @param mesh The mesh that this bone is attached to
  13899. * @param result The vector3 that the world direction will be copied to
  13900. */
  13901. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13902. /**
  13903. * Get the euler rotation of the bone in local or world space
  13904. * @param space The space that the rotation should be in
  13905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13906. * @returns The euler rotation
  13907. */
  13908. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13909. /**
  13910. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13911. * @param space The space that the rotation should be in
  13912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13913. * @param result The vector3 that the rotation should be copied to
  13914. */
  13915. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13916. /**
  13917. * Get the quaternion rotation of the bone in either local or world space
  13918. * @param space The space that the rotation should be in
  13919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13920. * @returns The quaternion rotation
  13921. */
  13922. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13923. /**
  13924. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13925. * @param space The space that the rotation should be in
  13926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13927. * @param result The quaternion that the rotation should be copied to
  13928. */
  13929. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13930. /**
  13931. * Get the rotation matrix of the bone in local or world space
  13932. * @param space The space that the rotation should be in
  13933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13934. * @returns The rotation matrix
  13935. */
  13936. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13937. /**
  13938. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13939. * @param space The space that the rotation should be in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. * @param result The quaternion that the rotation should be copied to
  13942. */
  13943. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13944. /**
  13945. * Get the world position of a point that is in the local space of the bone
  13946. * @param position The local position
  13947. * @param mesh The mesh that this bone is attached to
  13948. * @returns The world position
  13949. */
  13950. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13951. /**
  13952. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13953. * @param position The local position
  13954. * @param mesh The mesh that this bone is attached to
  13955. * @param result The vector3 that the world position should be copied to
  13956. */
  13957. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13958. /**
  13959. * Get the local position of a point that is in world space
  13960. * @param position The world position
  13961. * @param mesh The mesh that this bone is attached to
  13962. * @returns The local position
  13963. */
  13964. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13965. /**
  13966. * Get the local position of a point that is in world space and copy it to the result param
  13967. * @param position The world position
  13968. * @param mesh The mesh that this bone is attached to
  13969. * @param result The vector3 that the local position should be copied to
  13970. */
  13971. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13972. }
  13973. }
  13974. declare module "babylonjs/Meshes/transformNode" {
  13975. import { DeepImmutable } from "babylonjs/types";
  13976. import { Observable } from "babylonjs/Misc/observable";
  13977. import { Nullable } from "babylonjs/types";
  13978. import { Camera } from "babylonjs/Cameras/camera";
  13979. import { Scene } from "babylonjs/scene";
  13980. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13981. import { Node } from "babylonjs/node";
  13982. import { Bone } from "babylonjs/Bones/bone";
  13983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13984. import { Space } from "babylonjs/Maths/math.axis";
  13985. /**
  13986. * 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.
  13987. * @see https://doc.babylonjs.com/how_to/transformnode
  13988. */
  13989. export class TransformNode extends Node {
  13990. /**
  13991. * Object will not rotate to face the camera
  13992. */
  13993. static BILLBOARDMODE_NONE: number;
  13994. /**
  13995. * Object will rotate to face the camera but only on the x axis
  13996. */
  13997. static BILLBOARDMODE_X: number;
  13998. /**
  13999. * Object will rotate to face the camera but only on the y axis
  14000. */
  14001. static BILLBOARDMODE_Y: number;
  14002. /**
  14003. * Object will rotate to face the camera but only on the z axis
  14004. */
  14005. static BILLBOARDMODE_Z: number;
  14006. /**
  14007. * Object will rotate to face the camera
  14008. */
  14009. static BILLBOARDMODE_ALL: number;
  14010. /**
  14011. * Object will rotate to face the camera's position instead of orientation
  14012. */
  14013. static BILLBOARDMODE_USE_POSITION: number;
  14014. private _forward;
  14015. private _forwardInverted;
  14016. private _up;
  14017. private _right;
  14018. private _rightInverted;
  14019. private _position;
  14020. private _rotation;
  14021. private _rotationQuaternion;
  14022. protected _scaling: Vector3;
  14023. protected _isDirty: boolean;
  14024. private _transformToBoneReferal;
  14025. private _isAbsoluteSynced;
  14026. private _billboardMode;
  14027. /**
  14028. * Gets or sets the billboard mode. Default is 0.
  14029. *
  14030. * | Value | Type | Description |
  14031. * | --- | --- | --- |
  14032. * | 0 | BILLBOARDMODE_NONE | |
  14033. * | 1 | BILLBOARDMODE_X | |
  14034. * | 2 | BILLBOARDMODE_Y | |
  14035. * | 4 | BILLBOARDMODE_Z | |
  14036. * | 7 | BILLBOARDMODE_ALL | |
  14037. *
  14038. */
  14039. billboardMode: number;
  14040. private _preserveParentRotationForBillboard;
  14041. /**
  14042. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14043. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14044. */
  14045. preserveParentRotationForBillboard: boolean;
  14046. /**
  14047. * 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
  14048. */
  14049. scalingDeterminant: number;
  14050. private _infiniteDistance;
  14051. /**
  14052. * Gets or sets the distance of the object to max, often used by skybox
  14053. */
  14054. infiniteDistance: boolean;
  14055. /**
  14056. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14057. * By default the system will update normals to compensate
  14058. */
  14059. ignoreNonUniformScaling: boolean;
  14060. /**
  14061. * 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
  14062. */
  14063. reIntegrateRotationIntoRotationQuaternion: boolean;
  14064. /** @hidden */
  14065. _poseMatrix: Nullable<Matrix>;
  14066. /** @hidden */
  14067. _localMatrix: Matrix;
  14068. private _usePivotMatrix;
  14069. private _absolutePosition;
  14070. private _absoluteScaling;
  14071. private _absoluteRotationQuaternion;
  14072. private _pivotMatrix;
  14073. private _pivotMatrixInverse;
  14074. protected _postMultiplyPivotMatrix: boolean;
  14075. protected _isWorldMatrixFrozen: boolean;
  14076. /** @hidden */
  14077. _indexInSceneTransformNodesArray: number;
  14078. /**
  14079. * An event triggered after the world matrix is updated
  14080. */
  14081. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14082. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14083. /**
  14084. * Gets a string identifying the name of the class
  14085. * @returns "TransformNode" string
  14086. */
  14087. getClassName(): string;
  14088. /**
  14089. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14090. */
  14091. position: Vector3;
  14092. /**
  14093. * 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)).
  14094. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14095. */
  14096. rotation: Vector3;
  14097. /**
  14098. * 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)).
  14099. */
  14100. scaling: Vector3;
  14101. /**
  14102. * 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).
  14103. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14104. */
  14105. rotationQuaternion: Nullable<Quaternion>;
  14106. /**
  14107. * The forward direction of that transform in world space.
  14108. */
  14109. readonly forward: Vector3;
  14110. /**
  14111. * The up direction of that transform in world space.
  14112. */
  14113. readonly up: Vector3;
  14114. /**
  14115. * The right direction of that transform in world space.
  14116. */
  14117. readonly right: Vector3;
  14118. /**
  14119. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14120. * @param matrix the matrix to copy the pose from
  14121. * @returns this TransformNode.
  14122. */
  14123. updatePoseMatrix(matrix: Matrix): TransformNode;
  14124. /**
  14125. * Returns the mesh Pose matrix.
  14126. * @returns the pose matrix
  14127. */
  14128. getPoseMatrix(): Matrix;
  14129. /** @hidden */
  14130. _isSynchronized(): boolean;
  14131. /** @hidden */
  14132. _initCache(): void;
  14133. /**
  14134. * Flag the transform node as dirty (Forcing it to update everything)
  14135. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14136. * @returns this transform node
  14137. */
  14138. markAsDirty(property: string): TransformNode;
  14139. /**
  14140. * Returns the current mesh absolute position.
  14141. * Returns a Vector3.
  14142. */
  14143. readonly absolutePosition: Vector3;
  14144. /**
  14145. * Returns the current mesh absolute scaling.
  14146. * Returns a Vector3.
  14147. */
  14148. readonly absoluteScaling: Vector3;
  14149. /**
  14150. * Returns the current mesh absolute rotation.
  14151. * Returns a Quaternion.
  14152. */
  14153. readonly absoluteRotationQuaternion: Quaternion;
  14154. /**
  14155. * Sets a new matrix to apply before all other transformation
  14156. * @param matrix defines the transform matrix
  14157. * @returns the current TransformNode
  14158. */
  14159. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14160. /**
  14161. * Sets a new pivot matrix to the current node
  14162. * @param matrix defines the new pivot matrix to use
  14163. * @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
  14164. * @returns the current TransformNode
  14165. */
  14166. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14167. /**
  14168. * Returns the mesh pivot matrix.
  14169. * Default : Identity.
  14170. * @returns the matrix
  14171. */
  14172. getPivotMatrix(): Matrix;
  14173. /**
  14174. * Instantiate (when possible) or clone that node with its hierarchy
  14175. * @param newParent defines the new parent to use for the instance (or clone)
  14176. * @returns an instance (or a clone) of the current node with its hiearchy
  14177. */
  14178. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14179. /**
  14180. * Prevents the World matrix to be computed any longer
  14181. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14182. * @returns the TransformNode.
  14183. */
  14184. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14185. /**
  14186. * Allows back the World matrix computation.
  14187. * @returns the TransformNode.
  14188. */
  14189. unfreezeWorldMatrix(): this;
  14190. /**
  14191. * True if the World matrix has been frozen.
  14192. */
  14193. readonly isWorldMatrixFrozen: boolean;
  14194. /**
  14195. * Retuns the mesh absolute position in the World.
  14196. * @returns a Vector3.
  14197. */
  14198. getAbsolutePosition(): Vector3;
  14199. /**
  14200. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14201. * @param absolutePosition the absolute position to set
  14202. * @returns the TransformNode.
  14203. */
  14204. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14205. /**
  14206. * Sets the mesh position in its local space.
  14207. * @param vector3 the position to set in localspace
  14208. * @returns the TransformNode.
  14209. */
  14210. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14211. /**
  14212. * Returns the mesh position in the local space from the current World matrix values.
  14213. * @returns a new Vector3.
  14214. */
  14215. getPositionExpressedInLocalSpace(): Vector3;
  14216. /**
  14217. * Translates the mesh along the passed Vector3 in its local space.
  14218. * @param vector3 the distance to translate in localspace
  14219. * @returns the TransformNode.
  14220. */
  14221. locallyTranslate(vector3: Vector3): TransformNode;
  14222. private static _lookAtVectorCache;
  14223. /**
  14224. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14225. * @param targetPoint the position (must be in same space as current mesh) to look at
  14226. * @param yawCor optional yaw (y-axis) correction in radians
  14227. * @param pitchCor optional pitch (x-axis) correction in radians
  14228. * @param rollCor optional roll (z-axis) correction in radians
  14229. * @param space the choosen space of the target
  14230. * @returns the TransformNode.
  14231. */
  14232. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14233. /**
  14234. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14235. * This Vector3 is expressed in the World space.
  14236. * @param localAxis axis to rotate
  14237. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14238. */
  14239. getDirection(localAxis: Vector3): Vector3;
  14240. /**
  14241. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14242. * localAxis is expressed in the mesh local space.
  14243. * result is computed in the Wordl space from the mesh World matrix.
  14244. * @param localAxis axis to rotate
  14245. * @param result the resulting transformnode
  14246. * @returns this TransformNode.
  14247. */
  14248. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14249. /**
  14250. * Sets this transform node rotation to the given local axis.
  14251. * @param localAxis the axis in local space
  14252. * @param yawCor optional yaw (y-axis) correction in radians
  14253. * @param pitchCor optional pitch (x-axis) correction in radians
  14254. * @param rollCor optional roll (z-axis) correction in radians
  14255. * @returns this TransformNode
  14256. */
  14257. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14258. /**
  14259. * Sets a new pivot point to the current node
  14260. * @param point defines the new pivot point to use
  14261. * @param space defines if the point is in world or local space (local by default)
  14262. * @returns the current TransformNode
  14263. */
  14264. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14265. /**
  14266. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14267. * @returns the pivot point
  14268. */
  14269. getPivotPoint(): Vector3;
  14270. /**
  14271. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14272. * @param result the vector3 to store the result
  14273. * @returns this TransformNode.
  14274. */
  14275. getPivotPointToRef(result: Vector3): TransformNode;
  14276. /**
  14277. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14278. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14279. */
  14280. getAbsolutePivotPoint(): Vector3;
  14281. /**
  14282. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14283. * @param result vector3 to store the result
  14284. * @returns this TransformNode.
  14285. */
  14286. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14287. /**
  14288. * Defines the passed node as the parent of the current node.
  14289. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14290. * @see https://doc.babylonjs.com/how_to/parenting
  14291. * @param node the node ot set as the parent
  14292. * @returns this TransformNode.
  14293. */
  14294. setParent(node: Nullable<Node>): TransformNode;
  14295. private _nonUniformScaling;
  14296. /**
  14297. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14298. */
  14299. readonly nonUniformScaling: boolean;
  14300. /** @hidden */
  14301. _updateNonUniformScalingState(value: boolean): boolean;
  14302. /**
  14303. * Attach the current TransformNode to another TransformNode associated with a bone
  14304. * @param bone Bone affecting the TransformNode
  14305. * @param affectedTransformNode TransformNode associated with the bone
  14306. * @returns this object
  14307. */
  14308. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14309. /**
  14310. * Detach the transform node if its associated with a bone
  14311. * @returns this object
  14312. */
  14313. detachFromBone(): TransformNode;
  14314. private static _rotationAxisCache;
  14315. /**
  14316. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14317. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14318. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14319. * The passed axis is also normalized.
  14320. * @param axis the axis to rotate around
  14321. * @param amount the amount to rotate in radians
  14322. * @param space Space to rotate in (Default: local)
  14323. * @returns the TransformNode.
  14324. */
  14325. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14326. /**
  14327. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14328. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14329. * The passed axis is also normalized. .
  14330. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14331. * @param point the point to rotate around
  14332. * @param axis the axis to rotate around
  14333. * @param amount the amount to rotate in radians
  14334. * @returns the TransformNode
  14335. */
  14336. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14337. /**
  14338. * Translates the mesh along the axis vector for the passed distance in the given space.
  14339. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14340. * @param axis the axis to translate in
  14341. * @param distance the distance to translate
  14342. * @param space Space to rotate in (Default: local)
  14343. * @returns the TransformNode.
  14344. */
  14345. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14346. /**
  14347. * Adds a rotation step to the mesh current rotation.
  14348. * x, y, z are Euler angles expressed in radians.
  14349. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14350. * This means this rotation is made in the mesh local space only.
  14351. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14352. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14353. * ```javascript
  14354. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14355. * ```
  14356. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14357. * 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.
  14358. * @param x Rotation to add
  14359. * @param y Rotation to add
  14360. * @param z Rotation to add
  14361. * @returns the TransformNode.
  14362. */
  14363. addRotation(x: number, y: number, z: number): TransformNode;
  14364. /**
  14365. * @hidden
  14366. */
  14367. protected _getEffectiveParent(): Nullable<Node>;
  14368. /**
  14369. * Computes the world matrix of the node
  14370. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14371. * @returns the world matrix
  14372. */
  14373. computeWorldMatrix(force?: boolean): Matrix;
  14374. protected _afterComputeWorldMatrix(): void;
  14375. /**
  14376. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14377. * @param func callback function to add
  14378. *
  14379. * @returns the TransformNode.
  14380. */
  14381. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14382. /**
  14383. * Removes a registered callback function.
  14384. * @param func callback function to remove
  14385. * @returns the TransformNode.
  14386. */
  14387. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14388. /**
  14389. * Gets the position of the current mesh in camera space
  14390. * @param camera defines the camera to use
  14391. * @returns a position
  14392. */
  14393. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14394. /**
  14395. * Returns the distance from the mesh to the active camera
  14396. * @param camera defines the camera to use
  14397. * @returns the distance
  14398. */
  14399. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14400. /**
  14401. * Clone the current transform node
  14402. * @param name Name of the new clone
  14403. * @param newParent New parent for the clone
  14404. * @param doNotCloneChildren Do not clone children hierarchy
  14405. * @returns the new transform node
  14406. */
  14407. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14408. /**
  14409. * Serializes the objects information.
  14410. * @param currentSerializationObject defines the object to serialize in
  14411. * @returns the serialized object
  14412. */
  14413. serialize(currentSerializationObject?: any): any;
  14414. /**
  14415. * Returns a new TransformNode object parsed from the source provided.
  14416. * @param parsedTransformNode is the source.
  14417. * @param scene the scne the object belongs to
  14418. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14419. * @returns a new TransformNode object parsed from the source provided.
  14420. */
  14421. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14422. /**
  14423. * Get all child-transformNodes of this node
  14424. * @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
  14425. * @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
  14426. * @returns an array of TransformNode
  14427. */
  14428. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14429. /**
  14430. * Releases resources associated with this transform node.
  14431. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14432. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14433. */
  14434. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14435. /**
  14436. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14437. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14438. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14439. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14440. * @returns the current mesh
  14441. */
  14442. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14443. private _syncAbsoluteScalingAndRotation;
  14444. }
  14445. }
  14446. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14447. import { Observable } from "babylonjs/Misc/observable";
  14448. import { Nullable } from "babylonjs/types";
  14449. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14450. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14452. import { Ray } from "babylonjs/Culling/ray";
  14453. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14454. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14455. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14456. /**
  14457. * Defines the types of pose enabled controllers that are supported
  14458. */
  14459. export enum PoseEnabledControllerType {
  14460. /**
  14461. * HTC Vive
  14462. */
  14463. VIVE = 0,
  14464. /**
  14465. * Oculus Rift
  14466. */
  14467. OCULUS = 1,
  14468. /**
  14469. * Windows mixed reality
  14470. */
  14471. WINDOWS = 2,
  14472. /**
  14473. * Samsung gear VR
  14474. */
  14475. GEAR_VR = 3,
  14476. /**
  14477. * Google Daydream
  14478. */
  14479. DAYDREAM = 4,
  14480. /**
  14481. * Generic
  14482. */
  14483. GENERIC = 5
  14484. }
  14485. /**
  14486. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14487. */
  14488. export interface MutableGamepadButton {
  14489. /**
  14490. * Value of the button/trigger
  14491. */
  14492. value: number;
  14493. /**
  14494. * If the button/trigger is currently touched
  14495. */
  14496. touched: boolean;
  14497. /**
  14498. * If the button/trigger is currently pressed
  14499. */
  14500. pressed: boolean;
  14501. }
  14502. /**
  14503. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14504. * @hidden
  14505. */
  14506. export interface ExtendedGamepadButton extends GamepadButton {
  14507. /**
  14508. * If the button/trigger is currently pressed
  14509. */
  14510. readonly pressed: boolean;
  14511. /**
  14512. * If the button/trigger is currently touched
  14513. */
  14514. readonly touched: boolean;
  14515. /**
  14516. * Value of the button/trigger
  14517. */
  14518. readonly value: number;
  14519. }
  14520. /** @hidden */
  14521. export interface _GamePadFactory {
  14522. /**
  14523. * Returns wether or not the current gamepad can be created for this type of controller.
  14524. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14525. * @returns true if it can be created, otherwise false
  14526. */
  14527. canCreate(gamepadInfo: any): boolean;
  14528. /**
  14529. * Creates a new instance of the Gamepad.
  14530. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14531. * @returns the new gamepad instance
  14532. */
  14533. create(gamepadInfo: any): Gamepad;
  14534. }
  14535. /**
  14536. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14537. */
  14538. export class PoseEnabledControllerHelper {
  14539. /** @hidden */
  14540. static _ControllerFactories: _GamePadFactory[];
  14541. /** @hidden */
  14542. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14543. /**
  14544. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14545. * @param vrGamepad the gamepad to initialized
  14546. * @returns a vr controller of the type the gamepad identified as
  14547. */
  14548. static InitiateController(vrGamepad: any): Gamepad;
  14549. }
  14550. /**
  14551. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14552. */
  14553. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14554. /**
  14555. * If the controller is used in a webXR session
  14556. */
  14557. isXR: boolean;
  14558. private _deviceRoomPosition;
  14559. private _deviceRoomRotationQuaternion;
  14560. /**
  14561. * The device position in babylon space
  14562. */
  14563. devicePosition: Vector3;
  14564. /**
  14565. * The device rotation in babylon space
  14566. */
  14567. deviceRotationQuaternion: Quaternion;
  14568. /**
  14569. * The scale factor of the device in babylon space
  14570. */
  14571. deviceScaleFactor: number;
  14572. /**
  14573. * (Likely devicePosition should be used instead) The device position in its room space
  14574. */
  14575. position: Vector3;
  14576. /**
  14577. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14578. */
  14579. rotationQuaternion: Quaternion;
  14580. /**
  14581. * The type of controller (Eg. Windows mixed reality)
  14582. */
  14583. controllerType: PoseEnabledControllerType;
  14584. protected _calculatedPosition: Vector3;
  14585. private _calculatedRotation;
  14586. /**
  14587. * The raw pose from the device
  14588. */
  14589. rawPose: DevicePose;
  14590. private _trackPosition;
  14591. private _maxRotationDistFromHeadset;
  14592. private _draggedRoomRotation;
  14593. /**
  14594. * @hidden
  14595. */
  14596. _disableTrackPosition(fixedPosition: Vector3): void;
  14597. /**
  14598. * Internal, the mesh attached to the controller
  14599. * @hidden
  14600. */
  14601. _mesh: Nullable<AbstractMesh>;
  14602. private _poseControlledCamera;
  14603. private _leftHandSystemQuaternion;
  14604. /**
  14605. * Internal, matrix used to convert room space to babylon space
  14606. * @hidden
  14607. */
  14608. _deviceToWorld: Matrix;
  14609. /**
  14610. * Node to be used when casting a ray from the controller
  14611. * @hidden
  14612. */
  14613. _pointingPoseNode: Nullable<TransformNode>;
  14614. /**
  14615. * Name of the child mesh that can be used to cast a ray from the controller
  14616. */
  14617. static readonly POINTING_POSE: string;
  14618. /**
  14619. * Creates a new PoseEnabledController from a gamepad
  14620. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14621. */
  14622. constructor(browserGamepad: any);
  14623. private _workingMatrix;
  14624. /**
  14625. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14626. */
  14627. update(): void;
  14628. /**
  14629. * Updates only the pose device and mesh without doing any button event checking
  14630. */
  14631. protected _updatePoseAndMesh(): void;
  14632. /**
  14633. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14634. * @param poseData raw pose fromthe device
  14635. */
  14636. updateFromDevice(poseData: DevicePose): void;
  14637. /**
  14638. * @hidden
  14639. */
  14640. _meshAttachedObservable: Observable<AbstractMesh>;
  14641. /**
  14642. * Attaches a mesh to the controller
  14643. * @param mesh the mesh to be attached
  14644. */
  14645. attachToMesh(mesh: AbstractMesh): void;
  14646. /**
  14647. * Attaches the controllers mesh to a camera
  14648. * @param camera the camera the mesh should be attached to
  14649. */
  14650. attachToPoseControlledCamera(camera: TargetCamera): void;
  14651. /**
  14652. * Disposes of the controller
  14653. */
  14654. dispose(): void;
  14655. /**
  14656. * The mesh that is attached to the controller
  14657. */
  14658. readonly mesh: Nullable<AbstractMesh>;
  14659. /**
  14660. * Gets the ray of the controller in the direction the controller is pointing
  14661. * @param length the length the resulting ray should be
  14662. * @returns a ray in the direction the controller is pointing
  14663. */
  14664. getForwardRay(length?: number): Ray;
  14665. }
  14666. }
  14667. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14668. import { Observable } from "babylonjs/Misc/observable";
  14669. import { Scene } from "babylonjs/scene";
  14670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14671. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14672. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14673. /**
  14674. * Defines the WebVRController object that represents controllers tracked in 3D space
  14675. */
  14676. export abstract class WebVRController extends PoseEnabledController {
  14677. /**
  14678. * Internal, the default controller model for the controller
  14679. */
  14680. protected _defaultModel: AbstractMesh;
  14681. /**
  14682. * Fired when the trigger state has changed
  14683. */
  14684. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14685. /**
  14686. * Fired when the main button state has changed
  14687. */
  14688. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14689. /**
  14690. * Fired when the secondary button state has changed
  14691. */
  14692. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14693. /**
  14694. * Fired when the pad state has changed
  14695. */
  14696. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14697. /**
  14698. * Fired when controllers stick values have changed
  14699. */
  14700. onPadValuesChangedObservable: Observable<StickValues>;
  14701. /**
  14702. * Array of button availible on the controller
  14703. */
  14704. protected _buttons: Array<MutableGamepadButton>;
  14705. private _onButtonStateChange;
  14706. /**
  14707. * Fired when a controller button's state has changed
  14708. * @param callback the callback containing the button that was modified
  14709. */
  14710. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14711. /**
  14712. * X and Y axis corresponding to the controllers joystick
  14713. */
  14714. pad: StickValues;
  14715. /**
  14716. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14717. */
  14718. hand: string;
  14719. /**
  14720. * The default controller model for the controller
  14721. */
  14722. readonly defaultModel: AbstractMesh;
  14723. /**
  14724. * Creates a new WebVRController from a gamepad
  14725. * @param vrGamepad the gamepad that the WebVRController should be created from
  14726. */
  14727. constructor(vrGamepad: any);
  14728. /**
  14729. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14730. */
  14731. update(): void;
  14732. /**
  14733. * Function to be called when a button is modified
  14734. */
  14735. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14736. /**
  14737. * Loads a mesh and attaches it to the controller
  14738. * @param scene the scene the mesh should be added to
  14739. * @param meshLoaded callback for when the mesh has been loaded
  14740. */
  14741. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14742. private _setButtonValue;
  14743. private _changes;
  14744. private _checkChanges;
  14745. /**
  14746. * Disposes of th webVRCOntroller
  14747. */
  14748. dispose(): void;
  14749. }
  14750. }
  14751. declare module "babylonjs/Lights/hemisphericLight" {
  14752. import { Nullable } from "babylonjs/types";
  14753. import { Scene } from "babylonjs/scene";
  14754. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14755. import { Color3 } from "babylonjs/Maths/math.color";
  14756. import { Effect } from "babylonjs/Materials/effect";
  14757. import { Light } from "babylonjs/Lights/light";
  14758. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14759. /**
  14760. * The HemisphericLight simulates the ambient environment light,
  14761. * so the passed direction is the light reflection direction, not the incoming direction.
  14762. */
  14763. export class HemisphericLight extends Light {
  14764. /**
  14765. * The groundColor is the light in the opposite direction to the one specified during creation.
  14766. * 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.
  14767. */
  14768. groundColor: Color3;
  14769. /**
  14770. * The light reflection direction, not the incoming direction.
  14771. */
  14772. direction: Vector3;
  14773. /**
  14774. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14775. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14776. * The HemisphericLight can't cast shadows.
  14777. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14778. * @param name The friendly name of the light
  14779. * @param direction The direction of the light reflection
  14780. * @param scene The scene the light belongs to
  14781. */
  14782. constructor(name: string, direction: Vector3, scene: Scene);
  14783. protected _buildUniformLayout(): void;
  14784. /**
  14785. * Returns the string "HemisphericLight".
  14786. * @return The class name
  14787. */
  14788. getClassName(): string;
  14789. /**
  14790. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14791. * Returns the updated direction.
  14792. * @param target The target the direction should point to
  14793. * @return The computed direction
  14794. */
  14795. setDirectionToTarget(target: Vector3): Vector3;
  14796. /**
  14797. * Returns the shadow generator associated to the light.
  14798. * @returns Always null for hemispheric lights because it does not support shadows.
  14799. */
  14800. getShadowGenerator(): Nullable<IShadowGenerator>;
  14801. /**
  14802. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14803. * @param effect The effect to update
  14804. * @param lightIndex The index of the light in the effect to update
  14805. * @returns The hemispheric light
  14806. */
  14807. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14808. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14809. /**
  14810. * Computes the world matrix of the node
  14811. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14812. * @param useWasUpdatedFlag defines a reserved property
  14813. * @returns the world matrix
  14814. */
  14815. computeWorldMatrix(): Matrix;
  14816. /**
  14817. * Returns the integer 3.
  14818. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14819. */
  14820. getTypeID(): number;
  14821. /**
  14822. * Prepares the list of defines specific to the light type.
  14823. * @param defines the list of defines
  14824. * @param lightIndex defines the index of the light for the effect
  14825. */
  14826. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14827. }
  14828. }
  14829. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14830. /** @hidden */
  14831. export var vrMultiviewToSingleviewPixelShader: {
  14832. name: string;
  14833. shader: string;
  14834. };
  14835. }
  14836. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14838. import { Scene } from "babylonjs/scene";
  14839. /**
  14840. * Renders to multiple views with a single draw call
  14841. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14842. */
  14843. export class MultiviewRenderTarget extends RenderTargetTexture {
  14844. /**
  14845. * Creates a multiview render target
  14846. * @param scene scene used with the render target
  14847. * @param size the size of the render target (used for each view)
  14848. */
  14849. constructor(scene: Scene, size?: number | {
  14850. width: number;
  14851. height: number;
  14852. } | {
  14853. ratio: number;
  14854. });
  14855. /**
  14856. * @hidden
  14857. * @param faceIndex the face index, if its a cube texture
  14858. */
  14859. _bindFrameBuffer(faceIndex?: number): void;
  14860. /**
  14861. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14862. * @returns the view count
  14863. */
  14864. getViewCount(): number;
  14865. }
  14866. }
  14867. declare module "babylonjs/Maths/math.frustum" {
  14868. import { Matrix } from "babylonjs/Maths/math.vector";
  14869. import { DeepImmutable } from "babylonjs/types";
  14870. import { Plane } from "babylonjs/Maths/math.plane";
  14871. /**
  14872. * Represents a camera frustum
  14873. */
  14874. export class Frustum {
  14875. /**
  14876. * Gets the planes representing the frustum
  14877. * @param transform matrix to be applied to the returned planes
  14878. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14879. */
  14880. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14881. /**
  14882. * Gets the near frustum plane transformed by the transform matrix
  14883. * @param transform transformation matrix to be applied to the resulting frustum plane
  14884. * @param frustumPlane the resuling frustum plane
  14885. */
  14886. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14887. /**
  14888. * Gets the far frustum plane transformed by the transform matrix
  14889. * @param transform transformation matrix to be applied to the resulting frustum plane
  14890. * @param frustumPlane the resuling frustum plane
  14891. */
  14892. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14893. /**
  14894. * Gets the left frustum plane transformed by the transform matrix
  14895. * @param transform transformation matrix to be applied to the resulting frustum plane
  14896. * @param frustumPlane the resuling frustum plane
  14897. */
  14898. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14899. /**
  14900. * Gets the right frustum plane transformed by the transform matrix
  14901. * @param transform transformation matrix to be applied to the resulting frustum plane
  14902. * @param frustumPlane the resuling frustum plane
  14903. */
  14904. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14905. /**
  14906. * Gets the top frustum plane transformed by the transform matrix
  14907. * @param transform transformation matrix to be applied to the resulting frustum plane
  14908. * @param frustumPlane the resuling frustum plane
  14909. */
  14910. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14911. /**
  14912. * Gets the bottom frustum plane transformed by the transform matrix
  14913. * @param transform transformation matrix to be applied to the resulting frustum plane
  14914. * @param frustumPlane the resuling frustum plane
  14915. */
  14916. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14917. /**
  14918. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14919. * @param transform transformation matrix to be applied to the resulting frustum planes
  14920. * @param frustumPlanes the resuling frustum planes
  14921. */
  14922. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14923. }
  14924. }
  14925. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14926. import { Camera } from "babylonjs/Cameras/camera";
  14927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14928. import { Nullable } from "babylonjs/types";
  14929. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14930. import { Matrix } from "babylonjs/Maths/math.vector";
  14931. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14932. module "babylonjs/Engines/engine" {
  14933. interface Engine {
  14934. /**
  14935. * Creates a new multiview render target
  14936. * @param width defines the width of the texture
  14937. * @param height defines the height of the texture
  14938. * @returns the created multiview texture
  14939. */
  14940. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14941. /**
  14942. * Binds a multiview framebuffer to be drawn to
  14943. * @param multiviewTexture texture to bind
  14944. */
  14945. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14946. }
  14947. }
  14948. module "babylonjs/Cameras/camera" {
  14949. interface Camera {
  14950. /**
  14951. * @hidden
  14952. * 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)
  14953. */
  14954. _useMultiviewToSingleView: boolean;
  14955. /**
  14956. * @hidden
  14957. * 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)
  14958. */
  14959. _multiviewTexture: Nullable<RenderTargetTexture>;
  14960. /**
  14961. * @hidden
  14962. * ensures the multiview texture of the camera exists and has the specified width/height
  14963. * @param width height to set on the multiview texture
  14964. * @param height width to set on the multiview texture
  14965. */
  14966. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14967. }
  14968. }
  14969. module "babylonjs/scene" {
  14970. interface Scene {
  14971. /** @hidden */
  14972. _transformMatrixR: Matrix;
  14973. /** @hidden */
  14974. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14975. /** @hidden */
  14976. _createMultiviewUbo(): void;
  14977. /** @hidden */
  14978. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14979. /** @hidden */
  14980. _renderMultiviewToSingleView(camera: Camera): void;
  14981. }
  14982. }
  14983. }
  14984. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14985. import { Camera } from "babylonjs/Cameras/camera";
  14986. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14987. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14988. import "babylonjs/Engines/Extensions/engine.multiview";
  14989. /**
  14990. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14991. * This will not be used for webXR as it supports displaying texture arrays directly
  14992. */
  14993. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14994. /**
  14995. * Initializes a VRMultiviewToSingleview
  14996. * @param name name of the post process
  14997. * @param camera camera to be applied to
  14998. * @param scaleFactor scaling factor to the size of the output texture
  14999. */
  15000. constructor(name: string, camera: Camera, scaleFactor: number);
  15001. }
  15002. }
  15003. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15004. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15005. import { Nullable } from "babylonjs/types";
  15006. import { Size } from "babylonjs/Maths/math.size";
  15007. import { Observable } from "babylonjs/Misc/observable";
  15008. module "babylonjs/Engines/engine" {
  15009. interface Engine {
  15010. /** @hidden */
  15011. _vrDisplay: any;
  15012. /** @hidden */
  15013. _vrSupported: boolean;
  15014. /** @hidden */
  15015. _oldSize: Size;
  15016. /** @hidden */
  15017. _oldHardwareScaleFactor: number;
  15018. /** @hidden */
  15019. _vrExclusivePointerMode: boolean;
  15020. /** @hidden */
  15021. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15022. /** @hidden */
  15023. _onVRDisplayPointerRestricted: () => void;
  15024. /** @hidden */
  15025. _onVRDisplayPointerUnrestricted: () => void;
  15026. /** @hidden */
  15027. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15028. /** @hidden */
  15029. _onVrDisplayDisconnect: Nullable<() => void>;
  15030. /** @hidden */
  15031. _onVrDisplayPresentChange: Nullable<() => void>;
  15032. /**
  15033. * Observable signaled when VR display mode changes
  15034. */
  15035. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15036. /**
  15037. * Observable signaled when VR request present is complete
  15038. */
  15039. onVRRequestPresentComplete: Observable<boolean>;
  15040. /**
  15041. * Observable signaled when VR request present starts
  15042. */
  15043. onVRRequestPresentStart: Observable<Engine>;
  15044. /**
  15045. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15046. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15047. */
  15048. isInVRExclusivePointerMode: boolean;
  15049. /**
  15050. * Gets a boolean indicating if a webVR device was detected
  15051. * @returns true if a webVR device was detected
  15052. */
  15053. isVRDevicePresent(): boolean;
  15054. /**
  15055. * Gets the current webVR device
  15056. * @returns the current webVR device (or null)
  15057. */
  15058. getVRDevice(): any;
  15059. /**
  15060. * Initializes a webVR display and starts listening to display change events
  15061. * The onVRDisplayChangedObservable will be notified upon these changes
  15062. * @returns A promise containing a VRDisplay and if vr is supported
  15063. */
  15064. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15065. /** @hidden */
  15066. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15067. /**
  15068. * Call this function to switch to webVR mode
  15069. * Will do nothing if webVR is not supported or if there is no webVR device
  15070. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15071. */
  15072. enableVR(): void;
  15073. /** @hidden */
  15074. _onVRFullScreenTriggered(): void;
  15075. }
  15076. }
  15077. }
  15078. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15079. import { Nullable } from "babylonjs/types";
  15080. import { Observable } from "babylonjs/Misc/observable";
  15081. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15082. import { Scene } from "babylonjs/scene";
  15083. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15084. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15085. import { Node } from "babylonjs/node";
  15086. import { Ray } from "babylonjs/Culling/ray";
  15087. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15088. import "babylonjs/Engines/Extensions/engine.webVR";
  15089. /**
  15090. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15091. * IMPORTANT!! The data is right-hand data.
  15092. * @export
  15093. * @interface DevicePose
  15094. */
  15095. export interface DevicePose {
  15096. /**
  15097. * The position of the device, values in array are [x,y,z].
  15098. */
  15099. readonly position: Nullable<Float32Array>;
  15100. /**
  15101. * The linearVelocity of the device, values in array are [x,y,z].
  15102. */
  15103. readonly linearVelocity: Nullable<Float32Array>;
  15104. /**
  15105. * The linearAcceleration of the device, values in array are [x,y,z].
  15106. */
  15107. readonly linearAcceleration: Nullable<Float32Array>;
  15108. /**
  15109. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15110. */
  15111. readonly orientation: Nullable<Float32Array>;
  15112. /**
  15113. * The angularVelocity of the device, values in array are [x,y,z].
  15114. */
  15115. readonly angularVelocity: Nullable<Float32Array>;
  15116. /**
  15117. * The angularAcceleration of the device, values in array are [x,y,z].
  15118. */
  15119. readonly angularAcceleration: Nullable<Float32Array>;
  15120. }
  15121. /**
  15122. * Interface representing a pose controlled object in Babylon.
  15123. * A pose controlled object has both regular pose values as well as pose values
  15124. * from an external device such as a VR head mounted display
  15125. */
  15126. export interface PoseControlled {
  15127. /**
  15128. * The position of the object in babylon space.
  15129. */
  15130. position: Vector3;
  15131. /**
  15132. * The rotation quaternion of the object in babylon space.
  15133. */
  15134. rotationQuaternion: Quaternion;
  15135. /**
  15136. * The position of the device in babylon space.
  15137. */
  15138. devicePosition?: Vector3;
  15139. /**
  15140. * The rotation quaternion of the device in babylon space.
  15141. */
  15142. deviceRotationQuaternion: Quaternion;
  15143. /**
  15144. * The raw pose coming from the device.
  15145. */
  15146. rawPose: Nullable<DevicePose>;
  15147. /**
  15148. * The scale of the device to be used when translating from device space to babylon space.
  15149. */
  15150. deviceScaleFactor: number;
  15151. /**
  15152. * Updates the poseControlled values based on the input device pose.
  15153. * @param poseData the pose data to update the object with
  15154. */
  15155. updateFromDevice(poseData: DevicePose): void;
  15156. }
  15157. /**
  15158. * Set of options to customize the webVRCamera
  15159. */
  15160. export interface WebVROptions {
  15161. /**
  15162. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15163. */
  15164. trackPosition?: boolean;
  15165. /**
  15166. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15167. */
  15168. positionScale?: number;
  15169. /**
  15170. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15171. */
  15172. displayName?: string;
  15173. /**
  15174. * Should the native controller meshes be initialized. (default: true)
  15175. */
  15176. controllerMeshes?: boolean;
  15177. /**
  15178. * Creating a default HemiLight only on controllers. (default: true)
  15179. */
  15180. defaultLightingOnControllers?: boolean;
  15181. /**
  15182. * If you don't want to use the default VR button of the helper. (default: false)
  15183. */
  15184. useCustomVRButton?: boolean;
  15185. /**
  15186. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15187. */
  15188. customVRButton?: HTMLButtonElement;
  15189. /**
  15190. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15191. */
  15192. rayLength?: number;
  15193. /**
  15194. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15195. */
  15196. defaultHeight?: number;
  15197. /**
  15198. * If multiview should be used if availible (default: false)
  15199. */
  15200. useMultiview?: boolean;
  15201. }
  15202. /**
  15203. * This represents a WebVR camera.
  15204. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15205. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15206. */
  15207. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15208. private webVROptions;
  15209. /**
  15210. * @hidden
  15211. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15212. */
  15213. _vrDevice: any;
  15214. /**
  15215. * The rawPose of the vrDevice.
  15216. */
  15217. rawPose: Nullable<DevicePose>;
  15218. private _onVREnabled;
  15219. private _specsVersion;
  15220. private _attached;
  15221. private _frameData;
  15222. protected _descendants: Array<Node>;
  15223. private _deviceRoomPosition;
  15224. /** @hidden */
  15225. _deviceRoomRotationQuaternion: Quaternion;
  15226. private _standingMatrix;
  15227. /**
  15228. * Represents device position in babylon space.
  15229. */
  15230. devicePosition: Vector3;
  15231. /**
  15232. * Represents device rotation in babylon space.
  15233. */
  15234. deviceRotationQuaternion: Quaternion;
  15235. /**
  15236. * The scale of the device to be used when translating from device space to babylon space.
  15237. */
  15238. deviceScaleFactor: number;
  15239. private _deviceToWorld;
  15240. private _worldToDevice;
  15241. /**
  15242. * References to the webVR controllers for the vrDevice.
  15243. */
  15244. controllers: Array<WebVRController>;
  15245. /**
  15246. * Emits an event when a controller is attached.
  15247. */
  15248. onControllersAttachedObservable: Observable<WebVRController[]>;
  15249. /**
  15250. * Emits an event when a controller's mesh has been loaded;
  15251. */
  15252. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15253. /**
  15254. * Emits an event when the HMD's pose has been updated.
  15255. */
  15256. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15257. private _poseSet;
  15258. /**
  15259. * If the rig cameras be used as parent instead of this camera.
  15260. */
  15261. rigParenting: boolean;
  15262. private _lightOnControllers;
  15263. private _defaultHeight?;
  15264. /**
  15265. * Instantiates a WebVRFreeCamera.
  15266. * @param name The name of the WebVRFreeCamera
  15267. * @param position The starting anchor position for the camera
  15268. * @param scene The scene the camera belongs to
  15269. * @param webVROptions a set of customizable options for the webVRCamera
  15270. */
  15271. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15272. /**
  15273. * Gets the device distance from the ground in meters.
  15274. * @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.
  15275. */
  15276. deviceDistanceToRoomGround(): number;
  15277. /**
  15278. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15279. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15280. */
  15281. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15282. /**
  15283. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15284. * @returns A promise with a boolean set to if the standing matrix is supported.
  15285. */
  15286. useStandingMatrixAsync(): Promise<boolean>;
  15287. /**
  15288. * Disposes the camera
  15289. */
  15290. dispose(): void;
  15291. /**
  15292. * Gets a vrController by name.
  15293. * @param name The name of the controller to retreive
  15294. * @returns the controller matching the name specified or null if not found
  15295. */
  15296. getControllerByName(name: string): Nullable<WebVRController>;
  15297. private _leftController;
  15298. /**
  15299. * The controller corresponding to the users left hand.
  15300. */
  15301. readonly leftController: Nullable<WebVRController>;
  15302. private _rightController;
  15303. /**
  15304. * The controller corresponding to the users right hand.
  15305. */
  15306. readonly rightController: Nullable<WebVRController>;
  15307. /**
  15308. * Casts a ray forward from the vrCamera's gaze.
  15309. * @param length Length of the ray (default: 100)
  15310. * @returns the ray corresponding to the gaze
  15311. */
  15312. getForwardRay(length?: number): Ray;
  15313. /**
  15314. * @hidden
  15315. * Updates the camera based on device's frame data
  15316. */
  15317. _checkInputs(): void;
  15318. /**
  15319. * Updates the poseControlled values based on the input device pose.
  15320. * @param poseData Pose coming from the device
  15321. */
  15322. updateFromDevice(poseData: DevicePose): void;
  15323. private _htmlElementAttached;
  15324. private _detachIfAttached;
  15325. /**
  15326. * WebVR's attach control will start broadcasting frames to the device.
  15327. * Note that in certain browsers (chrome for example) this function must be called
  15328. * within a user-interaction callback. Example:
  15329. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15330. *
  15331. * @param element html element to attach the vrDevice to
  15332. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15333. */
  15334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15335. /**
  15336. * Detaches the camera from the html element and disables VR
  15337. *
  15338. * @param element html element to detach from
  15339. */
  15340. detachControl(element: HTMLElement): void;
  15341. /**
  15342. * @returns the name of this class
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Calls resetPose on the vrDisplay
  15347. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15348. */
  15349. resetToCurrentRotation(): void;
  15350. /**
  15351. * @hidden
  15352. * Updates the rig cameras (left and right eye)
  15353. */
  15354. _updateRigCameras(): void;
  15355. private _workingVector;
  15356. private _oneVector;
  15357. private _workingMatrix;
  15358. private updateCacheCalled;
  15359. private _correctPositionIfNotTrackPosition;
  15360. /**
  15361. * @hidden
  15362. * Updates the cached values of the camera
  15363. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15364. */
  15365. _updateCache(ignoreParentClass?: boolean): void;
  15366. /**
  15367. * @hidden
  15368. * Get current device position in babylon world
  15369. */
  15370. _computeDevicePosition(): void;
  15371. /**
  15372. * Updates the current device position and rotation in the babylon world
  15373. */
  15374. update(): void;
  15375. /**
  15376. * @hidden
  15377. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15378. * @returns an identity matrix
  15379. */
  15380. _getViewMatrix(): Matrix;
  15381. private _tmpMatrix;
  15382. /**
  15383. * This function is called by the two RIG cameras.
  15384. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15385. * @hidden
  15386. */
  15387. _getWebVRViewMatrix(): Matrix;
  15388. /** @hidden */
  15389. _getWebVRProjectionMatrix(): Matrix;
  15390. private _onGamepadConnectedObserver;
  15391. private _onGamepadDisconnectedObserver;
  15392. private _updateCacheWhenTrackingDisabledObserver;
  15393. /**
  15394. * Initializes the controllers and their meshes
  15395. */
  15396. initControllers(): void;
  15397. }
  15398. }
  15399. declare module "babylonjs/PostProcesses/postProcess" {
  15400. import { Nullable } from "babylonjs/types";
  15401. import { SmartArray } from "babylonjs/Misc/smartArray";
  15402. import { Observable } from "babylonjs/Misc/observable";
  15403. import { Vector2 } from "babylonjs/Maths/math.vector";
  15404. import { Camera } from "babylonjs/Cameras/camera";
  15405. import { Effect } from "babylonjs/Materials/effect";
  15406. import "babylonjs/Shaders/postprocess.vertex";
  15407. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15408. import { Engine } from "babylonjs/Engines/engine";
  15409. import { Color4 } from "babylonjs/Maths/math.color";
  15410. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15411. /**
  15412. * Size options for a post process
  15413. */
  15414. export type PostProcessOptions = {
  15415. width: number;
  15416. height: number;
  15417. };
  15418. /**
  15419. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15420. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15421. */
  15422. export class PostProcess {
  15423. /** Name of the PostProcess. */
  15424. name: string;
  15425. /**
  15426. * Gets or sets the unique id of the post process
  15427. */
  15428. uniqueId: number;
  15429. /**
  15430. * Width of the texture to apply the post process on
  15431. */
  15432. width: number;
  15433. /**
  15434. * Height of the texture to apply the post process on
  15435. */
  15436. height: number;
  15437. /**
  15438. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15439. * @hidden
  15440. */
  15441. _outputTexture: Nullable<InternalTexture>;
  15442. /**
  15443. * Sampling mode used by the shader
  15444. * See https://doc.babylonjs.com/classes/3.1/texture
  15445. */
  15446. renderTargetSamplingMode: number;
  15447. /**
  15448. * Clear color to use when screen clearing
  15449. */
  15450. clearColor: Color4;
  15451. /**
  15452. * If the buffer needs to be cleared before applying the post process. (default: true)
  15453. * Should be set to false if shader will overwrite all previous pixels.
  15454. */
  15455. autoClear: boolean;
  15456. /**
  15457. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15458. */
  15459. alphaMode: number;
  15460. /**
  15461. * Sets the setAlphaBlendConstants of the babylon engine
  15462. */
  15463. alphaConstants: Color4;
  15464. /**
  15465. * Animations to be used for the post processing
  15466. */
  15467. animations: import("babylonjs/Animations/animation").Animation[];
  15468. /**
  15469. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15470. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15471. */
  15472. enablePixelPerfectMode: boolean;
  15473. /**
  15474. * Force the postprocess to be applied without taking in account viewport
  15475. */
  15476. forceFullscreenViewport: boolean;
  15477. /**
  15478. * List of inspectable custom properties (used by the Inspector)
  15479. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15480. */
  15481. inspectableCustomProperties: IInspectable[];
  15482. /**
  15483. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15484. *
  15485. * | Value | Type | Description |
  15486. * | ----- | ----------------------------------- | ----------- |
  15487. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15488. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15489. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15490. *
  15491. */
  15492. scaleMode: number;
  15493. /**
  15494. * Force textures to be a power of two (default: false)
  15495. */
  15496. alwaysForcePOT: boolean;
  15497. private _samples;
  15498. /**
  15499. * Number of sample textures (default: 1)
  15500. */
  15501. samples: number;
  15502. /**
  15503. * Modify the scale of the post process to be the same as the viewport (default: false)
  15504. */
  15505. adaptScaleToCurrentViewport: boolean;
  15506. private _camera;
  15507. private _scene;
  15508. private _engine;
  15509. private _options;
  15510. private _reusable;
  15511. private _textureType;
  15512. /**
  15513. * Smart array of input and output textures for the post process.
  15514. * @hidden
  15515. */
  15516. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15517. /**
  15518. * The index in _textures that corresponds to the output texture.
  15519. * @hidden
  15520. */
  15521. _currentRenderTextureInd: number;
  15522. private _effect;
  15523. private _samplers;
  15524. private _fragmentUrl;
  15525. private _vertexUrl;
  15526. private _parameters;
  15527. private _scaleRatio;
  15528. protected _indexParameters: any;
  15529. private _shareOutputWithPostProcess;
  15530. private _texelSize;
  15531. private _forcedOutputTexture;
  15532. /**
  15533. * Returns the fragment url or shader name used in the post process.
  15534. * @returns the fragment url or name in the shader store.
  15535. */
  15536. getEffectName(): string;
  15537. /**
  15538. * An event triggered when the postprocess is activated.
  15539. */
  15540. onActivateObservable: Observable<Camera>;
  15541. private _onActivateObserver;
  15542. /**
  15543. * A function that is added to the onActivateObservable
  15544. */
  15545. onActivate: Nullable<(camera: Camera) => void>;
  15546. /**
  15547. * An event triggered when the postprocess changes its size.
  15548. */
  15549. onSizeChangedObservable: Observable<PostProcess>;
  15550. private _onSizeChangedObserver;
  15551. /**
  15552. * A function that is added to the onSizeChangedObservable
  15553. */
  15554. onSizeChanged: (postProcess: PostProcess) => void;
  15555. /**
  15556. * An event triggered when the postprocess applies its effect.
  15557. */
  15558. onApplyObservable: Observable<Effect>;
  15559. private _onApplyObserver;
  15560. /**
  15561. * A function that is added to the onApplyObservable
  15562. */
  15563. onApply: (effect: Effect) => void;
  15564. /**
  15565. * An event triggered before rendering the postprocess
  15566. */
  15567. onBeforeRenderObservable: Observable<Effect>;
  15568. private _onBeforeRenderObserver;
  15569. /**
  15570. * A function that is added to the onBeforeRenderObservable
  15571. */
  15572. onBeforeRender: (effect: Effect) => void;
  15573. /**
  15574. * An event triggered after rendering the postprocess
  15575. */
  15576. onAfterRenderObservable: Observable<Effect>;
  15577. private _onAfterRenderObserver;
  15578. /**
  15579. * A function that is added to the onAfterRenderObservable
  15580. */
  15581. onAfterRender: (efect: Effect) => void;
  15582. /**
  15583. * 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
  15584. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15585. */
  15586. inputTexture: InternalTexture;
  15587. /**
  15588. * Gets the camera which post process is applied to.
  15589. * @returns The camera the post process is applied to.
  15590. */
  15591. getCamera(): Camera;
  15592. /**
  15593. * Gets the texel size of the postprocess.
  15594. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15595. */
  15596. readonly texelSize: Vector2;
  15597. /**
  15598. * Creates a new instance PostProcess
  15599. * @param name The name of the PostProcess.
  15600. * @param fragmentUrl The url of the fragment shader to be used.
  15601. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15602. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15603. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15604. * @param camera The camera to apply the render pass to.
  15605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15606. * @param engine The engine which the post process will be applied. (default: current engine)
  15607. * @param reusable If the post process can be reused on the same frame. (default: false)
  15608. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15609. * @param textureType Type of textures used when performing the post process. (default: 0)
  15610. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15611. * @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
  15612. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15613. */
  15614. constructor(
  15615. /** Name of the PostProcess. */
  15616. 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);
  15617. /**
  15618. * Gets a string idenfifying the name of the class
  15619. * @returns "PostProcess" string
  15620. */
  15621. getClassName(): string;
  15622. /**
  15623. * Gets the engine which this post process belongs to.
  15624. * @returns The engine the post process was enabled with.
  15625. */
  15626. getEngine(): Engine;
  15627. /**
  15628. * The effect that is created when initializing the post process.
  15629. * @returns The created effect corresponding the the postprocess.
  15630. */
  15631. getEffect(): Effect;
  15632. /**
  15633. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15634. * @param postProcess The post process to share the output with.
  15635. * @returns This post process.
  15636. */
  15637. shareOutputWith(postProcess: PostProcess): PostProcess;
  15638. /**
  15639. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15640. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15641. */
  15642. useOwnOutput(): void;
  15643. /**
  15644. * Updates the effect with the current post process compile time values and recompiles the shader.
  15645. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15646. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15647. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15648. * @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
  15649. * @param onCompiled Called when the shader has been compiled.
  15650. * @param onError Called if there is an error when compiling a shader.
  15651. */
  15652. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15653. /**
  15654. * The post process is reusable if it can be used multiple times within one frame.
  15655. * @returns If the post process is reusable
  15656. */
  15657. isReusable(): boolean;
  15658. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15659. markTextureDirty(): void;
  15660. /**
  15661. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15662. * 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.
  15663. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15664. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15665. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15666. * @returns The target texture that was bound to be written to.
  15667. */
  15668. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15669. /**
  15670. * If the post process is supported.
  15671. */
  15672. readonly isSupported: boolean;
  15673. /**
  15674. * The aspect ratio of the output texture.
  15675. */
  15676. readonly aspectRatio: number;
  15677. /**
  15678. * Get a value indicating if the post-process is ready to be used
  15679. * @returns true if the post-process is ready (shader is compiled)
  15680. */
  15681. isReady(): boolean;
  15682. /**
  15683. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15684. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15685. */
  15686. apply(): Nullable<Effect>;
  15687. private _disposeTextures;
  15688. /**
  15689. * Disposes the post process.
  15690. * @param camera The camera to dispose the post process on.
  15691. */
  15692. dispose(camera?: Camera): void;
  15693. }
  15694. }
  15695. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15696. /** @hidden */
  15697. export var kernelBlurVaryingDeclaration: {
  15698. name: string;
  15699. shader: string;
  15700. };
  15701. }
  15702. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15703. /** @hidden */
  15704. export var kernelBlurFragment: {
  15705. name: string;
  15706. shader: string;
  15707. };
  15708. }
  15709. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15710. /** @hidden */
  15711. export var kernelBlurFragment2: {
  15712. name: string;
  15713. shader: string;
  15714. };
  15715. }
  15716. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15717. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15718. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15719. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15720. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15721. /** @hidden */
  15722. export var kernelBlurPixelShader: {
  15723. name: string;
  15724. shader: string;
  15725. };
  15726. }
  15727. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15728. /** @hidden */
  15729. export var kernelBlurVertex: {
  15730. name: string;
  15731. shader: string;
  15732. };
  15733. }
  15734. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15735. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15736. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15737. /** @hidden */
  15738. export var kernelBlurVertexShader: {
  15739. name: string;
  15740. shader: string;
  15741. };
  15742. }
  15743. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15744. import { Vector2 } from "babylonjs/Maths/math.vector";
  15745. import { Nullable } from "babylonjs/types";
  15746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15747. import { Camera } from "babylonjs/Cameras/camera";
  15748. import { Effect } from "babylonjs/Materials/effect";
  15749. import { Engine } from "babylonjs/Engines/engine";
  15750. import "babylonjs/Shaders/kernelBlur.fragment";
  15751. import "babylonjs/Shaders/kernelBlur.vertex";
  15752. /**
  15753. * The Blur Post Process which blurs an image based on a kernel and direction.
  15754. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15755. */
  15756. export class BlurPostProcess extends PostProcess {
  15757. /** The direction in which to blur the image. */
  15758. direction: Vector2;
  15759. private blockCompilation;
  15760. protected _kernel: number;
  15761. protected _idealKernel: number;
  15762. protected _packedFloat: boolean;
  15763. private _staticDefines;
  15764. /**
  15765. * Sets the length in pixels of the blur sample region
  15766. */
  15767. /**
  15768. * Gets the length in pixels of the blur sample region
  15769. */
  15770. kernel: number;
  15771. /**
  15772. * Sets wether or not the blur needs to unpack/repack floats
  15773. */
  15774. /**
  15775. * Gets wether or not the blur is unpacking/repacking floats
  15776. */
  15777. packedFloat: boolean;
  15778. /**
  15779. * Creates a new instance BlurPostProcess
  15780. * @param name The name of the effect.
  15781. * @param direction The direction in which to blur the image.
  15782. * @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.
  15783. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15784. * @param camera The camera to apply the render pass to.
  15785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15786. * @param engine The engine which the post process will be applied. (default: current engine)
  15787. * @param reusable If the post process can be reused on the same frame. (default: false)
  15788. * @param textureType Type of textures used when performing the post process. (default: 0)
  15789. * @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)
  15790. */
  15791. constructor(name: string,
  15792. /** The direction in which to blur the image. */
  15793. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15794. /**
  15795. * Updates the effect with the current post process compile time values and recompiles the shader.
  15796. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15797. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15798. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15799. * @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
  15800. * @param onCompiled Called when the shader has been compiled.
  15801. * @param onError Called if there is an error when compiling a shader.
  15802. */
  15803. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15804. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15805. /**
  15806. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15807. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15808. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15809. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15810. * The gaps between physical kernels are compensated for in the weighting of the samples
  15811. * @param idealKernel Ideal blur kernel.
  15812. * @return Nearest best kernel.
  15813. */
  15814. protected _nearestBestKernel(idealKernel: number): number;
  15815. /**
  15816. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15817. * @param x The point on the Gaussian distribution to sample.
  15818. * @return the value of the Gaussian function at x.
  15819. */
  15820. protected _gaussianWeight(x: number): number;
  15821. /**
  15822. * Generates a string that can be used as a floating point number in GLSL.
  15823. * @param x Value to print.
  15824. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15825. * @return GLSL float string.
  15826. */
  15827. protected _glslFloat(x: number, decimalFigures?: number): string;
  15828. }
  15829. }
  15830. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15831. import { Scene } from "babylonjs/scene";
  15832. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15833. import { Plane } from "babylonjs/Maths/math.plane";
  15834. /**
  15835. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15836. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15837. * You can then easily use it as a reflectionTexture on a flat surface.
  15838. * In case the surface is not a plane, please consider relying on reflection probes.
  15839. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15840. */
  15841. export class MirrorTexture extends RenderTargetTexture {
  15842. private scene;
  15843. /**
  15844. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15845. * 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.
  15846. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15847. */
  15848. mirrorPlane: Plane;
  15849. /**
  15850. * Define the blur ratio used to blur the reflection if needed.
  15851. */
  15852. blurRatio: number;
  15853. /**
  15854. * Define the adaptive blur kernel used to blur the reflection if needed.
  15855. * This will autocompute the closest best match for the `blurKernel`
  15856. */
  15857. adaptiveBlurKernel: number;
  15858. /**
  15859. * Define the blur kernel used to blur the reflection if needed.
  15860. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15861. */
  15862. blurKernel: number;
  15863. /**
  15864. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15865. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15866. */
  15867. blurKernelX: number;
  15868. /**
  15869. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15870. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15871. */
  15872. blurKernelY: number;
  15873. private _autoComputeBlurKernel;
  15874. protected _onRatioRescale(): void;
  15875. private _updateGammaSpace;
  15876. private _imageProcessingConfigChangeObserver;
  15877. private _transformMatrix;
  15878. private _mirrorMatrix;
  15879. private _savedViewMatrix;
  15880. private _blurX;
  15881. private _blurY;
  15882. private _adaptiveBlurKernel;
  15883. private _blurKernelX;
  15884. private _blurKernelY;
  15885. private _blurRatio;
  15886. /**
  15887. * Instantiates a Mirror Texture.
  15888. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15889. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15890. * You can then easily use it as a reflectionTexture on a flat surface.
  15891. * In case the surface is not a plane, please consider relying on reflection probes.
  15892. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15893. * @param name
  15894. * @param size
  15895. * @param scene
  15896. * @param generateMipMaps
  15897. * @param type
  15898. * @param samplingMode
  15899. * @param generateDepthBuffer
  15900. */
  15901. constructor(name: string, size: number | {
  15902. width: number;
  15903. height: number;
  15904. } | {
  15905. ratio: number;
  15906. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15907. private _preparePostProcesses;
  15908. /**
  15909. * Clone the mirror texture.
  15910. * @returns the cloned texture
  15911. */
  15912. clone(): MirrorTexture;
  15913. /**
  15914. * Serialize the texture to a JSON representation you could use in Parse later on
  15915. * @returns the serialized JSON representation
  15916. */
  15917. serialize(): any;
  15918. /**
  15919. * Dispose the texture and release its associated resources.
  15920. */
  15921. dispose(): void;
  15922. }
  15923. }
  15924. declare module "babylonjs/Materials/Textures/texture" {
  15925. import { Observable } from "babylonjs/Misc/observable";
  15926. import { Nullable } from "babylonjs/types";
  15927. import { Scene } from "babylonjs/scene";
  15928. import { Matrix } from "babylonjs/Maths/math.vector";
  15929. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15930. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15931. import { Engine } from "babylonjs/Engines/engine";
  15932. /**
  15933. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15934. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15935. */
  15936. export class Texture extends BaseTexture {
  15937. /**
  15938. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15939. */
  15940. static SerializeBuffers: boolean;
  15941. /** @hidden */
  15942. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15943. /** @hidden */
  15944. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15945. /** @hidden */
  15946. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15947. /** nearest is mag = nearest and min = nearest and mip = linear */
  15948. static readonly NEAREST_SAMPLINGMODE: number;
  15949. /** nearest is mag = nearest and min = nearest and mip = linear */
  15950. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15951. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15952. static readonly BILINEAR_SAMPLINGMODE: number;
  15953. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15954. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15955. /** Trilinear is mag = linear and min = linear and mip = linear */
  15956. static readonly TRILINEAR_SAMPLINGMODE: number;
  15957. /** Trilinear is mag = linear and min = linear and mip = linear */
  15958. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15959. /** mag = nearest and min = nearest and mip = nearest */
  15960. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15961. /** mag = nearest and min = linear and mip = nearest */
  15962. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15963. /** mag = nearest and min = linear and mip = linear */
  15964. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15965. /** mag = nearest and min = linear and mip = none */
  15966. static readonly NEAREST_LINEAR: number;
  15967. /** mag = nearest and min = nearest and mip = none */
  15968. static readonly NEAREST_NEAREST: number;
  15969. /** mag = linear and min = nearest and mip = nearest */
  15970. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15971. /** mag = linear and min = nearest and mip = linear */
  15972. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15973. /** mag = linear and min = linear and mip = none */
  15974. static readonly LINEAR_LINEAR: number;
  15975. /** mag = linear and min = nearest and mip = none */
  15976. static readonly LINEAR_NEAREST: number;
  15977. /** Explicit coordinates mode */
  15978. static readonly EXPLICIT_MODE: number;
  15979. /** Spherical coordinates mode */
  15980. static readonly SPHERICAL_MODE: number;
  15981. /** Planar coordinates mode */
  15982. static readonly PLANAR_MODE: number;
  15983. /** Cubic coordinates mode */
  15984. static readonly CUBIC_MODE: number;
  15985. /** Projection coordinates mode */
  15986. static readonly PROJECTION_MODE: number;
  15987. /** Inverse Cubic coordinates mode */
  15988. static readonly SKYBOX_MODE: number;
  15989. /** Inverse Cubic coordinates mode */
  15990. static readonly INVCUBIC_MODE: number;
  15991. /** Equirectangular coordinates mode */
  15992. static readonly EQUIRECTANGULAR_MODE: number;
  15993. /** Equirectangular Fixed coordinates mode */
  15994. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15995. /** Equirectangular Fixed Mirrored coordinates mode */
  15996. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15997. /** Texture is not repeating outside of 0..1 UVs */
  15998. static readonly CLAMP_ADDRESSMODE: number;
  15999. /** Texture is repeating outside of 0..1 UVs */
  16000. static readonly WRAP_ADDRESSMODE: number;
  16001. /** Texture is repeating and mirrored */
  16002. static readonly MIRROR_ADDRESSMODE: number;
  16003. /**
  16004. * 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
  16005. */
  16006. static UseSerializedUrlIfAny: boolean;
  16007. /**
  16008. * Define the url of the texture.
  16009. */
  16010. url: Nullable<string>;
  16011. /**
  16012. * Define an offset on the texture to offset the u coordinates of the UVs
  16013. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16014. */
  16015. uOffset: number;
  16016. /**
  16017. * Define an offset on the texture to offset the v coordinates of the UVs
  16018. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16019. */
  16020. vOffset: number;
  16021. /**
  16022. * Define an offset on the texture to scale the u coordinates of the UVs
  16023. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16024. */
  16025. uScale: number;
  16026. /**
  16027. * Define an offset on the texture to scale the v coordinates of the UVs
  16028. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16029. */
  16030. vScale: number;
  16031. /**
  16032. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16033. * @see http://doc.babylonjs.com/how_to/more_materials
  16034. */
  16035. uAng: number;
  16036. /**
  16037. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16038. * @see http://doc.babylonjs.com/how_to/more_materials
  16039. */
  16040. vAng: number;
  16041. /**
  16042. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16043. * @see http://doc.babylonjs.com/how_to/more_materials
  16044. */
  16045. wAng: number;
  16046. /**
  16047. * Defines the center of rotation (U)
  16048. */
  16049. uRotationCenter: number;
  16050. /**
  16051. * Defines the center of rotation (V)
  16052. */
  16053. vRotationCenter: number;
  16054. /**
  16055. * Defines the center of rotation (W)
  16056. */
  16057. wRotationCenter: number;
  16058. /**
  16059. * Are mip maps generated for this texture or not.
  16060. */
  16061. readonly noMipmap: boolean;
  16062. /**
  16063. * List of inspectable custom properties (used by the Inspector)
  16064. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16065. */
  16066. inspectableCustomProperties: Nullable<IInspectable[]>;
  16067. private _noMipmap;
  16068. /** @hidden */
  16069. _invertY: boolean;
  16070. private _rowGenerationMatrix;
  16071. private _cachedTextureMatrix;
  16072. private _projectionModeMatrix;
  16073. private _t0;
  16074. private _t1;
  16075. private _t2;
  16076. private _cachedUOffset;
  16077. private _cachedVOffset;
  16078. private _cachedUScale;
  16079. private _cachedVScale;
  16080. private _cachedUAng;
  16081. private _cachedVAng;
  16082. private _cachedWAng;
  16083. private _cachedProjectionMatrixId;
  16084. private _cachedCoordinatesMode;
  16085. /** @hidden */
  16086. protected _initialSamplingMode: number;
  16087. /** @hidden */
  16088. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16089. private _deleteBuffer;
  16090. protected _format: Nullable<number>;
  16091. private _delayedOnLoad;
  16092. private _delayedOnError;
  16093. /**
  16094. * Observable triggered once the texture has been loaded.
  16095. */
  16096. onLoadObservable: Observable<Texture>;
  16097. protected _isBlocking: boolean;
  16098. /**
  16099. * Is the texture preventing material to render while loading.
  16100. * If false, a default texture will be used instead of the loading one during the preparation step.
  16101. */
  16102. isBlocking: boolean;
  16103. /**
  16104. * Get the current sampling mode associated with the texture.
  16105. */
  16106. readonly samplingMode: number;
  16107. /**
  16108. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16109. */
  16110. readonly invertY: boolean;
  16111. /**
  16112. * Instantiates a new texture.
  16113. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16114. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16115. * @param url define the url of the picture to load as a texture
  16116. * @param scene define the scene or engine the texture will belong to
  16117. * @param noMipmap define if the texture will require mip maps or not
  16118. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16119. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16120. * @param onLoad define a callback triggered when the texture has been loaded
  16121. * @param onError define a callback triggered when an error occurred during the loading session
  16122. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16123. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16124. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16125. */
  16126. 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);
  16127. /**
  16128. * Update the url (and optional buffer) of this texture if url was null during construction.
  16129. * @param url the url of the texture
  16130. * @param buffer the buffer of the texture (defaults to null)
  16131. * @param onLoad callback called when the texture is loaded (defaults to null)
  16132. */
  16133. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16134. /**
  16135. * Finish the loading sequence of a texture flagged as delayed load.
  16136. * @hidden
  16137. */
  16138. delayLoad(): void;
  16139. private _prepareRowForTextureGeneration;
  16140. /**
  16141. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16142. * @returns the transform matrix of the texture.
  16143. */
  16144. getTextureMatrix(): Matrix;
  16145. /**
  16146. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16147. * @returns The reflection texture transform
  16148. */
  16149. getReflectionTextureMatrix(): Matrix;
  16150. /**
  16151. * Clones the texture.
  16152. * @returns the cloned texture
  16153. */
  16154. clone(): Texture;
  16155. /**
  16156. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16157. * @returns The JSON representation of the texture
  16158. */
  16159. serialize(): any;
  16160. /**
  16161. * Get the current class name of the texture useful for serialization or dynamic coding.
  16162. * @returns "Texture"
  16163. */
  16164. getClassName(): string;
  16165. /**
  16166. * Dispose the texture and release its associated resources.
  16167. */
  16168. dispose(): void;
  16169. /**
  16170. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16171. * @param parsedTexture Define the JSON representation of the texture
  16172. * @param scene Define the scene the parsed texture should be instantiated in
  16173. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16174. * @returns The parsed texture if successful
  16175. */
  16176. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16177. /**
  16178. * Creates a texture from its base 64 representation.
  16179. * @param data Define the base64 payload without the data: prefix
  16180. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16181. * @param scene Define the scene the texture should belong to
  16182. * @param noMipmap Forces the texture to not create mip map information if true
  16183. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16184. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16185. * @param onLoad define a callback triggered when the texture has been loaded
  16186. * @param onError define a callback triggered when an error occurred during the loading session
  16187. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16188. * @returns the created texture
  16189. */
  16190. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16191. /**
  16192. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16193. * @param data Define the base64 payload without the data: prefix
  16194. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16195. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16196. * @param scene Define the scene the texture should belong to
  16197. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16198. * @param noMipmap Forces the texture to not create mip map information if true
  16199. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16200. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16201. * @param onLoad define a callback triggered when the texture has been loaded
  16202. * @param onError define a callback triggered when an error occurred during the loading session
  16203. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16204. * @returns the created texture
  16205. */
  16206. 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;
  16207. }
  16208. }
  16209. declare module "babylonjs/PostProcesses/postProcessManager" {
  16210. import { Nullable } from "babylonjs/types";
  16211. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16212. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16213. import { Scene } from "babylonjs/scene";
  16214. /**
  16215. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16216. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16217. */
  16218. export class PostProcessManager {
  16219. private _scene;
  16220. private _indexBuffer;
  16221. private _vertexBuffers;
  16222. /**
  16223. * Creates a new instance PostProcess
  16224. * @param scene The scene that the post process is associated with.
  16225. */
  16226. constructor(scene: Scene);
  16227. private _prepareBuffers;
  16228. private _buildIndexBuffer;
  16229. /**
  16230. * Rebuilds the vertex buffers of the manager.
  16231. * @hidden
  16232. */
  16233. _rebuild(): void;
  16234. /**
  16235. * Prepares a frame to be run through a post process.
  16236. * @param sourceTexture The input texture to the post procesess. (default: null)
  16237. * @param postProcesses An array of post processes to be run. (default: null)
  16238. * @returns True if the post processes were able to be run.
  16239. * @hidden
  16240. */
  16241. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16242. /**
  16243. * Manually render a set of post processes to a texture.
  16244. * @param postProcesses An array of post processes to be run.
  16245. * @param targetTexture The target texture to render to.
  16246. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16247. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16248. * @param lodLevel defines which lod of the texture to render to
  16249. */
  16250. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16251. /**
  16252. * Finalize the result of the output of the postprocesses.
  16253. * @param doNotPresent If true the result will not be displayed to the screen.
  16254. * @param targetTexture The target texture to render to.
  16255. * @param faceIndex The index of the face to bind the target texture to.
  16256. * @param postProcesses The array of post processes to render.
  16257. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16258. * @hidden
  16259. */
  16260. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16261. /**
  16262. * Disposes of the post process manager.
  16263. */
  16264. dispose(): void;
  16265. }
  16266. }
  16267. declare module "babylonjs/Misc/gradients" {
  16268. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16269. /** Interface used by value gradients (color, factor, ...) */
  16270. export interface IValueGradient {
  16271. /**
  16272. * Gets or sets the gradient value (between 0 and 1)
  16273. */
  16274. gradient: number;
  16275. }
  16276. /** Class used to store color4 gradient */
  16277. export class ColorGradient implements IValueGradient {
  16278. /**
  16279. * Gets or sets the gradient value (between 0 and 1)
  16280. */
  16281. gradient: number;
  16282. /**
  16283. * Gets or sets first associated color
  16284. */
  16285. color1: Color4;
  16286. /**
  16287. * Gets or sets second associated color
  16288. */
  16289. color2?: Color4;
  16290. /**
  16291. * Will get a color picked randomly between color1 and color2.
  16292. * If color2 is undefined then color1 will be used
  16293. * @param result defines the target Color4 to store the result in
  16294. */
  16295. getColorToRef(result: Color4): void;
  16296. }
  16297. /** Class used to store color 3 gradient */
  16298. export class Color3Gradient implements IValueGradient {
  16299. /**
  16300. * Gets or sets the gradient value (between 0 and 1)
  16301. */
  16302. gradient: number;
  16303. /**
  16304. * Gets or sets the associated color
  16305. */
  16306. color: Color3;
  16307. }
  16308. /** Class used to store factor gradient */
  16309. export class FactorGradient implements IValueGradient {
  16310. /**
  16311. * Gets or sets the gradient value (between 0 and 1)
  16312. */
  16313. gradient: number;
  16314. /**
  16315. * Gets or sets first associated factor
  16316. */
  16317. factor1: number;
  16318. /**
  16319. * Gets or sets second associated factor
  16320. */
  16321. factor2?: number;
  16322. /**
  16323. * Will get a number picked randomly between factor1 and factor2.
  16324. * If factor2 is undefined then factor1 will be used
  16325. * @returns the picked number
  16326. */
  16327. getFactor(): number;
  16328. }
  16329. /**
  16330. * Helper used to simplify some generic gradient tasks
  16331. */
  16332. export class GradientHelper {
  16333. /**
  16334. * Gets the current gradient from an array of IValueGradient
  16335. * @param ratio defines the current ratio to get
  16336. * @param gradients defines the array of IValueGradient
  16337. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16338. */
  16339. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16340. }
  16341. }
  16342. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16343. import { Scene } from "babylonjs/scene";
  16344. import { Texture } from "babylonjs/Materials/Textures/texture";
  16345. /**
  16346. * A class extending Texture allowing drawing on a texture
  16347. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16348. */
  16349. export class DynamicTexture extends Texture {
  16350. private _generateMipMaps;
  16351. private _canvas;
  16352. private _context;
  16353. private _engine;
  16354. /**
  16355. * Creates a DynamicTexture
  16356. * @param name defines the name of the texture
  16357. * @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
  16358. * @param scene defines the scene where you want the texture
  16359. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16360. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16361. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16362. */
  16363. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16364. /**
  16365. * Get the current class name of the texture useful for serialization or dynamic coding.
  16366. * @returns "DynamicTexture"
  16367. */
  16368. getClassName(): string;
  16369. /**
  16370. * Gets the current state of canRescale
  16371. */
  16372. readonly canRescale: boolean;
  16373. private _recreate;
  16374. /**
  16375. * Scales the texture
  16376. * @param ratio the scale factor to apply to both width and height
  16377. */
  16378. scale(ratio: number): void;
  16379. /**
  16380. * Resizes the texture
  16381. * @param width the new width
  16382. * @param height the new height
  16383. */
  16384. scaleTo(width: number, height: number): void;
  16385. /**
  16386. * Gets the context of the canvas used by the texture
  16387. * @returns the canvas context of the dynamic texture
  16388. */
  16389. getContext(): CanvasRenderingContext2D;
  16390. /**
  16391. * Clears the texture
  16392. */
  16393. clear(): void;
  16394. /**
  16395. * Updates the texture
  16396. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16397. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16398. */
  16399. update(invertY?: boolean, premulAlpha?: boolean): void;
  16400. /**
  16401. * Draws text onto the texture
  16402. * @param text defines the text to be drawn
  16403. * @param x defines the placement of the text from the left
  16404. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16405. * @param font defines the font to be used with font-style, font-size, font-name
  16406. * @param color defines the color used for the text
  16407. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16408. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16409. * @param update defines whether texture is immediately update (default is true)
  16410. */
  16411. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16412. /**
  16413. * Clones the texture
  16414. * @returns the clone of the texture.
  16415. */
  16416. clone(): DynamicTexture;
  16417. /**
  16418. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16419. * @returns a serialized dynamic texture object
  16420. */
  16421. serialize(): any;
  16422. /** @hidden */
  16423. _rebuild(): void;
  16424. }
  16425. }
  16426. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16427. import { Scene } from "babylonjs/scene";
  16428. import { ISceneComponent } from "babylonjs/sceneComponent";
  16429. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16430. module "babylonjs/abstractScene" {
  16431. interface AbstractScene {
  16432. /**
  16433. * The list of procedural textures added to the scene
  16434. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16435. */
  16436. proceduralTextures: Array<ProceduralTexture>;
  16437. }
  16438. }
  16439. /**
  16440. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16441. * in a given scene.
  16442. */
  16443. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16444. /**
  16445. * The component name helpfull to identify the component in the list of scene components.
  16446. */
  16447. readonly name: string;
  16448. /**
  16449. * The scene the component belongs to.
  16450. */
  16451. scene: Scene;
  16452. /**
  16453. * Creates a new instance of the component for the given scene
  16454. * @param scene Defines the scene to register the component in
  16455. */
  16456. constructor(scene: Scene);
  16457. /**
  16458. * Registers the component in a given scene
  16459. */
  16460. register(): void;
  16461. /**
  16462. * Rebuilds the elements related to this component in case of
  16463. * context lost for instance.
  16464. */
  16465. rebuild(): void;
  16466. /**
  16467. * Disposes the component and the associated ressources.
  16468. */
  16469. dispose(): void;
  16470. private _beforeClear;
  16471. }
  16472. }
  16473. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16475. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16476. module "babylonjs/Engines/engine" {
  16477. interface Engine {
  16478. /**
  16479. * Creates a new render target cube texture
  16480. * @param size defines the size of the texture
  16481. * @param options defines the options used to create the texture
  16482. * @returns a new render target cube texture stored in an InternalTexture
  16483. */
  16484. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16485. }
  16486. }
  16487. }
  16488. declare module "babylonjs/Shaders/procedural.vertex" {
  16489. /** @hidden */
  16490. export var proceduralVertexShader: {
  16491. name: string;
  16492. shader: string;
  16493. };
  16494. }
  16495. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16496. import { Observable } from "babylonjs/Misc/observable";
  16497. import { Nullable } from "babylonjs/types";
  16498. import { Scene } from "babylonjs/scene";
  16499. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16500. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16501. import { Effect } from "babylonjs/Materials/effect";
  16502. import { Texture } from "babylonjs/Materials/Textures/texture";
  16503. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16504. import "babylonjs/Shaders/procedural.vertex";
  16505. /**
  16506. * 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.
  16507. * This is the base class of any Procedural texture and contains most of the shareable code.
  16508. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16509. */
  16510. export class ProceduralTexture extends Texture {
  16511. isCube: boolean;
  16512. /**
  16513. * Define if the texture is enabled or not (disabled texture will not render)
  16514. */
  16515. isEnabled: boolean;
  16516. /**
  16517. * Define if the texture must be cleared before rendering (default is true)
  16518. */
  16519. autoClear: boolean;
  16520. /**
  16521. * Callback called when the texture is generated
  16522. */
  16523. onGenerated: () => void;
  16524. /**
  16525. * Event raised when the texture is generated
  16526. */
  16527. onGeneratedObservable: Observable<ProceduralTexture>;
  16528. /** @hidden */
  16529. _generateMipMaps: boolean;
  16530. /** @hidden **/
  16531. _effect: Effect;
  16532. /** @hidden */
  16533. _textures: {
  16534. [key: string]: Texture;
  16535. };
  16536. private _size;
  16537. private _currentRefreshId;
  16538. private _refreshRate;
  16539. private _vertexBuffers;
  16540. private _indexBuffer;
  16541. private _uniforms;
  16542. private _samplers;
  16543. private _fragment;
  16544. private _floats;
  16545. private _ints;
  16546. private _floatsArrays;
  16547. private _colors3;
  16548. private _colors4;
  16549. private _vectors2;
  16550. private _vectors3;
  16551. private _matrices;
  16552. private _fallbackTexture;
  16553. private _fallbackTextureUsed;
  16554. private _engine;
  16555. private _cachedDefines;
  16556. private _contentUpdateId;
  16557. private _contentData;
  16558. /**
  16559. * Instantiates a new procedural texture.
  16560. * 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.
  16561. * This is the base class of any Procedural texture and contains most of the shareable code.
  16562. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16563. * @param name Define the name of the texture
  16564. * @param size Define the size of the texture to create
  16565. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16566. * @param scene Define the scene the texture belongs to
  16567. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16568. * @param generateMipMaps Define if the texture should creates mip maps or not
  16569. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16570. */
  16571. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16572. /**
  16573. * The effect that is created when initializing the post process.
  16574. * @returns The created effect corresponding the the postprocess.
  16575. */
  16576. getEffect(): Effect;
  16577. /**
  16578. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16579. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16580. */
  16581. getContent(): Nullable<ArrayBufferView>;
  16582. private _createIndexBuffer;
  16583. /** @hidden */
  16584. _rebuild(): void;
  16585. /**
  16586. * Resets the texture in order to recreate its associated resources.
  16587. * This can be called in case of context loss
  16588. */
  16589. reset(): void;
  16590. protected _getDefines(): string;
  16591. /**
  16592. * Is the texture ready to be used ? (rendered at least once)
  16593. * @returns true if ready, otherwise, false.
  16594. */
  16595. isReady(): boolean;
  16596. /**
  16597. * Resets the refresh counter of the texture and start bak from scratch.
  16598. * Could be useful to regenerate the texture if it is setup to render only once.
  16599. */
  16600. resetRefreshCounter(): void;
  16601. /**
  16602. * Set the fragment shader to use in order to render the texture.
  16603. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16604. */
  16605. setFragment(fragment: any): void;
  16606. /**
  16607. * Define the refresh rate of the texture or the rendering frequency.
  16608. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16609. */
  16610. refreshRate: number;
  16611. /** @hidden */
  16612. _shouldRender(): boolean;
  16613. /**
  16614. * Get the size the texture is rendering at.
  16615. * @returns the size (texture is always squared)
  16616. */
  16617. getRenderSize(): number;
  16618. /**
  16619. * Resize the texture to new value.
  16620. * @param size Define the new size the texture should have
  16621. * @param generateMipMaps Define whether the new texture should create mip maps
  16622. */
  16623. resize(size: number, generateMipMaps: boolean): void;
  16624. private _checkUniform;
  16625. /**
  16626. * Set a texture in the shader program used to render.
  16627. * @param name Define the name of the uniform samplers as defined in the shader
  16628. * @param texture Define the texture to bind to this sampler
  16629. * @return the texture itself allowing "fluent" like uniform updates
  16630. */
  16631. setTexture(name: string, texture: Texture): ProceduralTexture;
  16632. /**
  16633. * Set a float in the shader.
  16634. * @param name Define the name of the uniform as defined in the shader
  16635. * @param value Define the value to give to the uniform
  16636. * @return the texture itself allowing "fluent" like uniform updates
  16637. */
  16638. setFloat(name: string, value: number): ProceduralTexture;
  16639. /**
  16640. * Set a int in the shader.
  16641. * @param name Define the name of the uniform as defined in the shader
  16642. * @param value Define the value to give to the uniform
  16643. * @return the texture itself allowing "fluent" like uniform updates
  16644. */
  16645. setInt(name: string, value: number): ProceduralTexture;
  16646. /**
  16647. * Set an array of floats in the shader.
  16648. * @param name Define the name of the uniform as defined in the shader
  16649. * @param value Define the value to give to the uniform
  16650. * @return the texture itself allowing "fluent" like uniform updates
  16651. */
  16652. setFloats(name: string, value: number[]): ProceduralTexture;
  16653. /**
  16654. * Set a vec3 in the shader from a Color3.
  16655. * @param name Define the name of the uniform as defined in the shader
  16656. * @param value Define the value to give to the uniform
  16657. * @return the texture itself allowing "fluent" like uniform updates
  16658. */
  16659. setColor3(name: string, value: Color3): ProceduralTexture;
  16660. /**
  16661. * Set a vec4 in the shader from a Color4.
  16662. * @param name Define the name of the uniform as defined in the shader
  16663. * @param value Define the value to give to the uniform
  16664. * @return the texture itself allowing "fluent" like uniform updates
  16665. */
  16666. setColor4(name: string, value: Color4): ProceduralTexture;
  16667. /**
  16668. * Set a vec2 in the shader from a Vector2.
  16669. * @param name Define the name of the uniform as defined in the shader
  16670. * @param value Define the value to give to the uniform
  16671. * @return the texture itself allowing "fluent" like uniform updates
  16672. */
  16673. setVector2(name: string, value: Vector2): ProceduralTexture;
  16674. /**
  16675. * Set a vec3 in the shader from a Vector3.
  16676. * @param name Define the name of the uniform as defined in the shader
  16677. * @param value Define the value to give to the uniform
  16678. * @return the texture itself allowing "fluent" like uniform updates
  16679. */
  16680. setVector3(name: string, value: Vector3): ProceduralTexture;
  16681. /**
  16682. * Set a mat4 in the shader from a MAtrix.
  16683. * @param name Define the name of the uniform as defined in the shader
  16684. * @param value Define the value to give to the uniform
  16685. * @return the texture itself allowing "fluent" like uniform updates
  16686. */
  16687. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16688. /**
  16689. * Render the texture to its associated render target.
  16690. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16691. */
  16692. render(useCameraPostProcess?: boolean): void;
  16693. /**
  16694. * Clone the texture.
  16695. * @returns the cloned texture
  16696. */
  16697. clone(): ProceduralTexture;
  16698. /**
  16699. * Dispose the texture and release its asoociated resources.
  16700. */
  16701. dispose(): void;
  16702. }
  16703. }
  16704. declare module "babylonjs/Particles/baseParticleSystem" {
  16705. import { Nullable } from "babylonjs/types";
  16706. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16708. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16709. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16710. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16711. import { Scene } from "babylonjs/scene";
  16712. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16713. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16714. import { Texture } from "babylonjs/Materials/Textures/texture";
  16715. import { Color4 } from "babylonjs/Maths/math.color";
  16716. import { Animation } from "babylonjs/Animations/animation";
  16717. /**
  16718. * This represents the base class for particle system in Babylon.
  16719. * 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.
  16720. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16721. * @example https://doc.babylonjs.com/babylon101/particles
  16722. */
  16723. export class BaseParticleSystem {
  16724. /**
  16725. * Source color is added to the destination color without alpha affecting the result
  16726. */
  16727. static BLENDMODE_ONEONE: number;
  16728. /**
  16729. * Blend current color and particle color using particle’s alpha
  16730. */
  16731. static BLENDMODE_STANDARD: number;
  16732. /**
  16733. * Add current color and particle color multiplied by particle’s alpha
  16734. */
  16735. static BLENDMODE_ADD: number;
  16736. /**
  16737. * Multiply current color with particle color
  16738. */
  16739. static BLENDMODE_MULTIPLY: number;
  16740. /**
  16741. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16742. */
  16743. static BLENDMODE_MULTIPLYADD: number;
  16744. /**
  16745. * List of animations used by the particle system.
  16746. */
  16747. animations: Animation[];
  16748. /**
  16749. * The id of the Particle system.
  16750. */
  16751. id: string;
  16752. /**
  16753. * The friendly name of the Particle system.
  16754. */
  16755. name: string;
  16756. /**
  16757. * The rendering group used by the Particle system to chose when to render.
  16758. */
  16759. renderingGroupId: number;
  16760. /**
  16761. * The emitter represents the Mesh or position we are attaching the particle system to.
  16762. */
  16763. emitter: Nullable<AbstractMesh | Vector3>;
  16764. /**
  16765. * The maximum number of particles to emit per frame
  16766. */
  16767. emitRate: number;
  16768. /**
  16769. * If you want to launch only a few particles at once, that can be done, as well.
  16770. */
  16771. manualEmitCount: number;
  16772. /**
  16773. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16774. */
  16775. updateSpeed: number;
  16776. /**
  16777. * The amount of time the particle system is running (depends of the overall update speed).
  16778. */
  16779. targetStopDuration: number;
  16780. /**
  16781. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16782. */
  16783. disposeOnStop: boolean;
  16784. /**
  16785. * Minimum power of emitting particles.
  16786. */
  16787. minEmitPower: number;
  16788. /**
  16789. * Maximum power of emitting particles.
  16790. */
  16791. maxEmitPower: number;
  16792. /**
  16793. * Minimum life time of emitting particles.
  16794. */
  16795. minLifeTime: number;
  16796. /**
  16797. * Maximum life time of emitting particles.
  16798. */
  16799. maxLifeTime: number;
  16800. /**
  16801. * Minimum Size of emitting particles.
  16802. */
  16803. minSize: number;
  16804. /**
  16805. * Maximum Size of emitting particles.
  16806. */
  16807. maxSize: number;
  16808. /**
  16809. * Minimum scale of emitting particles on X axis.
  16810. */
  16811. minScaleX: number;
  16812. /**
  16813. * Maximum scale of emitting particles on X axis.
  16814. */
  16815. maxScaleX: number;
  16816. /**
  16817. * Minimum scale of emitting particles on Y axis.
  16818. */
  16819. minScaleY: number;
  16820. /**
  16821. * Maximum scale of emitting particles on Y axis.
  16822. */
  16823. maxScaleY: number;
  16824. /**
  16825. * Gets or sets the minimal initial rotation in radians.
  16826. */
  16827. minInitialRotation: number;
  16828. /**
  16829. * Gets or sets the maximal initial rotation in radians.
  16830. */
  16831. maxInitialRotation: number;
  16832. /**
  16833. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16834. */
  16835. minAngularSpeed: number;
  16836. /**
  16837. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16838. */
  16839. maxAngularSpeed: number;
  16840. /**
  16841. * The texture used to render each particle. (this can be a spritesheet)
  16842. */
  16843. particleTexture: Nullable<Texture>;
  16844. /**
  16845. * The layer mask we are rendering the particles through.
  16846. */
  16847. layerMask: number;
  16848. /**
  16849. * This can help using your own shader to render the particle system.
  16850. * The according effect will be created
  16851. */
  16852. customShader: any;
  16853. /**
  16854. * By default particle system starts as soon as they are created. This prevents the
  16855. * automatic start to happen and let you decide when to start emitting particles.
  16856. */
  16857. preventAutoStart: boolean;
  16858. private _noiseTexture;
  16859. /**
  16860. * Gets or sets a texture used to add random noise to particle positions
  16861. */
  16862. noiseTexture: Nullable<ProceduralTexture>;
  16863. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16864. noiseStrength: Vector3;
  16865. /**
  16866. * Callback triggered when the particle animation is ending.
  16867. */
  16868. onAnimationEnd: Nullable<() => void>;
  16869. /**
  16870. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16871. */
  16872. blendMode: number;
  16873. /**
  16874. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16875. * to override the particles.
  16876. */
  16877. forceDepthWrite: boolean;
  16878. /** 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 */
  16879. preWarmCycles: number;
  16880. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16881. preWarmStepOffset: number;
  16882. /**
  16883. * 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)
  16884. */
  16885. spriteCellChangeSpeed: number;
  16886. /**
  16887. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16888. */
  16889. startSpriteCellID: number;
  16890. /**
  16891. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16892. */
  16893. endSpriteCellID: number;
  16894. /**
  16895. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16896. */
  16897. spriteCellWidth: number;
  16898. /**
  16899. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16900. */
  16901. spriteCellHeight: number;
  16902. /**
  16903. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16904. */
  16905. spriteRandomStartCell: boolean;
  16906. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16907. translationPivot: Vector2;
  16908. /** @hidden */
  16909. protected _isAnimationSheetEnabled: boolean;
  16910. /**
  16911. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16912. */
  16913. beginAnimationOnStart: boolean;
  16914. /**
  16915. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16916. */
  16917. beginAnimationFrom: number;
  16918. /**
  16919. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16920. */
  16921. beginAnimationTo: number;
  16922. /**
  16923. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16924. */
  16925. beginAnimationLoop: boolean;
  16926. /**
  16927. * Gets or sets a world offset applied to all particles
  16928. */
  16929. worldOffset: Vector3;
  16930. /**
  16931. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16932. */
  16933. isAnimationSheetEnabled: boolean;
  16934. /**
  16935. * Get hosting scene
  16936. * @returns the scene
  16937. */
  16938. getScene(): Scene;
  16939. /**
  16940. * You can use gravity if you want to give an orientation to your particles.
  16941. */
  16942. gravity: Vector3;
  16943. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16944. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16945. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16946. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16947. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16948. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16949. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16950. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16951. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16952. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16953. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16954. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16955. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16956. /**
  16957. * Defines the delay in milliseconds before starting the system (0 by default)
  16958. */
  16959. startDelay: number;
  16960. /**
  16961. * Gets the current list of drag gradients.
  16962. * You must use addDragGradient and removeDragGradient to udpate this list
  16963. * @returns the list of drag gradients
  16964. */
  16965. getDragGradients(): Nullable<Array<FactorGradient>>;
  16966. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16967. limitVelocityDamping: number;
  16968. /**
  16969. * Gets the current list of limit velocity gradients.
  16970. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16971. * @returns the list of limit velocity gradients
  16972. */
  16973. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16974. /**
  16975. * Gets the current list of color gradients.
  16976. * You must use addColorGradient and removeColorGradient to udpate this list
  16977. * @returns the list of color gradients
  16978. */
  16979. getColorGradients(): Nullable<Array<ColorGradient>>;
  16980. /**
  16981. * Gets the current list of size gradients.
  16982. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16983. * @returns the list of size gradients
  16984. */
  16985. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16986. /**
  16987. * Gets the current list of color remap gradients.
  16988. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16989. * @returns the list of color remap gradients
  16990. */
  16991. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16992. /**
  16993. * Gets the current list of alpha remap gradients.
  16994. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16995. * @returns the list of alpha remap gradients
  16996. */
  16997. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16998. /**
  16999. * Gets the current list of life time gradients.
  17000. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17001. * @returns the list of life time gradients
  17002. */
  17003. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17004. /**
  17005. * Gets the current list of angular speed gradients.
  17006. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17007. * @returns the list of angular speed gradients
  17008. */
  17009. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17010. /**
  17011. * Gets the current list of velocity gradients.
  17012. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17013. * @returns the list of velocity gradients
  17014. */
  17015. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17016. /**
  17017. * Gets the current list of start size gradients.
  17018. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17019. * @returns the list of start size gradients
  17020. */
  17021. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17022. /**
  17023. * Gets the current list of emit rate gradients.
  17024. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17025. * @returns the list of emit rate gradients
  17026. */
  17027. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17028. /**
  17029. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17030. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17031. */
  17032. direction1: Vector3;
  17033. /**
  17034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17035. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17036. */
  17037. direction2: Vector3;
  17038. /**
  17039. * 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.
  17040. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17041. */
  17042. minEmitBox: Vector3;
  17043. /**
  17044. * 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.
  17045. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17046. */
  17047. maxEmitBox: Vector3;
  17048. /**
  17049. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17050. */
  17051. color1: Color4;
  17052. /**
  17053. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17054. */
  17055. color2: Color4;
  17056. /**
  17057. * Color the particle will have at the end of its lifetime
  17058. */
  17059. colorDead: Color4;
  17060. /**
  17061. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17062. */
  17063. textureMask: Color4;
  17064. /**
  17065. * The particle emitter type defines the emitter used by the particle system.
  17066. * It can be for example box, sphere, or cone...
  17067. */
  17068. particleEmitterType: IParticleEmitterType;
  17069. /** @hidden */
  17070. _isSubEmitter: boolean;
  17071. /**
  17072. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17073. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17074. */
  17075. billboardMode: number;
  17076. protected _isBillboardBased: boolean;
  17077. /**
  17078. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17079. */
  17080. isBillboardBased: boolean;
  17081. /**
  17082. * The scene the particle system belongs to.
  17083. */
  17084. protected _scene: Scene;
  17085. /**
  17086. * Local cache of defines for image processing.
  17087. */
  17088. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17089. /**
  17090. * Default configuration related to image processing available in the standard Material.
  17091. */
  17092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17093. /**
  17094. * Gets the image processing configuration used either in this material.
  17095. */
  17096. /**
  17097. * Sets the Default image processing configuration used either in the this material.
  17098. *
  17099. * If sets to null, the scene one is in use.
  17100. */
  17101. imageProcessingConfiguration: ImageProcessingConfiguration;
  17102. /**
  17103. * Attaches a new image processing configuration to the Standard Material.
  17104. * @param configuration
  17105. */
  17106. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17107. /** @hidden */
  17108. protected _reset(): void;
  17109. /** @hidden */
  17110. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17111. /**
  17112. * Instantiates a particle system.
  17113. * 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.
  17114. * @param name The name of the particle system
  17115. */
  17116. constructor(name: string);
  17117. /**
  17118. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17119. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17120. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17121. * @returns the emitter
  17122. */
  17123. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17124. /**
  17125. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17126. * @param radius The radius of the hemisphere to emit from
  17127. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17128. * @returns the emitter
  17129. */
  17130. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17131. /**
  17132. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17133. * @param radius The radius of the sphere to emit from
  17134. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17135. * @returns the emitter
  17136. */
  17137. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17138. /**
  17139. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17140. * @param radius The radius of the sphere to emit from
  17141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17143. * @returns the emitter
  17144. */
  17145. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17146. /**
  17147. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17148. * @param radius The radius of the emission cylinder
  17149. * @param height The height of the emission cylinder
  17150. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17151. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17152. * @returns the emitter
  17153. */
  17154. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17155. /**
  17156. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17157. * @param radius The radius of the cylinder to emit from
  17158. * @param height The height of the emission cylinder
  17159. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17162. * @returns the emitter
  17163. */
  17164. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17165. /**
  17166. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17167. * @param radius The radius of the cone to emit from
  17168. * @param angle The base angle of the cone
  17169. * @returns the emitter
  17170. */
  17171. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17172. /**
  17173. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17174. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17175. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17176. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17177. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17178. * @returns the emitter
  17179. */
  17180. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17181. }
  17182. }
  17183. declare module "babylonjs/Particles/subEmitter" {
  17184. import { Scene } from "babylonjs/scene";
  17185. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17186. /**
  17187. * Type of sub emitter
  17188. */
  17189. export enum SubEmitterType {
  17190. /**
  17191. * Attached to the particle over it's lifetime
  17192. */
  17193. ATTACHED = 0,
  17194. /**
  17195. * Created when the particle dies
  17196. */
  17197. END = 1
  17198. }
  17199. /**
  17200. * Sub emitter class used to emit particles from an existing particle
  17201. */
  17202. export class SubEmitter {
  17203. /**
  17204. * the particle system to be used by the sub emitter
  17205. */
  17206. particleSystem: ParticleSystem;
  17207. /**
  17208. * Type of the submitter (Default: END)
  17209. */
  17210. type: SubEmitterType;
  17211. /**
  17212. * 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)
  17213. * Note: This only is supported when using an emitter of type Mesh
  17214. */
  17215. inheritDirection: boolean;
  17216. /**
  17217. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17218. */
  17219. inheritedVelocityAmount: number;
  17220. /**
  17221. * Creates a sub emitter
  17222. * @param particleSystem the particle system to be used by the sub emitter
  17223. */
  17224. constructor(
  17225. /**
  17226. * the particle system to be used by the sub emitter
  17227. */
  17228. particleSystem: ParticleSystem);
  17229. /**
  17230. * Clones the sub emitter
  17231. * @returns the cloned sub emitter
  17232. */
  17233. clone(): SubEmitter;
  17234. /**
  17235. * Serialize current object to a JSON object
  17236. * @returns the serialized object
  17237. */
  17238. serialize(): any;
  17239. /** @hidden */
  17240. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17241. /**
  17242. * Creates a new SubEmitter from a serialized JSON version
  17243. * @param serializationObject defines the JSON object to read from
  17244. * @param scene defines the hosting scene
  17245. * @param rootUrl defines the rootUrl for data loading
  17246. * @returns a new SubEmitter
  17247. */
  17248. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17249. /** Release associated resources */
  17250. dispose(): void;
  17251. }
  17252. }
  17253. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17254. /** @hidden */
  17255. export var clipPlaneFragmentDeclaration: {
  17256. name: string;
  17257. shader: string;
  17258. };
  17259. }
  17260. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17261. /** @hidden */
  17262. export var imageProcessingDeclaration: {
  17263. name: string;
  17264. shader: string;
  17265. };
  17266. }
  17267. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17268. /** @hidden */
  17269. export var imageProcessingFunctions: {
  17270. name: string;
  17271. shader: string;
  17272. };
  17273. }
  17274. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17275. /** @hidden */
  17276. export var clipPlaneFragment: {
  17277. name: string;
  17278. shader: string;
  17279. };
  17280. }
  17281. declare module "babylonjs/Shaders/particles.fragment" {
  17282. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17283. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17284. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17285. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17286. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17287. /** @hidden */
  17288. export var particlesPixelShader: {
  17289. name: string;
  17290. shader: string;
  17291. };
  17292. }
  17293. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17294. /** @hidden */
  17295. export var clipPlaneVertexDeclaration: {
  17296. name: string;
  17297. shader: string;
  17298. };
  17299. }
  17300. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17301. /** @hidden */
  17302. export var clipPlaneVertex: {
  17303. name: string;
  17304. shader: string;
  17305. };
  17306. }
  17307. declare module "babylonjs/Shaders/particles.vertex" {
  17308. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17309. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17310. /** @hidden */
  17311. export var particlesVertexShader: {
  17312. name: string;
  17313. shader: string;
  17314. };
  17315. }
  17316. declare module "babylonjs/Particles/particleSystem" {
  17317. import { Nullable } from "babylonjs/types";
  17318. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17319. import { Observable } from "babylonjs/Misc/observable";
  17320. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17321. import { Effect } from "babylonjs/Materials/effect";
  17322. import { Scene, IDisposable } from "babylonjs/scene";
  17323. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17324. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17325. import { Particle } from "babylonjs/Particles/particle";
  17326. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17327. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17328. import "babylonjs/Shaders/particles.fragment";
  17329. import "babylonjs/Shaders/particles.vertex";
  17330. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17331. /**
  17332. * This represents a particle system in Babylon.
  17333. * 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.
  17334. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17335. * @example https://doc.babylonjs.com/babylon101/particles
  17336. */
  17337. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17338. /**
  17339. * Billboard mode will only apply to Y axis
  17340. */
  17341. static readonly BILLBOARDMODE_Y: number;
  17342. /**
  17343. * Billboard mode will apply to all axes
  17344. */
  17345. static readonly BILLBOARDMODE_ALL: number;
  17346. /**
  17347. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17348. */
  17349. static readonly BILLBOARDMODE_STRETCHED: number;
  17350. /**
  17351. * This function can be defined to provide custom update for active particles.
  17352. * This function will be called instead of regular update (age, position, color, etc.).
  17353. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17354. */
  17355. updateFunction: (particles: Particle[]) => void;
  17356. private _emitterWorldMatrix;
  17357. /**
  17358. * This function can be defined to specify initial direction for every new particle.
  17359. * It by default use the emitterType defined function
  17360. */
  17361. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17362. /**
  17363. * This function can be defined to specify initial position for every new particle.
  17364. * It by default use the emitterType defined function
  17365. */
  17366. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17367. /**
  17368. * @hidden
  17369. */
  17370. _inheritedVelocityOffset: Vector3;
  17371. /**
  17372. * An event triggered when the system is disposed
  17373. */
  17374. onDisposeObservable: Observable<ParticleSystem>;
  17375. private _onDisposeObserver;
  17376. /**
  17377. * Sets a callback that will be triggered when the system is disposed
  17378. */
  17379. onDispose: () => void;
  17380. private _particles;
  17381. private _epsilon;
  17382. private _capacity;
  17383. private _stockParticles;
  17384. private _newPartsExcess;
  17385. private _vertexData;
  17386. private _vertexBuffer;
  17387. private _vertexBuffers;
  17388. private _spriteBuffer;
  17389. private _indexBuffer;
  17390. private _effect;
  17391. private _customEffect;
  17392. private _cachedDefines;
  17393. private _scaledColorStep;
  17394. private _colorDiff;
  17395. private _scaledDirection;
  17396. private _scaledGravity;
  17397. private _currentRenderId;
  17398. private _alive;
  17399. private _useInstancing;
  17400. private _started;
  17401. private _stopped;
  17402. private _actualFrame;
  17403. private _scaledUpdateSpeed;
  17404. private _vertexBufferSize;
  17405. /** @hidden */
  17406. _currentEmitRateGradient: Nullable<FactorGradient>;
  17407. /** @hidden */
  17408. _currentEmitRate1: number;
  17409. /** @hidden */
  17410. _currentEmitRate2: number;
  17411. /** @hidden */
  17412. _currentStartSizeGradient: Nullable<FactorGradient>;
  17413. /** @hidden */
  17414. _currentStartSize1: number;
  17415. /** @hidden */
  17416. _currentStartSize2: number;
  17417. private readonly _rawTextureWidth;
  17418. private _rampGradientsTexture;
  17419. private _useRampGradients;
  17420. /** Gets or sets a boolean indicating that ramp gradients must be used
  17421. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17422. */
  17423. useRampGradients: boolean;
  17424. /**
  17425. * 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.
  17426. * 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: [])
  17427. */
  17428. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17429. private _subEmitters;
  17430. /**
  17431. * @hidden
  17432. * If the particle systems emitter should be disposed when the particle system is disposed
  17433. */
  17434. _disposeEmitterOnDispose: boolean;
  17435. /**
  17436. * The current active Sub-systems, this property is used by the root particle system only.
  17437. */
  17438. activeSubSystems: Array<ParticleSystem>;
  17439. private _rootParticleSystem;
  17440. /**
  17441. * Gets the current list of active particles
  17442. */
  17443. readonly particles: Particle[];
  17444. /**
  17445. * Returns the string "ParticleSystem"
  17446. * @returns a string containing the class name
  17447. */
  17448. getClassName(): string;
  17449. /**
  17450. * Instantiates a particle system.
  17451. * 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.
  17452. * @param name The name of the particle system
  17453. * @param capacity The max number of particles alive at the same time
  17454. * @param scene The scene the particle system belongs to
  17455. * @param customEffect a custom effect used to change the way particles are rendered by default
  17456. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17457. * @param epsilon Offset used to render the particles
  17458. */
  17459. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17460. private _addFactorGradient;
  17461. private _removeFactorGradient;
  17462. /**
  17463. * Adds a new life time gradient
  17464. * @param gradient defines the gradient to use (between 0 and 1)
  17465. * @param factor defines the life time factor to affect to the specified gradient
  17466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17467. * @returns the current particle system
  17468. */
  17469. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17470. /**
  17471. * Remove a specific life time gradient
  17472. * @param gradient defines the gradient to remove
  17473. * @returns the current particle system
  17474. */
  17475. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17476. /**
  17477. * Adds a new size gradient
  17478. * @param gradient defines the gradient to use (between 0 and 1)
  17479. * @param factor defines the size factor to affect to the specified gradient
  17480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17481. * @returns the current particle system
  17482. */
  17483. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17484. /**
  17485. * Remove a specific size gradient
  17486. * @param gradient defines the gradient to remove
  17487. * @returns the current particle system
  17488. */
  17489. removeSizeGradient(gradient: number): IParticleSystem;
  17490. /**
  17491. * Adds a new color remap gradient
  17492. * @param gradient defines the gradient to use (between 0 and 1)
  17493. * @param min defines the color remap minimal range
  17494. * @param max defines the color remap maximal range
  17495. * @returns the current particle system
  17496. */
  17497. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17498. /**
  17499. * Remove a specific color remap gradient
  17500. * @param gradient defines the gradient to remove
  17501. * @returns the current particle system
  17502. */
  17503. removeColorRemapGradient(gradient: number): IParticleSystem;
  17504. /**
  17505. * Adds a new alpha remap gradient
  17506. * @param gradient defines the gradient to use (between 0 and 1)
  17507. * @param min defines the alpha remap minimal range
  17508. * @param max defines the alpha remap maximal range
  17509. * @returns the current particle system
  17510. */
  17511. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17512. /**
  17513. * Remove a specific alpha remap gradient
  17514. * @param gradient defines the gradient to remove
  17515. * @returns the current particle system
  17516. */
  17517. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17518. /**
  17519. * Adds a new angular speed gradient
  17520. * @param gradient defines the gradient to use (between 0 and 1)
  17521. * @param factor defines the angular speed to affect to the specified gradient
  17522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17523. * @returns the current particle system
  17524. */
  17525. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17526. /**
  17527. * Remove a specific angular speed gradient
  17528. * @param gradient defines the gradient to remove
  17529. * @returns the current particle system
  17530. */
  17531. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17532. /**
  17533. * Adds a new velocity gradient
  17534. * @param gradient defines the gradient to use (between 0 and 1)
  17535. * @param factor defines the velocity to affect to the specified gradient
  17536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17537. * @returns the current particle system
  17538. */
  17539. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17540. /**
  17541. * Remove a specific velocity gradient
  17542. * @param gradient defines the gradient to remove
  17543. * @returns the current particle system
  17544. */
  17545. removeVelocityGradient(gradient: number): IParticleSystem;
  17546. /**
  17547. * Adds a new limit velocity gradient
  17548. * @param gradient defines the gradient to use (between 0 and 1)
  17549. * @param factor defines the limit velocity value to affect to the specified gradient
  17550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17551. * @returns the current particle system
  17552. */
  17553. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17554. /**
  17555. * Remove a specific limit velocity gradient
  17556. * @param gradient defines the gradient to remove
  17557. * @returns the current particle system
  17558. */
  17559. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17560. /**
  17561. * Adds a new drag gradient
  17562. * @param gradient defines the gradient to use (between 0 and 1)
  17563. * @param factor defines the drag value to affect to the specified gradient
  17564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17565. * @returns the current particle system
  17566. */
  17567. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17568. /**
  17569. * Remove a specific drag gradient
  17570. * @param gradient defines the gradient to remove
  17571. * @returns the current particle system
  17572. */
  17573. removeDragGradient(gradient: number): IParticleSystem;
  17574. /**
  17575. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17576. * @param gradient defines the gradient to use (between 0 and 1)
  17577. * @param factor defines the emit rate value to affect to the specified gradient
  17578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17579. * @returns the current particle system
  17580. */
  17581. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17582. /**
  17583. * Remove a specific emit rate gradient
  17584. * @param gradient defines the gradient to remove
  17585. * @returns the current particle system
  17586. */
  17587. removeEmitRateGradient(gradient: number): IParticleSystem;
  17588. /**
  17589. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17590. * @param gradient defines the gradient to use (between 0 and 1)
  17591. * @param factor defines the start size value to affect to the specified gradient
  17592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17593. * @returns the current particle system
  17594. */
  17595. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17596. /**
  17597. * Remove a specific start size gradient
  17598. * @param gradient defines the gradient to remove
  17599. * @returns the current particle system
  17600. */
  17601. removeStartSizeGradient(gradient: number): IParticleSystem;
  17602. private _createRampGradientTexture;
  17603. /**
  17604. * Gets the current list of ramp gradients.
  17605. * You must use addRampGradient and removeRampGradient to udpate this list
  17606. * @returns the list of ramp gradients
  17607. */
  17608. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17609. /**
  17610. * Adds a new ramp gradient used to remap particle colors
  17611. * @param gradient defines the gradient to use (between 0 and 1)
  17612. * @param color defines the color to affect to the specified gradient
  17613. * @returns the current particle system
  17614. */
  17615. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17616. /**
  17617. * Remove a specific ramp gradient
  17618. * @param gradient defines the gradient to remove
  17619. * @returns the current particle system
  17620. */
  17621. removeRampGradient(gradient: number): ParticleSystem;
  17622. /**
  17623. * Adds a new color gradient
  17624. * @param gradient defines the gradient to use (between 0 and 1)
  17625. * @param color1 defines the color to affect to the specified gradient
  17626. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17627. * @returns this particle system
  17628. */
  17629. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17630. /**
  17631. * Remove a specific color gradient
  17632. * @param gradient defines the gradient to remove
  17633. * @returns this particle system
  17634. */
  17635. removeColorGradient(gradient: number): IParticleSystem;
  17636. private _fetchR;
  17637. protected _reset(): void;
  17638. private _resetEffect;
  17639. private _createVertexBuffers;
  17640. private _createIndexBuffer;
  17641. /**
  17642. * Gets the maximum number of particles active at the same time.
  17643. * @returns The max number of active particles.
  17644. */
  17645. getCapacity(): number;
  17646. /**
  17647. * Gets whether there are still active particles in the system.
  17648. * @returns True if it is alive, otherwise false.
  17649. */
  17650. isAlive(): boolean;
  17651. /**
  17652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17653. * @returns True if it has been started, otherwise false.
  17654. */
  17655. isStarted(): boolean;
  17656. private _prepareSubEmitterInternalArray;
  17657. /**
  17658. * Starts the particle system and begins to emit
  17659. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17660. */
  17661. start(delay?: number): void;
  17662. /**
  17663. * Stops the particle system.
  17664. * @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.
  17665. */
  17666. stop(stopSubEmitters?: boolean): void;
  17667. /**
  17668. * Remove all active particles
  17669. */
  17670. reset(): void;
  17671. /**
  17672. * @hidden (for internal use only)
  17673. */
  17674. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17675. /**
  17676. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17677. * Its lifetime will start back at 0.
  17678. */
  17679. recycleParticle: (particle: Particle) => void;
  17680. private _stopSubEmitters;
  17681. private _createParticle;
  17682. private _removeFromRoot;
  17683. private _emitFromParticle;
  17684. private _update;
  17685. /** @hidden */
  17686. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17687. /** @hidden */
  17688. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17689. /** @hidden */
  17690. private _getEffect;
  17691. /**
  17692. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17693. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17694. */
  17695. animate(preWarmOnly?: boolean): void;
  17696. private _appendParticleVertices;
  17697. /**
  17698. * Rebuilds the particle system.
  17699. */
  17700. rebuild(): void;
  17701. /**
  17702. * Is this system ready to be used/rendered
  17703. * @return true if the system is ready
  17704. */
  17705. isReady(): boolean;
  17706. private _render;
  17707. /**
  17708. * Renders the particle system in its current state.
  17709. * @returns the current number of particles
  17710. */
  17711. render(): number;
  17712. /**
  17713. * Disposes the particle system and free the associated resources
  17714. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17715. */
  17716. dispose(disposeTexture?: boolean): void;
  17717. /**
  17718. * Clones the particle system.
  17719. * @param name The name of the cloned object
  17720. * @param newEmitter The new emitter to use
  17721. * @returns the cloned particle system
  17722. */
  17723. clone(name: string, newEmitter: any): ParticleSystem;
  17724. /**
  17725. * Serializes the particle system to a JSON object.
  17726. * @returns the JSON object
  17727. */
  17728. serialize(): any;
  17729. /** @hidden */
  17730. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17731. /** @hidden */
  17732. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17733. /**
  17734. * Parses a JSON object to create a particle system.
  17735. * @param parsedParticleSystem The JSON object to parse
  17736. * @param scene The scene to create the particle system in
  17737. * @param rootUrl The root url to use to load external dependencies like texture
  17738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17739. * @returns the Parsed particle system
  17740. */
  17741. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17742. }
  17743. }
  17744. declare module "babylonjs/Particles/particle" {
  17745. import { Nullable } from "babylonjs/types";
  17746. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17747. import { Color4 } from "babylonjs/Maths/math.color";
  17748. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17749. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17750. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17751. /**
  17752. * A particle represents one of the element emitted by a particle system.
  17753. * This is mainly define by its coordinates, direction, velocity and age.
  17754. */
  17755. export class Particle {
  17756. /**
  17757. * The particle system the particle belongs to.
  17758. */
  17759. particleSystem: ParticleSystem;
  17760. private static _Count;
  17761. /**
  17762. * Unique ID of the particle
  17763. */
  17764. id: number;
  17765. /**
  17766. * The world position of the particle in the scene.
  17767. */
  17768. position: Vector3;
  17769. /**
  17770. * The world direction of the particle in the scene.
  17771. */
  17772. direction: Vector3;
  17773. /**
  17774. * The color of the particle.
  17775. */
  17776. color: Color4;
  17777. /**
  17778. * The color change of the particle per step.
  17779. */
  17780. colorStep: Color4;
  17781. /**
  17782. * Defines how long will the life of the particle be.
  17783. */
  17784. lifeTime: number;
  17785. /**
  17786. * The current age of the particle.
  17787. */
  17788. age: number;
  17789. /**
  17790. * The current size of the particle.
  17791. */
  17792. size: number;
  17793. /**
  17794. * The current scale of the particle.
  17795. */
  17796. scale: Vector2;
  17797. /**
  17798. * The current angle of the particle.
  17799. */
  17800. angle: number;
  17801. /**
  17802. * Defines how fast is the angle changing.
  17803. */
  17804. angularSpeed: number;
  17805. /**
  17806. * Defines the cell index used by the particle to be rendered from a sprite.
  17807. */
  17808. cellIndex: number;
  17809. /**
  17810. * The information required to support color remapping
  17811. */
  17812. remapData: Vector4;
  17813. /** @hidden */
  17814. _randomCellOffset?: number;
  17815. /** @hidden */
  17816. _initialDirection: Nullable<Vector3>;
  17817. /** @hidden */
  17818. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17819. /** @hidden */
  17820. _initialStartSpriteCellID: number;
  17821. /** @hidden */
  17822. _initialEndSpriteCellID: number;
  17823. /** @hidden */
  17824. _currentColorGradient: Nullable<ColorGradient>;
  17825. /** @hidden */
  17826. _currentColor1: Color4;
  17827. /** @hidden */
  17828. _currentColor2: Color4;
  17829. /** @hidden */
  17830. _currentSizeGradient: Nullable<FactorGradient>;
  17831. /** @hidden */
  17832. _currentSize1: number;
  17833. /** @hidden */
  17834. _currentSize2: number;
  17835. /** @hidden */
  17836. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17837. /** @hidden */
  17838. _currentAngularSpeed1: number;
  17839. /** @hidden */
  17840. _currentAngularSpeed2: number;
  17841. /** @hidden */
  17842. _currentVelocityGradient: Nullable<FactorGradient>;
  17843. /** @hidden */
  17844. _currentVelocity1: number;
  17845. /** @hidden */
  17846. _currentVelocity2: number;
  17847. /** @hidden */
  17848. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17849. /** @hidden */
  17850. _currentLimitVelocity1: number;
  17851. /** @hidden */
  17852. _currentLimitVelocity2: number;
  17853. /** @hidden */
  17854. _currentDragGradient: Nullable<FactorGradient>;
  17855. /** @hidden */
  17856. _currentDrag1: number;
  17857. /** @hidden */
  17858. _currentDrag2: number;
  17859. /** @hidden */
  17860. _randomNoiseCoordinates1: Vector3;
  17861. /** @hidden */
  17862. _randomNoiseCoordinates2: Vector3;
  17863. /**
  17864. * Creates a new instance Particle
  17865. * @param particleSystem the particle system the particle belongs to
  17866. */
  17867. constructor(
  17868. /**
  17869. * The particle system the particle belongs to.
  17870. */
  17871. particleSystem: ParticleSystem);
  17872. private updateCellInfoFromSystem;
  17873. /**
  17874. * Defines how the sprite cell index is updated for the particle
  17875. */
  17876. updateCellIndex(): void;
  17877. /** @hidden */
  17878. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17879. /** @hidden */
  17880. _inheritParticleInfoToSubEmitters(): void;
  17881. /** @hidden */
  17882. _reset(): void;
  17883. /**
  17884. * Copy the properties of particle to another one.
  17885. * @param other the particle to copy the information to.
  17886. */
  17887. copyTo(other: Particle): void;
  17888. }
  17889. }
  17890. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17891. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17892. import { Effect } from "babylonjs/Materials/effect";
  17893. import { Particle } from "babylonjs/Particles/particle";
  17894. /**
  17895. * Particle emitter represents a volume emitting particles.
  17896. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17897. */
  17898. export interface IParticleEmitterType {
  17899. /**
  17900. * Called by the particle System when the direction is computed for the created particle.
  17901. * @param worldMatrix is the world matrix of the particle system
  17902. * @param directionToUpdate is the direction vector to update with the result
  17903. * @param particle is the particle we are computed the direction for
  17904. */
  17905. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17906. /**
  17907. * Called by the particle System when the position is computed for the created particle.
  17908. * @param worldMatrix is the world matrix of the particle system
  17909. * @param positionToUpdate is the position vector to update with the result
  17910. * @param particle is the particle we are computed the position for
  17911. */
  17912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17913. /**
  17914. * Clones the current emitter and returns a copy of it
  17915. * @returns the new emitter
  17916. */
  17917. clone(): IParticleEmitterType;
  17918. /**
  17919. * Called by the GPUParticleSystem to setup the update shader
  17920. * @param effect defines the update shader
  17921. */
  17922. applyToShader(effect: Effect): void;
  17923. /**
  17924. * Returns a string to use to update the GPU particles update shader
  17925. * @returns the effect defines string
  17926. */
  17927. getEffectDefines(): string;
  17928. /**
  17929. * Returns a string representing the class name
  17930. * @returns a string containing the class name
  17931. */
  17932. getClassName(): string;
  17933. /**
  17934. * Serializes the particle system to a JSON object.
  17935. * @returns the JSON object
  17936. */
  17937. serialize(): any;
  17938. /**
  17939. * Parse properties from a JSON object
  17940. * @param serializationObject defines the JSON object
  17941. */
  17942. parse(serializationObject: any): void;
  17943. }
  17944. }
  17945. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17947. import { Effect } from "babylonjs/Materials/effect";
  17948. import { Particle } from "babylonjs/Particles/particle";
  17949. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17950. /**
  17951. * Particle emitter emitting particles from the inside of a box.
  17952. * It emits the particles randomly between 2 given directions.
  17953. */
  17954. export class BoxParticleEmitter implements IParticleEmitterType {
  17955. /**
  17956. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17957. */
  17958. direction1: Vector3;
  17959. /**
  17960. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17961. */
  17962. direction2: Vector3;
  17963. /**
  17964. * 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.
  17965. */
  17966. minEmitBox: Vector3;
  17967. /**
  17968. * 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.
  17969. */
  17970. maxEmitBox: Vector3;
  17971. /**
  17972. * Creates a new instance BoxParticleEmitter
  17973. */
  17974. constructor();
  17975. /**
  17976. * Called by the particle System when the direction is computed for the created particle.
  17977. * @param worldMatrix is the world matrix of the particle system
  17978. * @param directionToUpdate is the direction vector to update with the result
  17979. * @param particle is the particle we are computed the direction for
  17980. */
  17981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17982. /**
  17983. * Called by the particle System when the position is computed for the created particle.
  17984. * @param worldMatrix is the world matrix of the particle system
  17985. * @param positionToUpdate is the position vector to update with the result
  17986. * @param particle is the particle we are computed the position for
  17987. */
  17988. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17989. /**
  17990. * Clones the current emitter and returns a copy of it
  17991. * @returns the new emitter
  17992. */
  17993. clone(): BoxParticleEmitter;
  17994. /**
  17995. * Called by the GPUParticleSystem to setup the update shader
  17996. * @param effect defines the update shader
  17997. */
  17998. applyToShader(effect: Effect): void;
  17999. /**
  18000. * Returns a string to use to update the GPU particles update shader
  18001. * @returns a string containng the defines string
  18002. */
  18003. getEffectDefines(): string;
  18004. /**
  18005. * Returns the string "BoxParticleEmitter"
  18006. * @returns a string containing the class name
  18007. */
  18008. getClassName(): string;
  18009. /**
  18010. * Serializes the particle system to a JSON object.
  18011. * @returns the JSON object
  18012. */
  18013. serialize(): any;
  18014. /**
  18015. * Parse properties from a JSON object
  18016. * @param serializationObject defines the JSON object
  18017. */
  18018. parse(serializationObject: any): void;
  18019. }
  18020. }
  18021. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18022. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18023. import { Effect } from "babylonjs/Materials/effect";
  18024. import { Particle } from "babylonjs/Particles/particle";
  18025. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18026. /**
  18027. * Particle emitter emitting particles from the inside of a cone.
  18028. * It emits the particles alongside the cone volume from the base to the particle.
  18029. * The emission direction might be randomized.
  18030. */
  18031. export class ConeParticleEmitter implements IParticleEmitterType {
  18032. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18033. directionRandomizer: number;
  18034. private _radius;
  18035. private _angle;
  18036. private _height;
  18037. /**
  18038. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18039. */
  18040. radiusRange: number;
  18041. /**
  18042. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18043. */
  18044. heightRange: number;
  18045. /**
  18046. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18047. */
  18048. emitFromSpawnPointOnly: boolean;
  18049. /**
  18050. * Gets or sets the radius of the emission cone
  18051. */
  18052. radius: number;
  18053. /**
  18054. * Gets or sets the angle of the emission cone
  18055. */
  18056. angle: number;
  18057. private _buildHeight;
  18058. /**
  18059. * Creates a new instance ConeParticleEmitter
  18060. * @param radius the radius of the emission cone (1 by default)
  18061. * @param angle the cone base angle (PI by default)
  18062. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18063. */
  18064. constructor(radius?: number, angle?: number,
  18065. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18066. directionRandomizer?: number);
  18067. /**
  18068. * Called by the particle System when the direction is computed for the created particle.
  18069. * @param worldMatrix is the world matrix of the particle system
  18070. * @param directionToUpdate is the direction vector to update with the result
  18071. * @param particle is the particle we are computed the direction for
  18072. */
  18073. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18074. /**
  18075. * Called by the particle System when the position is computed for the created particle.
  18076. * @param worldMatrix is the world matrix of the particle system
  18077. * @param positionToUpdate is the position vector to update with the result
  18078. * @param particle is the particle we are computed the position for
  18079. */
  18080. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18081. /**
  18082. * Clones the current emitter and returns a copy of it
  18083. * @returns the new emitter
  18084. */
  18085. clone(): ConeParticleEmitter;
  18086. /**
  18087. * Called by the GPUParticleSystem to setup the update shader
  18088. * @param effect defines the update shader
  18089. */
  18090. applyToShader(effect: Effect): void;
  18091. /**
  18092. * Returns a string to use to update the GPU particles update shader
  18093. * @returns a string containng the defines string
  18094. */
  18095. getEffectDefines(): string;
  18096. /**
  18097. * Returns the string "ConeParticleEmitter"
  18098. * @returns a string containing the class name
  18099. */
  18100. getClassName(): string;
  18101. /**
  18102. * Serializes the particle system to a JSON object.
  18103. * @returns the JSON object
  18104. */
  18105. serialize(): any;
  18106. /**
  18107. * Parse properties from a JSON object
  18108. * @param serializationObject defines the JSON object
  18109. */
  18110. parse(serializationObject: any): void;
  18111. }
  18112. }
  18113. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18114. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18115. import { Effect } from "babylonjs/Materials/effect";
  18116. import { Particle } from "babylonjs/Particles/particle";
  18117. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18118. /**
  18119. * Particle emitter emitting particles from the inside of a cylinder.
  18120. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18121. */
  18122. export class CylinderParticleEmitter implements IParticleEmitterType {
  18123. /**
  18124. * The radius of the emission cylinder.
  18125. */
  18126. radius: number;
  18127. /**
  18128. * The height of the emission cylinder.
  18129. */
  18130. height: number;
  18131. /**
  18132. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18133. */
  18134. radiusRange: number;
  18135. /**
  18136. * How much to randomize the particle direction [0-1].
  18137. */
  18138. directionRandomizer: number;
  18139. /**
  18140. * Creates a new instance CylinderParticleEmitter
  18141. * @param radius the radius of the emission cylinder (1 by default)
  18142. * @param height the height of the emission cylinder (1 by default)
  18143. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18144. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18145. */
  18146. constructor(
  18147. /**
  18148. * The radius of the emission cylinder.
  18149. */
  18150. radius?: number,
  18151. /**
  18152. * The height of the emission cylinder.
  18153. */
  18154. height?: number,
  18155. /**
  18156. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18157. */
  18158. radiusRange?: number,
  18159. /**
  18160. * How much to randomize the particle direction [0-1].
  18161. */
  18162. directionRandomizer?: number);
  18163. /**
  18164. * Called by the particle System when the direction is computed for the created particle.
  18165. * @param worldMatrix is the world matrix of the particle system
  18166. * @param directionToUpdate is the direction vector to update with the result
  18167. * @param particle is the particle we are computed the direction for
  18168. */
  18169. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18170. /**
  18171. * Called by the particle System when the position is computed for the created particle.
  18172. * @param worldMatrix is the world matrix of the particle system
  18173. * @param positionToUpdate is the position vector to update with the result
  18174. * @param particle is the particle we are computed the position for
  18175. */
  18176. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18177. /**
  18178. * Clones the current emitter and returns a copy of it
  18179. * @returns the new emitter
  18180. */
  18181. clone(): CylinderParticleEmitter;
  18182. /**
  18183. * Called by the GPUParticleSystem to setup the update shader
  18184. * @param effect defines the update shader
  18185. */
  18186. applyToShader(effect: Effect): void;
  18187. /**
  18188. * Returns a string to use to update the GPU particles update shader
  18189. * @returns a string containng the defines string
  18190. */
  18191. getEffectDefines(): string;
  18192. /**
  18193. * Returns the string "CylinderParticleEmitter"
  18194. * @returns a string containing the class name
  18195. */
  18196. getClassName(): string;
  18197. /**
  18198. * Serializes the particle system to a JSON object.
  18199. * @returns the JSON object
  18200. */
  18201. serialize(): any;
  18202. /**
  18203. * Parse properties from a JSON object
  18204. * @param serializationObject defines the JSON object
  18205. */
  18206. parse(serializationObject: any): void;
  18207. }
  18208. /**
  18209. * Particle emitter emitting particles from the inside of a cylinder.
  18210. * It emits the particles randomly between two vectors.
  18211. */
  18212. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18213. /**
  18214. * The min limit of the emission direction.
  18215. */
  18216. direction1: Vector3;
  18217. /**
  18218. * The max limit of the emission direction.
  18219. */
  18220. direction2: Vector3;
  18221. /**
  18222. * Creates a new instance CylinderDirectedParticleEmitter
  18223. * @param radius the radius of the emission cylinder (1 by default)
  18224. * @param height the height of the emission cylinder (1 by default)
  18225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18226. * @param direction1 the min limit of the emission direction (up vector by default)
  18227. * @param direction2 the max limit of the emission direction (up vector by default)
  18228. */
  18229. constructor(radius?: number, height?: number, radiusRange?: number,
  18230. /**
  18231. * The min limit of the emission direction.
  18232. */
  18233. direction1?: Vector3,
  18234. /**
  18235. * The max limit of the emission direction.
  18236. */
  18237. direction2?: Vector3);
  18238. /**
  18239. * Called by the particle System when the direction is computed for the created particle.
  18240. * @param worldMatrix is the world matrix of the particle system
  18241. * @param directionToUpdate is the direction vector to update with the result
  18242. * @param particle is the particle we are computed the direction for
  18243. */
  18244. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18245. /**
  18246. * Clones the current emitter and returns a copy of it
  18247. * @returns the new emitter
  18248. */
  18249. clone(): CylinderDirectedParticleEmitter;
  18250. /**
  18251. * Called by the GPUParticleSystem to setup the update shader
  18252. * @param effect defines the update shader
  18253. */
  18254. applyToShader(effect: Effect): void;
  18255. /**
  18256. * Returns a string to use to update the GPU particles update shader
  18257. * @returns a string containng the defines string
  18258. */
  18259. getEffectDefines(): string;
  18260. /**
  18261. * Returns the string "CylinderDirectedParticleEmitter"
  18262. * @returns a string containing the class name
  18263. */
  18264. getClassName(): string;
  18265. /**
  18266. * Serializes the particle system to a JSON object.
  18267. * @returns the JSON object
  18268. */
  18269. serialize(): any;
  18270. /**
  18271. * Parse properties from a JSON object
  18272. * @param serializationObject defines the JSON object
  18273. */
  18274. parse(serializationObject: any): void;
  18275. }
  18276. }
  18277. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18278. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18279. import { Effect } from "babylonjs/Materials/effect";
  18280. import { Particle } from "babylonjs/Particles/particle";
  18281. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18282. /**
  18283. * Particle emitter emitting particles from the inside of a hemisphere.
  18284. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18285. */
  18286. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18287. /**
  18288. * The radius of the emission hemisphere.
  18289. */
  18290. radius: number;
  18291. /**
  18292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18293. */
  18294. radiusRange: number;
  18295. /**
  18296. * How much to randomize the particle direction [0-1].
  18297. */
  18298. directionRandomizer: number;
  18299. /**
  18300. * Creates a new instance HemisphericParticleEmitter
  18301. * @param radius the radius of the emission hemisphere (1 by default)
  18302. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18304. */
  18305. constructor(
  18306. /**
  18307. * The radius of the emission hemisphere.
  18308. */
  18309. radius?: number,
  18310. /**
  18311. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18312. */
  18313. radiusRange?: number,
  18314. /**
  18315. * How much to randomize the particle direction [0-1].
  18316. */
  18317. directionRandomizer?: number);
  18318. /**
  18319. * Called by the particle System when the direction is computed for the created particle.
  18320. * @param worldMatrix is the world matrix of the particle system
  18321. * @param directionToUpdate is the direction vector to update with the result
  18322. * @param particle is the particle we are computed the direction for
  18323. */
  18324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18325. /**
  18326. * Called by the particle System when the position is computed for the created particle.
  18327. * @param worldMatrix is the world matrix of the particle system
  18328. * @param positionToUpdate is the position vector to update with the result
  18329. * @param particle is the particle we are computed the position for
  18330. */
  18331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18332. /**
  18333. * Clones the current emitter and returns a copy of it
  18334. * @returns the new emitter
  18335. */
  18336. clone(): HemisphericParticleEmitter;
  18337. /**
  18338. * Called by the GPUParticleSystem to setup the update shader
  18339. * @param effect defines the update shader
  18340. */
  18341. applyToShader(effect: Effect): void;
  18342. /**
  18343. * Returns a string to use to update the GPU particles update shader
  18344. * @returns a string containng the defines string
  18345. */
  18346. getEffectDefines(): string;
  18347. /**
  18348. * Returns the string "HemisphericParticleEmitter"
  18349. * @returns a string containing the class name
  18350. */
  18351. getClassName(): string;
  18352. /**
  18353. * Serializes the particle system to a JSON object.
  18354. * @returns the JSON object
  18355. */
  18356. serialize(): any;
  18357. /**
  18358. * Parse properties from a JSON object
  18359. * @param serializationObject defines the JSON object
  18360. */
  18361. parse(serializationObject: any): void;
  18362. }
  18363. }
  18364. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18365. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18366. import { Effect } from "babylonjs/Materials/effect";
  18367. import { Particle } from "babylonjs/Particles/particle";
  18368. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18369. /**
  18370. * Particle emitter emitting particles from a point.
  18371. * It emits the particles randomly between 2 given directions.
  18372. */
  18373. export class PointParticleEmitter implements IParticleEmitterType {
  18374. /**
  18375. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18376. */
  18377. direction1: Vector3;
  18378. /**
  18379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18380. */
  18381. direction2: Vector3;
  18382. /**
  18383. * Creates a new instance PointParticleEmitter
  18384. */
  18385. constructor();
  18386. /**
  18387. * Called by the particle System when the direction is computed for the created particle.
  18388. * @param worldMatrix is the world matrix of the particle system
  18389. * @param directionToUpdate is the direction vector to update with the result
  18390. * @param particle is the particle we are computed the direction for
  18391. */
  18392. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18393. /**
  18394. * Called by the particle System when the position is computed for the created particle.
  18395. * @param worldMatrix is the world matrix of the particle system
  18396. * @param positionToUpdate is the position vector to update with the result
  18397. * @param particle is the particle we are computed the position for
  18398. */
  18399. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18400. /**
  18401. * Clones the current emitter and returns a copy of it
  18402. * @returns the new emitter
  18403. */
  18404. clone(): PointParticleEmitter;
  18405. /**
  18406. * Called by the GPUParticleSystem to setup the update shader
  18407. * @param effect defines the update shader
  18408. */
  18409. applyToShader(effect: Effect): void;
  18410. /**
  18411. * Returns a string to use to update the GPU particles update shader
  18412. * @returns a string containng the defines string
  18413. */
  18414. getEffectDefines(): string;
  18415. /**
  18416. * Returns the string "PointParticleEmitter"
  18417. * @returns a string containing the class name
  18418. */
  18419. getClassName(): string;
  18420. /**
  18421. * Serializes the particle system to a JSON object.
  18422. * @returns the JSON object
  18423. */
  18424. serialize(): any;
  18425. /**
  18426. * Parse properties from a JSON object
  18427. * @param serializationObject defines the JSON object
  18428. */
  18429. parse(serializationObject: any): void;
  18430. }
  18431. }
  18432. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18433. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18434. import { Effect } from "babylonjs/Materials/effect";
  18435. import { Particle } from "babylonjs/Particles/particle";
  18436. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18437. /**
  18438. * Particle emitter emitting particles from the inside of a sphere.
  18439. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18440. */
  18441. export class SphereParticleEmitter implements IParticleEmitterType {
  18442. /**
  18443. * The radius of the emission sphere.
  18444. */
  18445. radius: number;
  18446. /**
  18447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18448. */
  18449. radiusRange: number;
  18450. /**
  18451. * How much to randomize the particle direction [0-1].
  18452. */
  18453. directionRandomizer: number;
  18454. /**
  18455. * Creates a new instance SphereParticleEmitter
  18456. * @param radius the radius of the emission sphere (1 by default)
  18457. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18458. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18459. */
  18460. constructor(
  18461. /**
  18462. * The radius of the emission sphere.
  18463. */
  18464. radius?: number,
  18465. /**
  18466. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18467. */
  18468. radiusRange?: number,
  18469. /**
  18470. * How much to randomize the particle direction [0-1].
  18471. */
  18472. directionRandomizer?: number);
  18473. /**
  18474. * Called by the particle System when the direction is computed for the created particle.
  18475. * @param worldMatrix is the world matrix of the particle system
  18476. * @param directionToUpdate is the direction vector to update with the result
  18477. * @param particle is the particle we are computed the direction for
  18478. */
  18479. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18480. /**
  18481. * Called by the particle System when the position is computed for the created particle.
  18482. * @param worldMatrix is the world matrix of the particle system
  18483. * @param positionToUpdate is the position vector to update with the result
  18484. * @param particle is the particle we are computed the position for
  18485. */
  18486. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18487. /**
  18488. * Clones the current emitter and returns a copy of it
  18489. * @returns the new emitter
  18490. */
  18491. clone(): SphereParticleEmitter;
  18492. /**
  18493. * Called by the GPUParticleSystem to setup the update shader
  18494. * @param effect defines the update shader
  18495. */
  18496. applyToShader(effect: Effect): void;
  18497. /**
  18498. * Returns a string to use to update the GPU particles update shader
  18499. * @returns a string containng the defines string
  18500. */
  18501. getEffectDefines(): string;
  18502. /**
  18503. * Returns the string "SphereParticleEmitter"
  18504. * @returns a string containing the class name
  18505. */
  18506. getClassName(): string;
  18507. /**
  18508. * Serializes the particle system to a JSON object.
  18509. * @returns the JSON object
  18510. */
  18511. serialize(): any;
  18512. /**
  18513. * Parse properties from a JSON object
  18514. * @param serializationObject defines the JSON object
  18515. */
  18516. parse(serializationObject: any): void;
  18517. }
  18518. /**
  18519. * Particle emitter emitting particles from the inside of a sphere.
  18520. * It emits the particles randomly between two vectors.
  18521. */
  18522. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18523. /**
  18524. * The min limit of the emission direction.
  18525. */
  18526. direction1: Vector3;
  18527. /**
  18528. * The max limit of the emission direction.
  18529. */
  18530. direction2: Vector3;
  18531. /**
  18532. * Creates a new instance SphereDirectedParticleEmitter
  18533. * @param radius the radius of the emission sphere (1 by default)
  18534. * @param direction1 the min limit of the emission direction (up vector by default)
  18535. * @param direction2 the max limit of the emission direction (up vector by default)
  18536. */
  18537. constructor(radius?: number,
  18538. /**
  18539. * The min limit of the emission direction.
  18540. */
  18541. direction1?: Vector3,
  18542. /**
  18543. * The max limit of the emission direction.
  18544. */
  18545. direction2?: Vector3);
  18546. /**
  18547. * Called by the particle System when the direction is computed for the created particle.
  18548. * @param worldMatrix is the world matrix of the particle system
  18549. * @param directionToUpdate is the direction vector to update with the result
  18550. * @param particle is the particle we are computed the direction for
  18551. */
  18552. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18553. /**
  18554. * Clones the current emitter and returns a copy of it
  18555. * @returns the new emitter
  18556. */
  18557. clone(): SphereDirectedParticleEmitter;
  18558. /**
  18559. * Called by the GPUParticleSystem to setup the update shader
  18560. * @param effect defines the update shader
  18561. */
  18562. applyToShader(effect: Effect): void;
  18563. /**
  18564. * Returns a string to use to update the GPU particles update shader
  18565. * @returns a string containng the defines string
  18566. */
  18567. getEffectDefines(): string;
  18568. /**
  18569. * Returns the string "SphereDirectedParticleEmitter"
  18570. * @returns a string containing the class name
  18571. */
  18572. getClassName(): string;
  18573. /**
  18574. * Serializes the particle system to a JSON object.
  18575. * @returns the JSON object
  18576. */
  18577. serialize(): any;
  18578. /**
  18579. * Parse properties from a JSON object
  18580. * @param serializationObject defines the JSON object
  18581. */
  18582. parse(serializationObject: any): void;
  18583. }
  18584. }
  18585. declare module "babylonjs/Particles/EmitterTypes/index" {
  18586. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18587. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18588. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18589. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18590. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18591. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18592. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18593. }
  18594. declare module "babylonjs/Particles/IParticleSystem" {
  18595. import { Nullable } from "babylonjs/types";
  18596. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18597. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18600. import { Texture } from "babylonjs/Materials/Textures/texture";
  18601. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18602. import { Scene } from "babylonjs/scene";
  18603. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18604. import { Animation } from "babylonjs/Animations/animation";
  18605. /**
  18606. * Interface representing a particle system in Babylon.js.
  18607. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18608. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18609. */
  18610. export interface IParticleSystem {
  18611. /**
  18612. * List of animations used by the particle system.
  18613. */
  18614. animations: Animation[];
  18615. /**
  18616. * The id of the Particle system.
  18617. */
  18618. id: string;
  18619. /**
  18620. * The name of the Particle system.
  18621. */
  18622. name: string;
  18623. /**
  18624. * The emitter represents the Mesh or position we are attaching the particle system to.
  18625. */
  18626. emitter: Nullable<AbstractMesh | Vector3>;
  18627. /**
  18628. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18629. */
  18630. isBillboardBased: boolean;
  18631. /**
  18632. * The rendering group used by the Particle system to chose when to render.
  18633. */
  18634. renderingGroupId: number;
  18635. /**
  18636. * The layer mask we are rendering the particles through.
  18637. */
  18638. layerMask: number;
  18639. /**
  18640. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18641. */
  18642. updateSpeed: number;
  18643. /**
  18644. * The amount of time the particle system is running (depends of the overall update speed).
  18645. */
  18646. targetStopDuration: number;
  18647. /**
  18648. * The texture used to render each particle. (this can be a spritesheet)
  18649. */
  18650. particleTexture: Nullable<Texture>;
  18651. /**
  18652. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18653. */
  18654. blendMode: number;
  18655. /**
  18656. * Minimum life time of emitting particles.
  18657. */
  18658. minLifeTime: number;
  18659. /**
  18660. * Maximum life time of emitting particles.
  18661. */
  18662. maxLifeTime: number;
  18663. /**
  18664. * Minimum Size of emitting particles.
  18665. */
  18666. minSize: number;
  18667. /**
  18668. * Maximum Size of emitting particles.
  18669. */
  18670. maxSize: number;
  18671. /**
  18672. * Minimum scale of emitting particles on X axis.
  18673. */
  18674. minScaleX: number;
  18675. /**
  18676. * Maximum scale of emitting particles on X axis.
  18677. */
  18678. maxScaleX: number;
  18679. /**
  18680. * Minimum scale of emitting particles on Y axis.
  18681. */
  18682. minScaleY: number;
  18683. /**
  18684. * Maximum scale of emitting particles on Y axis.
  18685. */
  18686. maxScaleY: number;
  18687. /**
  18688. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18689. */
  18690. color1: Color4;
  18691. /**
  18692. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18693. */
  18694. color2: Color4;
  18695. /**
  18696. * Color the particle will have at the end of its lifetime.
  18697. */
  18698. colorDead: Color4;
  18699. /**
  18700. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18701. */
  18702. emitRate: number;
  18703. /**
  18704. * You can use gravity if you want to give an orientation to your particles.
  18705. */
  18706. gravity: Vector3;
  18707. /**
  18708. * Minimum power of emitting particles.
  18709. */
  18710. minEmitPower: number;
  18711. /**
  18712. * Maximum power of emitting particles.
  18713. */
  18714. maxEmitPower: number;
  18715. /**
  18716. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18717. */
  18718. minAngularSpeed: number;
  18719. /**
  18720. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18721. */
  18722. maxAngularSpeed: number;
  18723. /**
  18724. * Gets or sets the minimal initial rotation in radians.
  18725. */
  18726. minInitialRotation: number;
  18727. /**
  18728. * Gets or sets the maximal initial rotation in radians.
  18729. */
  18730. maxInitialRotation: number;
  18731. /**
  18732. * The particle emitter type defines the emitter used by the particle system.
  18733. * It can be for example box, sphere, or cone...
  18734. */
  18735. particleEmitterType: Nullable<IParticleEmitterType>;
  18736. /**
  18737. * Defines the delay in milliseconds before starting the system (0 by default)
  18738. */
  18739. startDelay: number;
  18740. /**
  18741. * 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
  18742. */
  18743. preWarmCycles: number;
  18744. /**
  18745. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18746. */
  18747. preWarmStepOffset: number;
  18748. /**
  18749. * 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)
  18750. */
  18751. spriteCellChangeSpeed: number;
  18752. /**
  18753. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18754. */
  18755. startSpriteCellID: number;
  18756. /**
  18757. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18758. */
  18759. endSpriteCellID: number;
  18760. /**
  18761. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18762. */
  18763. spriteCellWidth: number;
  18764. /**
  18765. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18766. */
  18767. spriteCellHeight: number;
  18768. /**
  18769. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18770. */
  18771. spriteRandomStartCell: boolean;
  18772. /**
  18773. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18774. */
  18775. isAnimationSheetEnabled: boolean;
  18776. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18777. translationPivot: Vector2;
  18778. /**
  18779. * Gets or sets a texture used to add random noise to particle positions
  18780. */
  18781. noiseTexture: Nullable<BaseTexture>;
  18782. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18783. noiseStrength: Vector3;
  18784. /**
  18785. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18786. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18787. */
  18788. billboardMode: number;
  18789. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18790. limitVelocityDamping: number;
  18791. /**
  18792. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18793. */
  18794. beginAnimationOnStart: boolean;
  18795. /**
  18796. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18797. */
  18798. beginAnimationFrom: number;
  18799. /**
  18800. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18801. */
  18802. beginAnimationTo: number;
  18803. /**
  18804. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18805. */
  18806. beginAnimationLoop: boolean;
  18807. /**
  18808. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18809. */
  18810. disposeOnStop: boolean;
  18811. /**
  18812. * Gets the maximum number of particles active at the same time.
  18813. * @returns The max number of active particles.
  18814. */
  18815. getCapacity(): number;
  18816. /**
  18817. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18818. * @returns True if it has been started, otherwise false.
  18819. */
  18820. isStarted(): boolean;
  18821. /**
  18822. * Animates the particle system for this frame.
  18823. */
  18824. animate(): void;
  18825. /**
  18826. * Renders the particle system in its current state.
  18827. * @returns the current number of particles
  18828. */
  18829. render(): number;
  18830. /**
  18831. * Dispose the particle system and frees its associated resources.
  18832. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18833. */
  18834. dispose(disposeTexture?: boolean): void;
  18835. /**
  18836. * Clones the particle system.
  18837. * @param name The name of the cloned object
  18838. * @param newEmitter The new emitter to use
  18839. * @returns the cloned particle system
  18840. */
  18841. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18842. /**
  18843. * Serializes the particle system to a JSON object.
  18844. * @returns the JSON object
  18845. */
  18846. serialize(): any;
  18847. /**
  18848. * Rebuild the particle system
  18849. */
  18850. rebuild(): void;
  18851. /**
  18852. * Starts the particle system and begins to emit
  18853. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18854. */
  18855. start(delay?: number): void;
  18856. /**
  18857. * Stops the particle system.
  18858. */
  18859. stop(): void;
  18860. /**
  18861. * Remove all active particles
  18862. */
  18863. reset(): void;
  18864. /**
  18865. * Is this system ready to be used/rendered
  18866. * @return true if the system is ready
  18867. */
  18868. isReady(): boolean;
  18869. /**
  18870. * Adds a new color gradient
  18871. * @param gradient defines the gradient to use (between 0 and 1)
  18872. * @param color1 defines the color to affect to the specified gradient
  18873. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18874. * @returns the current particle system
  18875. */
  18876. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18877. /**
  18878. * Remove a specific color gradient
  18879. * @param gradient defines the gradient to remove
  18880. * @returns the current particle system
  18881. */
  18882. removeColorGradient(gradient: number): IParticleSystem;
  18883. /**
  18884. * Adds a new size gradient
  18885. * @param gradient defines the gradient to use (between 0 and 1)
  18886. * @param factor defines the size factor to affect to the specified gradient
  18887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18888. * @returns the current particle system
  18889. */
  18890. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18891. /**
  18892. * Remove a specific size gradient
  18893. * @param gradient defines the gradient to remove
  18894. * @returns the current particle system
  18895. */
  18896. removeSizeGradient(gradient: number): IParticleSystem;
  18897. /**
  18898. * Gets the current list of color gradients.
  18899. * You must use addColorGradient and removeColorGradient to udpate this list
  18900. * @returns the list of color gradients
  18901. */
  18902. getColorGradients(): Nullable<Array<ColorGradient>>;
  18903. /**
  18904. * Gets the current list of size gradients.
  18905. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18906. * @returns the list of size gradients
  18907. */
  18908. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18909. /**
  18910. * Gets the current list of angular speed gradients.
  18911. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18912. * @returns the list of angular speed gradients
  18913. */
  18914. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18915. /**
  18916. * Adds a new angular speed gradient
  18917. * @param gradient defines the gradient to use (between 0 and 1)
  18918. * @param factor defines the angular speed to affect to the specified gradient
  18919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18920. * @returns the current particle system
  18921. */
  18922. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18923. /**
  18924. * Remove a specific angular speed gradient
  18925. * @param gradient defines the gradient to remove
  18926. * @returns the current particle system
  18927. */
  18928. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18929. /**
  18930. * Gets the current list of velocity gradients.
  18931. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18932. * @returns the list of velocity gradients
  18933. */
  18934. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18935. /**
  18936. * Adds a new velocity gradient
  18937. * @param gradient defines the gradient to use (between 0 and 1)
  18938. * @param factor defines the velocity to affect to the specified gradient
  18939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18940. * @returns the current particle system
  18941. */
  18942. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18943. /**
  18944. * Remove a specific velocity gradient
  18945. * @param gradient defines the gradient to remove
  18946. * @returns the current particle system
  18947. */
  18948. removeVelocityGradient(gradient: number): IParticleSystem;
  18949. /**
  18950. * Gets the current list of limit velocity gradients.
  18951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18952. * @returns the list of limit velocity gradients
  18953. */
  18954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18955. /**
  18956. * Adds a new limit velocity gradient
  18957. * @param gradient defines the gradient to use (between 0 and 1)
  18958. * @param factor defines the limit velocity to affect to the specified gradient
  18959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18960. * @returns the current particle system
  18961. */
  18962. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18963. /**
  18964. * Remove a specific limit velocity gradient
  18965. * @param gradient defines the gradient to remove
  18966. * @returns the current particle system
  18967. */
  18968. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18969. /**
  18970. * Adds a new drag gradient
  18971. * @param gradient defines the gradient to use (between 0 and 1)
  18972. * @param factor defines the drag to affect to the specified gradient
  18973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18974. * @returns the current particle system
  18975. */
  18976. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18977. /**
  18978. * Remove a specific drag gradient
  18979. * @param gradient defines the gradient to remove
  18980. * @returns the current particle system
  18981. */
  18982. removeDragGradient(gradient: number): IParticleSystem;
  18983. /**
  18984. * Gets the current list of drag gradients.
  18985. * You must use addDragGradient and removeDragGradient to udpate this list
  18986. * @returns the list of drag gradients
  18987. */
  18988. getDragGradients(): Nullable<Array<FactorGradient>>;
  18989. /**
  18990. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18991. * @param gradient defines the gradient to use (between 0 and 1)
  18992. * @param factor defines the emit rate to affect to the specified gradient
  18993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18994. * @returns the current particle system
  18995. */
  18996. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18997. /**
  18998. * Remove a specific emit rate gradient
  18999. * @param gradient defines the gradient to remove
  19000. * @returns the current particle system
  19001. */
  19002. removeEmitRateGradient(gradient: number): IParticleSystem;
  19003. /**
  19004. * Gets the current list of emit rate gradients.
  19005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19006. * @returns the list of emit rate gradients
  19007. */
  19008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19009. /**
  19010. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19011. * @param gradient defines the gradient to use (between 0 and 1)
  19012. * @param factor defines the start size to affect to the specified gradient
  19013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19014. * @returns the current particle system
  19015. */
  19016. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19017. /**
  19018. * Remove a specific start size gradient
  19019. * @param gradient defines the gradient to remove
  19020. * @returns the current particle system
  19021. */
  19022. removeStartSizeGradient(gradient: number): IParticleSystem;
  19023. /**
  19024. * Gets the current list of start size gradients.
  19025. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19026. * @returns the list of start size gradients
  19027. */
  19028. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19029. /**
  19030. * Adds a new life time gradient
  19031. * @param gradient defines the gradient to use (between 0 and 1)
  19032. * @param factor defines the life time factor to affect to the specified gradient
  19033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19034. * @returns the current particle system
  19035. */
  19036. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19037. /**
  19038. * Remove a specific life time gradient
  19039. * @param gradient defines the gradient to remove
  19040. * @returns the current particle system
  19041. */
  19042. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19043. /**
  19044. * Gets the current list of life time gradients.
  19045. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19046. * @returns the list of life time gradients
  19047. */
  19048. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19049. /**
  19050. * Gets the current list of color gradients.
  19051. * You must use addColorGradient and removeColorGradient to udpate this list
  19052. * @returns the list of color gradients
  19053. */
  19054. getColorGradients(): Nullable<Array<ColorGradient>>;
  19055. /**
  19056. * Adds a new ramp gradient used to remap particle colors
  19057. * @param gradient defines the gradient to use (between 0 and 1)
  19058. * @param color defines the color to affect to the specified gradient
  19059. * @returns the current particle system
  19060. */
  19061. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19062. /**
  19063. * Gets the current list of ramp gradients.
  19064. * You must use addRampGradient and removeRampGradient to udpate this list
  19065. * @returns the list of ramp gradients
  19066. */
  19067. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19068. /** Gets or sets a boolean indicating that ramp gradients must be used
  19069. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19070. */
  19071. useRampGradients: boolean;
  19072. /**
  19073. * Adds a new color remap gradient
  19074. * @param gradient defines the gradient to use (between 0 and 1)
  19075. * @param min defines the color remap minimal range
  19076. * @param max defines the color remap maximal range
  19077. * @returns the current particle system
  19078. */
  19079. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19080. /**
  19081. * Gets the current list of color remap gradients.
  19082. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19083. * @returns the list of color remap gradients
  19084. */
  19085. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19086. /**
  19087. * Adds a new alpha remap gradient
  19088. * @param gradient defines the gradient to use (between 0 and 1)
  19089. * @param min defines the alpha remap minimal range
  19090. * @param max defines the alpha remap maximal range
  19091. * @returns the current particle system
  19092. */
  19093. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19094. /**
  19095. * Gets the current list of alpha remap gradients.
  19096. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19097. * @returns the list of alpha remap gradients
  19098. */
  19099. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19100. /**
  19101. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19102. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19103. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19104. * @returns the emitter
  19105. */
  19106. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19107. /**
  19108. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19109. * @param radius The radius of the hemisphere to emit from
  19110. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19111. * @returns the emitter
  19112. */
  19113. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19114. /**
  19115. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19116. * @param radius The radius of the sphere to emit from
  19117. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19118. * @returns the emitter
  19119. */
  19120. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19121. /**
  19122. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19123. * @param radius The radius of the sphere to emit from
  19124. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19125. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19126. * @returns the emitter
  19127. */
  19128. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19129. /**
  19130. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19131. * @param radius The radius of the emission cylinder
  19132. * @param height The height of the emission cylinder
  19133. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19134. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19135. * @returns the emitter
  19136. */
  19137. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19138. /**
  19139. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19140. * @param radius The radius of the cylinder to emit from
  19141. * @param height The height of the emission cylinder
  19142. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19143. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19144. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19145. * @returns the emitter
  19146. */
  19147. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19148. /**
  19149. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19150. * @param radius The radius of the cone to emit from
  19151. * @param angle The base angle of the cone
  19152. * @returns the emitter
  19153. */
  19154. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19155. /**
  19156. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19157. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19158. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19159. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19160. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19161. * @returns the emitter
  19162. */
  19163. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19164. /**
  19165. * Get hosting scene
  19166. * @returns the scene
  19167. */
  19168. getScene(): Scene;
  19169. }
  19170. }
  19171. declare module "babylonjs/Meshes/instancedMesh" {
  19172. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19173. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19174. import { Camera } from "babylonjs/Cameras/camera";
  19175. import { Node } from "babylonjs/node";
  19176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19177. import { Mesh } from "babylonjs/Meshes/mesh";
  19178. import { Material } from "babylonjs/Materials/material";
  19179. import { Skeleton } from "babylonjs/Bones/skeleton";
  19180. import { Light } from "babylonjs/Lights/light";
  19181. /**
  19182. * Creates an instance based on a source mesh.
  19183. */
  19184. export class InstancedMesh extends AbstractMesh {
  19185. private _sourceMesh;
  19186. private _currentLOD;
  19187. /** @hidden */
  19188. _indexInSourceMeshInstanceArray: number;
  19189. constructor(name: string, source: Mesh);
  19190. /**
  19191. * Returns the string "InstancedMesh".
  19192. */
  19193. getClassName(): string;
  19194. /** Gets the list of lights affecting that mesh */
  19195. readonly lightSources: Light[];
  19196. _resyncLightSources(): void;
  19197. _resyncLighSource(light: Light): void;
  19198. _removeLightSource(light: Light, dispose: boolean): void;
  19199. /**
  19200. * If the source mesh receives shadows
  19201. */
  19202. readonly receiveShadows: boolean;
  19203. /**
  19204. * The material of the source mesh
  19205. */
  19206. readonly material: Nullable<Material>;
  19207. /**
  19208. * Visibility of the source mesh
  19209. */
  19210. readonly visibility: number;
  19211. /**
  19212. * Skeleton of the source mesh
  19213. */
  19214. readonly skeleton: Nullable<Skeleton>;
  19215. /**
  19216. * Rendering ground id of the source mesh
  19217. */
  19218. renderingGroupId: number;
  19219. /**
  19220. * Returns the total number of vertices (integer).
  19221. */
  19222. getTotalVertices(): number;
  19223. /**
  19224. * Returns a positive integer : the total number of indices in this mesh geometry.
  19225. * @returns the numner of indices or zero if the mesh has no geometry.
  19226. */
  19227. getTotalIndices(): number;
  19228. /**
  19229. * The source mesh of the instance
  19230. */
  19231. readonly sourceMesh: Mesh;
  19232. /**
  19233. * Is this node ready to be used/rendered
  19234. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19235. * @return {boolean} is it ready
  19236. */
  19237. isReady(completeCheck?: boolean): boolean;
  19238. /**
  19239. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19240. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19241. * @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.
  19242. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19243. */
  19244. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19245. /**
  19246. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19247. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19248. * The `data` are either a numeric array either a Float32Array.
  19249. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19250. * 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).
  19251. * Note that a new underlying VertexBuffer object is created each call.
  19252. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19253. *
  19254. * Possible `kind` values :
  19255. * - VertexBuffer.PositionKind
  19256. * - VertexBuffer.UVKind
  19257. * - VertexBuffer.UV2Kind
  19258. * - VertexBuffer.UV3Kind
  19259. * - VertexBuffer.UV4Kind
  19260. * - VertexBuffer.UV5Kind
  19261. * - VertexBuffer.UV6Kind
  19262. * - VertexBuffer.ColorKind
  19263. * - VertexBuffer.MatricesIndicesKind
  19264. * - VertexBuffer.MatricesIndicesExtraKind
  19265. * - VertexBuffer.MatricesWeightsKind
  19266. * - VertexBuffer.MatricesWeightsExtraKind
  19267. *
  19268. * Returns the Mesh.
  19269. */
  19270. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19271. /**
  19272. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19273. * If the mesh has no geometry, it is simply returned as it is.
  19274. * The `data` are either a numeric array either a Float32Array.
  19275. * No new underlying VertexBuffer object is created.
  19276. * 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.
  19277. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19278. *
  19279. * Possible `kind` values :
  19280. * - VertexBuffer.PositionKind
  19281. * - VertexBuffer.UVKind
  19282. * - VertexBuffer.UV2Kind
  19283. * - VertexBuffer.UV3Kind
  19284. * - VertexBuffer.UV4Kind
  19285. * - VertexBuffer.UV5Kind
  19286. * - VertexBuffer.UV6Kind
  19287. * - VertexBuffer.ColorKind
  19288. * - VertexBuffer.MatricesIndicesKind
  19289. * - VertexBuffer.MatricesIndicesExtraKind
  19290. * - VertexBuffer.MatricesWeightsKind
  19291. * - VertexBuffer.MatricesWeightsExtraKind
  19292. *
  19293. * Returns the Mesh.
  19294. */
  19295. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19296. /**
  19297. * Sets the mesh indices.
  19298. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19299. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19300. * This method creates a new index buffer each call.
  19301. * Returns the Mesh.
  19302. */
  19303. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19304. /**
  19305. * Boolean : True if the mesh owns the requested kind of data.
  19306. */
  19307. isVerticesDataPresent(kind: string): boolean;
  19308. /**
  19309. * Returns an array of indices (IndicesArray).
  19310. */
  19311. getIndices(): Nullable<IndicesArray>;
  19312. readonly _positions: Nullable<Vector3[]>;
  19313. /**
  19314. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19315. * This means the mesh underlying bounding box and sphere are recomputed.
  19316. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19317. * @returns the current mesh
  19318. */
  19319. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19320. /** @hidden */
  19321. _preActivate(): InstancedMesh;
  19322. /** @hidden */
  19323. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19324. /** @hidden */
  19325. _postActivate(): void;
  19326. getWorldMatrix(): Matrix;
  19327. readonly isAnInstance: boolean;
  19328. /**
  19329. * Returns the current associated LOD AbstractMesh.
  19330. */
  19331. getLOD(camera: Camera): AbstractMesh;
  19332. /** @hidden */
  19333. _syncSubMeshes(): InstancedMesh;
  19334. /** @hidden */
  19335. _generatePointsArray(): boolean;
  19336. /**
  19337. * Creates a new InstancedMesh from the current mesh.
  19338. * - name (string) : the cloned mesh name
  19339. * - newParent (optional Node) : the optional Node to parent the clone to.
  19340. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19341. *
  19342. * Returns the clone.
  19343. */
  19344. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19345. /**
  19346. * Disposes the InstancedMesh.
  19347. * Returns nothing.
  19348. */
  19349. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19350. }
  19351. }
  19352. declare module "babylonjs/Materials/shaderMaterial" {
  19353. import { Scene } from "babylonjs/scene";
  19354. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19356. import { Mesh } from "babylonjs/Meshes/mesh";
  19357. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19359. import { Texture } from "babylonjs/Materials/Textures/texture";
  19360. import { Material } from "babylonjs/Materials/material";
  19361. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19362. /**
  19363. * Defines the options associated with the creation of a shader material.
  19364. */
  19365. export interface IShaderMaterialOptions {
  19366. /**
  19367. * Does the material work in alpha blend mode
  19368. */
  19369. needAlphaBlending: boolean;
  19370. /**
  19371. * Does the material work in alpha test mode
  19372. */
  19373. needAlphaTesting: boolean;
  19374. /**
  19375. * The list of attribute names used in the shader
  19376. */
  19377. attributes: string[];
  19378. /**
  19379. * The list of unifrom names used in the shader
  19380. */
  19381. uniforms: string[];
  19382. /**
  19383. * The list of UBO names used in the shader
  19384. */
  19385. uniformBuffers: string[];
  19386. /**
  19387. * The list of sampler names used in the shader
  19388. */
  19389. samplers: string[];
  19390. /**
  19391. * The list of defines used in the shader
  19392. */
  19393. defines: string[];
  19394. }
  19395. /**
  19396. * 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.
  19397. *
  19398. * This returned material effects how the mesh will look based on the code in the shaders.
  19399. *
  19400. * @see http://doc.babylonjs.com/how_to/shader_material
  19401. */
  19402. export class ShaderMaterial extends Material {
  19403. private _shaderPath;
  19404. private _options;
  19405. private _textures;
  19406. private _textureArrays;
  19407. private _floats;
  19408. private _ints;
  19409. private _floatsArrays;
  19410. private _colors3;
  19411. private _colors3Arrays;
  19412. private _colors4;
  19413. private _colors4Arrays;
  19414. private _vectors2;
  19415. private _vectors3;
  19416. private _vectors4;
  19417. private _matrices;
  19418. private _matrices3x3;
  19419. private _matrices2x2;
  19420. private _vectors2Arrays;
  19421. private _vectors3Arrays;
  19422. private _vectors4Arrays;
  19423. private _cachedWorldViewMatrix;
  19424. private _cachedWorldViewProjectionMatrix;
  19425. private _renderId;
  19426. /**
  19427. * Instantiate a new shader material.
  19428. * 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.
  19429. * This returned material effects how the mesh will look based on the code in the shaders.
  19430. * @see http://doc.babylonjs.com/how_to/shader_material
  19431. * @param name Define the name of the material in the scene
  19432. * @param scene Define the scene the material belongs to
  19433. * @param shaderPath Defines the route to the shader code in one of three ways:
  19434. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19435. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19436. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19437. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19438. * @param options Define the options used to create the shader
  19439. */
  19440. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19441. /**
  19442. * Gets the options used to compile the shader.
  19443. * They can be modified to trigger a new compilation
  19444. */
  19445. readonly options: IShaderMaterialOptions;
  19446. /**
  19447. * Gets the current class name of the material e.g. "ShaderMaterial"
  19448. * Mainly use in serialization.
  19449. * @returns the class name
  19450. */
  19451. getClassName(): string;
  19452. /**
  19453. * Specifies if the material will require alpha blending
  19454. * @returns a boolean specifying if alpha blending is needed
  19455. */
  19456. needAlphaBlending(): boolean;
  19457. /**
  19458. * Specifies if this material should be rendered in alpha test mode
  19459. * @returns a boolean specifying if an alpha test is needed.
  19460. */
  19461. needAlphaTesting(): boolean;
  19462. private _checkUniform;
  19463. /**
  19464. * Set a texture in the shader.
  19465. * @param name Define the name of the uniform samplers as defined in the shader
  19466. * @param texture Define the texture to bind to this sampler
  19467. * @return the material itself allowing "fluent" like uniform updates
  19468. */
  19469. setTexture(name: string, texture: Texture): ShaderMaterial;
  19470. /**
  19471. * Set a texture array in the shader.
  19472. * @param name Define the name of the uniform sampler array as defined in the shader
  19473. * @param textures Define the list of textures to bind to this sampler
  19474. * @return the material itself allowing "fluent" like uniform updates
  19475. */
  19476. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19477. /**
  19478. * Set a float in the shader.
  19479. * @param name Define the name of the uniform as defined in the shader
  19480. * @param value Define the value to give to the uniform
  19481. * @return the material itself allowing "fluent" like uniform updates
  19482. */
  19483. setFloat(name: string, value: number): ShaderMaterial;
  19484. /**
  19485. * Set a int in the shader.
  19486. * @param name Define the name of the uniform as defined in the shader
  19487. * @param value Define the value to give to the uniform
  19488. * @return the material itself allowing "fluent" like uniform updates
  19489. */
  19490. setInt(name: string, value: number): ShaderMaterial;
  19491. /**
  19492. * Set an array of floats in the shader.
  19493. * @param name Define the name of the uniform as defined in the shader
  19494. * @param value Define the value to give to the uniform
  19495. * @return the material itself allowing "fluent" like uniform updates
  19496. */
  19497. setFloats(name: string, value: number[]): ShaderMaterial;
  19498. /**
  19499. * Set a vec3 in the shader from a Color3.
  19500. * @param name Define the name of the uniform as defined in the shader
  19501. * @param value Define the value to give to the uniform
  19502. * @return the material itself allowing "fluent" like uniform updates
  19503. */
  19504. setColor3(name: string, value: Color3): ShaderMaterial;
  19505. /**
  19506. * Set a vec3 array in the shader from a Color3 array.
  19507. * @param name Define the name of the uniform as defined in the shader
  19508. * @param value Define the value to give to the uniform
  19509. * @return the material itself allowing "fluent" like uniform updates
  19510. */
  19511. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19512. /**
  19513. * Set a vec4 in the shader from a Color4.
  19514. * @param name Define the name of the uniform as defined in the shader
  19515. * @param value Define the value to give to the uniform
  19516. * @return the material itself allowing "fluent" like uniform updates
  19517. */
  19518. setColor4(name: string, value: Color4): ShaderMaterial;
  19519. /**
  19520. * Set a vec4 array in the shader from a Color4 array.
  19521. * @param name Define the name of the uniform as defined in the shader
  19522. * @param value Define the value to give to the uniform
  19523. * @return the material itself allowing "fluent" like uniform updates
  19524. */
  19525. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19526. /**
  19527. * Set a vec2 in the shader from a Vector2.
  19528. * @param name Define the name of the uniform as defined in the shader
  19529. * @param value Define the value to give to the uniform
  19530. * @return the material itself allowing "fluent" like uniform updates
  19531. */
  19532. setVector2(name: string, value: Vector2): ShaderMaterial;
  19533. /**
  19534. * Set a vec3 in the shader from a Vector3.
  19535. * @param name Define the name of the uniform as defined in the shader
  19536. * @param value Define the value to give to the uniform
  19537. * @return the material itself allowing "fluent" like uniform updates
  19538. */
  19539. setVector3(name: string, value: Vector3): ShaderMaterial;
  19540. /**
  19541. * Set a vec4 in the shader from a Vector4.
  19542. * @param name Define the name of the uniform as defined in the shader
  19543. * @param value Define the value to give to the uniform
  19544. * @return the material itself allowing "fluent" like uniform updates
  19545. */
  19546. setVector4(name: string, value: Vector4): ShaderMaterial;
  19547. /**
  19548. * Set a mat4 in the shader from a Matrix.
  19549. * @param name Define the name of the uniform as defined in the shader
  19550. * @param value Define the value to give to the uniform
  19551. * @return the material itself allowing "fluent" like uniform updates
  19552. */
  19553. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19554. /**
  19555. * Set a mat3 in the shader from a Float32Array.
  19556. * @param name Define the name of the uniform as defined in the shader
  19557. * @param value Define the value to give to the uniform
  19558. * @return the material itself allowing "fluent" like uniform updates
  19559. */
  19560. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19561. /**
  19562. * Set a mat2 in the shader from a Float32Array.
  19563. * @param name Define the name of the uniform as defined in the shader
  19564. * @param value Define the value to give to the uniform
  19565. * @return the material itself allowing "fluent" like uniform updates
  19566. */
  19567. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19568. /**
  19569. * Set a vec2 array in the shader from a number array.
  19570. * @param name Define the name of the uniform as defined in the shader
  19571. * @param value Define the value to give to the uniform
  19572. * @return the material itself allowing "fluent" like uniform updates
  19573. */
  19574. setArray2(name: string, value: number[]): ShaderMaterial;
  19575. /**
  19576. * Set a vec3 array in the shader from a number array.
  19577. * @param name Define the name of the uniform as defined in the shader
  19578. * @param value Define the value to give to the uniform
  19579. * @return the material itself allowing "fluent" like uniform updates
  19580. */
  19581. setArray3(name: string, value: number[]): ShaderMaterial;
  19582. /**
  19583. * Set a vec4 array in the shader from a number array.
  19584. * @param name Define the name of the uniform as defined in the shader
  19585. * @param value Define the value to give to the uniform
  19586. * @return the material itself allowing "fluent" like uniform updates
  19587. */
  19588. setArray4(name: string, value: number[]): ShaderMaterial;
  19589. private _checkCache;
  19590. /**
  19591. * Specifies that the submesh is ready to be used
  19592. * @param mesh defines the mesh to check
  19593. * @param subMesh defines which submesh to check
  19594. * @param useInstances specifies that instances should be used
  19595. * @returns a boolean indicating that the submesh is ready or not
  19596. */
  19597. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19598. /**
  19599. * Checks if the material is ready to render the requested mesh
  19600. * @param mesh Define the mesh to render
  19601. * @param useInstances Define whether or not the material is used with instances
  19602. * @returns true if ready, otherwise false
  19603. */
  19604. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19605. /**
  19606. * Binds the world matrix to the material
  19607. * @param world defines the world transformation matrix
  19608. */
  19609. bindOnlyWorldMatrix(world: Matrix): void;
  19610. /**
  19611. * Binds the material to the mesh
  19612. * @param world defines the world transformation matrix
  19613. * @param mesh defines the mesh to bind the material to
  19614. */
  19615. bind(world: Matrix, mesh?: Mesh): void;
  19616. /**
  19617. * Gets the active textures from the material
  19618. * @returns an array of textures
  19619. */
  19620. getActiveTextures(): BaseTexture[];
  19621. /**
  19622. * Specifies if the material uses a texture
  19623. * @param texture defines the texture to check against the material
  19624. * @returns a boolean specifying if the material uses the texture
  19625. */
  19626. hasTexture(texture: BaseTexture): boolean;
  19627. /**
  19628. * Makes a duplicate of the material, and gives it a new name
  19629. * @param name defines the new name for the duplicated material
  19630. * @returns the cloned material
  19631. */
  19632. clone(name: string): ShaderMaterial;
  19633. /**
  19634. * Disposes the material
  19635. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19636. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19637. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19638. */
  19639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19640. /**
  19641. * Serializes this material in a JSON representation
  19642. * @returns the serialized material object
  19643. */
  19644. serialize(): any;
  19645. /**
  19646. * Creates a shader material from parsed shader material data
  19647. * @param source defines the JSON represnetation of the material
  19648. * @param scene defines the hosting scene
  19649. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19650. * @returns a new material
  19651. */
  19652. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19653. }
  19654. }
  19655. declare module "babylonjs/Shaders/color.fragment" {
  19656. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19657. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19658. /** @hidden */
  19659. export var colorPixelShader: {
  19660. name: string;
  19661. shader: string;
  19662. };
  19663. }
  19664. declare module "babylonjs/Shaders/color.vertex" {
  19665. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19666. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19667. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19668. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19669. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19670. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19671. /** @hidden */
  19672. export var colorVertexShader: {
  19673. name: string;
  19674. shader: string;
  19675. };
  19676. }
  19677. declare module "babylonjs/Meshes/linesMesh" {
  19678. import { Nullable } from "babylonjs/types";
  19679. import { Scene } from "babylonjs/scene";
  19680. import { Color3 } from "babylonjs/Maths/math.color";
  19681. import { Node } from "babylonjs/node";
  19682. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19683. import { Mesh } from "babylonjs/Meshes/mesh";
  19684. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19685. import { Effect } from "babylonjs/Materials/effect";
  19686. import { Material } from "babylonjs/Materials/material";
  19687. import "babylonjs/Shaders/color.fragment";
  19688. import "babylonjs/Shaders/color.vertex";
  19689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19690. /**
  19691. * Line mesh
  19692. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19693. */
  19694. export class LinesMesh extends Mesh {
  19695. /**
  19696. * If vertex color should be applied to the mesh
  19697. */
  19698. readonly useVertexColor?: boolean | undefined;
  19699. /**
  19700. * If vertex alpha should be applied to the mesh
  19701. */
  19702. readonly useVertexAlpha?: boolean | undefined;
  19703. /**
  19704. * Color of the line (Default: White)
  19705. */
  19706. color: Color3;
  19707. /**
  19708. * Alpha of the line (Default: 1)
  19709. */
  19710. alpha: number;
  19711. /**
  19712. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19713. * This margin is expressed in world space coordinates, so its value may vary.
  19714. * Default value is 0.1
  19715. */
  19716. intersectionThreshold: number;
  19717. private _colorShader;
  19718. private color4;
  19719. /**
  19720. * Creates a new LinesMesh
  19721. * @param name defines the name
  19722. * @param scene defines the hosting scene
  19723. * @param parent defines the parent mesh if any
  19724. * @param source defines the optional source LinesMesh used to clone data from
  19725. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19726. * When false, achieved by calling a clone(), also passing False.
  19727. * This will make creation of children, recursive.
  19728. * @param useVertexColor defines if this LinesMesh supports vertex color
  19729. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19730. */
  19731. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19732. /**
  19733. * If vertex color should be applied to the mesh
  19734. */
  19735. useVertexColor?: boolean | undefined,
  19736. /**
  19737. * If vertex alpha should be applied to the mesh
  19738. */
  19739. useVertexAlpha?: boolean | undefined);
  19740. private _addClipPlaneDefine;
  19741. private _removeClipPlaneDefine;
  19742. isReady(): boolean;
  19743. /**
  19744. * Returns the string "LineMesh"
  19745. */
  19746. getClassName(): string;
  19747. /**
  19748. * @hidden
  19749. */
  19750. /**
  19751. * @hidden
  19752. */
  19753. material: Material;
  19754. /**
  19755. * @hidden
  19756. */
  19757. readonly checkCollisions: boolean;
  19758. /** @hidden */
  19759. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19760. /** @hidden */
  19761. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19762. /**
  19763. * Disposes of the line mesh
  19764. * @param doNotRecurse If children should be disposed
  19765. */
  19766. dispose(doNotRecurse?: boolean): void;
  19767. /**
  19768. * Returns a new LineMesh object cloned from the current one.
  19769. */
  19770. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19771. /**
  19772. * Creates a new InstancedLinesMesh object from the mesh model.
  19773. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19774. * @param name defines the name of the new instance
  19775. * @returns a new InstancedLinesMesh
  19776. */
  19777. createInstance(name: string): InstancedLinesMesh;
  19778. }
  19779. /**
  19780. * Creates an instance based on a source LinesMesh
  19781. */
  19782. export class InstancedLinesMesh extends InstancedMesh {
  19783. /**
  19784. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19785. * This margin is expressed in world space coordinates, so its value may vary.
  19786. * Initilized with the intersectionThreshold value of the source LinesMesh
  19787. */
  19788. intersectionThreshold: number;
  19789. constructor(name: string, source: LinesMesh);
  19790. /**
  19791. * Returns the string "InstancedLinesMesh".
  19792. */
  19793. getClassName(): string;
  19794. }
  19795. }
  19796. declare module "babylonjs/Shaders/line.fragment" {
  19797. /** @hidden */
  19798. export var linePixelShader: {
  19799. name: string;
  19800. shader: string;
  19801. };
  19802. }
  19803. declare module "babylonjs/Shaders/line.vertex" {
  19804. /** @hidden */
  19805. export var lineVertexShader: {
  19806. name: string;
  19807. shader: string;
  19808. };
  19809. }
  19810. declare module "babylonjs/Rendering/edgesRenderer" {
  19811. import { Nullable } from "babylonjs/types";
  19812. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19814. import { Vector3 } from "babylonjs/Maths/math.vector";
  19815. import { IDisposable } from "babylonjs/scene";
  19816. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19817. import "babylonjs/Shaders/line.fragment";
  19818. import "babylonjs/Shaders/line.vertex";
  19819. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19820. module "babylonjs/Meshes/abstractMesh" {
  19821. interface AbstractMesh {
  19822. /**
  19823. * Gets the edgesRenderer associated with the mesh
  19824. */
  19825. edgesRenderer: Nullable<EdgesRenderer>;
  19826. }
  19827. }
  19828. module "babylonjs/Meshes/linesMesh" {
  19829. interface LinesMesh {
  19830. /**
  19831. * Enables the edge rendering mode on the mesh.
  19832. * This mode makes the mesh edges visible
  19833. * @param epsilon defines the maximal distance between two angles to detect a face
  19834. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19835. * @returns the currentAbstractMesh
  19836. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19837. */
  19838. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19839. }
  19840. }
  19841. module "babylonjs/Meshes/linesMesh" {
  19842. interface InstancedLinesMesh {
  19843. /**
  19844. * Enables the edge rendering mode on the mesh.
  19845. * This mode makes the mesh edges visible
  19846. * @param epsilon defines the maximal distance between two angles to detect a face
  19847. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19848. * @returns the current InstancedLinesMesh
  19849. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19850. */
  19851. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19852. }
  19853. }
  19854. /**
  19855. * Defines the minimum contract an Edges renderer should follow.
  19856. */
  19857. export interface IEdgesRenderer extends IDisposable {
  19858. /**
  19859. * Gets or sets a boolean indicating if the edgesRenderer is active
  19860. */
  19861. isEnabled: boolean;
  19862. /**
  19863. * Renders the edges of the attached mesh,
  19864. */
  19865. render(): void;
  19866. /**
  19867. * Checks wether or not the edges renderer is ready to render.
  19868. * @return true if ready, otherwise false.
  19869. */
  19870. isReady(): boolean;
  19871. }
  19872. /**
  19873. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19874. */
  19875. export class EdgesRenderer implements IEdgesRenderer {
  19876. /**
  19877. * Define the size of the edges with an orthographic camera
  19878. */
  19879. edgesWidthScalerForOrthographic: number;
  19880. /**
  19881. * Define the size of the edges with a perspective camera
  19882. */
  19883. edgesWidthScalerForPerspective: number;
  19884. protected _source: AbstractMesh;
  19885. protected _linesPositions: number[];
  19886. protected _linesNormals: number[];
  19887. protected _linesIndices: number[];
  19888. protected _epsilon: number;
  19889. protected _indicesCount: number;
  19890. protected _lineShader: ShaderMaterial;
  19891. protected _ib: DataBuffer;
  19892. protected _buffers: {
  19893. [key: string]: Nullable<VertexBuffer>;
  19894. };
  19895. protected _checkVerticesInsteadOfIndices: boolean;
  19896. private _meshRebuildObserver;
  19897. private _meshDisposeObserver;
  19898. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19899. isEnabled: boolean;
  19900. /**
  19901. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19902. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19903. * @param source Mesh used to create edges
  19904. * @param epsilon sum of angles in adjacency to check for edge
  19905. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19906. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19907. */
  19908. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19909. protected _prepareRessources(): void;
  19910. /** @hidden */
  19911. _rebuild(): void;
  19912. /**
  19913. * Releases the required resources for the edges renderer
  19914. */
  19915. dispose(): void;
  19916. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19917. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19918. /**
  19919. * Checks if the pair of p0 and p1 is en edge
  19920. * @param faceIndex
  19921. * @param edge
  19922. * @param faceNormals
  19923. * @param p0
  19924. * @param p1
  19925. * @private
  19926. */
  19927. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19928. /**
  19929. * push line into the position, normal and index buffer
  19930. * @protected
  19931. */
  19932. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19933. /**
  19934. * Generates lines edges from adjacencjes
  19935. * @private
  19936. */
  19937. _generateEdgesLines(): void;
  19938. /**
  19939. * Checks wether or not the edges renderer is ready to render.
  19940. * @return true if ready, otherwise false.
  19941. */
  19942. isReady(): boolean;
  19943. /**
  19944. * Renders the edges of the attached mesh,
  19945. */
  19946. render(): void;
  19947. }
  19948. /**
  19949. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19950. */
  19951. export class LineEdgesRenderer extends EdgesRenderer {
  19952. /**
  19953. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19954. * @param source LineMesh used to generate edges
  19955. * @param epsilon not important (specified angle for edge detection)
  19956. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19957. */
  19958. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19959. /**
  19960. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19961. */
  19962. _generateEdgesLines(): void;
  19963. }
  19964. }
  19965. declare module "babylonjs/Rendering/renderingGroup" {
  19966. import { SmartArray } from "babylonjs/Misc/smartArray";
  19967. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19969. import { Nullable } from "babylonjs/types";
  19970. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19971. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19972. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19973. import { Material } from "babylonjs/Materials/material";
  19974. import { Scene } from "babylonjs/scene";
  19975. /**
  19976. * This represents the object necessary to create a rendering group.
  19977. * This is exclusively used and created by the rendering manager.
  19978. * To modify the behavior, you use the available helpers in your scene or meshes.
  19979. * @hidden
  19980. */
  19981. export class RenderingGroup {
  19982. index: number;
  19983. private static _zeroVector;
  19984. private _scene;
  19985. private _opaqueSubMeshes;
  19986. private _transparentSubMeshes;
  19987. private _alphaTestSubMeshes;
  19988. private _depthOnlySubMeshes;
  19989. private _particleSystems;
  19990. private _spriteManagers;
  19991. private _opaqueSortCompareFn;
  19992. private _alphaTestSortCompareFn;
  19993. private _transparentSortCompareFn;
  19994. private _renderOpaque;
  19995. private _renderAlphaTest;
  19996. private _renderTransparent;
  19997. /** @hidden */
  19998. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19999. onBeforeTransparentRendering: () => void;
  20000. /**
  20001. * Set the opaque sort comparison function.
  20002. * If null the sub meshes will be render in the order they were created
  20003. */
  20004. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20005. /**
  20006. * Set the alpha test sort comparison function.
  20007. * If null the sub meshes will be render in the order they were created
  20008. */
  20009. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20010. /**
  20011. * Set the transparent sort comparison function.
  20012. * If null the sub meshes will be render in the order they were created
  20013. */
  20014. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20015. /**
  20016. * Creates a new rendering group.
  20017. * @param index The rendering group index
  20018. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20019. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20020. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20021. */
  20022. 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>);
  20023. /**
  20024. * Render all the sub meshes contained in the group.
  20025. * @param customRenderFunction Used to override the default render behaviour of the group.
  20026. * @returns true if rendered some submeshes.
  20027. */
  20028. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20029. /**
  20030. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20031. * @param subMeshes The submeshes to render
  20032. */
  20033. private renderOpaqueSorted;
  20034. /**
  20035. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20036. * @param subMeshes The submeshes to render
  20037. */
  20038. private renderAlphaTestSorted;
  20039. /**
  20040. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20041. * @param subMeshes The submeshes to render
  20042. */
  20043. private renderTransparentSorted;
  20044. /**
  20045. * Renders the submeshes in a specified order.
  20046. * @param subMeshes The submeshes to sort before render
  20047. * @param sortCompareFn The comparison function use to sort
  20048. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20049. * @param transparent Specifies to activate blending if true
  20050. */
  20051. private static renderSorted;
  20052. /**
  20053. * Renders the submeshes in the order they were dispatched (no sort applied).
  20054. * @param subMeshes The submeshes to render
  20055. */
  20056. private static renderUnsorted;
  20057. /**
  20058. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20059. * are rendered back to front if in the same alpha index.
  20060. *
  20061. * @param a The first submesh
  20062. * @param b The second submesh
  20063. * @returns The result of the comparison
  20064. */
  20065. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20066. /**
  20067. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20068. * are rendered back to front.
  20069. *
  20070. * @param a The first submesh
  20071. * @param b The second submesh
  20072. * @returns The result of the comparison
  20073. */
  20074. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20075. /**
  20076. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20077. * are rendered front to back (prevent overdraw).
  20078. *
  20079. * @param a The first submesh
  20080. * @param b The second submesh
  20081. * @returns The result of the comparison
  20082. */
  20083. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20084. /**
  20085. * Resets the different lists of submeshes to prepare a new frame.
  20086. */
  20087. prepare(): void;
  20088. dispose(): void;
  20089. /**
  20090. * Inserts the submesh in its correct queue depending on its material.
  20091. * @param subMesh The submesh to dispatch
  20092. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20093. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20094. */
  20095. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20096. dispatchSprites(spriteManager: ISpriteManager): void;
  20097. dispatchParticles(particleSystem: IParticleSystem): void;
  20098. private _renderParticles;
  20099. private _renderSprites;
  20100. }
  20101. }
  20102. declare module "babylonjs/Rendering/renderingManager" {
  20103. import { Nullable } from "babylonjs/types";
  20104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20105. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20106. import { SmartArray } from "babylonjs/Misc/smartArray";
  20107. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20108. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20109. import { Material } from "babylonjs/Materials/material";
  20110. import { Scene } from "babylonjs/scene";
  20111. import { Camera } from "babylonjs/Cameras/camera";
  20112. /**
  20113. * Interface describing the different options available in the rendering manager
  20114. * regarding Auto Clear between groups.
  20115. */
  20116. export interface IRenderingManagerAutoClearSetup {
  20117. /**
  20118. * Defines whether or not autoclear is enable.
  20119. */
  20120. autoClear: boolean;
  20121. /**
  20122. * Defines whether or not to autoclear the depth buffer.
  20123. */
  20124. depth: boolean;
  20125. /**
  20126. * Defines whether or not to autoclear the stencil buffer.
  20127. */
  20128. stencil: boolean;
  20129. }
  20130. /**
  20131. * This class is used by the onRenderingGroupObservable
  20132. */
  20133. export class RenderingGroupInfo {
  20134. /**
  20135. * The Scene that being rendered
  20136. */
  20137. scene: Scene;
  20138. /**
  20139. * The camera currently used for the rendering pass
  20140. */
  20141. camera: Nullable<Camera>;
  20142. /**
  20143. * The ID of the renderingGroup being processed
  20144. */
  20145. renderingGroupId: number;
  20146. }
  20147. /**
  20148. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20149. * It is enable to manage the different groups as well as the different necessary sort functions.
  20150. * This should not be used directly aside of the few static configurations
  20151. */
  20152. export class RenderingManager {
  20153. /**
  20154. * The max id used for rendering groups (not included)
  20155. */
  20156. static MAX_RENDERINGGROUPS: number;
  20157. /**
  20158. * The min id used for rendering groups (included)
  20159. */
  20160. static MIN_RENDERINGGROUPS: number;
  20161. /**
  20162. * Used to globally prevent autoclearing scenes.
  20163. */
  20164. static AUTOCLEAR: boolean;
  20165. /**
  20166. * @hidden
  20167. */
  20168. _useSceneAutoClearSetup: boolean;
  20169. private _scene;
  20170. private _renderingGroups;
  20171. private _depthStencilBufferAlreadyCleaned;
  20172. private _autoClearDepthStencil;
  20173. private _customOpaqueSortCompareFn;
  20174. private _customAlphaTestSortCompareFn;
  20175. private _customTransparentSortCompareFn;
  20176. private _renderingGroupInfo;
  20177. /**
  20178. * Instantiates a new rendering group for a particular scene
  20179. * @param scene Defines the scene the groups belongs to
  20180. */
  20181. constructor(scene: Scene);
  20182. private _clearDepthStencilBuffer;
  20183. /**
  20184. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20185. * @hidden
  20186. */
  20187. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20188. /**
  20189. * Resets the different information of the group to prepare a new frame
  20190. * @hidden
  20191. */
  20192. reset(): void;
  20193. /**
  20194. * Dispose and release the group and its associated resources.
  20195. * @hidden
  20196. */
  20197. dispose(): void;
  20198. /**
  20199. * Clear the info related to rendering groups preventing retention points during dispose.
  20200. */
  20201. freeRenderingGroups(): void;
  20202. private _prepareRenderingGroup;
  20203. /**
  20204. * Add a sprite manager to the rendering manager in order to render it this frame.
  20205. * @param spriteManager Define the sprite manager to render
  20206. */
  20207. dispatchSprites(spriteManager: ISpriteManager): void;
  20208. /**
  20209. * Add a particle system to the rendering manager in order to render it this frame.
  20210. * @param particleSystem Define the particle system to render
  20211. */
  20212. dispatchParticles(particleSystem: IParticleSystem): void;
  20213. /**
  20214. * Add a submesh to the manager in order to render it this frame
  20215. * @param subMesh The submesh to dispatch
  20216. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20217. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20218. */
  20219. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20220. /**
  20221. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20222. * This allowed control for front to back rendering or reversly depending of the special needs.
  20223. *
  20224. * @param renderingGroupId The rendering group id corresponding to its index
  20225. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20226. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20227. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20228. */
  20229. 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;
  20230. /**
  20231. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20232. *
  20233. * @param renderingGroupId The rendering group id corresponding to its index
  20234. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20235. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20236. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20237. */
  20238. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20239. /**
  20240. * Gets the current auto clear configuration for one rendering group of the rendering
  20241. * manager.
  20242. * @param index the rendering group index to get the information for
  20243. * @returns The auto clear setup for the requested rendering group
  20244. */
  20245. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20246. }
  20247. }
  20248. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20249. import { Observable } from "babylonjs/Misc/observable";
  20250. import { SmartArray } from "babylonjs/Misc/smartArray";
  20251. import { Nullable } from "babylonjs/types";
  20252. import { Camera } from "babylonjs/Cameras/camera";
  20253. import { Scene } from "babylonjs/scene";
  20254. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20255. import { Color4 } from "babylonjs/Maths/math.color";
  20256. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20260. import { Texture } from "babylonjs/Materials/Textures/texture";
  20261. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20262. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20263. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20264. import { Engine } from "babylonjs/Engines/engine";
  20265. /**
  20266. * This Helps creating a texture that will be created from a camera in your scene.
  20267. * It is basically a dynamic texture that could be used to create special effects for instance.
  20268. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20269. */
  20270. export class RenderTargetTexture extends Texture {
  20271. isCube: boolean;
  20272. /**
  20273. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20274. */
  20275. static readonly REFRESHRATE_RENDER_ONCE: number;
  20276. /**
  20277. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20278. */
  20279. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20280. /**
  20281. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20282. * the central point of your effect and can save a lot of performances.
  20283. */
  20284. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20285. /**
  20286. * Use this predicate to dynamically define the list of mesh you want to render.
  20287. * If set, the renderList property will be overwritten.
  20288. */
  20289. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20290. private _renderList;
  20291. /**
  20292. * Use this list to define the list of mesh you want to render.
  20293. */
  20294. renderList: Nullable<Array<AbstractMesh>>;
  20295. private _hookArray;
  20296. /**
  20297. * Define if particles should be rendered in your texture.
  20298. */
  20299. renderParticles: boolean;
  20300. /**
  20301. * Define if sprites should be rendered in your texture.
  20302. */
  20303. renderSprites: boolean;
  20304. /**
  20305. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20306. */
  20307. coordinatesMode: number;
  20308. /**
  20309. * Define the camera used to render the texture.
  20310. */
  20311. activeCamera: Nullable<Camera>;
  20312. /**
  20313. * Override the render function of the texture with your own one.
  20314. */
  20315. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20316. /**
  20317. * Define if camera post processes should be use while rendering the texture.
  20318. */
  20319. useCameraPostProcesses: boolean;
  20320. /**
  20321. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20322. */
  20323. ignoreCameraViewport: boolean;
  20324. private _postProcessManager;
  20325. private _postProcesses;
  20326. private _resizeObserver;
  20327. /**
  20328. * An event triggered when the texture is unbind.
  20329. */
  20330. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20331. /**
  20332. * An event triggered when the texture is unbind.
  20333. */
  20334. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20335. private _onAfterUnbindObserver;
  20336. /**
  20337. * Set a after unbind callback in the texture.
  20338. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20339. */
  20340. onAfterUnbind: () => void;
  20341. /**
  20342. * An event triggered before rendering the texture
  20343. */
  20344. onBeforeRenderObservable: Observable<number>;
  20345. private _onBeforeRenderObserver;
  20346. /**
  20347. * Set a before render callback in the texture.
  20348. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20349. */
  20350. onBeforeRender: (faceIndex: number) => void;
  20351. /**
  20352. * An event triggered after rendering the texture
  20353. */
  20354. onAfterRenderObservable: Observable<number>;
  20355. private _onAfterRenderObserver;
  20356. /**
  20357. * Set a after render callback in the texture.
  20358. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20359. */
  20360. onAfterRender: (faceIndex: number) => void;
  20361. /**
  20362. * An event triggered after the texture clear
  20363. */
  20364. onClearObservable: Observable<Engine>;
  20365. private _onClearObserver;
  20366. /**
  20367. * Set a clear callback in the texture.
  20368. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20369. */
  20370. onClear: (Engine: Engine) => void;
  20371. /**
  20372. * An event triggered when the texture is resized.
  20373. */
  20374. onResizeObservable: Observable<RenderTargetTexture>;
  20375. /**
  20376. * Define the clear color of the Render Target if it should be different from the scene.
  20377. */
  20378. clearColor: Color4;
  20379. protected _size: number | {
  20380. width: number;
  20381. height: number;
  20382. };
  20383. protected _initialSizeParameter: number | {
  20384. width: number;
  20385. height: number;
  20386. } | {
  20387. ratio: number;
  20388. };
  20389. protected _sizeRatio: Nullable<number>;
  20390. /** @hidden */
  20391. _generateMipMaps: boolean;
  20392. protected _renderingManager: RenderingManager;
  20393. /** @hidden */
  20394. _waitingRenderList: string[];
  20395. protected _doNotChangeAspectRatio: boolean;
  20396. protected _currentRefreshId: number;
  20397. protected _refreshRate: number;
  20398. protected _textureMatrix: Matrix;
  20399. protected _samples: number;
  20400. protected _renderTargetOptions: RenderTargetCreationOptions;
  20401. /**
  20402. * Gets render target creation options that were used.
  20403. */
  20404. readonly renderTargetOptions: RenderTargetCreationOptions;
  20405. protected _engine: Engine;
  20406. protected _onRatioRescale(): void;
  20407. /**
  20408. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20409. * It must define where the camera used to render the texture is set
  20410. */
  20411. boundingBoxPosition: Vector3;
  20412. private _boundingBoxSize;
  20413. /**
  20414. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20415. * When defined, the cubemap will switch to local mode
  20416. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20417. * @example https://www.babylonjs-playground.com/#RNASML
  20418. */
  20419. boundingBoxSize: Vector3;
  20420. /**
  20421. * In case the RTT has been created with a depth texture, get the associated
  20422. * depth texture.
  20423. * Otherwise, return null.
  20424. */
  20425. depthStencilTexture: Nullable<InternalTexture>;
  20426. /**
  20427. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20428. * or used a shadow, depth texture...
  20429. * @param name The friendly name of the texture
  20430. * @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)
  20431. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20432. * @param generateMipMaps True if mip maps need to be generated after render.
  20433. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20434. * @param type The type of the buffer in the RTT (int, half float, float...)
  20435. * @param isCube True if a cube texture needs to be created
  20436. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20437. * @param generateDepthBuffer True to generate a depth buffer
  20438. * @param generateStencilBuffer True to generate a stencil buffer
  20439. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20440. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20441. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20442. */
  20443. constructor(name: string, size: number | {
  20444. width: number;
  20445. height: number;
  20446. } | {
  20447. ratio: number;
  20448. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20449. /**
  20450. * Creates a depth stencil texture.
  20451. * This is only available in WebGL 2 or with the depth texture extension available.
  20452. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20453. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20454. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20455. */
  20456. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20457. private _processSizeParameter;
  20458. /**
  20459. * Define the number of samples to use in case of MSAA.
  20460. * It defaults to one meaning no MSAA has been enabled.
  20461. */
  20462. samples: number;
  20463. /**
  20464. * Resets the refresh counter of the texture and start bak from scratch.
  20465. * Could be useful to regenerate the texture if it is setup to render only once.
  20466. */
  20467. resetRefreshCounter(): void;
  20468. /**
  20469. * Define the refresh rate of the texture or the rendering frequency.
  20470. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20471. */
  20472. refreshRate: number;
  20473. /**
  20474. * Adds a post process to the render target rendering passes.
  20475. * @param postProcess define the post process to add
  20476. */
  20477. addPostProcess(postProcess: PostProcess): void;
  20478. /**
  20479. * Clear all the post processes attached to the render target
  20480. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20481. */
  20482. clearPostProcesses(dispose?: boolean): void;
  20483. /**
  20484. * Remove one of the post process from the list of attached post processes to the texture
  20485. * @param postProcess define the post process to remove from the list
  20486. */
  20487. removePostProcess(postProcess: PostProcess): void;
  20488. /** @hidden */
  20489. _shouldRender(): boolean;
  20490. /**
  20491. * Gets the actual render size of the texture.
  20492. * @returns the width of the render size
  20493. */
  20494. getRenderSize(): number;
  20495. /**
  20496. * Gets the actual render width of the texture.
  20497. * @returns the width of the render size
  20498. */
  20499. getRenderWidth(): number;
  20500. /**
  20501. * Gets the actual render height of the texture.
  20502. * @returns the height of the render size
  20503. */
  20504. getRenderHeight(): number;
  20505. /**
  20506. * Get if the texture can be rescaled or not.
  20507. */
  20508. readonly canRescale: boolean;
  20509. /**
  20510. * Resize the texture using a ratio.
  20511. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20512. */
  20513. scale(ratio: number): void;
  20514. /**
  20515. * Get the texture reflection matrix used to rotate/transform the reflection.
  20516. * @returns the reflection matrix
  20517. */
  20518. getReflectionTextureMatrix(): Matrix;
  20519. /**
  20520. * Resize the texture to a new desired size.
  20521. * Be carrefull as it will recreate all the data in the new texture.
  20522. * @param size Define the new size. It can be:
  20523. * - a number for squared texture,
  20524. * - an object containing { width: number, height: number }
  20525. * - or an object containing a ratio { ratio: number }
  20526. */
  20527. resize(size: number | {
  20528. width: number;
  20529. height: number;
  20530. } | {
  20531. ratio: number;
  20532. }): void;
  20533. /**
  20534. * Renders all the objects from the render list into the texture.
  20535. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20536. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20537. */
  20538. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20539. private _bestReflectionRenderTargetDimension;
  20540. /**
  20541. * @hidden
  20542. * @param faceIndex face index to bind to if this is a cubetexture
  20543. */
  20544. _bindFrameBuffer(faceIndex?: number): void;
  20545. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20546. private renderToTarget;
  20547. /**
  20548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20549. * This allowed control for front to back rendering or reversly depending of the special needs.
  20550. *
  20551. * @param renderingGroupId The rendering group id corresponding to its index
  20552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20555. */
  20556. 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;
  20557. /**
  20558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20559. *
  20560. * @param renderingGroupId The rendering group id corresponding to its index
  20561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20562. */
  20563. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20564. /**
  20565. * Clones the texture.
  20566. * @returns the cloned texture
  20567. */
  20568. clone(): RenderTargetTexture;
  20569. /**
  20570. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20571. * @returns The JSON representation of the texture
  20572. */
  20573. serialize(): any;
  20574. /**
  20575. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20576. */
  20577. disposeFramebufferObjects(): void;
  20578. /**
  20579. * Dispose the texture and release its associated resources.
  20580. */
  20581. dispose(): void;
  20582. /** @hidden */
  20583. _rebuild(): void;
  20584. /**
  20585. * Clear the info related to rendering groups preventing retention point in material dispose.
  20586. */
  20587. freeRenderingGroups(): void;
  20588. /**
  20589. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20590. * @returns the view count
  20591. */
  20592. getViewCount(): number;
  20593. }
  20594. }
  20595. declare module "babylonjs/Materials/material" {
  20596. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20597. import { SmartArray } from "babylonjs/Misc/smartArray";
  20598. import { Observable } from "babylonjs/Misc/observable";
  20599. import { Nullable } from "babylonjs/types";
  20600. import { Scene } from "babylonjs/scene";
  20601. import { Matrix } from "babylonjs/Maths/math.vector";
  20602. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20604. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20605. import { Effect } from "babylonjs/Materials/effect";
  20606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20608. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20609. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20610. import { Mesh } from "babylonjs/Meshes/mesh";
  20611. import { Animation } from "babylonjs/Animations/animation";
  20612. /**
  20613. * Base class for the main features of a material in Babylon.js
  20614. */
  20615. export class Material implements IAnimatable {
  20616. /**
  20617. * Returns the triangle fill mode
  20618. */
  20619. static readonly TriangleFillMode: number;
  20620. /**
  20621. * Returns the wireframe mode
  20622. */
  20623. static readonly WireFrameFillMode: number;
  20624. /**
  20625. * Returns the point fill mode
  20626. */
  20627. static readonly PointFillMode: number;
  20628. /**
  20629. * Returns the point list draw mode
  20630. */
  20631. static readonly PointListDrawMode: number;
  20632. /**
  20633. * Returns the line list draw mode
  20634. */
  20635. static readonly LineListDrawMode: number;
  20636. /**
  20637. * Returns the line loop draw mode
  20638. */
  20639. static readonly LineLoopDrawMode: number;
  20640. /**
  20641. * Returns the line strip draw mode
  20642. */
  20643. static readonly LineStripDrawMode: number;
  20644. /**
  20645. * Returns the triangle strip draw mode
  20646. */
  20647. static readonly TriangleStripDrawMode: number;
  20648. /**
  20649. * Returns the triangle fan draw mode
  20650. */
  20651. static readonly TriangleFanDrawMode: number;
  20652. /**
  20653. * Stores the clock-wise side orientation
  20654. */
  20655. static readonly ClockWiseSideOrientation: number;
  20656. /**
  20657. * Stores the counter clock-wise side orientation
  20658. */
  20659. static readonly CounterClockWiseSideOrientation: number;
  20660. /**
  20661. * The dirty texture flag value
  20662. */
  20663. static readonly TextureDirtyFlag: number;
  20664. /**
  20665. * The dirty light flag value
  20666. */
  20667. static readonly LightDirtyFlag: number;
  20668. /**
  20669. * The dirty fresnel flag value
  20670. */
  20671. static readonly FresnelDirtyFlag: number;
  20672. /**
  20673. * The dirty attribute flag value
  20674. */
  20675. static readonly AttributesDirtyFlag: number;
  20676. /**
  20677. * The dirty misc flag value
  20678. */
  20679. static readonly MiscDirtyFlag: number;
  20680. /**
  20681. * The all dirty flag value
  20682. */
  20683. static readonly AllDirtyFlag: number;
  20684. /**
  20685. * The ID of the material
  20686. */
  20687. id: string;
  20688. /**
  20689. * Gets or sets the unique id of the material
  20690. */
  20691. uniqueId: number;
  20692. /**
  20693. * The name of the material
  20694. */
  20695. name: string;
  20696. /**
  20697. * Gets or sets user defined metadata
  20698. */
  20699. metadata: any;
  20700. /**
  20701. * For internal use only. Please do not use.
  20702. */
  20703. reservedDataStore: any;
  20704. /**
  20705. * Specifies if the ready state should be checked on each call
  20706. */
  20707. checkReadyOnEveryCall: boolean;
  20708. /**
  20709. * Specifies if the ready state should be checked once
  20710. */
  20711. checkReadyOnlyOnce: boolean;
  20712. /**
  20713. * The state of the material
  20714. */
  20715. state: string;
  20716. /**
  20717. * The alpha value of the material
  20718. */
  20719. protected _alpha: number;
  20720. /**
  20721. * List of inspectable custom properties (used by the Inspector)
  20722. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20723. */
  20724. inspectableCustomProperties: IInspectable[];
  20725. /**
  20726. * Sets the alpha value of the material
  20727. */
  20728. /**
  20729. * Gets the alpha value of the material
  20730. */
  20731. alpha: number;
  20732. /**
  20733. * Specifies if back face culling is enabled
  20734. */
  20735. protected _backFaceCulling: boolean;
  20736. /**
  20737. * Sets the back-face culling state
  20738. */
  20739. /**
  20740. * Gets the back-face culling state
  20741. */
  20742. backFaceCulling: boolean;
  20743. /**
  20744. * Stores the value for side orientation
  20745. */
  20746. sideOrientation: number;
  20747. /**
  20748. * Callback triggered when the material is compiled
  20749. */
  20750. onCompiled: Nullable<(effect: Effect) => void>;
  20751. /**
  20752. * Callback triggered when an error occurs
  20753. */
  20754. onError: Nullable<(effect: Effect, errors: string) => void>;
  20755. /**
  20756. * Callback triggered to get the render target textures
  20757. */
  20758. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20759. /**
  20760. * Gets a boolean indicating that current material needs to register RTT
  20761. */
  20762. readonly hasRenderTargetTextures: boolean;
  20763. /**
  20764. * Specifies if the material should be serialized
  20765. */
  20766. doNotSerialize: boolean;
  20767. /**
  20768. * @hidden
  20769. */
  20770. _storeEffectOnSubMeshes: boolean;
  20771. /**
  20772. * Stores the animations for the material
  20773. */
  20774. animations: Nullable<Array<Animation>>;
  20775. /**
  20776. * An event triggered when the material is disposed
  20777. */
  20778. onDisposeObservable: Observable<Material>;
  20779. /**
  20780. * An observer which watches for dispose events
  20781. */
  20782. private _onDisposeObserver;
  20783. private _onUnBindObservable;
  20784. /**
  20785. * Called during a dispose event
  20786. */
  20787. onDispose: () => void;
  20788. private _onBindObservable;
  20789. /**
  20790. * An event triggered when the material is bound
  20791. */
  20792. readonly onBindObservable: Observable<AbstractMesh>;
  20793. /**
  20794. * An observer which watches for bind events
  20795. */
  20796. private _onBindObserver;
  20797. /**
  20798. * Called during a bind event
  20799. */
  20800. onBind: (Mesh: AbstractMesh) => void;
  20801. /**
  20802. * An event triggered when the material is unbound
  20803. */
  20804. readonly onUnBindObservable: Observable<Material>;
  20805. /**
  20806. * Stores the value of the alpha mode
  20807. */
  20808. private _alphaMode;
  20809. /**
  20810. * Sets the value of the alpha mode.
  20811. *
  20812. * | Value | Type | Description |
  20813. * | --- | --- | --- |
  20814. * | 0 | ALPHA_DISABLE | |
  20815. * | 1 | ALPHA_ADD | |
  20816. * | 2 | ALPHA_COMBINE | |
  20817. * | 3 | ALPHA_SUBTRACT | |
  20818. * | 4 | ALPHA_MULTIPLY | |
  20819. * | 5 | ALPHA_MAXIMIZED | |
  20820. * | 6 | ALPHA_ONEONE | |
  20821. * | 7 | ALPHA_PREMULTIPLIED | |
  20822. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20823. * | 9 | ALPHA_INTERPOLATE | |
  20824. * | 10 | ALPHA_SCREENMODE | |
  20825. *
  20826. */
  20827. /**
  20828. * Gets the value of the alpha mode
  20829. */
  20830. alphaMode: number;
  20831. /**
  20832. * Stores the state of the need depth pre-pass value
  20833. */
  20834. private _needDepthPrePass;
  20835. /**
  20836. * Sets the need depth pre-pass value
  20837. */
  20838. /**
  20839. * Gets the depth pre-pass value
  20840. */
  20841. needDepthPrePass: boolean;
  20842. /**
  20843. * Specifies if depth writing should be disabled
  20844. */
  20845. disableDepthWrite: boolean;
  20846. /**
  20847. * Specifies if depth writing should be forced
  20848. */
  20849. forceDepthWrite: boolean;
  20850. /**
  20851. * Specifies if there should be a separate pass for culling
  20852. */
  20853. separateCullingPass: boolean;
  20854. /**
  20855. * Stores the state specifing if fog should be enabled
  20856. */
  20857. private _fogEnabled;
  20858. /**
  20859. * Sets the state for enabling fog
  20860. */
  20861. /**
  20862. * Gets the value of the fog enabled state
  20863. */
  20864. fogEnabled: boolean;
  20865. /**
  20866. * Stores the size of points
  20867. */
  20868. pointSize: number;
  20869. /**
  20870. * Stores the z offset value
  20871. */
  20872. zOffset: number;
  20873. /**
  20874. * Gets a value specifying if wireframe mode is enabled
  20875. */
  20876. /**
  20877. * Sets the state of wireframe mode
  20878. */
  20879. wireframe: boolean;
  20880. /**
  20881. * Gets the value specifying if point clouds are enabled
  20882. */
  20883. /**
  20884. * Sets the state of point cloud mode
  20885. */
  20886. pointsCloud: boolean;
  20887. /**
  20888. * Gets the material fill mode
  20889. */
  20890. /**
  20891. * Sets the material fill mode
  20892. */
  20893. fillMode: number;
  20894. /**
  20895. * @hidden
  20896. * Stores the effects for the material
  20897. */
  20898. _effect: Nullable<Effect>;
  20899. /**
  20900. * @hidden
  20901. * Specifies if the material was previously ready
  20902. */
  20903. _wasPreviouslyReady: boolean;
  20904. /**
  20905. * Specifies if uniform buffers should be used
  20906. */
  20907. private _useUBO;
  20908. /**
  20909. * Stores a reference to the scene
  20910. */
  20911. private _scene;
  20912. /**
  20913. * Stores the fill mode state
  20914. */
  20915. private _fillMode;
  20916. /**
  20917. * Specifies if the depth write state should be cached
  20918. */
  20919. private _cachedDepthWriteState;
  20920. /**
  20921. * Stores the uniform buffer
  20922. */
  20923. protected _uniformBuffer: UniformBuffer;
  20924. /** @hidden */
  20925. _indexInSceneMaterialArray: number;
  20926. /** @hidden */
  20927. meshMap: Nullable<{
  20928. [id: string]: AbstractMesh | undefined;
  20929. }>;
  20930. /**
  20931. * Creates a material instance
  20932. * @param name defines the name of the material
  20933. * @param scene defines the scene to reference
  20934. * @param doNotAdd specifies if the material should be added to the scene
  20935. */
  20936. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20937. /**
  20938. * Returns a string representation of the current material
  20939. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20940. * @returns a string with material information
  20941. */
  20942. toString(fullDetails?: boolean): string;
  20943. /**
  20944. * Gets the class name of the material
  20945. * @returns a string with the class name of the material
  20946. */
  20947. getClassName(): string;
  20948. /**
  20949. * Specifies if updates for the material been locked
  20950. */
  20951. readonly isFrozen: boolean;
  20952. /**
  20953. * Locks updates for the material
  20954. */
  20955. freeze(): void;
  20956. /**
  20957. * Unlocks updates for the material
  20958. */
  20959. unfreeze(): void;
  20960. /**
  20961. * Specifies if the material is ready to be used
  20962. * @param mesh defines the mesh to check
  20963. * @param useInstances specifies if instances should be used
  20964. * @returns a boolean indicating if the material is ready to be used
  20965. */
  20966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20967. /**
  20968. * Specifies that the submesh is ready to be used
  20969. * @param mesh defines the mesh to check
  20970. * @param subMesh defines which submesh to check
  20971. * @param useInstances specifies that instances should be used
  20972. * @returns a boolean indicating that the submesh is ready or not
  20973. */
  20974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20975. /**
  20976. * Returns the material effect
  20977. * @returns the effect associated with the material
  20978. */
  20979. getEffect(): Nullable<Effect>;
  20980. /**
  20981. * Returns the current scene
  20982. * @returns a Scene
  20983. */
  20984. getScene(): Scene;
  20985. /**
  20986. * Specifies if the material will require alpha blending
  20987. * @returns a boolean specifying if alpha blending is needed
  20988. */
  20989. needAlphaBlending(): boolean;
  20990. /**
  20991. * Specifies if the mesh will require alpha blending
  20992. * @param mesh defines the mesh to check
  20993. * @returns a boolean specifying if alpha blending is needed for the mesh
  20994. */
  20995. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20996. /**
  20997. * Specifies if this material should be rendered in alpha test mode
  20998. * @returns a boolean specifying if an alpha test is needed.
  20999. */
  21000. needAlphaTesting(): boolean;
  21001. /**
  21002. * Gets the texture used for the alpha test
  21003. * @returns the texture to use for alpha testing
  21004. */
  21005. getAlphaTestTexture(): Nullable<BaseTexture>;
  21006. /**
  21007. * Marks the material to indicate that it needs to be re-calculated
  21008. */
  21009. markDirty(): void;
  21010. /** @hidden */
  21011. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21012. /**
  21013. * Binds the material to the mesh
  21014. * @param world defines the world transformation matrix
  21015. * @param mesh defines the mesh to bind the material to
  21016. */
  21017. bind(world: Matrix, mesh?: Mesh): void;
  21018. /**
  21019. * Binds the submesh to the material
  21020. * @param world defines the world transformation matrix
  21021. * @param mesh defines the mesh containing the submesh
  21022. * @param subMesh defines the submesh to bind the material to
  21023. */
  21024. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21025. /**
  21026. * Binds the world matrix to the material
  21027. * @param world defines the world transformation matrix
  21028. */
  21029. bindOnlyWorldMatrix(world: Matrix): void;
  21030. /**
  21031. * Binds the scene's uniform buffer to the effect.
  21032. * @param effect defines the effect to bind to the scene uniform buffer
  21033. * @param sceneUbo defines the uniform buffer storing scene data
  21034. */
  21035. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21036. /**
  21037. * Binds the view matrix to the effect
  21038. * @param effect defines the effect to bind the view matrix to
  21039. */
  21040. bindView(effect: Effect): void;
  21041. /**
  21042. * Binds the view projection matrix to the effect
  21043. * @param effect defines the effect to bind the view projection matrix to
  21044. */
  21045. bindViewProjection(effect: Effect): void;
  21046. /**
  21047. * Specifies if material alpha testing should be turned on for the mesh
  21048. * @param mesh defines the mesh to check
  21049. */
  21050. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21051. /**
  21052. * Processes to execute after binding the material to a mesh
  21053. * @param mesh defines the rendered mesh
  21054. */
  21055. protected _afterBind(mesh?: Mesh): void;
  21056. /**
  21057. * Unbinds the material from the mesh
  21058. */
  21059. unbind(): void;
  21060. /**
  21061. * Gets the active textures from the material
  21062. * @returns an array of textures
  21063. */
  21064. getActiveTextures(): BaseTexture[];
  21065. /**
  21066. * Specifies if the material uses a texture
  21067. * @param texture defines the texture to check against the material
  21068. * @returns a boolean specifying if the material uses the texture
  21069. */
  21070. hasTexture(texture: BaseTexture): boolean;
  21071. /**
  21072. * Makes a duplicate of the material, and gives it a new name
  21073. * @param name defines the new name for the duplicated material
  21074. * @returns the cloned material
  21075. */
  21076. clone(name: string): Nullable<Material>;
  21077. /**
  21078. * Gets the meshes bound to the material
  21079. * @returns an array of meshes bound to the material
  21080. */
  21081. getBindedMeshes(): AbstractMesh[];
  21082. /**
  21083. * Force shader compilation
  21084. * @param mesh defines the mesh associated with this material
  21085. * @param onCompiled defines a function to execute once the material is compiled
  21086. * @param options defines the options to configure the compilation
  21087. */
  21088. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21089. clipPlane: boolean;
  21090. }>): void;
  21091. /**
  21092. * Force shader compilation
  21093. * @param mesh defines the mesh that will use this material
  21094. * @param options defines additional options for compiling the shaders
  21095. * @returns a promise that resolves when the compilation completes
  21096. */
  21097. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21098. clipPlane: boolean;
  21099. }>): Promise<void>;
  21100. private static readonly _AllDirtyCallBack;
  21101. private static readonly _ImageProcessingDirtyCallBack;
  21102. private static readonly _TextureDirtyCallBack;
  21103. private static readonly _FresnelDirtyCallBack;
  21104. private static readonly _MiscDirtyCallBack;
  21105. private static readonly _LightsDirtyCallBack;
  21106. private static readonly _AttributeDirtyCallBack;
  21107. private static _FresnelAndMiscDirtyCallBack;
  21108. private static _TextureAndMiscDirtyCallBack;
  21109. private static readonly _DirtyCallbackArray;
  21110. private static readonly _RunDirtyCallBacks;
  21111. /**
  21112. * Marks a define in the material to indicate that it needs to be re-computed
  21113. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21114. */
  21115. markAsDirty(flag: number): void;
  21116. /**
  21117. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21118. * @param func defines a function which checks material defines against the submeshes
  21119. */
  21120. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21121. /**
  21122. * Indicates that we need to re-calculated for all submeshes
  21123. */
  21124. protected _markAllSubMeshesAsAllDirty(): void;
  21125. /**
  21126. * Indicates that image processing needs to be re-calculated for all submeshes
  21127. */
  21128. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21129. /**
  21130. * Indicates that textures need to be re-calculated for all submeshes
  21131. */
  21132. protected _markAllSubMeshesAsTexturesDirty(): void;
  21133. /**
  21134. * Indicates that fresnel needs to be re-calculated for all submeshes
  21135. */
  21136. protected _markAllSubMeshesAsFresnelDirty(): void;
  21137. /**
  21138. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21139. */
  21140. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21141. /**
  21142. * Indicates that lights need to be re-calculated for all submeshes
  21143. */
  21144. protected _markAllSubMeshesAsLightsDirty(): void;
  21145. /**
  21146. * Indicates that attributes need to be re-calculated for all submeshes
  21147. */
  21148. protected _markAllSubMeshesAsAttributesDirty(): void;
  21149. /**
  21150. * Indicates that misc needs to be re-calculated for all submeshes
  21151. */
  21152. protected _markAllSubMeshesAsMiscDirty(): void;
  21153. /**
  21154. * Indicates that textures and misc need to be re-calculated for all submeshes
  21155. */
  21156. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21157. /**
  21158. * Disposes the material
  21159. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21160. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21161. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21162. */
  21163. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21164. /** @hidden */
  21165. private releaseVertexArrayObject;
  21166. /**
  21167. * Serializes this material
  21168. * @returns the serialized material object
  21169. */
  21170. serialize(): any;
  21171. /**
  21172. * Creates a material from parsed material data
  21173. * @param parsedMaterial defines parsed material data
  21174. * @param scene defines the hosting scene
  21175. * @param rootUrl defines the root URL to use to load textures
  21176. * @returns a new material
  21177. */
  21178. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21179. }
  21180. }
  21181. declare module "babylonjs/Materials/multiMaterial" {
  21182. import { Nullable } from "babylonjs/types";
  21183. import { Scene } from "babylonjs/scene";
  21184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21185. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21187. import { Material } from "babylonjs/Materials/material";
  21188. /**
  21189. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21190. * separate meshes. This can be use to improve performances.
  21191. * @see http://doc.babylonjs.com/how_to/multi_materials
  21192. */
  21193. export class MultiMaterial extends Material {
  21194. private _subMaterials;
  21195. /**
  21196. * Gets or Sets the list of Materials used within the multi material.
  21197. * They need to be ordered according to the submeshes order in the associated mesh
  21198. */
  21199. subMaterials: Nullable<Material>[];
  21200. /**
  21201. * Function used to align with Node.getChildren()
  21202. * @returns the list of Materials used within the multi material
  21203. */
  21204. getChildren(): Nullable<Material>[];
  21205. /**
  21206. * Instantiates a new Multi Material
  21207. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21208. * separate meshes. This can be use to improve performances.
  21209. * @see http://doc.babylonjs.com/how_to/multi_materials
  21210. * @param name Define the name in the scene
  21211. * @param scene Define the scene the material belongs to
  21212. */
  21213. constructor(name: string, scene: Scene);
  21214. private _hookArray;
  21215. /**
  21216. * Get one of the submaterial by its index in the submaterials array
  21217. * @param index The index to look the sub material at
  21218. * @returns The Material if the index has been defined
  21219. */
  21220. getSubMaterial(index: number): Nullable<Material>;
  21221. /**
  21222. * Get the list of active textures for the whole sub materials list.
  21223. * @returns All the textures that will be used during the rendering
  21224. */
  21225. getActiveTextures(): BaseTexture[];
  21226. /**
  21227. * Gets the current class name of the material e.g. "MultiMaterial"
  21228. * Mainly use in serialization.
  21229. * @returns the class name
  21230. */
  21231. getClassName(): string;
  21232. /**
  21233. * Checks if the material is ready to render the requested sub mesh
  21234. * @param mesh Define the mesh the submesh belongs to
  21235. * @param subMesh Define the sub mesh to look readyness for
  21236. * @param useInstances Define whether or not the material is used with instances
  21237. * @returns true if ready, otherwise false
  21238. */
  21239. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21240. /**
  21241. * Clones the current material and its related sub materials
  21242. * @param name Define the name of the newly cloned material
  21243. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21244. * @returns the cloned material
  21245. */
  21246. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21247. /**
  21248. * Serializes the materials into a JSON representation.
  21249. * @returns the JSON representation
  21250. */
  21251. serialize(): any;
  21252. /**
  21253. * Dispose the material and release its associated resources
  21254. * @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)
  21255. * @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)
  21256. * @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)
  21257. */
  21258. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21259. /**
  21260. * Creates a MultiMaterial from parsed MultiMaterial data.
  21261. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21262. * @param scene defines the hosting scene
  21263. * @returns a new MultiMaterial
  21264. */
  21265. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21266. }
  21267. }
  21268. declare module "babylonjs/Meshes/subMesh" {
  21269. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21270. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21271. import { Engine } from "babylonjs/Engines/engine";
  21272. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21273. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21274. import { Effect } from "babylonjs/Materials/effect";
  21275. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21276. import { Plane } from "babylonjs/Maths/math.plane";
  21277. import { Collider } from "babylonjs/Collisions/collider";
  21278. import { Material } from "babylonjs/Materials/material";
  21279. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21281. import { Mesh } from "babylonjs/Meshes/mesh";
  21282. import { Ray } from "babylonjs/Culling/ray";
  21283. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21284. /**
  21285. * Base class for submeshes
  21286. */
  21287. export class BaseSubMesh {
  21288. /** @hidden */
  21289. _materialDefines: Nullable<MaterialDefines>;
  21290. /** @hidden */
  21291. _materialEffect: Nullable<Effect>;
  21292. /**
  21293. * Gets associated effect
  21294. */
  21295. readonly effect: Nullable<Effect>;
  21296. /**
  21297. * Sets associated effect (effect used to render this submesh)
  21298. * @param effect defines the effect to associate with
  21299. * @param defines defines the set of defines used to compile this effect
  21300. */
  21301. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21302. }
  21303. /**
  21304. * Defines a subdivision inside a mesh
  21305. */
  21306. export class SubMesh extends BaseSubMesh implements ICullable {
  21307. /** the material index to use */
  21308. materialIndex: number;
  21309. /** vertex index start */
  21310. verticesStart: number;
  21311. /** vertices count */
  21312. verticesCount: number;
  21313. /** index start */
  21314. indexStart: number;
  21315. /** indices count */
  21316. indexCount: number;
  21317. /** @hidden */
  21318. _linesIndexCount: number;
  21319. private _mesh;
  21320. private _renderingMesh;
  21321. private _boundingInfo;
  21322. private _linesIndexBuffer;
  21323. /** @hidden */
  21324. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21325. /** @hidden */
  21326. _trianglePlanes: Plane[];
  21327. /** @hidden */
  21328. _lastColliderTransformMatrix: Nullable<Matrix>;
  21329. /** @hidden */
  21330. _renderId: number;
  21331. /** @hidden */
  21332. _alphaIndex: number;
  21333. /** @hidden */
  21334. _distanceToCamera: number;
  21335. /** @hidden */
  21336. _id: number;
  21337. private _currentMaterial;
  21338. /**
  21339. * Add a new submesh to a mesh
  21340. * @param materialIndex defines the material index to use
  21341. * @param verticesStart defines vertex index start
  21342. * @param verticesCount defines vertices count
  21343. * @param indexStart defines index start
  21344. * @param indexCount defines indices count
  21345. * @param mesh defines the parent mesh
  21346. * @param renderingMesh defines an optional rendering mesh
  21347. * @param createBoundingBox defines if bounding box should be created for this submesh
  21348. * @returns the new submesh
  21349. */
  21350. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21351. /**
  21352. * Creates a new submesh
  21353. * @param materialIndex defines the material index to use
  21354. * @param verticesStart defines vertex index start
  21355. * @param verticesCount defines vertices count
  21356. * @param indexStart defines index start
  21357. * @param indexCount defines indices count
  21358. * @param mesh defines the parent mesh
  21359. * @param renderingMesh defines an optional rendering mesh
  21360. * @param createBoundingBox defines if bounding box should be created for this submesh
  21361. */
  21362. constructor(
  21363. /** the material index to use */
  21364. materialIndex: number,
  21365. /** vertex index start */
  21366. verticesStart: number,
  21367. /** vertices count */
  21368. verticesCount: number,
  21369. /** index start */
  21370. indexStart: number,
  21371. /** indices count */
  21372. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21373. /**
  21374. * Returns true if this submesh covers the entire parent mesh
  21375. * @ignorenaming
  21376. */
  21377. readonly IsGlobal: boolean;
  21378. /**
  21379. * Returns the submesh BoudingInfo object
  21380. * @returns current bounding info (or mesh's one if the submesh is global)
  21381. */
  21382. getBoundingInfo(): BoundingInfo;
  21383. /**
  21384. * Sets the submesh BoundingInfo
  21385. * @param boundingInfo defines the new bounding info to use
  21386. * @returns the SubMesh
  21387. */
  21388. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21389. /**
  21390. * Returns the mesh of the current submesh
  21391. * @return the parent mesh
  21392. */
  21393. getMesh(): AbstractMesh;
  21394. /**
  21395. * Returns the rendering mesh of the submesh
  21396. * @returns the rendering mesh (could be different from parent mesh)
  21397. */
  21398. getRenderingMesh(): Mesh;
  21399. /**
  21400. * Returns the submesh material
  21401. * @returns null or the current material
  21402. */
  21403. getMaterial(): Nullable<Material>;
  21404. /**
  21405. * Sets a new updated BoundingInfo object to the submesh
  21406. * @param data defines an optional position array to use to determine the bounding info
  21407. * @returns the SubMesh
  21408. */
  21409. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21410. /** @hidden */
  21411. _checkCollision(collider: Collider): boolean;
  21412. /**
  21413. * Updates the submesh BoundingInfo
  21414. * @param world defines the world matrix to use to update the bounding info
  21415. * @returns the submesh
  21416. */
  21417. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21418. /**
  21419. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21420. * @param frustumPlanes defines the frustum planes
  21421. * @returns true if the submesh is intersecting with the frustum
  21422. */
  21423. isInFrustum(frustumPlanes: Plane[]): boolean;
  21424. /**
  21425. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21426. * @param frustumPlanes defines the frustum planes
  21427. * @returns true if the submesh is inside the frustum
  21428. */
  21429. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21430. /**
  21431. * Renders the submesh
  21432. * @param enableAlphaMode defines if alpha needs to be used
  21433. * @returns the submesh
  21434. */
  21435. render(enableAlphaMode: boolean): SubMesh;
  21436. /**
  21437. * @hidden
  21438. */
  21439. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21440. /**
  21441. * Checks if the submesh intersects with a ray
  21442. * @param ray defines the ray to test
  21443. * @returns true is the passed ray intersects the submesh bounding box
  21444. */
  21445. canIntersects(ray: Ray): boolean;
  21446. /**
  21447. * Intersects current submesh with a ray
  21448. * @param ray defines the ray to test
  21449. * @param positions defines mesh's positions array
  21450. * @param indices defines mesh's indices array
  21451. * @param fastCheck defines if only bounding info should be used
  21452. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21453. * @returns intersection info or null if no intersection
  21454. */
  21455. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21456. /** @hidden */
  21457. private _intersectLines;
  21458. /** @hidden */
  21459. private _intersectUnIndexedLines;
  21460. /** @hidden */
  21461. private _intersectTriangles;
  21462. /** @hidden */
  21463. private _intersectUnIndexedTriangles;
  21464. /** @hidden */
  21465. _rebuild(): void;
  21466. /**
  21467. * Creates a new submesh from the passed mesh
  21468. * @param newMesh defines the new hosting mesh
  21469. * @param newRenderingMesh defines an optional rendering mesh
  21470. * @returns the new submesh
  21471. */
  21472. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21473. /**
  21474. * Release associated resources
  21475. */
  21476. dispose(): void;
  21477. /**
  21478. * Gets the class name
  21479. * @returns the string "SubMesh".
  21480. */
  21481. getClassName(): string;
  21482. /**
  21483. * Creates a new submesh from indices data
  21484. * @param materialIndex the index of the main mesh material
  21485. * @param startIndex the index where to start the copy in the mesh indices array
  21486. * @param indexCount the number of indices to copy then from the startIndex
  21487. * @param mesh the main mesh to create the submesh from
  21488. * @param renderingMesh the optional rendering mesh
  21489. * @returns a new submesh
  21490. */
  21491. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21492. }
  21493. }
  21494. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21495. /**
  21496. * Class used to represent data loading progression
  21497. */
  21498. export class SceneLoaderFlags {
  21499. private static _ForceFullSceneLoadingForIncremental;
  21500. private static _ShowLoadingScreen;
  21501. private static _CleanBoneMatrixWeights;
  21502. private static _loggingLevel;
  21503. /**
  21504. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21505. */
  21506. static ForceFullSceneLoadingForIncremental: boolean;
  21507. /**
  21508. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21509. */
  21510. static ShowLoadingScreen: boolean;
  21511. /**
  21512. * Defines the current logging level (while loading the scene)
  21513. * @ignorenaming
  21514. */
  21515. static loggingLevel: number;
  21516. /**
  21517. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21518. */
  21519. static CleanBoneMatrixWeights: boolean;
  21520. }
  21521. }
  21522. declare module "babylonjs/Meshes/geometry" {
  21523. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21524. import { Scene } from "babylonjs/scene";
  21525. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21526. import { Engine } from "babylonjs/Engines/engine";
  21527. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21528. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21529. import { Effect } from "babylonjs/Materials/effect";
  21530. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21531. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21532. import { Mesh } from "babylonjs/Meshes/mesh";
  21533. /**
  21534. * Class used to store geometry data (vertex buffers + index buffer)
  21535. */
  21536. export class Geometry implements IGetSetVerticesData {
  21537. /**
  21538. * Gets or sets the ID of the geometry
  21539. */
  21540. id: string;
  21541. /**
  21542. * Gets or sets the unique ID of the geometry
  21543. */
  21544. uniqueId: number;
  21545. /**
  21546. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21547. */
  21548. delayLoadState: number;
  21549. /**
  21550. * Gets the file containing the data to load when running in delay load state
  21551. */
  21552. delayLoadingFile: Nullable<string>;
  21553. /**
  21554. * Callback called when the geometry is updated
  21555. */
  21556. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21557. private _scene;
  21558. private _engine;
  21559. private _meshes;
  21560. private _totalVertices;
  21561. /** @hidden */
  21562. _indices: IndicesArray;
  21563. /** @hidden */
  21564. _vertexBuffers: {
  21565. [key: string]: VertexBuffer;
  21566. };
  21567. private _isDisposed;
  21568. private _extend;
  21569. private _boundingBias;
  21570. /** @hidden */
  21571. _delayInfo: Array<string>;
  21572. private _indexBuffer;
  21573. private _indexBufferIsUpdatable;
  21574. /** @hidden */
  21575. _boundingInfo: Nullable<BoundingInfo>;
  21576. /** @hidden */
  21577. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21578. /** @hidden */
  21579. _softwareSkinningFrameId: number;
  21580. private _vertexArrayObjects;
  21581. private _updatable;
  21582. /** @hidden */
  21583. _positions: Nullable<Vector3[]>;
  21584. /**
  21585. * 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
  21586. */
  21587. /**
  21588. * 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
  21589. */
  21590. boundingBias: Vector2;
  21591. /**
  21592. * Static function used to attach a new empty geometry to a mesh
  21593. * @param mesh defines the mesh to attach the geometry to
  21594. * @returns the new Geometry
  21595. */
  21596. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21597. /**
  21598. * Creates a new geometry
  21599. * @param id defines the unique ID
  21600. * @param scene defines the hosting scene
  21601. * @param vertexData defines the VertexData used to get geometry data
  21602. * @param updatable defines if geometry must be updatable (false by default)
  21603. * @param mesh defines the mesh that will be associated with the geometry
  21604. */
  21605. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21606. /**
  21607. * Gets the current extend of the geometry
  21608. */
  21609. readonly extend: {
  21610. minimum: Vector3;
  21611. maximum: Vector3;
  21612. };
  21613. /**
  21614. * Gets the hosting scene
  21615. * @returns the hosting Scene
  21616. */
  21617. getScene(): Scene;
  21618. /**
  21619. * Gets the hosting engine
  21620. * @returns the hosting Engine
  21621. */
  21622. getEngine(): Engine;
  21623. /**
  21624. * Defines if the geometry is ready to use
  21625. * @returns true if the geometry is ready to be used
  21626. */
  21627. isReady(): boolean;
  21628. /**
  21629. * Gets a value indicating that the geometry should not be serialized
  21630. */
  21631. readonly doNotSerialize: boolean;
  21632. /** @hidden */
  21633. _rebuild(): void;
  21634. /**
  21635. * Affects all geometry data in one call
  21636. * @param vertexData defines the geometry data
  21637. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21638. */
  21639. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21640. /**
  21641. * Set specific vertex data
  21642. * @param kind defines the data kind (Position, normal, etc...)
  21643. * @param data defines the vertex data to use
  21644. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21645. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21646. */
  21647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21648. /**
  21649. * Removes a specific vertex data
  21650. * @param kind defines the data kind (Position, normal, etc...)
  21651. */
  21652. removeVerticesData(kind: string): void;
  21653. /**
  21654. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21655. * @param buffer defines the vertex buffer to use
  21656. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21657. */
  21658. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21659. /**
  21660. * Update a specific vertex buffer
  21661. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21662. * It will do nothing if the buffer is not updatable
  21663. * @param kind defines the data kind (Position, normal, etc...)
  21664. * @param data defines the data to use
  21665. * @param offset defines the offset in the target buffer where to store the data
  21666. * @param useBytes set to true if the offset is in bytes
  21667. */
  21668. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21669. /**
  21670. * Update a specific vertex buffer
  21671. * This function will create a new buffer if the current one is not updatable
  21672. * @param kind defines the data kind (Position, normal, etc...)
  21673. * @param data defines the data to use
  21674. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21675. */
  21676. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21677. private _updateBoundingInfo;
  21678. /** @hidden */
  21679. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21680. /**
  21681. * Gets total number of vertices
  21682. * @returns the total number of vertices
  21683. */
  21684. getTotalVertices(): number;
  21685. /**
  21686. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21687. * @param kind defines the data kind (Position, normal, etc...)
  21688. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21690. * @returns a float array containing vertex data
  21691. */
  21692. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21693. /**
  21694. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21695. * @param kind defines the data kind (Position, normal, etc...)
  21696. * @returns true if the vertex buffer with the specified kind is updatable
  21697. */
  21698. isVertexBufferUpdatable(kind: string): boolean;
  21699. /**
  21700. * Gets a specific vertex buffer
  21701. * @param kind defines the data kind (Position, normal, etc...)
  21702. * @returns a VertexBuffer
  21703. */
  21704. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21705. /**
  21706. * Returns all vertex buffers
  21707. * @return an object holding all vertex buffers indexed by kind
  21708. */
  21709. getVertexBuffers(): Nullable<{
  21710. [key: string]: VertexBuffer;
  21711. }>;
  21712. /**
  21713. * Gets a boolean indicating if specific vertex buffer is present
  21714. * @param kind defines the data kind (Position, normal, etc...)
  21715. * @returns true if data is present
  21716. */
  21717. isVerticesDataPresent(kind: string): boolean;
  21718. /**
  21719. * Gets a list of all attached data kinds (Position, normal, etc...)
  21720. * @returns a list of string containing all kinds
  21721. */
  21722. getVerticesDataKinds(): string[];
  21723. /**
  21724. * Update index buffer
  21725. * @param indices defines the indices to store in the index buffer
  21726. * @param offset defines the offset in the target buffer where to store the data
  21727. * @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)
  21728. */
  21729. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21730. /**
  21731. * Creates a new index buffer
  21732. * @param indices defines the indices to store in the index buffer
  21733. * @param totalVertices defines the total number of vertices (could be null)
  21734. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21735. */
  21736. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21737. /**
  21738. * Return the total number of indices
  21739. * @returns the total number of indices
  21740. */
  21741. getTotalIndices(): number;
  21742. /**
  21743. * Gets the index buffer array
  21744. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21745. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21746. * @returns the index buffer array
  21747. */
  21748. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21749. /**
  21750. * Gets the index buffer
  21751. * @return the index buffer
  21752. */
  21753. getIndexBuffer(): Nullable<DataBuffer>;
  21754. /** @hidden */
  21755. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21756. /**
  21757. * Release the associated resources for a specific mesh
  21758. * @param mesh defines the source mesh
  21759. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21760. */
  21761. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21762. /**
  21763. * Apply current geometry to a given mesh
  21764. * @param mesh defines the mesh to apply geometry to
  21765. */
  21766. applyToMesh(mesh: Mesh): void;
  21767. private _updateExtend;
  21768. private _applyToMesh;
  21769. private notifyUpdate;
  21770. /**
  21771. * Load the geometry if it was flagged as delay loaded
  21772. * @param scene defines the hosting scene
  21773. * @param onLoaded defines a callback called when the geometry is loaded
  21774. */
  21775. load(scene: Scene, onLoaded?: () => void): void;
  21776. private _queueLoad;
  21777. /**
  21778. * Invert the geometry to move from a right handed system to a left handed one.
  21779. */
  21780. toLeftHanded(): void;
  21781. /** @hidden */
  21782. _resetPointsArrayCache(): void;
  21783. /** @hidden */
  21784. _generatePointsArray(): boolean;
  21785. /**
  21786. * Gets a value indicating if the geometry is disposed
  21787. * @returns true if the geometry was disposed
  21788. */
  21789. isDisposed(): boolean;
  21790. private _disposeVertexArrayObjects;
  21791. /**
  21792. * Free all associated resources
  21793. */
  21794. dispose(): void;
  21795. /**
  21796. * Clone the current geometry into a new geometry
  21797. * @param id defines the unique ID of the new geometry
  21798. * @returns a new geometry object
  21799. */
  21800. copy(id: string): Geometry;
  21801. /**
  21802. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21803. * @return a JSON representation of the current geometry data (without the vertices data)
  21804. */
  21805. serialize(): any;
  21806. private toNumberArray;
  21807. /**
  21808. * Serialize all vertices data into a JSON oject
  21809. * @returns a JSON representation of the current geometry data
  21810. */
  21811. serializeVerticeData(): any;
  21812. /**
  21813. * Extracts a clone of a mesh geometry
  21814. * @param mesh defines the source mesh
  21815. * @param id defines the unique ID of the new geometry object
  21816. * @returns the new geometry object
  21817. */
  21818. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21819. /**
  21820. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21821. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21822. * Be aware Math.random() could cause collisions, but:
  21823. * "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"
  21824. * @returns a string containing a new GUID
  21825. */
  21826. static RandomId(): string;
  21827. /** @hidden */
  21828. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21829. private static _CleanMatricesWeights;
  21830. /**
  21831. * Create a new geometry from persisted data (Using .babylon file format)
  21832. * @param parsedVertexData defines the persisted data
  21833. * @param scene defines the hosting scene
  21834. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21835. * @returns the new geometry object
  21836. */
  21837. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21838. }
  21839. }
  21840. declare module "babylonjs/Meshes/mesh.vertexData" {
  21841. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21842. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21843. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21844. import { Geometry } from "babylonjs/Meshes/geometry";
  21845. import { Mesh } from "babylonjs/Meshes/mesh";
  21846. /**
  21847. * Define an interface for all classes that will get and set the data on vertices
  21848. */
  21849. export interface IGetSetVerticesData {
  21850. /**
  21851. * Gets a boolean indicating if specific vertex data is present
  21852. * @param kind defines the vertex data kind to use
  21853. * @returns true is data kind is present
  21854. */
  21855. isVerticesDataPresent(kind: string): boolean;
  21856. /**
  21857. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21858. * @param kind defines the data kind (Position, normal, etc...)
  21859. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21860. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21861. * @returns a float array containing vertex data
  21862. */
  21863. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21864. /**
  21865. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21866. * @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.
  21867. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21868. * @returns the indices array or an empty array if the mesh has no geometry
  21869. */
  21870. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21871. /**
  21872. * Set specific vertex data
  21873. * @param kind defines the data kind (Position, normal, etc...)
  21874. * @param data defines the vertex data to use
  21875. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21876. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21877. */
  21878. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21879. /**
  21880. * Update a specific associated vertex buffer
  21881. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21882. * - VertexBuffer.PositionKind
  21883. * - VertexBuffer.UVKind
  21884. * - VertexBuffer.UV2Kind
  21885. * - VertexBuffer.UV3Kind
  21886. * - VertexBuffer.UV4Kind
  21887. * - VertexBuffer.UV5Kind
  21888. * - VertexBuffer.UV6Kind
  21889. * - VertexBuffer.ColorKind
  21890. * - VertexBuffer.MatricesIndicesKind
  21891. * - VertexBuffer.MatricesIndicesExtraKind
  21892. * - VertexBuffer.MatricesWeightsKind
  21893. * - VertexBuffer.MatricesWeightsExtraKind
  21894. * @param data defines the data source
  21895. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21896. * @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)
  21897. */
  21898. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21899. /**
  21900. * Creates a new index buffer
  21901. * @param indices defines the indices to store in the index buffer
  21902. * @param totalVertices defines the total number of vertices (could be null)
  21903. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21904. */
  21905. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21906. }
  21907. /**
  21908. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21909. */
  21910. export class VertexData {
  21911. /**
  21912. * Mesh side orientation : usually the external or front surface
  21913. */
  21914. static readonly FRONTSIDE: number;
  21915. /**
  21916. * Mesh side orientation : usually the internal or back surface
  21917. */
  21918. static readonly BACKSIDE: number;
  21919. /**
  21920. * Mesh side orientation : both internal and external or front and back surfaces
  21921. */
  21922. static readonly DOUBLESIDE: number;
  21923. /**
  21924. * Mesh side orientation : by default, `FRONTSIDE`
  21925. */
  21926. static readonly DEFAULTSIDE: number;
  21927. /**
  21928. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21929. */
  21930. positions: Nullable<FloatArray>;
  21931. /**
  21932. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21933. */
  21934. normals: Nullable<FloatArray>;
  21935. /**
  21936. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21937. */
  21938. tangents: Nullable<FloatArray>;
  21939. /**
  21940. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21941. */
  21942. uvs: Nullable<FloatArray>;
  21943. /**
  21944. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21945. */
  21946. uvs2: Nullable<FloatArray>;
  21947. /**
  21948. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21949. */
  21950. uvs3: Nullable<FloatArray>;
  21951. /**
  21952. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21953. */
  21954. uvs4: Nullable<FloatArray>;
  21955. /**
  21956. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21957. */
  21958. uvs5: Nullable<FloatArray>;
  21959. /**
  21960. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21961. */
  21962. uvs6: Nullable<FloatArray>;
  21963. /**
  21964. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21965. */
  21966. colors: Nullable<FloatArray>;
  21967. /**
  21968. * 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).
  21969. */
  21970. matricesIndices: Nullable<FloatArray>;
  21971. /**
  21972. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21973. */
  21974. matricesWeights: Nullable<FloatArray>;
  21975. /**
  21976. * An array extending the number of possible indices
  21977. */
  21978. matricesIndicesExtra: Nullable<FloatArray>;
  21979. /**
  21980. * An array extending the number of possible weights when the number of indices is extended
  21981. */
  21982. matricesWeightsExtra: Nullable<FloatArray>;
  21983. /**
  21984. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21985. */
  21986. indices: Nullable<IndicesArray>;
  21987. /**
  21988. * Uses the passed data array to set the set the values for the specified kind of data
  21989. * @param data a linear array of floating numbers
  21990. * @param kind the type of data that is being set, eg positions, colors etc
  21991. */
  21992. set(data: FloatArray, kind: string): void;
  21993. /**
  21994. * Associates the vertexData to the passed Mesh.
  21995. * Sets it as updatable or not (default `false`)
  21996. * @param mesh the mesh the vertexData is applied to
  21997. * @param updatable when used and having the value true allows new data to update the vertexData
  21998. * @returns the VertexData
  21999. */
  22000. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22001. /**
  22002. * Associates the vertexData to the passed Geometry.
  22003. * Sets it as updatable or not (default `false`)
  22004. * @param geometry the geometry the vertexData is applied to
  22005. * @param updatable when used and having the value true allows new data to update the vertexData
  22006. * @returns VertexData
  22007. */
  22008. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22009. /**
  22010. * Updates the associated mesh
  22011. * @param mesh the mesh to be updated
  22012. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22013. * @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
  22014. * @returns VertexData
  22015. */
  22016. updateMesh(mesh: Mesh): VertexData;
  22017. /**
  22018. * Updates the associated geometry
  22019. * @param geometry the geometry to be updated
  22020. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22021. * @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
  22022. * @returns VertexData.
  22023. */
  22024. updateGeometry(geometry: Geometry): VertexData;
  22025. private _applyTo;
  22026. private _update;
  22027. /**
  22028. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22029. * @param matrix the transforming matrix
  22030. * @returns the VertexData
  22031. */
  22032. transform(matrix: Matrix): VertexData;
  22033. /**
  22034. * Merges the passed VertexData into the current one
  22035. * @param other the VertexData to be merged into the current one
  22036. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22037. * @returns the modified VertexData
  22038. */
  22039. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22040. private _mergeElement;
  22041. private _validate;
  22042. /**
  22043. * Serializes the VertexData
  22044. * @returns a serialized object
  22045. */
  22046. serialize(): any;
  22047. /**
  22048. * Extracts the vertexData from a mesh
  22049. * @param mesh the mesh from which to extract the VertexData
  22050. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22051. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22052. * @returns the object VertexData associated to the passed mesh
  22053. */
  22054. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22055. /**
  22056. * Extracts the vertexData from the geometry
  22057. * @param geometry the geometry from which to extract the VertexData
  22058. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22059. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22060. * @returns the object VertexData associated to the passed mesh
  22061. */
  22062. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22063. private static _ExtractFrom;
  22064. /**
  22065. * Creates the VertexData for a Ribbon
  22066. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22067. * * pathArray array of paths, each of which an array of successive Vector3
  22068. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22069. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22070. * * 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
  22071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22072. * * 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)
  22073. * * 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)
  22074. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22075. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22076. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22077. * @returns the VertexData of the ribbon
  22078. */
  22079. static CreateRibbon(options: {
  22080. pathArray: Vector3[][];
  22081. closeArray?: boolean;
  22082. closePath?: boolean;
  22083. offset?: number;
  22084. sideOrientation?: number;
  22085. frontUVs?: Vector4;
  22086. backUVs?: Vector4;
  22087. invertUV?: boolean;
  22088. uvs?: Vector2[];
  22089. colors?: Color4[];
  22090. }): VertexData;
  22091. /**
  22092. * Creates the VertexData for a box
  22093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22094. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22095. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22096. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22097. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22098. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22099. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22101. * * 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)
  22102. * * 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)
  22103. * @returns the VertexData of the box
  22104. */
  22105. static CreateBox(options: {
  22106. size?: number;
  22107. width?: number;
  22108. height?: number;
  22109. depth?: number;
  22110. faceUV?: Vector4[];
  22111. faceColors?: Color4[];
  22112. sideOrientation?: number;
  22113. frontUVs?: Vector4;
  22114. backUVs?: Vector4;
  22115. }): VertexData;
  22116. /**
  22117. * Creates the VertexData for a tiled box
  22118. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22119. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22120. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22121. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22122. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22123. * @returns the VertexData of the box
  22124. */
  22125. static CreateTiledBox(options: {
  22126. pattern?: number;
  22127. width?: number;
  22128. height?: number;
  22129. depth?: number;
  22130. tileSize?: number;
  22131. tileWidth?: number;
  22132. tileHeight?: number;
  22133. alignHorizontal?: number;
  22134. alignVertical?: number;
  22135. faceUV?: Vector4[];
  22136. faceColors?: Color4[];
  22137. sideOrientation?: number;
  22138. }): VertexData;
  22139. /**
  22140. * Creates the VertexData for a tiled plane
  22141. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22142. * * pattern a limited pattern arrangement depending on the number
  22143. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22144. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22145. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22147. * * 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)
  22148. * * 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)
  22149. * @returns the VertexData of the tiled plane
  22150. */
  22151. static CreateTiledPlane(options: {
  22152. pattern?: number;
  22153. tileSize?: number;
  22154. tileWidth?: number;
  22155. tileHeight?: number;
  22156. size?: number;
  22157. width?: number;
  22158. height?: number;
  22159. alignHorizontal?: number;
  22160. alignVertical?: number;
  22161. sideOrientation?: number;
  22162. frontUVs?: Vector4;
  22163. backUVs?: Vector4;
  22164. }): VertexData;
  22165. /**
  22166. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22167. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22168. * * segments sets the number of horizontal strips optional, default 32
  22169. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22170. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22171. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22172. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22173. * * 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
  22174. * * 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
  22175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22176. * * 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)
  22177. * * 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)
  22178. * @returns the VertexData of the ellipsoid
  22179. */
  22180. static CreateSphere(options: {
  22181. segments?: number;
  22182. diameter?: number;
  22183. diameterX?: number;
  22184. diameterY?: number;
  22185. diameterZ?: number;
  22186. arc?: number;
  22187. slice?: number;
  22188. sideOrientation?: number;
  22189. frontUVs?: Vector4;
  22190. backUVs?: Vector4;
  22191. }): VertexData;
  22192. /**
  22193. * Creates the VertexData for a cylinder, cone or prism
  22194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22195. * * height sets the height (y direction) of the cylinder, optional, default 2
  22196. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22197. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22198. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22199. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22200. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22201. * * 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
  22202. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22203. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22204. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22205. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22207. * * 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)
  22208. * * 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)
  22209. * @returns the VertexData of the cylinder, cone or prism
  22210. */
  22211. static CreateCylinder(options: {
  22212. height?: number;
  22213. diameterTop?: number;
  22214. diameterBottom?: number;
  22215. diameter?: number;
  22216. tessellation?: number;
  22217. subdivisions?: number;
  22218. arc?: number;
  22219. faceColors?: Color4[];
  22220. faceUV?: Vector4[];
  22221. hasRings?: boolean;
  22222. enclose?: boolean;
  22223. sideOrientation?: number;
  22224. frontUVs?: Vector4;
  22225. backUVs?: Vector4;
  22226. }): VertexData;
  22227. /**
  22228. * Creates the VertexData for a torus
  22229. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22230. * * diameter the diameter of the torus, optional default 1
  22231. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22232. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22234. * * 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)
  22235. * * 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)
  22236. * @returns the VertexData of the torus
  22237. */
  22238. static CreateTorus(options: {
  22239. diameter?: number;
  22240. thickness?: number;
  22241. tessellation?: number;
  22242. sideOrientation?: number;
  22243. frontUVs?: Vector4;
  22244. backUVs?: Vector4;
  22245. }): VertexData;
  22246. /**
  22247. * Creates the VertexData of the LineSystem
  22248. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22249. * - lines an array of lines, each line being an array of successive Vector3
  22250. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22251. * @returns the VertexData of the LineSystem
  22252. */
  22253. static CreateLineSystem(options: {
  22254. lines: Vector3[][];
  22255. colors?: Nullable<Color4[][]>;
  22256. }): VertexData;
  22257. /**
  22258. * Create the VertexData for a DashedLines
  22259. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22260. * - points an array successive Vector3
  22261. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22262. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22263. * - dashNb the intended total number of dashes, optional, default 200
  22264. * @returns the VertexData for the DashedLines
  22265. */
  22266. static CreateDashedLines(options: {
  22267. points: Vector3[];
  22268. dashSize?: number;
  22269. gapSize?: number;
  22270. dashNb?: number;
  22271. }): VertexData;
  22272. /**
  22273. * Creates the VertexData for a Ground
  22274. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22275. * - width the width (x direction) of the ground, optional, default 1
  22276. * - height the height (z direction) of the ground, optional, default 1
  22277. * - subdivisions the number of subdivisions per side, optional, default 1
  22278. * @returns the VertexData of the Ground
  22279. */
  22280. static CreateGround(options: {
  22281. width?: number;
  22282. height?: number;
  22283. subdivisions?: number;
  22284. subdivisionsX?: number;
  22285. subdivisionsY?: number;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22289. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22290. * * xmin the ground minimum X coordinate, optional, default -1
  22291. * * zmin the ground minimum Z coordinate, optional, default -1
  22292. * * xmax the ground maximum X coordinate, optional, default 1
  22293. * * zmax the ground maximum Z coordinate, optional, default 1
  22294. * * 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}
  22295. * * 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}
  22296. * @returns the VertexData of the TiledGround
  22297. */
  22298. static CreateTiledGround(options: {
  22299. xmin: number;
  22300. zmin: number;
  22301. xmax: number;
  22302. zmax: number;
  22303. subdivisions?: {
  22304. w: number;
  22305. h: number;
  22306. };
  22307. precision?: {
  22308. w: number;
  22309. h: number;
  22310. };
  22311. }): VertexData;
  22312. /**
  22313. * Creates the VertexData of the Ground designed from a heightmap
  22314. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22315. * * width the width (x direction) of the ground
  22316. * * height the height (z direction) of the ground
  22317. * * subdivisions the number of subdivisions per side
  22318. * * minHeight the minimum altitude on the ground, optional, default 0
  22319. * * maxHeight the maximum altitude on the ground, optional default 1
  22320. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22321. * * buffer the array holding the image color data
  22322. * * bufferWidth the width of image
  22323. * * bufferHeight the height of image
  22324. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22325. * @returns the VertexData of the Ground designed from a heightmap
  22326. */
  22327. static CreateGroundFromHeightMap(options: {
  22328. width: number;
  22329. height: number;
  22330. subdivisions: number;
  22331. minHeight: number;
  22332. maxHeight: number;
  22333. colorFilter: Color3;
  22334. buffer: Uint8Array;
  22335. bufferWidth: number;
  22336. bufferHeight: number;
  22337. alphaFilter: number;
  22338. }): VertexData;
  22339. /**
  22340. * Creates the VertexData for a Plane
  22341. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22342. * * size sets the width and height of the plane to the value of size, optional default 1
  22343. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22344. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22346. * * 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)
  22347. * * 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)
  22348. * @returns the VertexData of the box
  22349. */
  22350. static CreatePlane(options: {
  22351. size?: number;
  22352. width?: number;
  22353. height?: number;
  22354. sideOrientation?: number;
  22355. frontUVs?: Vector4;
  22356. backUVs?: Vector4;
  22357. }): VertexData;
  22358. /**
  22359. * Creates the VertexData of the Disc or regular Polygon
  22360. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22361. * * radius the radius of the disc, optional default 0.5
  22362. * * tessellation the number of polygon sides, optional, default 64
  22363. * * 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
  22364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22365. * * 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)
  22366. * * 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)
  22367. * @returns the VertexData of the box
  22368. */
  22369. static CreateDisc(options: {
  22370. radius?: number;
  22371. tessellation?: number;
  22372. arc?: number;
  22373. sideOrientation?: number;
  22374. frontUVs?: Vector4;
  22375. backUVs?: Vector4;
  22376. }): VertexData;
  22377. /**
  22378. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22379. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22380. * @param polygon a mesh built from polygonTriangulation.build()
  22381. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22382. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22383. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22384. * @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)
  22385. * @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)
  22386. * @returns the VertexData of the Polygon
  22387. */
  22388. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22389. /**
  22390. * Creates the VertexData of the IcoSphere
  22391. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22392. * * radius the radius of the IcoSphere, optional default 1
  22393. * * radiusX allows stretching in the x direction, optional, default radius
  22394. * * radiusY allows stretching in the y direction, optional, default radius
  22395. * * radiusZ allows stretching in the z direction, optional, default radius
  22396. * * flat when true creates a flat shaded mesh, optional, default true
  22397. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22399. * * 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)
  22400. * * 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)
  22401. * @returns the VertexData of the IcoSphere
  22402. */
  22403. static CreateIcoSphere(options: {
  22404. radius?: number;
  22405. radiusX?: number;
  22406. radiusY?: number;
  22407. radiusZ?: number;
  22408. flat?: boolean;
  22409. subdivisions?: number;
  22410. sideOrientation?: number;
  22411. frontUVs?: Vector4;
  22412. backUVs?: Vector4;
  22413. }): VertexData;
  22414. /**
  22415. * Creates the VertexData for a Polyhedron
  22416. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22417. * * type provided types are:
  22418. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22419. * * 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)
  22420. * * size the size of the IcoSphere, optional default 1
  22421. * * sizeX allows stretching in the x direction, optional, default size
  22422. * * sizeY allows stretching in the y direction, optional, default size
  22423. * * sizeZ allows stretching in the z direction, optional, default size
  22424. * * 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
  22425. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22426. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22427. * * flat when true creates a flat shaded mesh, optional, default true
  22428. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22430. * * 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)
  22431. * * 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)
  22432. * @returns the VertexData of the Polyhedron
  22433. */
  22434. static CreatePolyhedron(options: {
  22435. type?: number;
  22436. size?: number;
  22437. sizeX?: number;
  22438. sizeY?: number;
  22439. sizeZ?: number;
  22440. custom?: any;
  22441. faceUV?: Vector4[];
  22442. faceColors?: Color4[];
  22443. flat?: boolean;
  22444. sideOrientation?: number;
  22445. frontUVs?: Vector4;
  22446. backUVs?: Vector4;
  22447. }): VertexData;
  22448. /**
  22449. * Creates the VertexData for a TorusKnot
  22450. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22451. * * radius the radius of the torus knot, optional, default 2
  22452. * * tube the thickness of the tube, optional, default 0.5
  22453. * * radialSegments the number of sides on each tube segments, optional, default 32
  22454. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22455. * * p the number of windings around the z axis, optional, default 2
  22456. * * q the number of windings around the x axis, optional, default 3
  22457. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22458. * * 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)
  22459. * * 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)
  22460. * @returns the VertexData of the Torus Knot
  22461. */
  22462. static CreateTorusKnot(options: {
  22463. radius?: number;
  22464. tube?: number;
  22465. radialSegments?: number;
  22466. tubularSegments?: number;
  22467. p?: number;
  22468. q?: number;
  22469. sideOrientation?: number;
  22470. frontUVs?: Vector4;
  22471. backUVs?: Vector4;
  22472. }): VertexData;
  22473. /**
  22474. * Compute normals for given positions and indices
  22475. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22476. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22477. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22478. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22479. * * facetNormals : optional array of facet normals (vector3)
  22480. * * facetPositions : optional array of facet positions (vector3)
  22481. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22482. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22483. * * bInfo : optional bounding info, required for facetPartitioning computation
  22484. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22485. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22486. * * useRightHandedSystem: optional boolean to for right handed system computation
  22487. * * depthSort : optional boolean to enable the facet depth sort computation
  22488. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22489. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22490. */
  22491. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22492. facetNormals?: any;
  22493. facetPositions?: any;
  22494. facetPartitioning?: any;
  22495. ratio?: number;
  22496. bInfo?: any;
  22497. bbSize?: Vector3;
  22498. subDiv?: any;
  22499. useRightHandedSystem?: boolean;
  22500. depthSort?: boolean;
  22501. distanceTo?: Vector3;
  22502. depthSortedFacets?: any;
  22503. }): void;
  22504. /** @hidden */
  22505. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22506. /**
  22507. * Applies VertexData created from the imported parameters to the geometry
  22508. * @param parsedVertexData the parsed data from an imported file
  22509. * @param geometry the geometry to apply the VertexData to
  22510. */
  22511. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22512. }
  22513. }
  22514. declare module "babylonjs/Morph/morphTarget" {
  22515. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22516. import { Observable } from "babylonjs/Misc/observable";
  22517. import { Nullable, FloatArray } from "babylonjs/types";
  22518. import { Scene } from "babylonjs/scene";
  22519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22520. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22521. /**
  22522. * Defines a target to use with MorphTargetManager
  22523. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22524. */
  22525. export class MorphTarget implements IAnimatable {
  22526. /** defines the name of the target */
  22527. name: string;
  22528. /**
  22529. * Gets or sets the list of animations
  22530. */
  22531. animations: import("babylonjs/Animations/animation").Animation[];
  22532. private _scene;
  22533. private _positions;
  22534. private _normals;
  22535. private _tangents;
  22536. private _uvs;
  22537. private _influence;
  22538. /**
  22539. * Observable raised when the influence changes
  22540. */
  22541. onInfluenceChanged: Observable<boolean>;
  22542. /** @hidden */
  22543. _onDataLayoutChanged: Observable<void>;
  22544. /**
  22545. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22546. */
  22547. influence: number;
  22548. /**
  22549. * Gets or sets the id of the morph Target
  22550. */
  22551. id: string;
  22552. private _animationPropertiesOverride;
  22553. /**
  22554. * Gets or sets the animation properties override
  22555. */
  22556. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22557. /**
  22558. * Creates a new MorphTarget
  22559. * @param name defines the name of the target
  22560. * @param influence defines the influence to use
  22561. * @param scene defines the scene the morphtarget belongs to
  22562. */
  22563. constructor(
  22564. /** defines the name of the target */
  22565. name: string, influence?: number, scene?: Nullable<Scene>);
  22566. /**
  22567. * Gets a boolean defining if the target contains position data
  22568. */
  22569. readonly hasPositions: boolean;
  22570. /**
  22571. * Gets a boolean defining if the target contains normal data
  22572. */
  22573. readonly hasNormals: boolean;
  22574. /**
  22575. * Gets a boolean defining if the target contains tangent data
  22576. */
  22577. readonly hasTangents: boolean;
  22578. /**
  22579. * Gets a boolean defining if the target contains texture coordinates data
  22580. */
  22581. readonly hasUVs: boolean;
  22582. /**
  22583. * Affects position data to this target
  22584. * @param data defines the position data to use
  22585. */
  22586. setPositions(data: Nullable<FloatArray>): void;
  22587. /**
  22588. * Gets the position data stored in this target
  22589. * @returns a FloatArray containing the position data (or null if not present)
  22590. */
  22591. getPositions(): Nullable<FloatArray>;
  22592. /**
  22593. * Affects normal data to this target
  22594. * @param data defines the normal data to use
  22595. */
  22596. setNormals(data: Nullable<FloatArray>): void;
  22597. /**
  22598. * Gets the normal data stored in this target
  22599. * @returns a FloatArray containing the normal data (or null if not present)
  22600. */
  22601. getNormals(): Nullable<FloatArray>;
  22602. /**
  22603. * Affects tangent data to this target
  22604. * @param data defines the tangent data to use
  22605. */
  22606. setTangents(data: Nullable<FloatArray>): void;
  22607. /**
  22608. * Gets the tangent data stored in this target
  22609. * @returns a FloatArray containing the tangent data (or null if not present)
  22610. */
  22611. getTangents(): Nullable<FloatArray>;
  22612. /**
  22613. * Affects texture coordinates data to this target
  22614. * @param data defines the texture coordinates data to use
  22615. */
  22616. setUVs(data: Nullable<FloatArray>): void;
  22617. /**
  22618. * Gets the texture coordinates data stored in this target
  22619. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22620. */
  22621. getUVs(): Nullable<FloatArray>;
  22622. /**
  22623. * Serializes the current target into a Serialization object
  22624. * @returns the serialized object
  22625. */
  22626. serialize(): any;
  22627. /**
  22628. * Returns the string "MorphTarget"
  22629. * @returns "MorphTarget"
  22630. */
  22631. getClassName(): string;
  22632. /**
  22633. * Creates a new target from serialized data
  22634. * @param serializationObject defines the serialized data to use
  22635. * @returns a new MorphTarget
  22636. */
  22637. static Parse(serializationObject: any): MorphTarget;
  22638. /**
  22639. * Creates a MorphTarget from mesh data
  22640. * @param mesh defines the source mesh
  22641. * @param name defines the name to use for the new target
  22642. * @param influence defines the influence to attach to the target
  22643. * @returns a new MorphTarget
  22644. */
  22645. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22646. }
  22647. }
  22648. declare module "babylonjs/Morph/morphTargetManager" {
  22649. import { Nullable } from "babylonjs/types";
  22650. import { Scene } from "babylonjs/scene";
  22651. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22652. /**
  22653. * This class is used to deform meshes using morphing between different targets
  22654. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22655. */
  22656. export class MorphTargetManager {
  22657. private _targets;
  22658. private _targetInfluenceChangedObservers;
  22659. private _targetDataLayoutChangedObservers;
  22660. private _activeTargets;
  22661. private _scene;
  22662. private _influences;
  22663. private _supportsNormals;
  22664. private _supportsTangents;
  22665. private _supportsUVs;
  22666. private _vertexCount;
  22667. private _uniqueId;
  22668. private _tempInfluences;
  22669. /**
  22670. * Gets or sets a boolean indicating if normals must be morphed
  22671. */
  22672. enableNormalMorphing: boolean;
  22673. /**
  22674. * Gets or sets a boolean indicating if tangents must be morphed
  22675. */
  22676. enableTangentMorphing: boolean;
  22677. /**
  22678. * Gets or sets a boolean indicating if UV must be morphed
  22679. */
  22680. enableUVMorphing: boolean;
  22681. /**
  22682. * Creates a new MorphTargetManager
  22683. * @param scene defines the current scene
  22684. */
  22685. constructor(scene?: Nullable<Scene>);
  22686. /**
  22687. * Gets the unique ID of this manager
  22688. */
  22689. readonly uniqueId: number;
  22690. /**
  22691. * Gets the number of vertices handled by this manager
  22692. */
  22693. readonly vertexCount: number;
  22694. /**
  22695. * Gets a boolean indicating if this manager supports morphing of normals
  22696. */
  22697. readonly supportsNormals: boolean;
  22698. /**
  22699. * Gets a boolean indicating if this manager supports morphing of tangents
  22700. */
  22701. readonly supportsTangents: boolean;
  22702. /**
  22703. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22704. */
  22705. readonly supportsUVs: boolean;
  22706. /**
  22707. * Gets the number of targets stored in this manager
  22708. */
  22709. readonly numTargets: number;
  22710. /**
  22711. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22712. */
  22713. readonly numInfluencers: number;
  22714. /**
  22715. * Gets the list of influences (one per target)
  22716. */
  22717. readonly influences: Float32Array;
  22718. /**
  22719. * Gets the active target at specified index. An active target is a target with an influence > 0
  22720. * @param index defines the index to check
  22721. * @returns the requested target
  22722. */
  22723. getActiveTarget(index: number): MorphTarget;
  22724. /**
  22725. * Gets the target at specified index
  22726. * @param index defines the index to check
  22727. * @returns the requested target
  22728. */
  22729. getTarget(index: number): MorphTarget;
  22730. /**
  22731. * Add a new target to this manager
  22732. * @param target defines the target to add
  22733. */
  22734. addTarget(target: MorphTarget): void;
  22735. /**
  22736. * Removes a target from the manager
  22737. * @param target defines the target to remove
  22738. */
  22739. removeTarget(target: MorphTarget): void;
  22740. /**
  22741. * Serializes the current manager into a Serialization object
  22742. * @returns the serialized object
  22743. */
  22744. serialize(): any;
  22745. private _syncActiveTargets;
  22746. /**
  22747. * Syncrhonize the targets with all the meshes using this morph target manager
  22748. */
  22749. synchronize(): void;
  22750. /**
  22751. * Creates a new MorphTargetManager from serialized data
  22752. * @param serializationObject defines the serialized data
  22753. * @param scene defines the hosting scene
  22754. * @returns the new MorphTargetManager
  22755. */
  22756. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22757. }
  22758. }
  22759. declare module "babylonjs/Meshes/meshLODLevel" {
  22760. import { Mesh } from "babylonjs/Meshes/mesh";
  22761. import { Nullable } from "babylonjs/types";
  22762. /**
  22763. * Class used to represent a specific level of detail of a mesh
  22764. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22765. */
  22766. export class MeshLODLevel {
  22767. /** Defines the distance where this level should start being displayed */
  22768. distance: number;
  22769. /** Defines the mesh to use to render this level */
  22770. mesh: Nullable<Mesh>;
  22771. /**
  22772. * Creates a new LOD level
  22773. * @param distance defines the distance where this level should star being displayed
  22774. * @param mesh defines the mesh to use to render this level
  22775. */
  22776. constructor(
  22777. /** Defines the distance where this level should start being displayed */
  22778. distance: number,
  22779. /** Defines the mesh to use to render this level */
  22780. mesh: Nullable<Mesh>);
  22781. }
  22782. }
  22783. declare module "babylonjs/Meshes/groundMesh" {
  22784. import { Scene } from "babylonjs/scene";
  22785. import { Vector3 } from "babylonjs/Maths/math.vector";
  22786. import { Mesh } from "babylonjs/Meshes/mesh";
  22787. /**
  22788. * Mesh representing the gorund
  22789. */
  22790. export class GroundMesh extends Mesh {
  22791. /** If octree should be generated */
  22792. generateOctree: boolean;
  22793. private _heightQuads;
  22794. /** @hidden */
  22795. _subdivisionsX: number;
  22796. /** @hidden */
  22797. _subdivisionsY: number;
  22798. /** @hidden */
  22799. _width: number;
  22800. /** @hidden */
  22801. _height: number;
  22802. /** @hidden */
  22803. _minX: number;
  22804. /** @hidden */
  22805. _maxX: number;
  22806. /** @hidden */
  22807. _minZ: number;
  22808. /** @hidden */
  22809. _maxZ: number;
  22810. constructor(name: string, scene: Scene);
  22811. /**
  22812. * "GroundMesh"
  22813. * @returns "GroundMesh"
  22814. */
  22815. getClassName(): string;
  22816. /**
  22817. * The minimum of x and y subdivisions
  22818. */
  22819. readonly subdivisions: number;
  22820. /**
  22821. * X subdivisions
  22822. */
  22823. readonly subdivisionsX: number;
  22824. /**
  22825. * Y subdivisions
  22826. */
  22827. readonly subdivisionsY: number;
  22828. /**
  22829. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22830. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22831. * @param chunksCount the number of subdivisions for x and y
  22832. * @param octreeBlocksSize (Default: 32)
  22833. */
  22834. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22835. /**
  22836. * Returns a height (y) value in the Worl system :
  22837. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22838. * @param x x coordinate
  22839. * @param z z coordinate
  22840. * @returns the ground y position if (x, z) are outside the ground surface.
  22841. */
  22842. getHeightAtCoordinates(x: number, z: number): number;
  22843. /**
  22844. * Returns a normalized vector (Vector3) orthogonal to the ground
  22845. * at the ground coordinates (x, z) expressed in the World system.
  22846. * @param x x coordinate
  22847. * @param z z coordinate
  22848. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22849. */
  22850. getNormalAtCoordinates(x: number, z: number): Vector3;
  22851. /**
  22852. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22853. * at the ground coordinates (x, z) expressed in the World system.
  22854. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22855. * @param x x coordinate
  22856. * @param z z coordinate
  22857. * @param ref vector to store the result
  22858. * @returns the GroundMesh.
  22859. */
  22860. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22861. /**
  22862. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22863. * if the ground has been updated.
  22864. * This can be used in the render loop.
  22865. * @returns the GroundMesh.
  22866. */
  22867. updateCoordinateHeights(): GroundMesh;
  22868. private _getFacetAt;
  22869. private _initHeightQuads;
  22870. private _computeHeightQuads;
  22871. /**
  22872. * Serializes this ground mesh
  22873. * @param serializationObject object to write serialization to
  22874. */
  22875. serialize(serializationObject: any): void;
  22876. /**
  22877. * Parses a serialized ground mesh
  22878. * @param parsedMesh the serialized mesh
  22879. * @param scene the scene to create the ground mesh in
  22880. * @returns the created ground mesh
  22881. */
  22882. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22883. }
  22884. }
  22885. declare module "babylonjs/Physics/physicsJoint" {
  22886. import { Vector3 } from "babylonjs/Maths/math.vector";
  22887. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22888. /**
  22889. * Interface for Physics-Joint data
  22890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22891. */
  22892. export interface PhysicsJointData {
  22893. /**
  22894. * The main pivot of the joint
  22895. */
  22896. mainPivot?: Vector3;
  22897. /**
  22898. * The connected pivot of the joint
  22899. */
  22900. connectedPivot?: Vector3;
  22901. /**
  22902. * The main axis of the joint
  22903. */
  22904. mainAxis?: Vector3;
  22905. /**
  22906. * The connected axis of the joint
  22907. */
  22908. connectedAxis?: Vector3;
  22909. /**
  22910. * The collision of the joint
  22911. */
  22912. collision?: boolean;
  22913. /**
  22914. * Native Oimo/Cannon/Energy data
  22915. */
  22916. nativeParams?: any;
  22917. }
  22918. /**
  22919. * This is a holder class for the physics joint created by the physics plugin
  22920. * It holds a set of functions to control the underlying joint
  22921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22922. */
  22923. export class PhysicsJoint {
  22924. /**
  22925. * The type of the physics joint
  22926. */
  22927. type: number;
  22928. /**
  22929. * The data for the physics joint
  22930. */
  22931. jointData: PhysicsJointData;
  22932. private _physicsJoint;
  22933. protected _physicsPlugin: IPhysicsEnginePlugin;
  22934. /**
  22935. * Initializes the physics joint
  22936. * @param type The type of the physics joint
  22937. * @param jointData The data for the physics joint
  22938. */
  22939. constructor(
  22940. /**
  22941. * The type of the physics joint
  22942. */
  22943. type: number,
  22944. /**
  22945. * The data for the physics joint
  22946. */
  22947. jointData: PhysicsJointData);
  22948. /**
  22949. * Gets the physics joint
  22950. */
  22951. /**
  22952. * Sets the physics joint
  22953. */
  22954. physicsJoint: any;
  22955. /**
  22956. * Sets the physics plugin
  22957. */
  22958. physicsPlugin: IPhysicsEnginePlugin;
  22959. /**
  22960. * Execute a function that is physics-plugin specific.
  22961. * @param {Function} func the function that will be executed.
  22962. * It accepts two parameters: the physics world and the physics joint
  22963. */
  22964. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22965. /**
  22966. * Distance-Joint type
  22967. */
  22968. static DistanceJoint: number;
  22969. /**
  22970. * Hinge-Joint type
  22971. */
  22972. static HingeJoint: number;
  22973. /**
  22974. * Ball-and-Socket joint type
  22975. */
  22976. static BallAndSocketJoint: number;
  22977. /**
  22978. * Wheel-Joint type
  22979. */
  22980. static WheelJoint: number;
  22981. /**
  22982. * Slider-Joint type
  22983. */
  22984. static SliderJoint: number;
  22985. /**
  22986. * Prismatic-Joint type
  22987. */
  22988. static PrismaticJoint: number;
  22989. /**
  22990. * Universal-Joint type
  22991. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22992. */
  22993. static UniversalJoint: number;
  22994. /**
  22995. * Hinge-Joint 2 type
  22996. */
  22997. static Hinge2Joint: number;
  22998. /**
  22999. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23000. */
  23001. static PointToPointJoint: number;
  23002. /**
  23003. * Spring-Joint type
  23004. */
  23005. static SpringJoint: number;
  23006. /**
  23007. * Lock-Joint type
  23008. */
  23009. static LockJoint: number;
  23010. }
  23011. /**
  23012. * A class representing a physics distance joint
  23013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23014. */
  23015. export class DistanceJoint extends PhysicsJoint {
  23016. /**
  23017. *
  23018. * @param jointData The data for the Distance-Joint
  23019. */
  23020. constructor(jointData: DistanceJointData);
  23021. /**
  23022. * Update the predefined distance.
  23023. * @param maxDistance The maximum preferred distance
  23024. * @param minDistance The minimum preferred distance
  23025. */
  23026. updateDistance(maxDistance: number, minDistance?: number): void;
  23027. }
  23028. /**
  23029. * Represents a Motor-Enabled Joint
  23030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23031. */
  23032. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23033. /**
  23034. * Initializes the Motor-Enabled Joint
  23035. * @param type The type of the joint
  23036. * @param jointData The physica joint data for the joint
  23037. */
  23038. constructor(type: number, jointData: PhysicsJointData);
  23039. /**
  23040. * Set the motor values.
  23041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23042. * @param force the force to apply
  23043. * @param maxForce max force for this motor.
  23044. */
  23045. setMotor(force?: number, maxForce?: number): void;
  23046. /**
  23047. * Set the motor's limits.
  23048. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23049. * @param upperLimit The upper limit of the motor
  23050. * @param lowerLimit The lower limit of the motor
  23051. */
  23052. setLimit(upperLimit: number, lowerLimit?: number): void;
  23053. }
  23054. /**
  23055. * This class represents a single physics Hinge-Joint
  23056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23057. */
  23058. export class HingeJoint extends MotorEnabledJoint {
  23059. /**
  23060. * Initializes the Hinge-Joint
  23061. * @param jointData The joint data for the Hinge-Joint
  23062. */
  23063. constructor(jointData: PhysicsJointData);
  23064. /**
  23065. * Set the motor values.
  23066. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23067. * @param {number} force the force to apply
  23068. * @param {number} maxForce max force for this motor.
  23069. */
  23070. setMotor(force?: number, maxForce?: number): void;
  23071. /**
  23072. * Set the motor's limits.
  23073. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23074. * @param upperLimit The upper limit of the motor
  23075. * @param lowerLimit The lower limit of the motor
  23076. */
  23077. setLimit(upperLimit: number, lowerLimit?: number): void;
  23078. }
  23079. /**
  23080. * This class represents a dual hinge physics joint (same as wheel joint)
  23081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23082. */
  23083. export class Hinge2Joint extends MotorEnabledJoint {
  23084. /**
  23085. * Initializes the Hinge2-Joint
  23086. * @param jointData The joint data for the Hinge2-Joint
  23087. */
  23088. constructor(jointData: PhysicsJointData);
  23089. /**
  23090. * Set the motor values.
  23091. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23092. * @param {number} targetSpeed the speed the motor is to reach
  23093. * @param {number} maxForce max force for this motor.
  23094. * @param {motorIndex} the motor's index, 0 or 1.
  23095. */
  23096. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23097. /**
  23098. * Set the motor limits.
  23099. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23100. * @param {number} upperLimit the upper limit
  23101. * @param {number} lowerLimit lower limit
  23102. * @param {motorIndex} the motor's index, 0 or 1.
  23103. */
  23104. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23105. }
  23106. /**
  23107. * Interface for a motor enabled joint
  23108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23109. */
  23110. export interface IMotorEnabledJoint {
  23111. /**
  23112. * Physics joint
  23113. */
  23114. physicsJoint: any;
  23115. /**
  23116. * Sets the motor of the motor-enabled joint
  23117. * @param force The force of the motor
  23118. * @param maxForce The maximum force of the motor
  23119. * @param motorIndex The index of the motor
  23120. */
  23121. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23122. /**
  23123. * Sets the limit of the motor
  23124. * @param upperLimit The upper limit of the motor
  23125. * @param lowerLimit The lower limit of the motor
  23126. * @param motorIndex The index of the motor
  23127. */
  23128. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23129. }
  23130. /**
  23131. * Joint data for a Distance-Joint
  23132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23133. */
  23134. export interface DistanceJointData extends PhysicsJointData {
  23135. /**
  23136. * Max distance the 2 joint objects can be apart
  23137. */
  23138. maxDistance: number;
  23139. }
  23140. /**
  23141. * Joint data from a spring joint
  23142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23143. */
  23144. export interface SpringJointData extends PhysicsJointData {
  23145. /**
  23146. * Length of the spring
  23147. */
  23148. length: number;
  23149. /**
  23150. * Stiffness of the spring
  23151. */
  23152. stiffness: number;
  23153. /**
  23154. * Damping of the spring
  23155. */
  23156. damping: number;
  23157. /** this callback will be called when applying the force to the impostors. */
  23158. forceApplicationCallback: () => void;
  23159. }
  23160. }
  23161. declare module "babylonjs/Physics/physicsRaycastResult" {
  23162. import { Vector3 } from "babylonjs/Maths/math.vector";
  23163. /**
  23164. * Holds the data for the raycast result
  23165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23166. */
  23167. export class PhysicsRaycastResult {
  23168. private _hasHit;
  23169. private _hitDistance;
  23170. private _hitNormalWorld;
  23171. private _hitPointWorld;
  23172. private _rayFromWorld;
  23173. private _rayToWorld;
  23174. /**
  23175. * Gets if there was a hit
  23176. */
  23177. readonly hasHit: boolean;
  23178. /**
  23179. * Gets the distance from the hit
  23180. */
  23181. readonly hitDistance: number;
  23182. /**
  23183. * Gets the hit normal/direction in the world
  23184. */
  23185. readonly hitNormalWorld: Vector3;
  23186. /**
  23187. * Gets the hit point in the world
  23188. */
  23189. readonly hitPointWorld: Vector3;
  23190. /**
  23191. * Gets the ray "start point" of the ray in the world
  23192. */
  23193. readonly rayFromWorld: Vector3;
  23194. /**
  23195. * Gets the ray "end point" of the ray in the world
  23196. */
  23197. readonly rayToWorld: Vector3;
  23198. /**
  23199. * Sets the hit data (normal & point in world space)
  23200. * @param hitNormalWorld defines the normal in world space
  23201. * @param hitPointWorld defines the point in world space
  23202. */
  23203. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23204. /**
  23205. * Sets the distance from the start point to the hit point
  23206. * @param distance
  23207. */
  23208. setHitDistance(distance: number): void;
  23209. /**
  23210. * Calculates the distance manually
  23211. */
  23212. calculateHitDistance(): void;
  23213. /**
  23214. * Resets all the values to default
  23215. * @param from The from point on world space
  23216. * @param to The to point on world space
  23217. */
  23218. reset(from?: Vector3, to?: Vector3): void;
  23219. }
  23220. /**
  23221. * Interface for the size containing width and height
  23222. */
  23223. interface IXYZ {
  23224. /**
  23225. * X
  23226. */
  23227. x: number;
  23228. /**
  23229. * Y
  23230. */
  23231. y: number;
  23232. /**
  23233. * Z
  23234. */
  23235. z: number;
  23236. }
  23237. }
  23238. declare module "babylonjs/Physics/IPhysicsEngine" {
  23239. import { Nullable } from "babylonjs/types";
  23240. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23242. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23243. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23244. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23245. /**
  23246. * Interface used to describe a physics joint
  23247. */
  23248. export interface PhysicsImpostorJoint {
  23249. /** Defines the main impostor to which the joint is linked */
  23250. mainImpostor: PhysicsImpostor;
  23251. /** Defines the impostor that is connected to the main impostor using this joint */
  23252. connectedImpostor: PhysicsImpostor;
  23253. /** Defines the joint itself */
  23254. joint: PhysicsJoint;
  23255. }
  23256. /** @hidden */
  23257. export interface IPhysicsEnginePlugin {
  23258. world: any;
  23259. name: string;
  23260. setGravity(gravity: Vector3): void;
  23261. setTimeStep(timeStep: number): void;
  23262. getTimeStep(): number;
  23263. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23264. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23265. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23266. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23267. removePhysicsBody(impostor: PhysicsImpostor): void;
  23268. generateJoint(joint: PhysicsImpostorJoint): void;
  23269. removeJoint(joint: PhysicsImpostorJoint): void;
  23270. isSupported(): boolean;
  23271. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23272. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23273. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23274. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23275. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23276. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23277. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23278. getBodyMass(impostor: PhysicsImpostor): number;
  23279. getBodyFriction(impostor: PhysicsImpostor): number;
  23280. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23281. getBodyRestitution(impostor: PhysicsImpostor): number;
  23282. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23283. getBodyPressure?(impostor: PhysicsImpostor): number;
  23284. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23285. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23286. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23287. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23288. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23289. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23290. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23291. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23292. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23293. sleepBody(impostor: PhysicsImpostor): void;
  23294. wakeUpBody(impostor: PhysicsImpostor): void;
  23295. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23296. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23297. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23298. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23299. getRadius(impostor: PhysicsImpostor): number;
  23300. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23301. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23302. dispose(): void;
  23303. }
  23304. /**
  23305. * Interface used to define a physics engine
  23306. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23307. */
  23308. export interface IPhysicsEngine {
  23309. /**
  23310. * Gets the gravity vector used by the simulation
  23311. */
  23312. gravity: Vector3;
  23313. /**
  23314. * Sets the gravity vector used by the simulation
  23315. * @param gravity defines the gravity vector to use
  23316. */
  23317. setGravity(gravity: Vector3): void;
  23318. /**
  23319. * Set the time step of the physics engine.
  23320. * Default is 1/60.
  23321. * To slow it down, enter 1/600 for example.
  23322. * To speed it up, 1/30
  23323. * @param newTimeStep the new timestep to apply to this world.
  23324. */
  23325. setTimeStep(newTimeStep: number): void;
  23326. /**
  23327. * Get the time step of the physics engine.
  23328. * @returns the current time step
  23329. */
  23330. getTimeStep(): number;
  23331. /**
  23332. * Release all resources
  23333. */
  23334. dispose(): void;
  23335. /**
  23336. * Gets the name of the current physics plugin
  23337. * @returns the name of the plugin
  23338. */
  23339. getPhysicsPluginName(): string;
  23340. /**
  23341. * Adding a new impostor for the impostor tracking.
  23342. * This will be done by the impostor itself.
  23343. * @param impostor the impostor to add
  23344. */
  23345. addImpostor(impostor: PhysicsImpostor): void;
  23346. /**
  23347. * Remove an impostor from the engine.
  23348. * This impostor and its mesh will not longer be updated by the physics engine.
  23349. * @param impostor the impostor to remove
  23350. */
  23351. removeImpostor(impostor: PhysicsImpostor): void;
  23352. /**
  23353. * Add a joint to the physics engine
  23354. * @param mainImpostor defines the main impostor to which the joint is added.
  23355. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23356. * @param joint defines the joint that will connect both impostors.
  23357. */
  23358. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23359. /**
  23360. * Removes a joint from the simulation
  23361. * @param mainImpostor defines the impostor used with the joint
  23362. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23363. * @param joint defines the joint to remove
  23364. */
  23365. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23366. /**
  23367. * Gets the current plugin used to run the simulation
  23368. * @returns current plugin
  23369. */
  23370. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23371. /**
  23372. * Gets the list of physic impostors
  23373. * @returns an array of PhysicsImpostor
  23374. */
  23375. getImpostors(): Array<PhysicsImpostor>;
  23376. /**
  23377. * Gets the impostor for a physics enabled object
  23378. * @param object defines the object impersonated by the impostor
  23379. * @returns the PhysicsImpostor or null if not found
  23380. */
  23381. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23382. /**
  23383. * Gets the impostor for a physics body object
  23384. * @param body defines physics body used by the impostor
  23385. * @returns the PhysicsImpostor or null if not found
  23386. */
  23387. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23388. /**
  23389. * Does a raycast in the physics world
  23390. * @param from when should the ray start?
  23391. * @param to when should the ray end?
  23392. * @returns PhysicsRaycastResult
  23393. */
  23394. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23395. /**
  23396. * Called by the scene. No need to call it.
  23397. * @param delta defines the timespam between frames
  23398. */
  23399. _step(delta: number): void;
  23400. }
  23401. }
  23402. declare module "babylonjs/Physics/physicsImpostor" {
  23403. import { Nullable, IndicesArray } from "babylonjs/types";
  23404. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23405. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23407. import { Scene } from "babylonjs/scene";
  23408. import { Bone } from "babylonjs/Bones/bone";
  23409. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23410. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23411. import { Space } from "babylonjs/Maths/math.axis";
  23412. /**
  23413. * The interface for the physics imposter parameters
  23414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23415. */
  23416. export interface PhysicsImpostorParameters {
  23417. /**
  23418. * The mass of the physics imposter
  23419. */
  23420. mass: number;
  23421. /**
  23422. * The friction of the physics imposter
  23423. */
  23424. friction?: number;
  23425. /**
  23426. * The coefficient of restitution of the physics imposter
  23427. */
  23428. restitution?: number;
  23429. /**
  23430. * The native options of the physics imposter
  23431. */
  23432. nativeOptions?: any;
  23433. /**
  23434. * Specifies if the parent should be ignored
  23435. */
  23436. ignoreParent?: boolean;
  23437. /**
  23438. * Specifies if bi-directional transformations should be disabled
  23439. */
  23440. disableBidirectionalTransformation?: boolean;
  23441. /**
  23442. * The pressure inside the physics imposter, soft object only
  23443. */
  23444. pressure?: number;
  23445. /**
  23446. * The stiffness the physics imposter, soft object only
  23447. */
  23448. stiffness?: number;
  23449. /**
  23450. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23451. */
  23452. velocityIterations?: number;
  23453. /**
  23454. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23455. */
  23456. positionIterations?: number;
  23457. /**
  23458. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23459. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23460. * Add to fix multiple points
  23461. */
  23462. fixedPoints?: number;
  23463. /**
  23464. * The collision margin around a soft object
  23465. */
  23466. margin?: number;
  23467. /**
  23468. * The collision margin around a soft object
  23469. */
  23470. damping?: number;
  23471. /**
  23472. * The path for a rope based on an extrusion
  23473. */
  23474. path?: any;
  23475. /**
  23476. * The shape of an extrusion used for a rope based on an extrusion
  23477. */
  23478. shape?: any;
  23479. }
  23480. /**
  23481. * Interface for a physics-enabled object
  23482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23483. */
  23484. export interface IPhysicsEnabledObject {
  23485. /**
  23486. * The position of the physics-enabled object
  23487. */
  23488. position: Vector3;
  23489. /**
  23490. * The rotation of the physics-enabled object
  23491. */
  23492. rotationQuaternion: Nullable<Quaternion>;
  23493. /**
  23494. * The scale of the physics-enabled object
  23495. */
  23496. scaling: Vector3;
  23497. /**
  23498. * The rotation of the physics-enabled object
  23499. */
  23500. rotation?: Vector3;
  23501. /**
  23502. * The parent of the physics-enabled object
  23503. */
  23504. parent?: any;
  23505. /**
  23506. * The bounding info of the physics-enabled object
  23507. * @returns The bounding info of the physics-enabled object
  23508. */
  23509. getBoundingInfo(): BoundingInfo;
  23510. /**
  23511. * Computes the world matrix
  23512. * @param force Specifies if the world matrix should be computed by force
  23513. * @returns A world matrix
  23514. */
  23515. computeWorldMatrix(force: boolean): Matrix;
  23516. /**
  23517. * Gets the world matrix
  23518. * @returns A world matrix
  23519. */
  23520. getWorldMatrix?(): Matrix;
  23521. /**
  23522. * Gets the child meshes
  23523. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23524. * @returns An array of abstract meshes
  23525. */
  23526. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23527. /**
  23528. * Gets the vertex data
  23529. * @param kind The type of vertex data
  23530. * @returns A nullable array of numbers, or a float32 array
  23531. */
  23532. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23533. /**
  23534. * Gets the indices from the mesh
  23535. * @returns A nullable array of index arrays
  23536. */
  23537. getIndices?(): Nullable<IndicesArray>;
  23538. /**
  23539. * Gets the scene from the mesh
  23540. * @returns the indices array or null
  23541. */
  23542. getScene?(): Scene;
  23543. /**
  23544. * Gets the absolute position from the mesh
  23545. * @returns the absolute position
  23546. */
  23547. getAbsolutePosition(): Vector3;
  23548. /**
  23549. * Gets the absolute pivot point from the mesh
  23550. * @returns the absolute pivot point
  23551. */
  23552. getAbsolutePivotPoint(): Vector3;
  23553. /**
  23554. * Rotates the mesh
  23555. * @param axis The axis of rotation
  23556. * @param amount The amount of rotation
  23557. * @param space The space of the rotation
  23558. * @returns The rotation transform node
  23559. */
  23560. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23561. /**
  23562. * Translates the mesh
  23563. * @param axis The axis of translation
  23564. * @param distance The distance of translation
  23565. * @param space The space of the translation
  23566. * @returns The transform node
  23567. */
  23568. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23569. /**
  23570. * Sets the absolute position of the mesh
  23571. * @param absolutePosition The absolute position of the mesh
  23572. * @returns The transform node
  23573. */
  23574. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23575. /**
  23576. * Gets the class name of the mesh
  23577. * @returns The class name
  23578. */
  23579. getClassName(): string;
  23580. }
  23581. /**
  23582. * Represents a physics imposter
  23583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23584. */
  23585. export class PhysicsImpostor {
  23586. /**
  23587. * The physics-enabled object used as the physics imposter
  23588. */
  23589. object: IPhysicsEnabledObject;
  23590. /**
  23591. * The type of the physics imposter
  23592. */
  23593. type: number;
  23594. private _options;
  23595. private _scene?;
  23596. /**
  23597. * The default object size of the imposter
  23598. */
  23599. static DEFAULT_OBJECT_SIZE: Vector3;
  23600. /**
  23601. * The identity quaternion of the imposter
  23602. */
  23603. static IDENTITY_QUATERNION: Quaternion;
  23604. /** @hidden */
  23605. _pluginData: any;
  23606. private _physicsEngine;
  23607. private _physicsBody;
  23608. private _bodyUpdateRequired;
  23609. private _onBeforePhysicsStepCallbacks;
  23610. private _onAfterPhysicsStepCallbacks;
  23611. /** @hidden */
  23612. _onPhysicsCollideCallbacks: Array<{
  23613. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23614. otherImpostors: Array<PhysicsImpostor>;
  23615. }>;
  23616. private _deltaPosition;
  23617. private _deltaRotation;
  23618. private _deltaRotationConjugated;
  23619. /** @hidden */
  23620. _isFromLine: boolean;
  23621. private _parent;
  23622. private _isDisposed;
  23623. private static _tmpVecs;
  23624. private static _tmpQuat;
  23625. /**
  23626. * Specifies if the physics imposter is disposed
  23627. */
  23628. readonly isDisposed: boolean;
  23629. /**
  23630. * Gets the mass of the physics imposter
  23631. */
  23632. mass: number;
  23633. /**
  23634. * Gets the coefficient of friction
  23635. */
  23636. /**
  23637. * Sets the coefficient of friction
  23638. */
  23639. friction: number;
  23640. /**
  23641. * Gets the coefficient of restitution
  23642. */
  23643. /**
  23644. * Sets the coefficient of restitution
  23645. */
  23646. restitution: number;
  23647. /**
  23648. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23649. */
  23650. /**
  23651. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23652. */
  23653. pressure: number;
  23654. /**
  23655. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23656. */
  23657. /**
  23658. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23659. */
  23660. stiffness: number;
  23661. /**
  23662. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23663. */
  23664. /**
  23665. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23666. */
  23667. velocityIterations: number;
  23668. /**
  23669. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23670. */
  23671. /**
  23672. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23673. */
  23674. positionIterations: number;
  23675. /**
  23676. * The unique id of the physics imposter
  23677. * set by the physics engine when adding this impostor to the array
  23678. */
  23679. uniqueId: number;
  23680. /**
  23681. * @hidden
  23682. */
  23683. soft: boolean;
  23684. /**
  23685. * @hidden
  23686. */
  23687. segments: number;
  23688. private _joints;
  23689. /**
  23690. * Initializes the physics imposter
  23691. * @param object The physics-enabled object used as the physics imposter
  23692. * @param type The type of the physics imposter
  23693. * @param _options The options for the physics imposter
  23694. * @param _scene The Babylon scene
  23695. */
  23696. constructor(
  23697. /**
  23698. * The physics-enabled object used as the physics imposter
  23699. */
  23700. object: IPhysicsEnabledObject,
  23701. /**
  23702. * The type of the physics imposter
  23703. */
  23704. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23705. /**
  23706. * This function will completly initialize this impostor.
  23707. * It will create a new body - but only if this mesh has no parent.
  23708. * If it has, this impostor will not be used other than to define the impostor
  23709. * of the child mesh.
  23710. * @hidden
  23711. */
  23712. _init(): void;
  23713. private _getPhysicsParent;
  23714. /**
  23715. * Should a new body be generated.
  23716. * @returns boolean specifying if body initialization is required
  23717. */
  23718. isBodyInitRequired(): boolean;
  23719. /**
  23720. * Sets the updated scaling
  23721. * @param updated Specifies if the scaling is updated
  23722. */
  23723. setScalingUpdated(): void;
  23724. /**
  23725. * Force a regeneration of this or the parent's impostor's body.
  23726. * Use under cautious - This will remove all joints already implemented.
  23727. */
  23728. forceUpdate(): void;
  23729. /**
  23730. * Gets the body that holds this impostor. Either its own, or its parent.
  23731. */
  23732. /**
  23733. * Set the physics body. Used mainly by the physics engine/plugin
  23734. */
  23735. physicsBody: any;
  23736. /**
  23737. * Get the parent of the physics imposter
  23738. * @returns Physics imposter or null
  23739. */
  23740. /**
  23741. * Sets the parent of the physics imposter
  23742. */
  23743. parent: Nullable<PhysicsImpostor>;
  23744. /**
  23745. * Resets the update flags
  23746. */
  23747. resetUpdateFlags(): void;
  23748. /**
  23749. * Gets the object extend size
  23750. * @returns the object extend size
  23751. */
  23752. getObjectExtendSize(): Vector3;
  23753. /**
  23754. * Gets the object center
  23755. * @returns The object center
  23756. */
  23757. getObjectCenter(): Vector3;
  23758. /**
  23759. * Get a specific parametes from the options parameter
  23760. * @param paramName The object parameter name
  23761. * @returns The object parameter
  23762. */
  23763. getParam(paramName: string): any;
  23764. /**
  23765. * Sets a specific parameter in the options given to the physics plugin
  23766. * @param paramName The parameter name
  23767. * @param value The value of the parameter
  23768. */
  23769. setParam(paramName: string, value: number): void;
  23770. /**
  23771. * Specifically change the body's mass option. Won't recreate the physics body object
  23772. * @param mass The mass of the physics imposter
  23773. */
  23774. setMass(mass: number): void;
  23775. /**
  23776. * Gets the linear velocity
  23777. * @returns linear velocity or null
  23778. */
  23779. getLinearVelocity(): Nullable<Vector3>;
  23780. /**
  23781. * Sets the linear velocity
  23782. * @param velocity linear velocity or null
  23783. */
  23784. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23785. /**
  23786. * Gets the angular velocity
  23787. * @returns angular velocity or null
  23788. */
  23789. getAngularVelocity(): Nullable<Vector3>;
  23790. /**
  23791. * Sets the angular velocity
  23792. * @param velocity The velocity or null
  23793. */
  23794. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23795. /**
  23796. * Execute a function with the physics plugin native code
  23797. * Provide a function the will have two variables - the world object and the physics body object
  23798. * @param func The function to execute with the physics plugin native code
  23799. */
  23800. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23801. /**
  23802. * Register a function that will be executed before the physics world is stepping forward
  23803. * @param func The function to execute before the physics world is stepped forward
  23804. */
  23805. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23806. /**
  23807. * Unregister a function that will be executed before the physics world is stepping forward
  23808. * @param func The function to execute before the physics world is stepped forward
  23809. */
  23810. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23811. /**
  23812. * Register a function that will be executed after the physics step
  23813. * @param func The function to execute after physics step
  23814. */
  23815. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23816. /**
  23817. * Unregisters a function that will be executed after the physics step
  23818. * @param func The function to execute after physics step
  23819. */
  23820. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23821. /**
  23822. * register a function that will be executed when this impostor collides against a different body
  23823. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23824. * @param func Callback that is executed on collision
  23825. */
  23826. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23827. /**
  23828. * Unregisters the physics imposter on contact
  23829. * @param collideAgainst The physics object to collide against
  23830. * @param func Callback to execute on collision
  23831. */
  23832. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23833. private _tmpQuat;
  23834. private _tmpQuat2;
  23835. /**
  23836. * Get the parent rotation
  23837. * @returns The parent rotation
  23838. */
  23839. getParentsRotation(): Quaternion;
  23840. /**
  23841. * this function is executed by the physics engine.
  23842. */
  23843. beforeStep: () => void;
  23844. /**
  23845. * this function is executed by the physics engine
  23846. */
  23847. afterStep: () => void;
  23848. /**
  23849. * Legacy collision detection event support
  23850. */
  23851. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23852. /**
  23853. * event and body object due to cannon's event-based architecture.
  23854. */
  23855. onCollide: (e: {
  23856. body: any;
  23857. }) => void;
  23858. /**
  23859. * Apply a force
  23860. * @param force The force to apply
  23861. * @param contactPoint The contact point for the force
  23862. * @returns The physics imposter
  23863. */
  23864. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23865. /**
  23866. * Apply an impulse
  23867. * @param force The impulse force
  23868. * @param contactPoint The contact point for the impulse force
  23869. * @returns The physics imposter
  23870. */
  23871. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23872. /**
  23873. * A help function to create a joint
  23874. * @param otherImpostor A physics imposter used to create a joint
  23875. * @param jointType The type of joint
  23876. * @param jointData The data for the joint
  23877. * @returns The physics imposter
  23878. */
  23879. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23880. /**
  23881. * Add a joint to this impostor with a different impostor
  23882. * @param otherImpostor A physics imposter used to add a joint
  23883. * @param joint The joint to add
  23884. * @returns The physics imposter
  23885. */
  23886. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23887. /**
  23888. * Add an anchor to a cloth impostor
  23889. * @param otherImpostor rigid impostor to anchor to
  23890. * @param width ratio across width from 0 to 1
  23891. * @param height ratio up height from 0 to 1
  23892. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23893. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23894. * @returns impostor the soft imposter
  23895. */
  23896. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23897. /**
  23898. * Add a hook to a rope impostor
  23899. * @param otherImpostor rigid impostor to anchor to
  23900. * @param length ratio across rope from 0 to 1
  23901. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23902. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23903. * @returns impostor the rope imposter
  23904. */
  23905. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23906. /**
  23907. * Will keep this body still, in a sleep mode.
  23908. * @returns the physics imposter
  23909. */
  23910. sleep(): PhysicsImpostor;
  23911. /**
  23912. * Wake the body up.
  23913. * @returns The physics imposter
  23914. */
  23915. wakeUp(): PhysicsImpostor;
  23916. /**
  23917. * Clones the physics imposter
  23918. * @param newObject The physics imposter clones to this physics-enabled object
  23919. * @returns A nullable physics imposter
  23920. */
  23921. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23922. /**
  23923. * Disposes the physics imposter
  23924. */
  23925. dispose(): void;
  23926. /**
  23927. * Sets the delta position
  23928. * @param position The delta position amount
  23929. */
  23930. setDeltaPosition(position: Vector3): void;
  23931. /**
  23932. * Sets the delta rotation
  23933. * @param rotation The delta rotation amount
  23934. */
  23935. setDeltaRotation(rotation: Quaternion): void;
  23936. /**
  23937. * Gets the box size of the physics imposter and stores the result in the input parameter
  23938. * @param result Stores the box size
  23939. * @returns The physics imposter
  23940. */
  23941. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23942. /**
  23943. * Gets the radius of the physics imposter
  23944. * @returns Radius of the physics imposter
  23945. */
  23946. getRadius(): number;
  23947. /**
  23948. * Sync a bone with this impostor
  23949. * @param bone The bone to sync to the impostor.
  23950. * @param boneMesh The mesh that the bone is influencing.
  23951. * @param jointPivot The pivot of the joint / bone in local space.
  23952. * @param distToJoint Optional distance from the impostor to the joint.
  23953. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23954. */
  23955. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23956. /**
  23957. * Sync impostor to a bone
  23958. * @param bone The bone that the impostor will be synced to.
  23959. * @param boneMesh The mesh that the bone is influencing.
  23960. * @param jointPivot The pivot of the joint / bone in local space.
  23961. * @param distToJoint Optional distance from the impostor to the joint.
  23962. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23963. * @param boneAxis Optional vector3 axis the bone is aligned with
  23964. */
  23965. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23966. /**
  23967. * No-Imposter type
  23968. */
  23969. static NoImpostor: number;
  23970. /**
  23971. * Sphere-Imposter type
  23972. */
  23973. static SphereImpostor: number;
  23974. /**
  23975. * Box-Imposter type
  23976. */
  23977. static BoxImpostor: number;
  23978. /**
  23979. * Plane-Imposter type
  23980. */
  23981. static PlaneImpostor: number;
  23982. /**
  23983. * Mesh-imposter type
  23984. */
  23985. static MeshImpostor: number;
  23986. /**
  23987. * Capsule-Impostor type (Ammo.js plugin only)
  23988. */
  23989. static CapsuleImpostor: number;
  23990. /**
  23991. * Cylinder-Imposter type
  23992. */
  23993. static CylinderImpostor: number;
  23994. /**
  23995. * Particle-Imposter type
  23996. */
  23997. static ParticleImpostor: number;
  23998. /**
  23999. * Heightmap-Imposter type
  24000. */
  24001. static HeightmapImpostor: number;
  24002. /**
  24003. * ConvexHull-Impostor type (Ammo.js plugin only)
  24004. */
  24005. static ConvexHullImpostor: number;
  24006. /**
  24007. * Rope-Imposter type
  24008. */
  24009. static RopeImpostor: number;
  24010. /**
  24011. * Cloth-Imposter type
  24012. */
  24013. static ClothImpostor: number;
  24014. /**
  24015. * Softbody-Imposter type
  24016. */
  24017. static SoftbodyImpostor: number;
  24018. }
  24019. }
  24020. declare module "babylonjs/Meshes/mesh" {
  24021. import { Observable } from "babylonjs/Misc/observable";
  24022. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24023. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24024. import { Camera } from "babylonjs/Cameras/camera";
  24025. import { Scene } from "babylonjs/scene";
  24026. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24027. import { Color4 } from "babylonjs/Maths/math.color";
  24028. import { Engine } from "babylonjs/Engines/engine";
  24029. import { Node } from "babylonjs/node";
  24030. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24031. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24032. import { Buffer } from "babylonjs/Meshes/buffer";
  24033. import { Geometry } from "babylonjs/Meshes/geometry";
  24034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24035. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24036. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24037. import { Effect } from "babylonjs/Materials/effect";
  24038. import { Material } from "babylonjs/Materials/material";
  24039. import { Skeleton } from "babylonjs/Bones/skeleton";
  24040. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24041. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24042. import { Path3D } from "babylonjs/Maths/math.path";
  24043. import { Plane } from "babylonjs/Maths/math.plane";
  24044. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24045. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24046. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24047. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24048. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24049. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24050. /**
  24051. * @hidden
  24052. **/
  24053. export class _CreationDataStorage {
  24054. closePath?: boolean;
  24055. closeArray?: boolean;
  24056. idx: number[];
  24057. dashSize: number;
  24058. gapSize: number;
  24059. path3D: Path3D;
  24060. pathArray: Vector3[][];
  24061. arc: number;
  24062. radius: number;
  24063. cap: number;
  24064. tessellation: number;
  24065. }
  24066. /**
  24067. * @hidden
  24068. **/
  24069. class _InstanceDataStorage {
  24070. visibleInstances: any;
  24071. batchCache: _InstancesBatch;
  24072. instancesBufferSize: number;
  24073. instancesBuffer: Nullable<Buffer>;
  24074. instancesData: Float32Array;
  24075. overridenInstanceCount: number;
  24076. isFrozen: boolean;
  24077. previousBatch: Nullable<_InstancesBatch>;
  24078. hardwareInstancedRendering: boolean;
  24079. sideOrientation: number;
  24080. }
  24081. /**
  24082. * @hidden
  24083. **/
  24084. export class _InstancesBatch {
  24085. mustReturn: boolean;
  24086. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24087. renderSelf: boolean[];
  24088. hardwareInstancedRendering: boolean[];
  24089. }
  24090. /**
  24091. * Class used to represent renderable models
  24092. */
  24093. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24094. /**
  24095. * Mesh side orientation : usually the external or front surface
  24096. */
  24097. static readonly FRONTSIDE: number;
  24098. /**
  24099. * Mesh side orientation : usually the internal or back surface
  24100. */
  24101. static readonly BACKSIDE: number;
  24102. /**
  24103. * Mesh side orientation : both internal and external or front and back surfaces
  24104. */
  24105. static readonly DOUBLESIDE: number;
  24106. /**
  24107. * Mesh side orientation : by default, `FRONTSIDE`
  24108. */
  24109. static readonly DEFAULTSIDE: number;
  24110. /**
  24111. * Mesh cap setting : no cap
  24112. */
  24113. static readonly NO_CAP: number;
  24114. /**
  24115. * Mesh cap setting : one cap at the beginning of the mesh
  24116. */
  24117. static readonly CAP_START: number;
  24118. /**
  24119. * Mesh cap setting : one cap at the end of the mesh
  24120. */
  24121. static readonly CAP_END: number;
  24122. /**
  24123. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24124. */
  24125. static readonly CAP_ALL: number;
  24126. /**
  24127. * Mesh pattern setting : no flip or rotate
  24128. */
  24129. static readonly NO_FLIP: number;
  24130. /**
  24131. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24132. */
  24133. static readonly FLIP_TILE: number;
  24134. /**
  24135. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24136. */
  24137. static readonly ROTATE_TILE: number;
  24138. /**
  24139. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24140. */
  24141. static readonly FLIP_ROW: number;
  24142. /**
  24143. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24144. */
  24145. static readonly ROTATE_ROW: number;
  24146. /**
  24147. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24148. */
  24149. static readonly FLIP_N_ROTATE_TILE: number;
  24150. /**
  24151. * Mesh pattern setting : rotate pattern and rotate
  24152. */
  24153. static readonly FLIP_N_ROTATE_ROW: number;
  24154. /**
  24155. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24156. */
  24157. static readonly CENTER: number;
  24158. /**
  24159. * Mesh tile positioning : part tiles on left
  24160. */
  24161. static readonly LEFT: number;
  24162. /**
  24163. * Mesh tile positioning : part tiles on right
  24164. */
  24165. static readonly RIGHT: number;
  24166. /**
  24167. * Mesh tile positioning : part tiles on top
  24168. */
  24169. static readonly TOP: number;
  24170. /**
  24171. * Mesh tile positioning : part tiles on bottom
  24172. */
  24173. static readonly BOTTOM: number;
  24174. /**
  24175. * Gets the default side orientation.
  24176. * @param orientation the orientation to value to attempt to get
  24177. * @returns the default orientation
  24178. * @hidden
  24179. */
  24180. static _GetDefaultSideOrientation(orientation?: number): number;
  24181. private _internalMeshDataInfo;
  24182. /**
  24183. * An event triggered before rendering the mesh
  24184. */
  24185. readonly onBeforeRenderObservable: Observable<Mesh>;
  24186. /**
  24187. * An event triggered before binding the mesh
  24188. */
  24189. readonly onBeforeBindObservable: Observable<Mesh>;
  24190. /**
  24191. * An event triggered after rendering the mesh
  24192. */
  24193. readonly onAfterRenderObservable: Observable<Mesh>;
  24194. /**
  24195. * An event triggered before drawing the mesh
  24196. */
  24197. readonly onBeforeDrawObservable: Observable<Mesh>;
  24198. private _onBeforeDrawObserver;
  24199. /**
  24200. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24201. */
  24202. onBeforeDraw: () => void;
  24203. readonly hasInstances: boolean;
  24204. /**
  24205. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24206. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24207. */
  24208. delayLoadState: number;
  24209. /**
  24210. * Gets the list of instances created from this mesh
  24211. * it is not supposed to be modified manually.
  24212. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24213. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24214. */
  24215. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24216. /**
  24217. * Gets the file containing delay loading data for this mesh
  24218. */
  24219. delayLoadingFile: string;
  24220. /** @hidden */
  24221. _binaryInfo: any;
  24222. /**
  24223. * User defined function used to change how LOD level selection is done
  24224. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24225. */
  24226. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24227. /**
  24228. * Gets or sets the morph target manager
  24229. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24230. */
  24231. morphTargetManager: Nullable<MorphTargetManager>;
  24232. /** @hidden */
  24233. _creationDataStorage: Nullable<_CreationDataStorage>;
  24234. /** @hidden */
  24235. _geometry: Nullable<Geometry>;
  24236. /** @hidden */
  24237. _delayInfo: Array<string>;
  24238. /** @hidden */
  24239. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24240. /** @hidden */
  24241. _instanceDataStorage: _InstanceDataStorage;
  24242. private _effectiveMaterial;
  24243. /** @hidden */
  24244. _shouldGenerateFlatShading: boolean;
  24245. /** @hidden */
  24246. _originalBuilderSideOrientation: number;
  24247. /**
  24248. * Use this property to change the original side orientation defined at construction time
  24249. */
  24250. overrideMaterialSideOrientation: Nullable<number>;
  24251. /**
  24252. * Gets the source mesh (the one used to clone this one from)
  24253. */
  24254. readonly source: Nullable<Mesh>;
  24255. /**
  24256. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24257. */
  24258. isUnIndexed: boolean;
  24259. /**
  24260. * @constructor
  24261. * @param name The value used by scene.getMeshByName() to do a lookup.
  24262. * @param scene The scene to add this mesh to.
  24263. * @param parent The parent of this mesh, if it has one
  24264. * @param source An optional Mesh from which geometry is shared, cloned.
  24265. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24266. * When false, achieved by calling a clone(), also passing False.
  24267. * This will make creation of children, recursive.
  24268. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24269. */
  24270. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24271. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24272. /**
  24273. * Gets the class name
  24274. * @returns the string "Mesh".
  24275. */
  24276. getClassName(): string;
  24277. /** @hidden */
  24278. readonly _isMesh: boolean;
  24279. /**
  24280. * Returns a description of this mesh
  24281. * @param fullDetails define if full details about this mesh must be used
  24282. * @returns a descriptive string representing this mesh
  24283. */
  24284. toString(fullDetails?: boolean): string;
  24285. /** @hidden */
  24286. _unBindEffect(): void;
  24287. /**
  24288. * Gets a boolean indicating if this mesh has LOD
  24289. */
  24290. readonly hasLODLevels: boolean;
  24291. /**
  24292. * Gets the list of MeshLODLevel associated with the current mesh
  24293. * @returns an array of MeshLODLevel
  24294. */
  24295. getLODLevels(): MeshLODLevel[];
  24296. private _sortLODLevels;
  24297. /**
  24298. * Add a mesh as LOD level triggered at the given distance.
  24299. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24300. * @param distance The distance from the center of the object to show this level
  24301. * @param mesh The mesh to be added as LOD level (can be null)
  24302. * @return This mesh (for chaining)
  24303. */
  24304. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24305. /**
  24306. * Returns the LOD level mesh at the passed distance or null if not found.
  24307. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24308. * @param distance The distance from the center of the object to show this level
  24309. * @returns a Mesh or `null`
  24310. */
  24311. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24312. /**
  24313. * Remove a mesh from the LOD array
  24314. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24315. * @param mesh defines the mesh to be removed
  24316. * @return This mesh (for chaining)
  24317. */
  24318. removeLODLevel(mesh: Mesh): Mesh;
  24319. /**
  24320. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24321. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24322. * @param camera defines the camera to use to compute distance
  24323. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24324. * @return This mesh (for chaining)
  24325. */
  24326. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24327. /**
  24328. * Gets the mesh internal Geometry object
  24329. */
  24330. readonly geometry: Nullable<Geometry>;
  24331. /**
  24332. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24333. * @returns the total number of vertices
  24334. */
  24335. getTotalVertices(): number;
  24336. /**
  24337. * Returns the content of an associated vertex buffer
  24338. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24339. * - VertexBuffer.PositionKind
  24340. * - VertexBuffer.UVKind
  24341. * - VertexBuffer.UV2Kind
  24342. * - VertexBuffer.UV3Kind
  24343. * - VertexBuffer.UV4Kind
  24344. * - VertexBuffer.UV5Kind
  24345. * - VertexBuffer.UV6Kind
  24346. * - VertexBuffer.ColorKind
  24347. * - VertexBuffer.MatricesIndicesKind
  24348. * - VertexBuffer.MatricesIndicesExtraKind
  24349. * - VertexBuffer.MatricesWeightsKind
  24350. * - VertexBuffer.MatricesWeightsExtraKind
  24351. * @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
  24352. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24353. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24354. */
  24355. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24356. /**
  24357. * Returns the mesh VertexBuffer object from the requested `kind`
  24358. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24359. * - VertexBuffer.PositionKind
  24360. * - VertexBuffer.NormalKind
  24361. * - VertexBuffer.UVKind
  24362. * - VertexBuffer.UV2Kind
  24363. * - VertexBuffer.UV3Kind
  24364. * - VertexBuffer.UV4Kind
  24365. * - VertexBuffer.UV5Kind
  24366. * - VertexBuffer.UV6Kind
  24367. * - VertexBuffer.ColorKind
  24368. * - VertexBuffer.MatricesIndicesKind
  24369. * - VertexBuffer.MatricesIndicesExtraKind
  24370. * - VertexBuffer.MatricesWeightsKind
  24371. * - VertexBuffer.MatricesWeightsExtraKind
  24372. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24373. */
  24374. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24375. /**
  24376. * Tests if a specific vertex buffer is associated with this mesh
  24377. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24378. * - VertexBuffer.PositionKind
  24379. * - VertexBuffer.NormalKind
  24380. * - VertexBuffer.UVKind
  24381. * - VertexBuffer.UV2Kind
  24382. * - VertexBuffer.UV3Kind
  24383. * - VertexBuffer.UV4Kind
  24384. * - VertexBuffer.UV5Kind
  24385. * - VertexBuffer.UV6Kind
  24386. * - VertexBuffer.ColorKind
  24387. * - VertexBuffer.MatricesIndicesKind
  24388. * - VertexBuffer.MatricesIndicesExtraKind
  24389. * - VertexBuffer.MatricesWeightsKind
  24390. * - VertexBuffer.MatricesWeightsExtraKind
  24391. * @returns a boolean
  24392. */
  24393. isVerticesDataPresent(kind: string): boolean;
  24394. /**
  24395. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24396. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24397. * - VertexBuffer.PositionKind
  24398. * - VertexBuffer.UVKind
  24399. * - VertexBuffer.UV2Kind
  24400. * - VertexBuffer.UV3Kind
  24401. * - VertexBuffer.UV4Kind
  24402. * - VertexBuffer.UV5Kind
  24403. * - VertexBuffer.UV6Kind
  24404. * - VertexBuffer.ColorKind
  24405. * - VertexBuffer.MatricesIndicesKind
  24406. * - VertexBuffer.MatricesIndicesExtraKind
  24407. * - VertexBuffer.MatricesWeightsKind
  24408. * - VertexBuffer.MatricesWeightsExtraKind
  24409. * @returns a boolean
  24410. */
  24411. isVertexBufferUpdatable(kind: string): boolean;
  24412. /**
  24413. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24414. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24415. * - VertexBuffer.PositionKind
  24416. * - VertexBuffer.NormalKind
  24417. * - VertexBuffer.UVKind
  24418. * - VertexBuffer.UV2Kind
  24419. * - VertexBuffer.UV3Kind
  24420. * - VertexBuffer.UV4Kind
  24421. * - VertexBuffer.UV5Kind
  24422. * - VertexBuffer.UV6Kind
  24423. * - VertexBuffer.ColorKind
  24424. * - VertexBuffer.MatricesIndicesKind
  24425. * - VertexBuffer.MatricesIndicesExtraKind
  24426. * - VertexBuffer.MatricesWeightsKind
  24427. * - VertexBuffer.MatricesWeightsExtraKind
  24428. * @returns an array of strings
  24429. */
  24430. getVerticesDataKinds(): string[];
  24431. /**
  24432. * Returns a positive integer : the total number of indices in this mesh geometry.
  24433. * @returns the numner of indices or zero if the mesh has no geometry.
  24434. */
  24435. getTotalIndices(): number;
  24436. /**
  24437. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24438. * @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.
  24439. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24440. * @returns the indices array or an empty array if the mesh has no geometry
  24441. */
  24442. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24443. readonly isBlocked: boolean;
  24444. /**
  24445. * Determine if the current mesh is ready to be rendered
  24446. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24447. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24448. * @returns true if all associated assets are ready (material, textures, shaders)
  24449. */
  24450. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24451. /**
  24452. * 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.
  24453. */
  24454. readonly areNormalsFrozen: boolean;
  24455. /**
  24456. * 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.
  24457. * @returns the current mesh
  24458. */
  24459. freezeNormals(): Mesh;
  24460. /**
  24461. * 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
  24462. * @returns the current mesh
  24463. */
  24464. unfreezeNormals(): Mesh;
  24465. /**
  24466. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24467. */
  24468. overridenInstanceCount: number;
  24469. /** @hidden */
  24470. _preActivate(): Mesh;
  24471. /** @hidden */
  24472. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24473. /** @hidden */
  24474. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24475. /**
  24476. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24477. * This means the mesh underlying bounding box and sphere are recomputed.
  24478. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24479. * @returns the current mesh
  24480. */
  24481. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24482. /** @hidden */
  24483. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24484. /**
  24485. * This function will subdivide the mesh into multiple submeshes
  24486. * @param count defines the expected number of submeshes
  24487. */
  24488. subdivide(count: number): void;
  24489. /**
  24490. * Copy a FloatArray into a specific associated vertex buffer
  24491. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24492. * - VertexBuffer.PositionKind
  24493. * - VertexBuffer.UVKind
  24494. * - VertexBuffer.UV2Kind
  24495. * - VertexBuffer.UV3Kind
  24496. * - VertexBuffer.UV4Kind
  24497. * - VertexBuffer.UV5Kind
  24498. * - VertexBuffer.UV6Kind
  24499. * - VertexBuffer.ColorKind
  24500. * - VertexBuffer.MatricesIndicesKind
  24501. * - VertexBuffer.MatricesIndicesExtraKind
  24502. * - VertexBuffer.MatricesWeightsKind
  24503. * - VertexBuffer.MatricesWeightsExtraKind
  24504. * @param data defines the data source
  24505. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24506. * @param stride defines the data stride size (can be null)
  24507. * @returns the current mesh
  24508. */
  24509. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24510. /**
  24511. * Flags an associated vertex buffer as updatable
  24512. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24513. * - VertexBuffer.PositionKind
  24514. * - VertexBuffer.UVKind
  24515. * - VertexBuffer.UV2Kind
  24516. * - VertexBuffer.UV3Kind
  24517. * - VertexBuffer.UV4Kind
  24518. * - VertexBuffer.UV5Kind
  24519. * - VertexBuffer.UV6Kind
  24520. * - VertexBuffer.ColorKind
  24521. * - VertexBuffer.MatricesIndicesKind
  24522. * - VertexBuffer.MatricesIndicesExtraKind
  24523. * - VertexBuffer.MatricesWeightsKind
  24524. * - VertexBuffer.MatricesWeightsExtraKind
  24525. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24526. */
  24527. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24528. /**
  24529. * Sets the mesh global Vertex Buffer
  24530. * @param buffer defines the buffer to use
  24531. * @returns the current mesh
  24532. */
  24533. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24534. /**
  24535. * Update a specific associated vertex buffer
  24536. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24537. * - VertexBuffer.PositionKind
  24538. * - VertexBuffer.UVKind
  24539. * - VertexBuffer.UV2Kind
  24540. * - VertexBuffer.UV3Kind
  24541. * - VertexBuffer.UV4Kind
  24542. * - VertexBuffer.UV5Kind
  24543. * - VertexBuffer.UV6Kind
  24544. * - VertexBuffer.ColorKind
  24545. * - VertexBuffer.MatricesIndicesKind
  24546. * - VertexBuffer.MatricesIndicesExtraKind
  24547. * - VertexBuffer.MatricesWeightsKind
  24548. * - VertexBuffer.MatricesWeightsExtraKind
  24549. * @param data defines the data source
  24550. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24551. * @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)
  24552. * @returns the current mesh
  24553. */
  24554. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24555. /**
  24556. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24557. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24558. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24559. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24560. * @returns the current mesh
  24561. */
  24562. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24563. /**
  24564. * Creates a un-shared specific occurence of the geometry for the mesh.
  24565. * @returns the current mesh
  24566. */
  24567. makeGeometryUnique(): Mesh;
  24568. /**
  24569. * Set the index buffer of this mesh
  24570. * @param indices defines the source data
  24571. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24572. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24573. * @returns the current mesh
  24574. */
  24575. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24576. /**
  24577. * Update the current index buffer
  24578. * @param indices defines the source data
  24579. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24580. * @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)
  24581. * @returns the current mesh
  24582. */
  24583. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24584. /**
  24585. * Invert the geometry to move from a right handed system to a left handed one.
  24586. * @returns the current mesh
  24587. */
  24588. toLeftHanded(): Mesh;
  24589. /** @hidden */
  24590. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24591. /** @hidden */
  24592. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24593. /**
  24594. * Registers for this mesh a javascript function called just before the rendering process
  24595. * @param func defines the function to call before rendering this mesh
  24596. * @returns the current mesh
  24597. */
  24598. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24599. /**
  24600. * Disposes a previously registered javascript function called before the rendering
  24601. * @param func defines the function to remove
  24602. * @returns the current mesh
  24603. */
  24604. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24605. /**
  24606. * Registers for this mesh a javascript function called just after the rendering is complete
  24607. * @param func defines the function to call after rendering this mesh
  24608. * @returns the current mesh
  24609. */
  24610. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24611. /**
  24612. * Disposes a previously registered javascript function called after the rendering.
  24613. * @param func defines the function to remove
  24614. * @returns the current mesh
  24615. */
  24616. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24617. /** @hidden */
  24618. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24619. /** @hidden */
  24620. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24621. /** @hidden */
  24622. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24623. /** @hidden */
  24624. _rebuild(): void;
  24625. /** @hidden */
  24626. _freeze(): void;
  24627. /** @hidden */
  24628. _unFreeze(): void;
  24629. /**
  24630. * 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
  24631. * @param subMesh defines the subMesh to render
  24632. * @param enableAlphaMode defines if alpha mode can be changed
  24633. * @returns the current mesh
  24634. */
  24635. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24636. private _onBeforeDraw;
  24637. /**
  24638. * Renormalize the mesh and patch it up if there are no weights
  24639. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24640. * However in the case of zero weights then we set just a single influence to 1.
  24641. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24642. */
  24643. cleanMatrixWeights(): void;
  24644. private normalizeSkinFourWeights;
  24645. private normalizeSkinWeightsAndExtra;
  24646. /**
  24647. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24648. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24649. * the user know there was an issue with importing the mesh
  24650. * @returns a validation object with skinned, valid and report string
  24651. */
  24652. validateSkinning(): {
  24653. skinned: boolean;
  24654. valid: boolean;
  24655. report: string;
  24656. };
  24657. /** @hidden */
  24658. _checkDelayState(): Mesh;
  24659. private _queueLoad;
  24660. /**
  24661. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24662. * A mesh is in the frustum if its bounding box intersects the frustum
  24663. * @param frustumPlanes defines the frustum to test
  24664. * @returns true if the mesh is in the frustum planes
  24665. */
  24666. isInFrustum(frustumPlanes: Plane[]): boolean;
  24667. /**
  24668. * Sets the mesh material by the material or multiMaterial `id` property
  24669. * @param id is a string identifying the material or the multiMaterial
  24670. * @returns the current mesh
  24671. */
  24672. setMaterialByID(id: string): Mesh;
  24673. /**
  24674. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24675. * @returns an array of IAnimatable
  24676. */
  24677. getAnimatables(): IAnimatable[];
  24678. /**
  24679. * Modifies the mesh geometry according to the passed transformation matrix.
  24680. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24681. * The mesh normals are modified using the same transformation.
  24682. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24683. * @param transform defines the transform matrix to use
  24684. * @see http://doc.babylonjs.com/resources/baking_transformations
  24685. * @returns the current mesh
  24686. */
  24687. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24688. /**
  24689. * Modifies the mesh geometry according to its own current World Matrix.
  24690. * The mesh World Matrix is then reset.
  24691. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24692. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24693. * @see http://doc.babylonjs.com/resources/baking_transformations
  24694. * @returns the current mesh
  24695. */
  24696. bakeCurrentTransformIntoVertices(): Mesh;
  24697. /** @hidden */
  24698. readonly _positions: Nullable<Vector3[]>;
  24699. /** @hidden */
  24700. _resetPointsArrayCache(): Mesh;
  24701. /** @hidden */
  24702. _generatePointsArray(): boolean;
  24703. /**
  24704. * Returns a new Mesh object generated from the current mesh properties.
  24705. * This method must not get confused with createInstance()
  24706. * @param name is a string, the name given to the new mesh
  24707. * @param newParent can be any Node object (default `null`)
  24708. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24709. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24710. * @returns a new mesh
  24711. */
  24712. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24713. /**
  24714. * Releases resources associated with this mesh.
  24715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24717. */
  24718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24719. /**
  24720. * Modifies the mesh geometry according to a displacement map.
  24721. * 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.
  24722. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24723. * @param url is a string, the URL from the image file is to be downloaded.
  24724. * @param minHeight is the lower limit of the displacement.
  24725. * @param maxHeight is the upper limit of the displacement.
  24726. * @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.
  24727. * @param uvOffset is an optional vector2 used to offset UV.
  24728. * @param uvScale is an optional vector2 used to scale UV.
  24729. * @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.
  24730. * @returns the Mesh.
  24731. */
  24732. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24733. /**
  24734. * Modifies the mesh geometry according to a displacementMap buffer.
  24735. * 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.
  24736. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24737. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24738. * @param heightMapWidth is the width of the buffer image.
  24739. * @param heightMapHeight is the height of the buffer image.
  24740. * @param minHeight is the lower limit of the displacement.
  24741. * @param maxHeight is the upper limit of the displacement.
  24742. * @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.
  24743. * @param uvOffset is an optional vector2 used to offset UV.
  24744. * @param uvScale is an optional vector2 used to scale UV.
  24745. * @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.
  24746. * @returns the Mesh.
  24747. */
  24748. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24749. /**
  24750. * Modify the mesh to get a flat shading rendering.
  24751. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24752. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24753. * @returns current mesh
  24754. */
  24755. convertToFlatShadedMesh(): Mesh;
  24756. /**
  24757. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24758. * In other words, more vertices, no more indices and a single bigger VBO.
  24759. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24760. * @returns current mesh
  24761. */
  24762. convertToUnIndexedMesh(): Mesh;
  24763. /**
  24764. * Inverses facet orientations.
  24765. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24766. * @param flipNormals will also inverts the normals
  24767. * @returns current mesh
  24768. */
  24769. flipFaces(flipNormals?: boolean): Mesh;
  24770. /**
  24771. * Increase the number of facets and hence vertices in a mesh
  24772. * Vertex normals are interpolated from existing vertex normals
  24773. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24774. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24775. */
  24776. increaseVertices(numberPerEdge: number): void;
  24777. /**
  24778. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24779. * This will undo any application of covertToFlatShadedMesh
  24780. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24781. */
  24782. forceSharedVertices(): void;
  24783. /** @hidden */
  24784. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24785. /** @hidden */
  24786. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24787. /**
  24788. * Creates a new InstancedMesh object from the mesh model.
  24789. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24790. * @param name defines the name of the new instance
  24791. * @returns a new InstancedMesh
  24792. */
  24793. createInstance(name: string): InstancedMesh;
  24794. /**
  24795. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24796. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24797. * @returns the current mesh
  24798. */
  24799. synchronizeInstances(): Mesh;
  24800. /**
  24801. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24802. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24803. * This should be used together with the simplification to avoid disappearing triangles.
  24804. * @param successCallback an optional success callback to be called after the optimization finished.
  24805. * @returns the current mesh
  24806. */
  24807. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24808. /**
  24809. * Serialize current mesh
  24810. * @param serializationObject defines the object which will receive the serialization data
  24811. */
  24812. serialize(serializationObject: any): void;
  24813. /** @hidden */
  24814. _syncGeometryWithMorphTargetManager(): void;
  24815. /** @hidden */
  24816. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24817. /**
  24818. * Returns a new Mesh object parsed from the source provided.
  24819. * @param parsedMesh is the source
  24820. * @param scene defines the hosting scene
  24821. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24822. * @returns a new Mesh
  24823. */
  24824. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24825. /**
  24826. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24827. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24828. * @param name defines the name of the mesh to create
  24829. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24830. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24831. * @param closePath creates a seam between the first and the last points of each path of the path array
  24832. * @param offset is taken in account only if the `pathArray` is containing a single path
  24833. * @param scene defines the hosting scene
  24834. * @param updatable defines if the mesh must be flagged as updatable
  24835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24836. * @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)
  24837. * @returns a new Mesh
  24838. */
  24839. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24840. /**
  24841. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24842. * @param name defines the name of the mesh to create
  24843. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24844. * @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
  24845. * @param scene defines the hosting scene
  24846. * @param updatable defines if the mesh must be flagged as updatable
  24847. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24848. * @returns a new Mesh
  24849. */
  24850. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24851. /**
  24852. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24853. * @param name defines the name of the mesh to create
  24854. * @param size sets the size (float) of each box side (default 1)
  24855. * @param scene defines the hosting scene
  24856. * @param updatable defines if the mesh must be flagged as updatable
  24857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24858. * @returns a new Mesh
  24859. */
  24860. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24861. /**
  24862. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24863. * @param name defines the name of the mesh to create
  24864. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24865. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24866. * @param scene defines the hosting scene
  24867. * @param updatable defines if the mesh must be flagged as updatable
  24868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24869. * @returns a new Mesh
  24870. */
  24871. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24872. /**
  24873. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24874. * @param name defines the name of the mesh to create
  24875. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24876. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24877. * @param scene defines the hosting scene
  24878. * @returns a new Mesh
  24879. */
  24880. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24881. /**
  24882. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24883. * @param name defines the name of the mesh to create
  24884. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24885. * @param diameterTop set the top cap diameter (floats, default 1)
  24886. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24887. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24888. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24889. * @param scene defines the hosting scene
  24890. * @param updatable defines if the mesh must be flagged as updatable
  24891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24892. * @returns a new Mesh
  24893. */
  24894. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24895. /**
  24896. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24897. * @param name defines the name of the mesh to create
  24898. * @param diameter sets the diameter size (float) of the torus (default 1)
  24899. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24900. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24901. * @param scene defines the hosting scene
  24902. * @param updatable defines if the mesh must be flagged as updatable
  24903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24904. * @returns a new Mesh
  24905. */
  24906. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24907. /**
  24908. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24909. * @param name defines the name of the mesh to create
  24910. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24911. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24912. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24913. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24914. * @param p the number of windings on X axis (positive integers, default 2)
  24915. * @param q the number of windings on Y axis (positive integers, default 3)
  24916. * @param scene defines the hosting scene
  24917. * @param updatable defines if the mesh must be flagged as updatable
  24918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24919. * @returns a new Mesh
  24920. */
  24921. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24922. /**
  24923. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24924. * @param name defines the name of the mesh to create
  24925. * @param points is an array successive Vector3
  24926. * @param scene defines the hosting scene
  24927. * @param updatable defines if the mesh must be flagged as updatable
  24928. * @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).
  24929. * @returns a new Mesh
  24930. */
  24931. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24932. /**
  24933. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24934. * @param name defines the name of the mesh to create
  24935. * @param points is an array successive Vector3
  24936. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24937. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24938. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24939. * @param scene defines the hosting scene
  24940. * @param updatable defines if the mesh must be flagged as updatable
  24941. * @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)
  24942. * @returns a new Mesh
  24943. */
  24944. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24945. /**
  24946. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24947. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24948. * 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.
  24949. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24950. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24951. * Remember you can only change the shape positions, not their number when updating a polygon.
  24952. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24953. * @param name defines the name of the mesh to create
  24954. * @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
  24955. * @param scene defines the hosting scene
  24956. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24957. * @param updatable defines if the mesh must be flagged as updatable
  24958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24959. * @param earcutInjection can be used to inject your own earcut reference
  24960. * @returns a new Mesh
  24961. */
  24962. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24963. /**
  24964. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24965. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24966. * @param name defines the name of the mesh to create
  24967. * @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
  24968. * @param depth defines the height of extrusion
  24969. * @param scene defines the hosting scene
  24970. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24973. * @param earcutInjection can be used to inject your own earcut reference
  24974. * @returns a new Mesh
  24975. */
  24976. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24977. /**
  24978. * Creates an extruded shape mesh.
  24979. * 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
  24980. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24981. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24982. * @param name defines the name of the mesh to create
  24983. * @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
  24984. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24985. * @param scale is the value to scale the shape
  24986. * @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
  24987. * @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
  24988. * @param scene defines the hosting scene
  24989. * @param updatable defines if the mesh must be flagged as updatable
  24990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24991. * @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)
  24992. * @returns a new Mesh
  24993. */
  24994. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24995. /**
  24996. * Creates an custom extruded shape mesh.
  24997. * The custom extrusion is a parametric shape.
  24998. * It has no predefined shape. Its final shape will depend on the input parameters.
  24999. * Please consider using the same method from the MeshBuilder class instead
  25000. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25001. * @param name defines the name of the mesh to create
  25002. * @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
  25003. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25004. * @param scaleFunction is a custom Javascript function called on each path point
  25005. * @param rotationFunction is a custom Javascript function called on each path point
  25006. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25007. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25008. * @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
  25009. * @param scene defines the hosting scene
  25010. * @param updatable defines if the mesh must be flagged as updatable
  25011. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25012. * @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)
  25013. * @returns a new Mesh
  25014. */
  25015. 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;
  25016. /**
  25017. * Creates lathe mesh.
  25018. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25019. * Please consider using the same method from the MeshBuilder class instead
  25020. * @param name defines the name of the mesh to create
  25021. * @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
  25022. * @param radius is the radius value of the lathe
  25023. * @param tessellation is the side number of the lathe.
  25024. * @param scene defines the hosting scene
  25025. * @param updatable defines if the mesh must be flagged as updatable
  25026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25027. * @returns a new Mesh
  25028. */
  25029. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25030. /**
  25031. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25032. * @param name defines the name of the mesh to create
  25033. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25034. * @param scene defines the hosting scene
  25035. * @param updatable defines if the mesh must be flagged as updatable
  25036. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25037. * @returns a new Mesh
  25038. */
  25039. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25040. /**
  25041. * Creates a ground mesh.
  25042. * Please consider using the same method from the MeshBuilder class instead
  25043. * @param name defines the name of the mesh to create
  25044. * @param width set the width of the ground
  25045. * @param height set the height of the ground
  25046. * @param subdivisions sets the number of subdivisions per side
  25047. * @param scene defines the hosting scene
  25048. * @param updatable defines if the mesh must be flagged as updatable
  25049. * @returns a new Mesh
  25050. */
  25051. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25052. /**
  25053. * Creates a tiled ground mesh.
  25054. * Please consider using the same method from the MeshBuilder class instead
  25055. * @param name defines the name of the mesh to create
  25056. * @param xmin set the ground minimum X coordinate
  25057. * @param zmin set the ground minimum Y coordinate
  25058. * @param xmax set the ground maximum X coordinate
  25059. * @param zmax set the ground maximum Z coordinate
  25060. * @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
  25061. * @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
  25062. * @param scene defines the hosting scene
  25063. * @param updatable defines if the mesh must be flagged as updatable
  25064. * @returns a new Mesh
  25065. */
  25066. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25067. w: number;
  25068. h: number;
  25069. }, precision: {
  25070. w: number;
  25071. h: number;
  25072. }, scene: Scene, updatable?: boolean): Mesh;
  25073. /**
  25074. * Creates a ground mesh from a height map.
  25075. * Please consider using the same method from the MeshBuilder class instead
  25076. * @see http://doc.babylonjs.com/babylon101/height_map
  25077. * @param name defines the name of the mesh to create
  25078. * @param url sets the URL of the height map image resource
  25079. * @param width set the ground width size
  25080. * @param height set the ground height size
  25081. * @param subdivisions sets the number of subdivision per side
  25082. * @param minHeight is the minimum altitude on the ground
  25083. * @param maxHeight is the maximum altitude on the ground
  25084. * @param scene defines the hosting scene
  25085. * @param updatable defines if the mesh must be flagged as updatable
  25086. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25087. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25088. * @returns a new Mesh
  25089. */
  25090. 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;
  25091. /**
  25092. * Creates a tube mesh.
  25093. * The tube is a parametric shape.
  25094. * It has no predefined shape. Its final shape will depend on the input parameters.
  25095. * Please consider using the same method from the MeshBuilder class instead
  25096. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25097. * @param name defines the name of the mesh to create
  25098. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25099. * @param radius sets the tube radius size
  25100. * @param tessellation is the number of sides on the tubular surface
  25101. * @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
  25102. * @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
  25103. * @param scene defines the hosting scene
  25104. * @param updatable defines if the mesh must be flagged as updatable
  25105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25106. * @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)
  25107. * @returns a new Mesh
  25108. */
  25109. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25110. (i: number, distance: number): number;
  25111. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25112. /**
  25113. * Creates a polyhedron mesh.
  25114. * Please consider using the same method from the MeshBuilder class instead.
  25115. * * 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
  25116. * * The parameter `size` (positive float, default 1) sets the polygon size
  25117. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25118. * * 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`
  25119. * * 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
  25120. * * 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)`)
  25121. * * 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
  25122. * * 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
  25123. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25124. * * If you create a double-sided mesh, you can choose what parts of 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
  25125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25126. * @param name defines the name of the mesh to create
  25127. * @param options defines the options used to create the mesh
  25128. * @param scene defines the hosting scene
  25129. * @returns a new Mesh
  25130. */
  25131. static CreatePolyhedron(name: string, options: {
  25132. type?: number;
  25133. size?: number;
  25134. sizeX?: number;
  25135. sizeY?: number;
  25136. sizeZ?: number;
  25137. custom?: any;
  25138. faceUV?: Vector4[];
  25139. faceColors?: Color4[];
  25140. updatable?: boolean;
  25141. sideOrientation?: number;
  25142. }, scene: Scene): Mesh;
  25143. /**
  25144. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25145. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25146. * * 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`)
  25147. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25148. * * 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
  25149. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25150. * * If you create a double-sided mesh, you can choose what parts of 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
  25151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25152. * @param name defines the name of the mesh
  25153. * @param options defines the options used to create the mesh
  25154. * @param scene defines the hosting scene
  25155. * @returns a new Mesh
  25156. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25157. */
  25158. static CreateIcoSphere(name: string, options: {
  25159. radius?: number;
  25160. flat?: boolean;
  25161. subdivisions?: number;
  25162. sideOrientation?: number;
  25163. updatable?: boolean;
  25164. }, scene: Scene): Mesh;
  25165. /**
  25166. * Creates a decal mesh.
  25167. * Please consider using the same method from the MeshBuilder class instead.
  25168. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25169. * @param name defines the name of the mesh
  25170. * @param sourceMesh defines the mesh receiving the decal
  25171. * @param position sets the position of the decal in world coordinates
  25172. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25173. * @param size sets the decal scaling
  25174. * @param angle sets the angle to rotate the decal
  25175. * @returns a new Mesh
  25176. */
  25177. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25178. /**
  25179. * Prepare internal position array for software CPU skinning
  25180. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25181. */
  25182. setPositionsForCPUSkinning(): Float32Array;
  25183. /**
  25184. * Prepare internal normal array for software CPU skinning
  25185. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25186. */
  25187. setNormalsForCPUSkinning(): Float32Array;
  25188. /**
  25189. * Updates the vertex buffer by applying transformation from the bones
  25190. * @param skeleton defines the skeleton to apply to current mesh
  25191. * @returns the current mesh
  25192. */
  25193. applySkeleton(skeleton: Skeleton): Mesh;
  25194. /**
  25195. * 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
  25196. * @param meshes defines the list of meshes to scan
  25197. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25198. */
  25199. static MinMax(meshes: AbstractMesh[]): {
  25200. min: Vector3;
  25201. max: Vector3;
  25202. };
  25203. /**
  25204. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25205. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25206. * @returns a vector3
  25207. */
  25208. static Center(meshesOrMinMaxVector: {
  25209. min: Vector3;
  25210. max: Vector3;
  25211. } | AbstractMesh[]): Vector3;
  25212. /**
  25213. * Merge the array of meshes into a single mesh for performance reasons.
  25214. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25215. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25216. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25217. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25218. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25219. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25220. * @returns a new mesh
  25221. */
  25222. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25223. /** @hidden */
  25224. addInstance(instance: InstancedMesh): void;
  25225. /** @hidden */
  25226. removeInstance(instance: InstancedMesh): void;
  25227. }
  25228. }
  25229. declare module "babylonjs/Cameras/camera" {
  25230. import { SmartArray } from "babylonjs/Misc/smartArray";
  25231. import { Observable } from "babylonjs/Misc/observable";
  25232. import { Nullable } from "babylonjs/types";
  25233. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25234. import { Scene } from "babylonjs/scene";
  25235. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25236. import { Node } from "babylonjs/node";
  25237. import { Mesh } from "babylonjs/Meshes/mesh";
  25238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25239. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25240. import { Viewport } from "babylonjs/Maths/math.viewport";
  25241. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25243. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25244. import { Ray } from "babylonjs/Culling/ray";
  25245. /**
  25246. * This is the base class of all the camera used in the application.
  25247. * @see http://doc.babylonjs.com/features/cameras
  25248. */
  25249. export class Camera extends Node {
  25250. /** @hidden */
  25251. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25252. /**
  25253. * This is the default projection mode used by the cameras.
  25254. * It helps recreating a feeling of perspective and better appreciate depth.
  25255. * This is the best way to simulate real life cameras.
  25256. */
  25257. static readonly PERSPECTIVE_CAMERA: number;
  25258. /**
  25259. * This helps creating camera with an orthographic mode.
  25260. * 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.
  25261. */
  25262. static readonly ORTHOGRAPHIC_CAMERA: number;
  25263. /**
  25264. * This is the default FOV mode for perspective cameras.
  25265. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25266. */
  25267. static readonly FOVMODE_VERTICAL_FIXED: number;
  25268. /**
  25269. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25270. */
  25271. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25272. /**
  25273. * This specifies ther is no need for a camera rig.
  25274. * Basically only one eye is rendered corresponding to the camera.
  25275. */
  25276. static readonly RIG_MODE_NONE: number;
  25277. /**
  25278. * Simulates a camera Rig with one blue eye and one red eye.
  25279. * This can be use with 3d blue and red glasses.
  25280. */
  25281. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25282. /**
  25283. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25284. */
  25285. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25286. /**
  25287. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25288. */
  25289. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25290. /**
  25291. * Defines that both eyes of the camera will be rendered over under each other.
  25292. */
  25293. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25294. /**
  25295. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25296. */
  25297. static readonly RIG_MODE_VR: number;
  25298. /**
  25299. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25300. */
  25301. static readonly RIG_MODE_WEBVR: number;
  25302. /**
  25303. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25304. */
  25305. static readonly RIG_MODE_CUSTOM: number;
  25306. /**
  25307. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25308. */
  25309. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25310. /**
  25311. * Define the input manager associated with the camera.
  25312. */
  25313. inputs: CameraInputsManager<Camera>;
  25314. /** @hidden */
  25315. _position: Vector3;
  25316. /**
  25317. * Define the current local position of the camera in the scene
  25318. */
  25319. position: Vector3;
  25320. /**
  25321. * The vector the camera should consider as up.
  25322. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25323. */
  25324. upVector: Vector3;
  25325. /**
  25326. * Define the current limit on the left side for an orthographic camera
  25327. * In scene unit
  25328. */
  25329. orthoLeft: Nullable<number>;
  25330. /**
  25331. * Define the current limit on the right side for an orthographic camera
  25332. * In scene unit
  25333. */
  25334. orthoRight: Nullable<number>;
  25335. /**
  25336. * Define the current limit on the bottom side for an orthographic camera
  25337. * In scene unit
  25338. */
  25339. orthoBottom: Nullable<number>;
  25340. /**
  25341. * Define the current limit on the top side for an orthographic camera
  25342. * In scene unit
  25343. */
  25344. orthoTop: Nullable<number>;
  25345. /**
  25346. * Field Of View is set in Radians. (default is 0.8)
  25347. */
  25348. fov: number;
  25349. /**
  25350. * Define the minimum distance the camera can see from.
  25351. * This is important to note that the depth buffer are not infinite and the closer it starts
  25352. * the more your scene might encounter depth fighting issue.
  25353. */
  25354. minZ: number;
  25355. /**
  25356. * Define the maximum distance the camera can see to.
  25357. * This is important to note that the depth buffer are not infinite and the further it end
  25358. * the more your scene might encounter depth fighting issue.
  25359. */
  25360. maxZ: number;
  25361. /**
  25362. * Define the default inertia of the camera.
  25363. * This helps giving a smooth feeling to the camera movement.
  25364. */
  25365. inertia: number;
  25366. /**
  25367. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25368. */
  25369. mode: number;
  25370. /**
  25371. * Define wether the camera is intermediate.
  25372. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25373. */
  25374. isIntermediate: boolean;
  25375. /**
  25376. * Define the viewport of the camera.
  25377. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25378. */
  25379. viewport: Viewport;
  25380. /**
  25381. * Restricts the camera to viewing objects with the same layerMask.
  25382. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25383. */
  25384. layerMask: number;
  25385. /**
  25386. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25387. */
  25388. fovMode: number;
  25389. /**
  25390. * Rig mode of the camera.
  25391. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25392. * This is normally controlled byt the camera themselves as internal use.
  25393. */
  25394. cameraRigMode: number;
  25395. /**
  25396. * Defines the distance between both "eyes" in case of a RIG
  25397. */
  25398. interaxialDistance: number;
  25399. /**
  25400. * Defines if stereoscopic rendering is done side by side or over under.
  25401. */
  25402. isStereoscopicSideBySide: boolean;
  25403. /**
  25404. * 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
  25405. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25406. * else in the scene. (Eg. security camera)
  25407. *
  25408. * 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)
  25409. */
  25410. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25411. /**
  25412. * When set, the camera will render to this render target instead of the default canvas
  25413. *
  25414. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25415. */
  25416. outputRenderTarget: Nullable<RenderTargetTexture>;
  25417. /**
  25418. * Observable triggered when the camera view matrix has changed.
  25419. */
  25420. onViewMatrixChangedObservable: Observable<Camera>;
  25421. /**
  25422. * Observable triggered when the camera Projection matrix has changed.
  25423. */
  25424. onProjectionMatrixChangedObservable: Observable<Camera>;
  25425. /**
  25426. * Observable triggered when the inputs have been processed.
  25427. */
  25428. onAfterCheckInputsObservable: Observable<Camera>;
  25429. /**
  25430. * Observable triggered when reset has been called and applied to the camera.
  25431. */
  25432. onRestoreStateObservable: Observable<Camera>;
  25433. /** @hidden */
  25434. _cameraRigParams: any;
  25435. /** @hidden */
  25436. _rigCameras: Camera[];
  25437. /** @hidden */
  25438. _rigPostProcess: Nullable<PostProcess>;
  25439. protected _webvrViewMatrix: Matrix;
  25440. /** @hidden */
  25441. _skipRendering: boolean;
  25442. /** @hidden */
  25443. _projectionMatrix: Matrix;
  25444. /** @hidden */
  25445. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25446. /** @hidden */
  25447. _activeMeshes: SmartArray<AbstractMesh>;
  25448. protected _globalPosition: Vector3;
  25449. /** @hidden */
  25450. _computedViewMatrix: Matrix;
  25451. private _doNotComputeProjectionMatrix;
  25452. private _transformMatrix;
  25453. private _frustumPlanes;
  25454. private _refreshFrustumPlanes;
  25455. private _storedFov;
  25456. private _stateStored;
  25457. /**
  25458. * Instantiates a new camera object.
  25459. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25460. * @see http://doc.babylonjs.com/features/cameras
  25461. * @param name Defines the name of the camera in the scene
  25462. * @param position Defines the position of the camera
  25463. * @param scene Defines the scene the camera belongs too
  25464. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25465. */
  25466. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25467. /**
  25468. * Store current camera state (fov, position, etc..)
  25469. * @returns the camera
  25470. */
  25471. storeState(): Camera;
  25472. /**
  25473. * Restores the camera state values if it has been stored. You must call storeState() first
  25474. */
  25475. protected _restoreStateValues(): boolean;
  25476. /**
  25477. * Restored camera state. You must call storeState() first.
  25478. * @returns true if restored and false otherwise
  25479. */
  25480. restoreState(): boolean;
  25481. /**
  25482. * Gets the class name of the camera.
  25483. * @returns the class name
  25484. */
  25485. getClassName(): string;
  25486. /** @hidden */
  25487. readonly _isCamera: boolean;
  25488. /**
  25489. * Gets a string representation of the camera useful for debug purpose.
  25490. * @param fullDetails Defines that a more verboe level of logging is required
  25491. * @returns the string representation
  25492. */
  25493. toString(fullDetails?: boolean): string;
  25494. /**
  25495. * Gets the current world space position of the camera.
  25496. */
  25497. readonly globalPosition: Vector3;
  25498. /**
  25499. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25500. * @returns the active meshe list
  25501. */
  25502. getActiveMeshes(): SmartArray<AbstractMesh>;
  25503. /**
  25504. * Check wether a mesh is part of the current active mesh list of the camera
  25505. * @param mesh Defines the mesh to check
  25506. * @returns true if active, false otherwise
  25507. */
  25508. isActiveMesh(mesh: Mesh): boolean;
  25509. /**
  25510. * Is this camera ready to be used/rendered
  25511. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25512. * @return true if the camera is ready
  25513. */
  25514. isReady(completeCheck?: boolean): boolean;
  25515. /** @hidden */
  25516. _initCache(): void;
  25517. /** @hidden */
  25518. _updateCache(ignoreParentClass?: boolean): void;
  25519. /** @hidden */
  25520. _isSynchronized(): boolean;
  25521. /** @hidden */
  25522. _isSynchronizedViewMatrix(): boolean;
  25523. /** @hidden */
  25524. _isSynchronizedProjectionMatrix(): boolean;
  25525. /**
  25526. * Attach the input controls to a specific dom element to get the input from.
  25527. * @param element Defines the element the controls should be listened from
  25528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25529. */
  25530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25531. /**
  25532. * Detach the current controls from the specified dom element.
  25533. * @param element Defines the element to stop listening the inputs from
  25534. */
  25535. detachControl(element: HTMLElement): void;
  25536. /**
  25537. * Update the camera state according to the different inputs gathered during the frame.
  25538. */
  25539. update(): void;
  25540. /** @hidden */
  25541. _checkInputs(): void;
  25542. /** @hidden */
  25543. readonly rigCameras: Camera[];
  25544. /**
  25545. * Gets the post process used by the rig cameras
  25546. */
  25547. readonly rigPostProcess: Nullable<PostProcess>;
  25548. /**
  25549. * Internal, gets the first post proces.
  25550. * @returns the first post process to be run on this camera.
  25551. */
  25552. _getFirstPostProcess(): Nullable<PostProcess>;
  25553. private _cascadePostProcessesToRigCams;
  25554. /**
  25555. * Attach a post process to the camera.
  25556. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25557. * @param postProcess The post process to attach to the camera
  25558. * @param insertAt The position of the post process in case several of them are in use in the scene
  25559. * @returns the position the post process has been inserted at
  25560. */
  25561. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25562. /**
  25563. * Detach a post process to the camera.
  25564. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25565. * @param postProcess The post process to detach from the camera
  25566. */
  25567. detachPostProcess(postProcess: PostProcess): void;
  25568. /**
  25569. * Gets the current world matrix of the camera
  25570. */
  25571. getWorldMatrix(): Matrix;
  25572. /** @hidden */
  25573. _getViewMatrix(): Matrix;
  25574. /**
  25575. * Gets the current view matrix of the camera.
  25576. * @param force forces the camera to recompute the matrix without looking at the cached state
  25577. * @returns the view matrix
  25578. */
  25579. getViewMatrix(force?: boolean): Matrix;
  25580. /**
  25581. * Freeze the projection matrix.
  25582. * It will prevent the cache check of the camera projection compute and can speed up perf
  25583. * if no parameter of the camera are meant to change
  25584. * @param projection Defines manually a projection if necessary
  25585. */
  25586. freezeProjectionMatrix(projection?: Matrix): void;
  25587. /**
  25588. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25589. */
  25590. unfreezeProjectionMatrix(): void;
  25591. /**
  25592. * Gets the current projection matrix of the camera.
  25593. * @param force forces the camera to recompute the matrix without looking at the cached state
  25594. * @returns the projection matrix
  25595. */
  25596. getProjectionMatrix(force?: boolean): Matrix;
  25597. /**
  25598. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25599. * @returns a Matrix
  25600. */
  25601. getTransformationMatrix(): Matrix;
  25602. private _updateFrustumPlanes;
  25603. /**
  25604. * Checks if a cullable object (mesh...) is in the camera frustum
  25605. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25606. * @param target The object to check
  25607. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25608. * @returns true if the object is in frustum otherwise false
  25609. */
  25610. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25611. /**
  25612. * Checks if a cullable object (mesh...) is in the camera frustum
  25613. * Unlike isInFrustum this cheks the full bounding box
  25614. * @param target The object to check
  25615. * @returns true if the object is in frustum otherwise false
  25616. */
  25617. isCompletelyInFrustum(target: ICullable): boolean;
  25618. /**
  25619. * Gets a ray in the forward direction from the camera.
  25620. * @param length Defines the length of the ray to create
  25621. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25622. * @param origin Defines the start point of the ray which defaults to the camera position
  25623. * @returns the forward ray
  25624. */
  25625. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25626. /**
  25627. * Releases resources associated with this node.
  25628. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25629. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25630. */
  25631. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25632. /** @hidden */
  25633. _isLeftCamera: boolean;
  25634. /**
  25635. * Gets the left camera of a rig setup in case of Rigged Camera
  25636. */
  25637. readonly isLeftCamera: boolean;
  25638. /** @hidden */
  25639. _isRightCamera: boolean;
  25640. /**
  25641. * Gets the right camera of a rig setup in case of Rigged Camera
  25642. */
  25643. readonly isRightCamera: boolean;
  25644. /**
  25645. * Gets the left camera of a rig setup in case of Rigged Camera
  25646. */
  25647. readonly leftCamera: Nullable<FreeCamera>;
  25648. /**
  25649. * Gets the right camera of a rig setup in case of Rigged Camera
  25650. */
  25651. readonly rightCamera: Nullable<FreeCamera>;
  25652. /**
  25653. * Gets the left camera target of a rig setup in case of Rigged Camera
  25654. * @returns the target position
  25655. */
  25656. getLeftTarget(): Nullable<Vector3>;
  25657. /**
  25658. * Gets the right camera target of a rig setup in case of Rigged Camera
  25659. * @returns the target position
  25660. */
  25661. getRightTarget(): Nullable<Vector3>;
  25662. /**
  25663. * @hidden
  25664. */
  25665. setCameraRigMode(mode: number, rigParams: any): void;
  25666. /** @hidden */
  25667. static _setStereoscopicRigMode(camera: Camera): void;
  25668. /** @hidden */
  25669. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25670. /** @hidden */
  25671. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25672. /** @hidden */
  25673. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25674. /** @hidden */
  25675. _getVRProjectionMatrix(): Matrix;
  25676. protected _updateCameraRotationMatrix(): void;
  25677. protected _updateWebVRCameraRotationMatrix(): void;
  25678. /**
  25679. * This function MUST be overwritten by the different WebVR cameras available.
  25680. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25681. * @hidden
  25682. */
  25683. _getWebVRProjectionMatrix(): Matrix;
  25684. /**
  25685. * This function MUST be overwritten by the different WebVR cameras available.
  25686. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25687. * @hidden
  25688. */
  25689. _getWebVRViewMatrix(): Matrix;
  25690. /** @hidden */
  25691. setCameraRigParameter(name: string, value: any): void;
  25692. /**
  25693. * needs to be overridden by children so sub has required properties to be copied
  25694. * @hidden
  25695. */
  25696. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25697. /**
  25698. * May need to be overridden by children
  25699. * @hidden
  25700. */
  25701. _updateRigCameras(): void;
  25702. /** @hidden */
  25703. _setupInputs(): void;
  25704. /**
  25705. * Serialiaze the camera setup to a json represention
  25706. * @returns the JSON representation
  25707. */
  25708. serialize(): any;
  25709. /**
  25710. * Clones the current camera.
  25711. * @param name The cloned camera name
  25712. * @returns the cloned camera
  25713. */
  25714. clone(name: string): Camera;
  25715. /**
  25716. * Gets the direction of the camera relative to a given local axis.
  25717. * @param localAxis Defines the reference axis to provide a relative direction.
  25718. * @return the direction
  25719. */
  25720. getDirection(localAxis: Vector3): Vector3;
  25721. /**
  25722. * Returns the current camera absolute rotation
  25723. */
  25724. readonly absoluteRotation: Quaternion;
  25725. /**
  25726. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25727. * @param localAxis Defines the reference axis to provide a relative direction.
  25728. * @param result Defines the vector to store the result in
  25729. */
  25730. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25731. /**
  25732. * Gets a camera constructor for a given camera type
  25733. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25734. * @param name The name of the camera the result will be able to instantiate
  25735. * @param scene The scene the result will construct the camera in
  25736. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25737. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25738. * @returns a factory method to construc the camera
  25739. */
  25740. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25741. /**
  25742. * Compute the world matrix of the camera.
  25743. * @returns the camera workd matrix
  25744. */
  25745. computeWorldMatrix(): Matrix;
  25746. /**
  25747. * Parse a JSON and creates the camera from the parsed information
  25748. * @param parsedCamera The JSON to parse
  25749. * @param scene The scene to instantiate the camera in
  25750. * @returns the newly constructed camera
  25751. */
  25752. static Parse(parsedCamera: any, scene: Scene): Camera;
  25753. }
  25754. }
  25755. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25756. import { Nullable } from "babylonjs/types";
  25757. import { Scene } from "babylonjs/scene";
  25758. import { Vector4 } from "babylonjs/Maths/math.vector";
  25759. import { Mesh } from "babylonjs/Meshes/mesh";
  25760. /**
  25761. * Class containing static functions to help procedurally build meshes
  25762. */
  25763. export class DiscBuilder {
  25764. /**
  25765. * Creates a plane polygonal mesh. By default, this is a disc
  25766. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25767. * * 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
  25768. * * 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
  25769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25772. * @param name defines the name of the mesh
  25773. * @param options defines the options used to create the mesh
  25774. * @param scene defines the hosting scene
  25775. * @returns the plane polygonal mesh
  25776. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25777. */
  25778. static CreateDisc(name: string, options: {
  25779. radius?: number;
  25780. tessellation?: number;
  25781. arc?: number;
  25782. updatable?: boolean;
  25783. sideOrientation?: number;
  25784. frontUVs?: Vector4;
  25785. backUVs?: Vector4;
  25786. }, scene?: Nullable<Scene>): Mesh;
  25787. }
  25788. }
  25789. declare module "babylonjs/Particles/solidParticleSystem" {
  25790. import { Vector3 } from "babylonjs/Maths/math.vector";
  25791. import { Mesh } from "babylonjs/Meshes/mesh";
  25792. import { Scene, IDisposable } from "babylonjs/scene";
  25793. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25794. /**
  25795. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25796. *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.
  25797. * The SPS is also a particle system. It provides some methods to manage the particles.
  25798. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25799. *
  25800. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25801. */
  25802. export class SolidParticleSystem implements IDisposable {
  25803. /**
  25804. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25805. * Example : var p = SPS.particles[i];
  25806. */
  25807. particles: SolidParticle[];
  25808. /**
  25809. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25810. */
  25811. nbParticles: number;
  25812. /**
  25813. * If the particles must ever face the camera (default false). Useful for planar particles.
  25814. */
  25815. billboard: boolean;
  25816. /**
  25817. * Recompute normals when adding a shape
  25818. */
  25819. recomputeNormals: boolean;
  25820. /**
  25821. * This a counter ofr your own usage. It's not set by any SPS functions.
  25822. */
  25823. counter: number;
  25824. /**
  25825. * The SPS name. This name is also given to the underlying mesh.
  25826. */
  25827. name: string;
  25828. /**
  25829. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25830. */
  25831. mesh: Mesh;
  25832. /**
  25833. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25834. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25835. */
  25836. vars: any;
  25837. /**
  25838. * This array is populated when the SPS is set as 'pickable'.
  25839. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25840. * Each element of this array is an object `{idx: int, faceId: int}`.
  25841. * `idx` is the picked particle index in the `SPS.particles` array
  25842. * `faceId` is the picked face index counted within this particle.
  25843. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25844. */
  25845. pickedParticles: {
  25846. idx: number;
  25847. faceId: number;
  25848. }[];
  25849. /**
  25850. * This array is populated when `enableDepthSort` is set to true.
  25851. * Each element of this array is an instance of the class DepthSortedParticle.
  25852. */
  25853. depthSortedParticles: DepthSortedParticle[];
  25854. /**
  25855. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25856. * @hidden
  25857. */
  25858. _bSphereOnly: boolean;
  25859. /**
  25860. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25861. * @hidden
  25862. */
  25863. _bSphereRadiusFactor: number;
  25864. private _scene;
  25865. private _positions;
  25866. private _indices;
  25867. private _normals;
  25868. private _colors;
  25869. private _uvs;
  25870. private _indices32;
  25871. private _positions32;
  25872. private _normals32;
  25873. private _fixedNormal32;
  25874. private _colors32;
  25875. private _uvs32;
  25876. private _index;
  25877. private _updatable;
  25878. private _pickable;
  25879. private _isVisibilityBoxLocked;
  25880. private _alwaysVisible;
  25881. private _depthSort;
  25882. private _shapeCounter;
  25883. private _copy;
  25884. private _color;
  25885. private _computeParticleColor;
  25886. private _computeParticleTexture;
  25887. private _computeParticleRotation;
  25888. private _computeParticleVertex;
  25889. private _computeBoundingBox;
  25890. private _depthSortParticles;
  25891. private _camera;
  25892. private _mustUnrotateFixedNormals;
  25893. private _particlesIntersect;
  25894. private _needs32Bits;
  25895. /**
  25896. * Creates a SPS (Solid Particle System) object.
  25897. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25898. * @param scene (Scene) is the scene in which the SPS is added.
  25899. * @param options defines the options of the sps e.g.
  25900. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25901. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25902. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25903. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25904. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25905. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25906. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25907. */
  25908. constructor(name: string, scene: Scene, options?: {
  25909. updatable?: boolean;
  25910. isPickable?: boolean;
  25911. enableDepthSort?: boolean;
  25912. particleIntersection?: boolean;
  25913. boundingSphereOnly?: boolean;
  25914. bSphereRadiusFactor?: number;
  25915. });
  25916. /**
  25917. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25918. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25919. * @returns the created mesh
  25920. */
  25921. buildMesh(): Mesh;
  25922. /**
  25923. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25924. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25925. * Thus the particles generated from `digest()` have their property `position` set yet.
  25926. * @param mesh ( Mesh ) is the mesh to be digested
  25927. * @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
  25928. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25929. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25930. * @returns the current SPS
  25931. */
  25932. digest(mesh: Mesh, options?: {
  25933. facetNb?: number;
  25934. number?: number;
  25935. delta?: number;
  25936. }): SolidParticleSystem;
  25937. private _unrotateFixedNormals;
  25938. private _resetCopy;
  25939. private _meshBuilder;
  25940. private _posToShape;
  25941. private _uvsToShapeUV;
  25942. private _addParticle;
  25943. /**
  25944. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25945. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25946. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25947. * @param nb (positive integer) the number of particles to be created from this model
  25948. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25949. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25950. * @returns the number of shapes in the system
  25951. */
  25952. addShape(mesh: Mesh, nb: number, options?: {
  25953. positionFunction?: any;
  25954. vertexFunction?: any;
  25955. }): number;
  25956. private _rebuildParticle;
  25957. /**
  25958. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25959. * @returns the SPS.
  25960. */
  25961. rebuildMesh(): SolidParticleSystem;
  25962. /**
  25963. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25964. * This method calls `updateParticle()` for each particle of the SPS.
  25965. * For an animated SPS, it is usually called within the render loop.
  25966. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25967. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25968. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25969. * @returns the SPS.
  25970. */
  25971. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25972. /**
  25973. * Disposes the SPS.
  25974. */
  25975. dispose(): void;
  25976. /**
  25977. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25978. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25979. * @returns the SPS.
  25980. */
  25981. refreshVisibleSize(): SolidParticleSystem;
  25982. /**
  25983. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25984. * @param size the size (float) of the visibility box
  25985. * note : this doesn't lock the SPS mesh bounding box.
  25986. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25987. */
  25988. setVisibilityBox(size: number): void;
  25989. /**
  25990. * Gets whether the SPS as always visible or not
  25991. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25992. */
  25993. /**
  25994. * Sets the SPS as always visible or not
  25995. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25996. */
  25997. isAlwaysVisible: boolean;
  25998. /**
  25999. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26000. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26001. */
  26002. /**
  26003. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26004. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26005. */
  26006. isVisibilityBoxLocked: boolean;
  26007. /**
  26008. * Tells to `setParticles()` to compute the particle rotations or not.
  26009. * Default value : true. The SPS is faster when it's set to false.
  26010. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26011. */
  26012. /**
  26013. * Gets if `setParticles()` computes the particle rotations or not.
  26014. * Default value : true. The SPS is faster when it's set to false.
  26015. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26016. */
  26017. computeParticleRotation: boolean;
  26018. /**
  26019. * Tells to `setParticles()` to compute the particle colors or not.
  26020. * Default value : true. The SPS is faster when it's set to false.
  26021. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26022. */
  26023. /**
  26024. * Gets if `setParticles()` computes the particle colors or not.
  26025. * Default value : true. The SPS is faster when it's set to false.
  26026. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26027. */
  26028. computeParticleColor: boolean;
  26029. /**
  26030. * Gets if `setParticles()` computes the particle textures or not.
  26031. * Default value : true. The SPS is faster when it's set to false.
  26032. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26033. */
  26034. computeParticleTexture: boolean;
  26035. /**
  26036. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26037. * Default value : false. The SPS is faster when it's set to false.
  26038. * Note : the particle custom vertex positions aren't stored values.
  26039. */
  26040. /**
  26041. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26042. * Default value : false. The SPS is faster when it's set to false.
  26043. * Note : the particle custom vertex positions aren't stored values.
  26044. */
  26045. computeParticleVertex: boolean;
  26046. /**
  26047. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26048. */
  26049. /**
  26050. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26051. */
  26052. computeBoundingBox: boolean;
  26053. /**
  26054. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26055. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26056. * Default : `true`
  26057. */
  26058. /**
  26059. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26060. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26061. * Default : `true`
  26062. */
  26063. depthSortParticles: boolean;
  26064. /**
  26065. * This function does nothing. It may be overwritten to set all the particle first values.
  26066. * The SPS doesn't call this function, you may have to call it by your own.
  26067. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26068. */
  26069. initParticles(): void;
  26070. /**
  26071. * This function does nothing. It may be overwritten to recycle a particle.
  26072. * The SPS doesn't call this function, you may have to call it by your own.
  26073. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26074. * @param particle The particle to recycle
  26075. * @returns the recycled particle
  26076. */
  26077. recycleParticle(particle: SolidParticle): SolidParticle;
  26078. /**
  26079. * Updates a particle : this function should be overwritten by the user.
  26080. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26082. * @example : just set a particle position or velocity and recycle conditions
  26083. * @param particle The particle to update
  26084. * @returns the updated particle
  26085. */
  26086. updateParticle(particle: SolidParticle): SolidParticle;
  26087. /**
  26088. * Updates a vertex of a particle : it can be overwritten by the user.
  26089. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26090. * @param particle the current particle
  26091. * @param vertex the current index of the current particle
  26092. * @param pt the index of the current vertex in the particle shape
  26093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26094. * @example : just set a vertex particle position
  26095. * @returns the updated vertex
  26096. */
  26097. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26098. /**
  26099. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26100. * This does nothing and may be overwritten by the user.
  26101. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26102. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26103. * @param update the boolean update value actually passed to setParticles()
  26104. */
  26105. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26106. /**
  26107. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26108. * This will be passed three parameters.
  26109. * This does nothing and may be overwritten by the user.
  26110. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26111. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26112. * @param update the boolean update value actually passed to setParticles()
  26113. */
  26114. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26115. }
  26116. }
  26117. declare module "babylonjs/Particles/solidParticle" {
  26118. import { Nullable } from "babylonjs/types";
  26119. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26120. import { Color4 } from "babylonjs/Maths/math.color";
  26121. import { Mesh } from "babylonjs/Meshes/mesh";
  26122. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26123. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26124. import { Plane } from "babylonjs/Maths/math.plane";
  26125. /**
  26126. * Represents one particle of a solid particle system.
  26127. */
  26128. export class SolidParticle {
  26129. /**
  26130. * particle global index
  26131. */
  26132. idx: number;
  26133. /**
  26134. * The color of the particle
  26135. */
  26136. color: Nullable<Color4>;
  26137. /**
  26138. * The world space position of the particle.
  26139. */
  26140. position: Vector3;
  26141. /**
  26142. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26143. */
  26144. rotation: Vector3;
  26145. /**
  26146. * The world space rotation quaternion of the particle.
  26147. */
  26148. rotationQuaternion: Nullable<Quaternion>;
  26149. /**
  26150. * The scaling of the particle.
  26151. */
  26152. scaling: Vector3;
  26153. /**
  26154. * The uvs of the particle.
  26155. */
  26156. uvs: Vector4;
  26157. /**
  26158. * The current speed of the particle.
  26159. */
  26160. velocity: Vector3;
  26161. /**
  26162. * The pivot point in the particle local space.
  26163. */
  26164. pivot: Vector3;
  26165. /**
  26166. * Must the particle be translated from its pivot point in its local space ?
  26167. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26168. * Default : false
  26169. */
  26170. translateFromPivot: boolean;
  26171. /**
  26172. * Is the particle active or not ?
  26173. */
  26174. alive: boolean;
  26175. /**
  26176. * Is the particle visible or not ?
  26177. */
  26178. isVisible: boolean;
  26179. /**
  26180. * Index of this particle in the global "positions" array (Internal use)
  26181. * @hidden
  26182. */
  26183. _pos: number;
  26184. /**
  26185. * @hidden Index of this particle in the global "indices" array (Internal use)
  26186. */
  26187. _ind: number;
  26188. /**
  26189. * @hidden ModelShape of this particle (Internal use)
  26190. */
  26191. _model: ModelShape;
  26192. /**
  26193. * ModelShape id of this particle
  26194. */
  26195. shapeId: number;
  26196. /**
  26197. * Index of the particle in its shape id
  26198. */
  26199. idxInShape: number;
  26200. /**
  26201. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26202. */
  26203. _modelBoundingInfo: BoundingInfo;
  26204. /**
  26205. * @hidden Particle BoundingInfo object (Internal use)
  26206. */
  26207. _boundingInfo: BoundingInfo;
  26208. /**
  26209. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26210. */
  26211. _sps: SolidParticleSystem;
  26212. /**
  26213. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26214. */
  26215. _stillInvisible: boolean;
  26216. /**
  26217. * @hidden Last computed particle rotation matrix
  26218. */
  26219. _rotationMatrix: number[];
  26220. /**
  26221. * Parent particle Id, if any.
  26222. * Default null.
  26223. */
  26224. parentId: Nullable<number>;
  26225. /**
  26226. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26227. * The possible values are :
  26228. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26229. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26230. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26231. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26232. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26233. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26234. * */
  26235. cullingStrategy: number;
  26236. /**
  26237. * @hidden Internal global position in the SPS.
  26238. */
  26239. _globalPosition: Vector3;
  26240. /**
  26241. * Creates a Solid Particle object.
  26242. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26243. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26244. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26245. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26246. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26247. * @param shapeId (integer) is the model shape identifier in the SPS.
  26248. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26249. * @param sps defines the sps it is associated to
  26250. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26251. */
  26252. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26253. /**
  26254. * Legacy support, changed scale to scaling
  26255. */
  26256. /**
  26257. * Legacy support, changed scale to scaling
  26258. */
  26259. scale: Vector3;
  26260. /**
  26261. * Legacy support, changed quaternion to rotationQuaternion
  26262. */
  26263. /**
  26264. * Legacy support, changed quaternion to rotationQuaternion
  26265. */
  26266. quaternion: Nullable<Quaternion>;
  26267. /**
  26268. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26269. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26270. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26271. * @returns true if it intersects
  26272. */
  26273. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26274. /**
  26275. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26276. * A particle is in the frustum if its bounding box intersects the frustum
  26277. * @param frustumPlanes defines the frustum to test
  26278. * @returns true if the particle is in the frustum planes
  26279. */
  26280. isInFrustum(frustumPlanes: Plane[]): boolean;
  26281. /**
  26282. * get the rotation matrix of the particle
  26283. * @hidden
  26284. */
  26285. getRotationMatrix(m: Matrix): void;
  26286. }
  26287. /**
  26288. * Represents the shape of the model used by one particle of a solid particle system.
  26289. * SPS internal tool, don't use it manually.
  26290. */
  26291. export class ModelShape {
  26292. /**
  26293. * The shape id
  26294. * @hidden
  26295. */
  26296. shapeID: number;
  26297. /**
  26298. * flat array of model positions (internal use)
  26299. * @hidden
  26300. */
  26301. _shape: Vector3[];
  26302. /**
  26303. * flat array of model UVs (internal use)
  26304. * @hidden
  26305. */
  26306. _shapeUV: number[];
  26307. /**
  26308. * length of the shape in the model indices array (internal use)
  26309. * @hidden
  26310. */
  26311. _indicesLength: number;
  26312. /**
  26313. * Custom position function (internal use)
  26314. * @hidden
  26315. */
  26316. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26317. /**
  26318. * Custom vertex function (internal use)
  26319. * @hidden
  26320. */
  26321. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26322. /**
  26323. * 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.
  26324. * SPS internal tool, don't use it manually.
  26325. * @hidden
  26326. */
  26327. 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>);
  26328. }
  26329. /**
  26330. * Represents a Depth Sorted Particle in the solid particle system.
  26331. */
  26332. export class DepthSortedParticle {
  26333. /**
  26334. * Index of the particle in the "indices" array
  26335. */
  26336. ind: number;
  26337. /**
  26338. * Length of the particle shape in the "indices" array
  26339. */
  26340. indicesLength: number;
  26341. /**
  26342. * Squared distance from the particle to the camera
  26343. */
  26344. sqDistance: number;
  26345. }
  26346. }
  26347. declare module "babylonjs/Collisions/meshCollisionData" {
  26348. import { Collider } from "babylonjs/Collisions/collider";
  26349. import { Vector3 } from "babylonjs/Maths/math.vector";
  26350. import { Nullable } from "babylonjs/types";
  26351. import { Observer } from "babylonjs/Misc/observable";
  26352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26353. /**
  26354. * @hidden
  26355. */
  26356. export class _MeshCollisionData {
  26357. _checkCollisions: boolean;
  26358. _collisionMask: number;
  26359. _collisionGroup: number;
  26360. _collider: Nullable<Collider>;
  26361. _oldPositionForCollisions: Vector3;
  26362. _diffPositionForCollisions: Vector3;
  26363. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26364. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26365. }
  26366. }
  26367. declare module "babylonjs/Meshes/abstractMesh" {
  26368. import { Observable } from "babylonjs/Misc/observable";
  26369. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26370. import { Camera } from "babylonjs/Cameras/camera";
  26371. import { Scene, IDisposable } from "babylonjs/scene";
  26372. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26373. import { Node } from "babylonjs/node";
  26374. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26377. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26378. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26379. import { Material } from "babylonjs/Materials/material";
  26380. import { Light } from "babylonjs/Lights/light";
  26381. import { Skeleton } from "babylonjs/Bones/skeleton";
  26382. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26383. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26384. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26385. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26386. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26387. import { Plane } from "babylonjs/Maths/math.plane";
  26388. import { Ray } from "babylonjs/Culling/ray";
  26389. import { Collider } from "babylonjs/Collisions/collider";
  26390. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26391. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26392. /** @hidden */
  26393. class _FacetDataStorage {
  26394. facetPositions: Vector3[];
  26395. facetNormals: Vector3[];
  26396. facetPartitioning: number[][];
  26397. facetNb: number;
  26398. partitioningSubdivisions: number;
  26399. partitioningBBoxRatio: number;
  26400. facetDataEnabled: boolean;
  26401. facetParameters: any;
  26402. bbSize: Vector3;
  26403. subDiv: {
  26404. max: number;
  26405. X: number;
  26406. Y: number;
  26407. Z: number;
  26408. };
  26409. facetDepthSort: boolean;
  26410. facetDepthSortEnabled: boolean;
  26411. depthSortedIndices: IndicesArray;
  26412. depthSortedFacets: {
  26413. ind: number;
  26414. sqDistance: number;
  26415. }[];
  26416. facetDepthSortFunction: (f1: {
  26417. ind: number;
  26418. sqDistance: number;
  26419. }, f2: {
  26420. ind: number;
  26421. sqDistance: number;
  26422. }) => number;
  26423. facetDepthSortFrom: Vector3;
  26424. facetDepthSortOrigin: Vector3;
  26425. invertedMatrix: Matrix;
  26426. }
  26427. /**
  26428. * @hidden
  26429. **/
  26430. class _InternalAbstractMeshDataInfo {
  26431. _hasVertexAlpha: boolean;
  26432. _useVertexColors: boolean;
  26433. _numBoneInfluencers: number;
  26434. _applyFog: boolean;
  26435. _receiveShadows: boolean;
  26436. _facetData: _FacetDataStorage;
  26437. _visibility: number;
  26438. _skeleton: Nullable<Skeleton>;
  26439. _layerMask: number;
  26440. _computeBonesUsingShaders: boolean;
  26441. _isActive: boolean;
  26442. _onlyForInstances: boolean;
  26443. _isActiveIntermediate: boolean;
  26444. _onlyForInstancesIntermediate: boolean;
  26445. }
  26446. /**
  26447. * Class used to store all common mesh properties
  26448. */
  26449. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26450. /** No occlusion */
  26451. static OCCLUSION_TYPE_NONE: number;
  26452. /** Occlusion set to optimisitic */
  26453. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26454. /** Occlusion set to strict */
  26455. static OCCLUSION_TYPE_STRICT: number;
  26456. /** Use an accurante occlusion algorithm */
  26457. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26458. /** Use a conservative occlusion algorithm */
  26459. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26460. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26461. * Test order :
  26462. * Is the bounding sphere outside the frustum ?
  26463. * If not, are the bounding box vertices outside the frustum ?
  26464. * It not, then the cullable object is in the frustum.
  26465. */
  26466. static readonly CULLINGSTRATEGY_STANDARD: number;
  26467. /** Culling strategy : Bounding Sphere Only.
  26468. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26469. * It's also less accurate than the standard because some not visible objects can still be selected.
  26470. * Test : is the bounding sphere outside the frustum ?
  26471. * If not, then the cullable object is in the frustum.
  26472. */
  26473. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26474. /** Culling strategy : Optimistic Inclusion.
  26475. * This in an inclusion test first, then the standard exclusion test.
  26476. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26477. * 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.
  26478. * Anyway, it's as accurate as the standard strategy.
  26479. * Test :
  26480. * Is the cullable object bounding sphere center in the frustum ?
  26481. * If not, apply the default culling strategy.
  26482. */
  26483. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26484. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26485. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26486. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26487. * 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.
  26488. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26489. * Test :
  26490. * Is the cullable object bounding sphere center in the frustum ?
  26491. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26492. */
  26493. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26494. /**
  26495. * No billboard
  26496. */
  26497. static readonly BILLBOARDMODE_NONE: number;
  26498. /** Billboard on X axis */
  26499. static readonly BILLBOARDMODE_X: number;
  26500. /** Billboard on Y axis */
  26501. static readonly BILLBOARDMODE_Y: number;
  26502. /** Billboard on Z axis */
  26503. static readonly BILLBOARDMODE_Z: number;
  26504. /** Billboard on all axes */
  26505. static readonly BILLBOARDMODE_ALL: number;
  26506. /** Billboard on using position instead of orientation */
  26507. static readonly BILLBOARDMODE_USE_POSITION: number;
  26508. /** @hidden */
  26509. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26510. /**
  26511. * The culling strategy to use to check whether the mesh must be rendered or not.
  26512. * This value can be changed at any time and will be used on the next render mesh selection.
  26513. * The possible values are :
  26514. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26515. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26516. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26517. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26518. * Please read each static variable documentation to get details about the culling process.
  26519. * */
  26520. cullingStrategy: number;
  26521. /**
  26522. * Gets the number of facets in the mesh
  26523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26524. */
  26525. readonly facetNb: number;
  26526. /**
  26527. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26529. */
  26530. partitioningSubdivisions: number;
  26531. /**
  26532. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26533. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26535. */
  26536. partitioningBBoxRatio: number;
  26537. /**
  26538. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26539. * Works only for updatable meshes.
  26540. * Doesn't work with multi-materials
  26541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26542. */
  26543. mustDepthSortFacets: boolean;
  26544. /**
  26545. * The location (Vector3) where the facet depth sort must be computed from.
  26546. * By default, the active camera position.
  26547. * Used only when facet depth sort is enabled
  26548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26549. */
  26550. facetDepthSortFrom: Vector3;
  26551. /**
  26552. * gets a boolean indicating if facetData is enabled
  26553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26554. */
  26555. readonly isFacetDataEnabled: boolean;
  26556. /** @hidden */
  26557. _updateNonUniformScalingState(value: boolean): boolean;
  26558. /**
  26559. * An event triggered when this mesh collides with another one
  26560. */
  26561. onCollideObservable: Observable<AbstractMesh>;
  26562. /** Set a function to call when this mesh collides with another one */
  26563. onCollide: () => void;
  26564. /**
  26565. * An event triggered when the collision's position changes
  26566. */
  26567. onCollisionPositionChangeObservable: Observable<Vector3>;
  26568. /** Set a function to call when the collision's position changes */
  26569. onCollisionPositionChange: () => void;
  26570. /**
  26571. * An event triggered when material is changed
  26572. */
  26573. onMaterialChangedObservable: Observable<AbstractMesh>;
  26574. /**
  26575. * Gets or sets the orientation for POV movement & rotation
  26576. */
  26577. definedFacingForward: boolean;
  26578. /** @hidden */
  26579. _occlusionQuery: Nullable<WebGLQuery>;
  26580. /** @hidden */
  26581. _renderingGroup: Nullable<RenderingGroup>;
  26582. /**
  26583. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26584. */
  26585. /**
  26586. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26587. */
  26588. visibility: number;
  26589. /** Gets or sets the alpha index used to sort transparent meshes
  26590. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26591. */
  26592. alphaIndex: number;
  26593. /**
  26594. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26595. */
  26596. isVisible: boolean;
  26597. /**
  26598. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26599. */
  26600. isPickable: boolean;
  26601. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26602. showSubMeshesBoundingBox: boolean;
  26603. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26605. */
  26606. isBlocker: boolean;
  26607. /**
  26608. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26609. */
  26610. enablePointerMoveEvents: boolean;
  26611. /**
  26612. * Specifies the rendering group id for this mesh (0 by default)
  26613. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26614. */
  26615. renderingGroupId: number;
  26616. private _material;
  26617. /** Gets or sets current material */
  26618. material: Nullable<Material>;
  26619. /**
  26620. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26621. * @see http://doc.babylonjs.com/babylon101/shadows
  26622. */
  26623. receiveShadows: boolean;
  26624. /** Defines color to use when rendering outline */
  26625. outlineColor: Color3;
  26626. /** Define width to use when rendering outline */
  26627. outlineWidth: number;
  26628. /** Defines color to use when rendering overlay */
  26629. overlayColor: Color3;
  26630. /** Defines alpha to use when rendering overlay */
  26631. overlayAlpha: number;
  26632. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26633. hasVertexAlpha: boolean;
  26634. /** 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) */
  26635. useVertexColors: boolean;
  26636. /**
  26637. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26638. */
  26639. computeBonesUsingShaders: boolean;
  26640. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26641. numBoneInfluencers: number;
  26642. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26643. applyFog: boolean;
  26644. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26645. useOctreeForRenderingSelection: boolean;
  26646. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26647. useOctreeForPicking: boolean;
  26648. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26649. useOctreeForCollisions: boolean;
  26650. /**
  26651. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26652. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26653. */
  26654. layerMask: number;
  26655. /**
  26656. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26657. */
  26658. alwaysSelectAsActiveMesh: boolean;
  26659. /**
  26660. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26661. */
  26662. doNotSyncBoundingInfo: boolean;
  26663. /**
  26664. * Gets or sets the current action manager
  26665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26666. */
  26667. actionManager: Nullable<AbstractActionManager>;
  26668. private _meshCollisionData;
  26669. /**
  26670. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26671. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26672. */
  26673. ellipsoid: Vector3;
  26674. /**
  26675. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26676. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26677. */
  26678. ellipsoidOffset: Vector3;
  26679. /**
  26680. * Gets or sets a collision mask used to mask collisions (default is -1).
  26681. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26682. */
  26683. collisionMask: number;
  26684. /**
  26685. * Gets or sets the current collision group mask (-1 by default).
  26686. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26687. */
  26688. collisionGroup: number;
  26689. /**
  26690. * Defines edge width used when edgesRenderer is enabled
  26691. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26692. */
  26693. edgesWidth: number;
  26694. /**
  26695. * Defines edge color used when edgesRenderer is enabled
  26696. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26697. */
  26698. edgesColor: Color4;
  26699. /** @hidden */
  26700. _edgesRenderer: Nullable<IEdgesRenderer>;
  26701. /** @hidden */
  26702. _masterMesh: Nullable<AbstractMesh>;
  26703. /** @hidden */
  26704. _boundingInfo: Nullable<BoundingInfo>;
  26705. /** @hidden */
  26706. _renderId: number;
  26707. /**
  26708. * Gets or sets the list of subMeshes
  26709. * @see http://doc.babylonjs.com/how_to/multi_materials
  26710. */
  26711. subMeshes: SubMesh[];
  26712. /** @hidden */
  26713. _intersectionsInProgress: AbstractMesh[];
  26714. /** @hidden */
  26715. _unIndexed: boolean;
  26716. /** @hidden */
  26717. _lightSources: Light[];
  26718. /** Gets the list of lights affecting that mesh */
  26719. readonly lightSources: Light[];
  26720. /** @hidden */
  26721. readonly _positions: Nullable<Vector3[]>;
  26722. /** @hidden */
  26723. _waitingData: {
  26724. lods: Nullable<any>;
  26725. actions: Nullable<any>;
  26726. freezeWorldMatrix: Nullable<boolean>;
  26727. };
  26728. /** @hidden */
  26729. _bonesTransformMatrices: Nullable<Float32Array>;
  26730. /** @hidden */
  26731. _transformMatrixTexture: Nullable<RawTexture>;
  26732. /**
  26733. * Gets or sets a skeleton to apply skining transformations
  26734. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26735. */
  26736. skeleton: Nullable<Skeleton>;
  26737. /**
  26738. * An event triggered when the mesh is rebuilt.
  26739. */
  26740. onRebuildObservable: Observable<AbstractMesh>;
  26741. /**
  26742. * Creates a new AbstractMesh
  26743. * @param name defines the name of the mesh
  26744. * @param scene defines the hosting scene
  26745. */
  26746. constructor(name: string, scene?: Nullable<Scene>);
  26747. /**
  26748. * Returns the string "AbstractMesh"
  26749. * @returns "AbstractMesh"
  26750. */
  26751. getClassName(): string;
  26752. /**
  26753. * Gets a string representation of the current mesh
  26754. * @param fullDetails defines a boolean indicating if full details must be included
  26755. * @returns a string representation of the current mesh
  26756. */
  26757. toString(fullDetails?: boolean): string;
  26758. /**
  26759. * @hidden
  26760. */
  26761. protected _getEffectiveParent(): Nullable<Node>;
  26762. /** @hidden */
  26763. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26764. /** @hidden */
  26765. _rebuild(): void;
  26766. /** @hidden */
  26767. _resyncLightSources(): void;
  26768. /** @hidden */
  26769. _resyncLighSource(light: Light): void;
  26770. /** @hidden */
  26771. _unBindEffect(): void;
  26772. /** @hidden */
  26773. _removeLightSource(light: Light, dispose: boolean): void;
  26774. private _markSubMeshesAsDirty;
  26775. /** @hidden */
  26776. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26777. /** @hidden */
  26778. _markSubMeshesAsAttributesDirty(): void;
  26779. /** @hidden */
  26780. _markSubMeshesAsMiscDirty(): void;
  26781. /**
  26782. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26783. */
  26784. scaling: Vector3;
  26785. /**
  26786. * Returns true if the mesh is blocked. Implemented by child classes
  26787. */
  26788. readonly isBlocked: boolean;
  26789. /**
  26790. * Returns the mesh itself by default. Implemented by child classes
  26791. * @param camera defines the camera to use to pick the right LOD level
  26792. * @returns the currentAbstractMesh
  26793. */
  26794. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26795. /**
  26796. * Returns 0 by default. Implemented by child classes
  26797. * @returns an integer
  26798. */
  26799. getTotalVertices(): number;
  26800. /**
  26801. * Returns a positive integer : the total number of indices in this mesh geometry.
  26802. * @returns the numner of indices or zero if the mesh has no geometry.
  26803. */
  26804. getTotalIndices(): number;
  26805. /**
  26806. * Returns null by default. Implemented by child classes
  26807. * @returns null
  26808. */
  26809. getIndices(): Nullable<IndicesArray>;
  26810. /**
  26811. * Returns the array of the requested vertex data kind. Implemented by child classes
  26812. * @param kind defines the vertex data kind to use
  26813. * @returns null
  26814. */
  26815. getVerticesData(kind: string): Nullable<FloatArray>;
  26816. /**
  26817. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26818. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26819. * Note that a new underlying VertexBuffer object is created each call.
  26820. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26821. * @param kind defines vertex data kind:
  26822. * * VertexBuffer.PositionKind
  26823. * * VertexBuffer.UVKind
  26824. * * VertexBuffer.UV2Kind
  26825. * * VertexBuffer.UV3Kind
  26826. * * VertexBuffer.UV4Kind
  26827. * * VertexBuffer.UV5Kind
  26828. * * VertexBuffer.UV6Kind
  26829. * * VertexBuffer.ColorKind
  26830. * * VertexBuffer.MatricesIndicesKind
  26831. * * VertexBuffer.MatricesIndicesExtraKind
  26832. * * VertexBuffer.MatricesWeightsKind
  26833. * * VertexBuffer.MatricesWeightsExtraKind
  26834. * @param data defines the data source
  26835. * @param updatable defines if the data must be flagged as updatable (or static)
  26836. * @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
  26837. * @returns the current mesh
  26838. */
  26839. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26840. /**
  26841. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26842. * If the mesh has no geometry, it is simply returned as it is.
  26843. * @param kind defines vertex data kind:
  26844. * * VertexBuffer.PositionKind
  26845. * * VertexBuffer.UVKind
  26846. * * VertexBuffer.UV2Kind
  26847. * * VertexBuffer.UV3Kind
  26848. * * VertexBuffer.UV4Kind
  26849. * * VertexBuffer.UV5Kind
  26850. * * VertexBuffer.UV6Kind
  26851. * * VertexBuffer.ColorKind
  26852. * * VertexBuffer.MatricesIndicesKind
  26853. * * VertexBuffer.MatricesIndicesExtraKind
  26854. * * VertexBuffer.MatricesWeightsKind
  26855. * * VertexBuffer.MatricesWeightsExtraKind
  26856. * @param data defines the data source
  26857. * @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
  26858. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26859. * @returns the current mesh
  26860. */
  26861. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26862. /**
  26863. * Sets the mesh indices,
  26864. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26865. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26866. * @param totalVertices Defines the total number of vertices
  26867. * @returns the current mesh
  26868. */
  26869. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26870. /**
  26871. * Gets a boolean indicating if specific vertex data is present
  26872. * @param kind defines the vertex data kind to use
  26873. * @returns true is data kind is present
  26874. */
  26875. isVerticesDataPresent(kind: string): boolean;
  26876. /**
  26877. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26878. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26879. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26880. * @returns a BoundingInfo
  26881. */
  26882. getBoundingInfo(): BoundingInfo;
  26883. /**
  26884. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26885. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26886. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26887. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26888. * @returns the current mesh
  26889. */
  26890. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26891. /**
  26892. * Overwrite the current bounding info
  26893. * @param boundingInfo defines the new bounding info
  26894. * @returns the current mesh
  26895. */
  26896. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26897. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26898. readonly useBones: boolean;
  26899. /** @hidden */
  26900. _preActivate(): void;
  26901. /** @hidden */
  26902. _preActivateForIntermediateRendering(renderId: number): void;
  26903. /** @hidden */
  26904. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26905. /** @hidden */
  26906. _postActivate(): void;
  26907. /** @hidden */
  26908. _freeze(): void;
  26909. /** @hidden */
  26910. _unFreeze(): void;
  26911. /**
  26912. * Gets the current world matrix
  26913. * @returns a Matrix
  26914. */
  26915. getWorldMatrix(): Matrix;
  26916. /** @hidden */
  26917. _getWorldMatrixDeterminant(): number;
  26918. /**
  26919. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26920. */
  26921. readonly isAnInstance: boolean;
  26922. /**
  26923. * Gets a boolean indicating if this mesh has instances
  26924. */
  26925. readonly hasInstances: boolean;
  26926. /**
  26927. * Perform relative position change from the point of view of behind the front of the mesh.
  26928. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26929. * Supports definition of mesh facing forward or backward
  26930. * @param amountRight defines the distance on the right axis
  26931. * @param amountUp defines the distance on the up axis
  26932. * @param amountForward defines the distance on the forward axis
  26933. * @returns the current mesh
  26934. */
  26935. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26936. /**
  26937. * Calculate relative position change from the point of view of behind the front of the mesh.
  26938. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26939. * Supports definition of mesh facing forward or backward
  26940. * @param amountRight defines the distance on the right axis
  26941. * @param amountUp defines the distance on the up axis
  26942. * @param amountForward defines the distance on the forward axis
  26943. * @returns the new displacement vector
  26944. */
  26945. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26946. /**
  26947. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26948. * Supports definition of mesh facing forward or backward
  26949. * @param flipBack defines the flip
  26950. * @param twirlClockwise defines the twirl
  26951. * @param tiltRight defines the tilt
  26952. * @returns the current mesh
  26953. */
  26954. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26955. /**
  26956. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26957. * Supports definition of mesh facing forward or backward.
  26958. * @param flipBack defines the flip
  26959. * @param twirlClockwise defines the twirl
  26960. * @param tiltRight defines the tilt
  26961. * @returns the new rotation vector
  26962. */
  26963. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26964. /**
  26965. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26966. * This means the mesh underlying bounding box and sphere are recomputed.
  26967. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26968. * @returns the current mesh
  26969. */
  26970. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26971. /** @hidden */
  26972. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26973. /** @hidden */
  26974. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26975. /** @hidden */
  26976. _updateBoundingInfo(): AbstractMesh;
  26977. /** @hidden */
  26978. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26979. /** @hidden */
  26980. protected _afterComputeWorldMatrix(): void;
  26981. /** @hidden */
  26982. readonly _effectiveMesh: AbstractMesh;
  26983. /**
  26984. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26985. * A mesh is in the frustum if its bounding box intersects the frustum
  26986. * @param frustumPlanes defines the frustum to test
  26987. * @returns true if the mesh is in the frustum planes
  26988. */
  26989. isInFrustum(frustumPlanes: Plane[]): boolean;
  26990. /**
  26991. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26992. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26993. * @param frustumPlanes defines the frustum to test
  26994. * @returns true if the mesh is completely in the frustum planes
  26995. */
  26996. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26997. /**
  26998. * True if the mesh intersects another mesh or a SolidParticle object
  26999. * @param mesh defines a target mesh or SolidParticle to test
  27000. * @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)
  27001. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27002. * @returns true if there is an intersection
  27003. */
  27004. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27005. /**
  27006. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27007. * @param point defines the point to test
  27008. * @returns true if there is an intersection
  27009. */
  27010. intersectsPoint(point: Vector3): boolean;
  27011. /**
  27012. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27014. */
  27015. checkCollisions: boolean;
  27016. /**
  27017. * Gets Collider object used to compute collisions (not physics)
  27018. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27019. */
  27020. readonly collider: Nullable<Collider>;
  27021. /**
  27022. * Move the mesh using collision engine
  27023. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27024. * @param displacement defines the requested displacement vector
  27025. * @returns the current mesh
  27026. */
  27027. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27028. private _onCollisionPositionChange;
  27029. /** @hidden */
  27030. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27031. /** @hidden */
  27032. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27033. /** @hidden */
  27034. _checkCollision(collider: Collider): AbstractMesh;
  27035. /** @hidden */
  27036. _generatePointsArray(): boolean;
  27037. /**
  27038. * Checks if the passed Ray intersects with the mesh
  27039. * @param ray defines the ray to use
  27040. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27041. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27042. * @returns the picking info
  27043. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27044. */
  27045. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27046. /**
  27047. * Clones the current mesh
  27048. * @param name defines the mesh name
  27049. * @param newParent defines the new mesh parent
  27050. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27051. * @returns the new mesh
  27052. */
  27053. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27054. /**
  27055. * Disposes all the submeshes of the current meshnp
  27056. * @returns the current mesh
  27057. */
  27058. releaseSubMeshes(): AbstractMesh;
  27059. /**
  27060. * Releases resources associated with this abstract mesh.
  27061. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27062. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27063. */
  27064. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27065. /**
  27066. * Adds the passed mesh as a child to the current mesh
  27067. * @param mesh defines the child mesh
  27068. * @returns the current mesh
  27069. */
  27070. addChild(mesh: AbstractMesh): AbstractMesh;
  27071. /**
  27072. * Removes the passed mesh from the current mesh children list
  27073. * @param mesh defines the child mesh
  27074. * @returns the current mesh
  27075. */
  27076. removeChild(mesh: AbstractMesh): AbstractMesh;
  27077. /** @hidden */
  27078. private _initFacetData;
  27079. /**
  27080. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27081. * This method can be called within the render loop.
  27082. * 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
  27083. * @returns the current mesh
  27084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27085. */
  27086. updateFacetData(): AbstractMesh;
  27087. /**
  27088. * Returns the facetLocalNormals array.
  27089. * The normals are expressed in the mesh local spac
  27090. * @returns an array of Vector3
  27091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27092. */
  27093. getFacetLocalNormals(): Vector3[];
  27094. /**
  27095. * Returns the facetLocalPositions array.
  27096. * The facet positions are expressed in the mesh local space
  27097. * @returns an array of Vector3
  27098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27099. */
  27100. getFacetLocalPositions(): Vector3[];
  27101. /**
  27102. * Returns the facetLocalPartioning array
  27103. * @returns an array of array of numbers
  27104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27105. */
  27106. getFacetLocalPartitioning(): number[][];
  27107. /**
  27108. * Returns the i-th facet position in the world system.
  27109. * This method allocates a new Vector3 per call
  27110. * @param i defines the facet index
  27111. * @returns a new Vector3
  27112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27113. */
  27114. getFacetPosition(i: number): Vector3;
  27115. /**
  27116. * Sets the reference Vector3 with the i-th facet position in the world system
  27117. * @param i defines the facet index
  27118. * @param ref defines the target vector
  27119. * @returns the current mesh
  27120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27121. */
  27122. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27123. /**
  27124. * Returns the i-th facet normal in the world system.
  27125. * This method allocates a new Vector3 per call
  27126. * @param i defines the facet index
  27127. * @returns a new Vector3
  27128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27129. */
  27130. getFacetNormal(i: number): Vector3;
  27131. /**
  27132. * Sets the reference Vector3 with the i-th facet normal in the world system
  27133. * @param i defines the facet index
  27134. * @param ref defines the target vector
  27135. * @returns the current mesh
  27136. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27137. */
  27138. getFacetNormalToRef(i: number, ref: Vector3): this;
  27139. /**
  27140. * 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)
  27141. * @param x defines x coordinate
  27142. * @param y defines y coordinate
  27143. * @param z defines z coordinate
  27144. * @returns the array of facet indexes
  27145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27146. */
  27147. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27148. /**
  27149. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27150. * @param projected sets as the (x,y,z) world projection on the facet
  27151. * @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
  27152. * @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
  27153. * @param x defines x coordinate
  27154. * @param y defines y coordinate
  27155. * @param z defines z coordinate
  27156. * @returns the face index if found (or null instead)
  27157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27158. */
  27159. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27160. /**
  27161. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27162. * @param projected sets as the (x,y,z) local projection on the facet
  27163. * @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
  27164. * @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
  27165. * @param x defines x coordinate
  27166. * @param y defines y coordinate
  27167. * @param z defines z coordinate
  27168. * @returns the face index if found (or null instead)
  27169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27170. */
  27171. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27172. /**
  27173. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27174. * @returns the parameters
  27175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27176. */
  27177. getFacetDataParameters(): any;
  27178. /**
  27179. * Disables the feature FacetData and frees the related memory
  27180. * @returns the current mesh
  27181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27182. */
  27183. disableFacetData(): AbstractMesh;
  27184. /**
  27185. * Updates the AbstractMesh indices array
  27186. * @param indices defines the data source
  27187. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27188. * @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)
  27189. * @returns the current mesh
  27190. */
  27191. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27192. /**
  27193. * Creates new normals data for the mesh
  27194. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27195. * @returns the current mesh
  27196. */
  27197. createNormals(updatable: boolean): AbstractMesh;
  27198. /**
  27199. * Align the mesh with a normal
  27200. * @param normal defines the normal to use
  27201. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27202. * @returns the current mesh
  27203. */
  27204. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27205. /** @hidden */
  27206. _checkOcclusionQuery(): boolean;
  27207. /**
  27208. * Disables the mesh edge rendering mode
  27209. * @returns the currentAbstractMesh
  27210. */
  27211. disableEdgesRendering(): AbstractMesh;
  27212. /**
  27213. * Enables the edge rendering mode on the mesh.
  27214. * This mode makes the mesh edges visible
  27215. * @param epsilon defines the maximal distance between two angles to detect a face
  27216. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27217. * @returns the currentAbstractMesh
  27218. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27219. */
  27220. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27221. }
  27222. }
  27223. declare module "babylonjs/Actions/actionEvent" {
  27224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27225. import { Nullable } from "babylonjs/types";
  27226. import { Sprite } from "babylonjs/Sprites/sprite";
  27227. import { Scene } from "babylonjs/scene";
  27228. import { Vector2 } from "babylonjs/Maths/math.vector";
  27229. /**
  27230. * Interface used to define ActionEvent
  27231. */
  27232. export interface IActionEvent {
  27233. /** The mesh or sprite that triggered the action */
  27234. source: any;
  27235. /** The X mouse cursor position at the time of the event */
  27236. pointerX: number;
  27237. /** The Y mouse cursor position at the time of the event */
  27238. pointerY: number;
  27239. /** The mesh that is currently pointed at (can be null) */
  27240. meshUnderPointer: Nullable<AbstractMesh>;
  27241. /** the original (browser) event that triggered the ActionEvent */
  27242. sourceEvent?: any;
  27243. /** additional data for the event */
  27244. additionalData?: any;
  27245. }
  27246. /**
  27247. * ActionEvent is the event being sent when an action is triggered.
  27248. */
  27249. export class ActionEvent implements IActionEvent {
  27250. /** The mesh or sprite that triggered the action */
  27251. source: any;
  27252. /** The X mouse cursor position at the time of the event */
  27253. pointerX: number;
  27254. /** The Y mouse cursor position at the time of the event */
  27255. pointerY: number;
  27256. /** The mesh that is currently pointed at (can be null) */
  27257. meshUnderPointer: Nullable<AbstractMesh>;
  27258. /** the original (browser) event that triggered the ActionEvent */
  27259. sourceEvent?: any;
  27260. /** additional data for the event */
  27261. additionalData?: any;
  27262. /**
  27263. * Creates a new ActionEvent
  27264. * @param source The mesh or sprite that triggered the action
  27265. * @param pointerX The X mouse cursor position at the time of the event
  27266. * @param pointerY The Y mouse cursor position at the time of the event
  27267. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27268. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27269. * @param additionalData additional data for the event
  27270. */
  27271. constructor(
  27272. /** The mesh or sprite that triggered the action */
  27273. source: any,
  27274. /** The X mouse cursor position at the time of the event */
  27275. pointerX: number,
  27276. /** The Y mouse cursor position at the time of the event */
  27277. pointerY: number,
  27278. /** The mesh that is currently pointed at (can be null) */
  27279. meshUnderPointer: Nullable<AbstractMesh>,
  27280. /** the original (browser) event that triggered the ActionEvent */
  27281. sourceEvent?: any,
  27282. /** additional data for the event */
  27283. additionalData?: any);
  27284. /**
  27285. * Helper function to auto-create an ActionEvent from a source mesh.
  27286. * @param source The source mesh that triggered the event
  27287. * @param evt The original (browser) event
  27288. * @param additionalData additional data for the event
  27289. * @returns the new ActionEvent
  27290. */
  27291. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27292. /**
  27293. * Helper function to auto-create an ActionEvent from a source sprite
  27294. * @param source The source sprite that triggered the event
  27295. * @param scene Scene associated with the sprite
  27296. * @param evt The original (browser) event
  27297. * @param additionalData additional data for the event
  27298. * @returns the new ActionEvent
  27299. */
  27300. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27301. /**
  27302. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27303. * @param scene the scene where the event occurred
  27304. * @param evt The original (browser) event
  27305. * @returns the new ActionEvent
  27306. */
  27307. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27308. /**
  27309. * Helper function to auto-create an ActionEvent from a primitive
  27310. * @param prim defines the target primitive
  27311. * @param pointerPos defines the pointer position
  27312. * @param evt The original (browser) event
  27313. * @param additionalData additional data for the event
  27314. * @returns the new ActionEvent
  27315. */
  27316. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27317. }
  27318. }
  27319. declare module "babylonjs/Actions/abstractActionManager" {
  27320. import { IDisposable } from "babylonjs/scene";
  27321. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27322. import { IAction } from "babylonjs/Actions/action";
  27323. import { Nullable } from "babylonjs/types";
  27324. /**
  27325. * Abstract class used to decouple action Manager from scene and meshes.
  27326. * Do not instantiate.
  27327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27328. */
  27329. export abstract class AbstractActionManager implements IDisposable {
  27330. /** Gets the list of active triggers */
  27331. static Triggers: {
  27332. [key: string]: number;
  27333. };
  27334. /** Gets the cursor to use when hovering items */
  27335. hoverCursor: string;
  27336. /** Gets the list of actions */
  27337. actions: IAction[];
  27338. /**
  27339. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27340. */
  27341. isRecursive: boolean;
  27342. /**
  27343. * Releases all associated resources
  27344. */
  27345. abstract dispose(): void;
  27346. /**
  27347. * Does this action manager has pointer triggers
  27348. */
  27349. abstract readonly hasPointerTriggers: boolean;
  27350. /**
  27351. * Does this action manager has pick triggers
  27352. */
  27353. abstract readonly hasPickTriggers: boolean;
  27354. /**
  27355. * Process a specific trigger
  27356. * @param trigger defines the trigger to process
  27357. * @param evt defines the event details to be processed
  27358. */
  27359. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27360. /**
  27361. * Does this action manager handles actions of any of the given triggers
  27362. * @param triggers defines the triggers to be tested
  27363. * @return a boolean indicating whether one (or more) of the triggers is handled
  27364. */
  27365. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27366. /**
  27367. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27368. * speed.
  27369. * @param triggerA defines the trigger to be tested
  27370. * @param triggerB defines the trigger to be tested
  27371. * @return a boolean indicating whether one (or more) of the triggers is handled
  27372. */
  27373. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27374. /**
  27375. * Does this action manager handles actions of a given trigger
  27376. * @param trigger defines the trigger to be tested
  27377. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27378. * @return whether the trigger is handled
  27379. */
  27380. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27381. /**
  27382. * Serialize this manager to a JSON object
  27383. * @param name defines the property name to store this manager
  27384. * @returns a JSON representation of this manager
  27385. */
  27386. abstract serialize(name: string): any;
  27387. /**
  27388. * Registers an action to this action manager
  27389. * @param action defines the action to be registered
  27390. * @return the action amended (prepared) after registration
  27391. */
  27392. abstract registerAction(action: IAction): Nullable<IAction>;
  27393. /**
  27394. * Unregisters an action to this action manager
  27395. * @param action defines the action to be unregistered
  27396. * @return a boolean indicating whether the action has been unregistered
  27397. */
  27398. abstract unregisterAction(action: IAction): Boolean;
  27399. /**
  27400. * Does exist one action manager with at least one trigger
  27401. **/
  27402. static readonly HasTriggers: boolean;
  27403. /**
  27404. * Does exist one action manager with at least one pick trigger
  27405. **/
  27406. static readonly HasPickTriggers: boolean;
  27407. /**
  27408. * Does exist one action manager that handles actions of a given trigger
  27409. * @param trigger defines the trigger to be tested
  27410. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27411. **/
  27412. static HasSpecificTrigger(trigger: number): boolean;
  27413. }
  27414. }
  27415. declare module "babylonjs/node" {
  27416. import { Scene } from "babylonjs/scene";
  27417. import { Nullable } from "babylonjs/types";
  27418. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27419. import { Engine } from "babylonjs/Engines/engine";
  27420. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27421. import { Observable } from "babylonjs/Misc/observable";
  27422. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27423. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27424. import { Animatable } from "babylonjs/Animations/animatable";
  27425. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27426. import { Animation } from "babylonjs/Animations/animation";
  27427. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27429. /**
  27430. * Defines how a node can be built from a string name.
  27431. */
  27432. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27433. /**
  27434. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27435. */
  27436. export class Node implements IBehaviorAware<Node> {
  27437. /** @hidden */
  27438. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27439. private static _NodeConstructors;
  27440. /**
  27441. * Add a new node constructor
  27442. * @param type defines the type name of the node to construct
  27443. * @param constructorFunc defines the constructor function
  27444. */
  27445. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27446. /**
  27447. * Returns a node constructor based on type name
  27448. * @param type defines the type name
  27449. * @param name defines the new node name
  27450. * @param scene defines the hosting scene
  27451. * @param options defines optional options to transmit to constructors
  27452. * @returns the new constructor or null
  27453. */
  27454. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27455. /**
  27456. * Gets or sets the name of the node
  27457. */
  27458. name: string;
  27459. /**
  27460. * Gets or sets the id of the node
  27461. */
  27462. id: string;
  27463. /**
  27464. * Gets or sets the unique id of the node
  27465. */
  27466. uniqueId: number;
  27467. /**
  27468. * Gets or sets a string used to store user defined state for the node
  27469. */
  27470. state: string;
  27471. /**
  27472. * Gets or sets an object used to store user defined information for the node
  27473. */
  27474. metadata: any;
  27475. /**
  27476. * For internal use only. Please do not use.
  27477. */
  27478. reservedDataStore: any;
  27479. /**
  27480. * List of inspectable custom properties (used by the Inspector)
  27481. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27482. */
  27483. inspectableCustomProperties: IInspectable[];
  27484. /**
  27485. * Gets or sets a boolean used to define if the node must be serialized
  27486. */
  27487. doNotSerialize: boolean;
  27488. /** @hidden */
  27489. _isDisposed: boolean;
  27490. /**
  27491. * Gets a list of Animations associated with the node
  27492. */
  27493. animations: import("babylonjs/Animations/animation").Animation[];
  27494. protected _ranges: {
  27495. [name: string]: Nullable<AnimationRange>;
  27496. };
  27497. /**
  27498. * Callback raised when the node is ready to be used
  27499. */
  27500. onReady: Nullable<(node: Node) => void>;
  27501. private _isEnabled;
  27502. private _isParentEnabled;
  27503. private _isReady;
  27504. /** @hidden */
  27505. _currentRenderId: number;
  27506. private _parentUpdateId;
  27507. /** @hidden */
  27508. _childUpdateId: number;
  27509. /** @hidden */
  27510. _waitingParentId: Nullable<string>;
  27511. /** @hidden */
  27512. _scene: Scene;
  27513. /** @hidden */
  27514. _cache: any;
  27515. private _parentNode;
  27516. private _children;
  27517. /** @hidden */
  27518. _worldMatrix: Matrix;
  27519. /** @hidden */
  27520. _worldMatrixDeterminant: number;
  27521. /** @hidden */
  27522. _worldMatrixDeterminantIsDirty: boolean;
  27523. /** @hidden */
  27524. private _sceneRootNodesIndex;
  27525. /**
  27526. * Gets a boolean indicating if the node has been disposed
  27527. * @returns true if the node was disposed
  27528. */
  27529. isDisposed(): boolean;
  27530. /**
  27531. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27532. * @see https://doc.babylonjs.com/how_to/parenting
  27533. */
  27534. parent: Nullable<Node>;
  27535. private addToSceneRootNodes;
  27536. private removeFromSceneRootNodes;
  27537. private _animationPropertiesOverride;
  27538. /**
  27539. * Gets or sets the animation properties override
  27540. */
  27541. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27542. /**
  27543. * Gets a string idenfifying the name of the class
  27544. * @returns "Node" string
  27545. */
  27546. getClassName(): string;
  27547. /** @hidden */
  27548. readonly _isNode: boolean;
  27549. /**
  27550. * An event triggered when the mesh is disposed
  27551. */
  27552. onDisposeObservable: Observable<Node>;
  27553. private _onDisposeObserver;
  27554. /**
  27555. * Sets a callback that will be raised when the node will be disposed
  27556. */
  27557. onDispose: () => void;
  27558. /**
  27559. * Creates a new Node
  27560. * @param name the name and id to be given to this node
  27561. * @param scene the scene this node will be added to
  27562. * @param addToRootNodes the node will be added to scene.rootNodes
  27563. */
  27564. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27565. /**
  27566. * Gets the scene of the node
  27567. * @returns a scene
  27568. */
  27569. getScene(): Scene;
  27570. /**
  27571. * Gets the engine of the node
  27572. * @returns a Engine
  27573. */
  27574. getEngine(): Engine;
  27575. private _behaviors;
  27576. /**
  27577. * Attach a behavior to the node
  27578. * @see http://doc.babylonjs.com/features/behaviour
  27579. * @param behavior defines the behavior to attach
  27580. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27581. * @returns the current Node
  27582. */
  27583. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27584. /**
  27585. * Remove an attached behavior
  27586. * @see http://doc.babylonjs.com/features/behaviour
  27587. * @param behavior defines the behavior to attach
  27588. * @returns the current Node
  27589. */
  27590. removeBehavior(behavior: Behavior<Node>): Node;
  27591. /**
  27592. * Gets the list of attached behaviors
  27593. * @see http://doc.babylonjs.com/features/behaviour
  27594. */
  27595. readonly behaviors: Behavior<Node>[];
  27596. /**
  27597. * Gets an attached behavior by name
  27598. * @param name defines the name of the behavior to look for
  27599. * @see http://doc.babylonjs.com/features/behaviour
  27600. * @returns null if behavior was not found else the requested behavior
  27601. */
  27602. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27603. /**
  27604. * Returns the latest update of the World matrix
  27605. * @returns a Matrix
  27606. */
  27607. getWorldMatrix(): Matrix;
  27608. /** @hidden */
  27609. _getWorldMatrixDeterminant(): number;
  27610. /**
  27611. * Returns directly the latest state of the mesh World matrix.
  27612. * A Matrix is returned.
  27613. */
  27614. readonly worldMatrixFromCache: Matrix;
  27615. /** @hidden */
  27616. _initCache(): void;
  27617. /** @hidden */
  27618. updateCache(force?: boolean): void;
  27619. /** @hidden */
  27620. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27621. /** @hidden */
  27622. _updateCache(ignoreParentClass?: boolean): void;
  27623. /** @hidden */
  27624. _isSynchronized(): boolean;
  27625. /** @hidden */
  27626. _markSyncedWithParent(): void;
  27627. /** @hidden */
  27628. isSynchronizedWithParent(): boolean;
  27629. /** @hidden */
  27630. isSynchronized(): boolean;
  27631. /**
  27632. * Is this node ready to be used/rendered
  27633. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27634. * @return true if the node is ready
  27635. */
  27636. isReady(completeCheck?: boolean): boolean;
  27637. /**
  27638. * Is this node enabled?
  27639. * 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
  27640. * @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
  27641. * @return whether this node (and its parent) is enabled
  27642. */
  27643. isEnabled(checkAncestors?: boolean): boolean;
  27644. /** @hidden */
  27645. protected _syncParentEnabledState(): void;
  27646. /**
  27647. * Set the enabled state of this node
  27648. * @param value defines the new enabled state
  27649. */
  27650. setEnabled(value: boolean): void;
  27651. /**
  27652. * Is this node a descendant of the given node?
  27653. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27654. * @param ancestor defines the parent node to inspect
  27655. * @returns a boolean indicating if this node is a descendant of the given node
  27656. */
  27657. isDescendantOf(ancestor: Node): boolean;
  27658. /** @hidden */
  27659. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27660. /**
  27661. * Will return all nodes that have this node as ascendant
  27662. * @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
  27663. * @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
  27664. * @return all children nodes of all types
  27665. */
  27666. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27667. /**
  27668. * Get all child-meshes of this node
  27669. * @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)
  27670. * @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
  27671. * @returns an array of AbstractMesh
  27672. */
  27673. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27674. /**
  27675. * Get all direct children of this node
  27676. * @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
  27677. * @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)
  27678. * @returns an array of Node
  27679. */
  27680. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27681. /** @hidden */
  27682. _setReady(state: boolean): void;
  27683. /**
  27684. * Get an animation by name
  27685. * @param name defines the name of the animation to look for
  27686. * @returns null if not found else the requested animation
  27687. */
  27688. getAnimationByName(name: string): Nullable<Animation>;
  27689. /**
  27690. * Creates an animation range for this node
  27691. * @param name defines the name of the range
  27692. * @param from defines the starting key
  27693. * @param to defines the end key
  27694. */
  27695. createAnimationRange(name: string, from: number, to: number): void;
  27696. /**
  27697. * Delete a specific animation range
  27698. * @param name defines the name of the range to delete
  27699. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27700. */
  27701. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27702. /**
  27703. * Get an animation range by name
  27704. * @param name defines the name of the animation range to look for
  27705. * @returns null if not found else the requested animation range
  27706. */
  27707. getAnimationRange(name: string): Nullable<AnimationRange>;
  27708. /**
  27709. * Gets the list of all animation ranges defined on this node
  27710. * @returns an array
  27711. */
  27712. getAnimationRanges(): Nullable<AnimationRange>[];
  27713. /**
  27714. * Will start the animation sequence
  27715. * @param name defines the range frames for animation sequence
  27716. * @param loop defines if the animation should loop (false by default)
  27717. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27718. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27719. * @returns the object created for this animation. If range does not exist, it will return null
  27720. */
  27721. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27722. /**
  27723. * Serialize animation ranges into a JSON compatible object
  27724. * @returns serialization object
  27725. */
  27726. serializeAnimationRanges(): any;
  27727. /**
  27728. * Computes the world matrix of the node
  27729. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27730. * @returns the world matrix
  27731. */
  27732. computeWorldMatrix(force?: boolean): Matrix;
  27733. /**
  27734. * Releases resources associated with this node.
  27735. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27736. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27737. */
  27738. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27739. /**
  27740. * Parse animation range data from a serialization object and store them into a given node
  27741. * @param node defines where to store the animation ranges
  27742. * @param parsedNode defines the serialization object to read data from
  27743. * @param scene defines the hosting scene
  27744. */
  27745. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27746. /**
  27747. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27748. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27749. * @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
  27750. * @returns the new bounding vectors
  27751. */
  27752. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27753. min: Vector3;
  27754. max: Vector3;
  27755. };
  27756. }
  27757. }
  27758. declare module "babylonjs/Animations/animation" {
  27759. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27760. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27761. import { Color3 } from "babylonjs/Maths/math.color";
  27762. import { Nullable } from "babylonjs/types";
  27763. import { Scene } from "babylonjs/scene";
  27764. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27765. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27766. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27767. import { Node } from "babylonjs/node";
  27768. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27769. import { Size } from "babylonjs/Maths/math.size";
  27770. import { Animatable } from "babylonjs/Animations/animatable";
  27771. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27772. /**
  27773. * @hidden
  27774. */
  27775. export class _IAnimationState {
  27776. key: number;
  27777. repeatCount: number;
  27778. workValue?: any;
  27779. loopMode?: number;
  27780. offsetValue?: any;
  27781. highLimitValue?: any;
  27782. }
  27783. /**
  27784. * Class used to store any kind of animation
  27785. */
  27786. export class Animation {
  27787. /**Name of the animation */
  27788. name: string;
  27789. /**Property to animate */
  27790. targetProperty: string;
  27791. /**The frames per second of the animation */
  27792. framePerSecond: number;
  27793. /**The data type of the animation */
  27794. dataType: number;
  27795. /**The loop mode of the animation */
  27796. loopMode?: number | undefined;
  27797. /**Specifies if blending should be enabled */
  27798. enableBlending?: boolean | undefined;
  27799. /**
  27800. * Use matrix interpolation instead of using direct key value when animating matrices
  27801. */
  27802. static AllowMatricesInterpolation: boolean;
  27803. /**
  27804. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27805. */
  27806. static AllowMatrixDecomposeForInterpolation: boolean;
  27807. /**
  27808. * Stores the key frames of the animation
  27809. */
  27810. private _keys;
  27811. /**
  27812. * Stores the easing function of the animation
  27813. */
  27814. private _easingFunction;
  27815. /**
  27816. * @hidden Internal use only
  27817. */
  27818. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27819. /**
  27820. * The set of event that will be linked to this animation
  27821. */
  27822. private _events;
  27823. /**
  27824. * Stores an array of target property paths
  27825. */
  27826. targetPropertyPath: string[];
  27827. /**
  27828. * Stores the blending speed of the animation
  27829. */
  27830. blendingSpeed: number;
  27831. /**
  27832. * Stores the animation ranges for the animation
  27833. */
  27834. private _ranges;
  27835. /**
  27836. * @hidden Internal use
  27837. */
  27838. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27839. /**
  27840. * Sets up an animation
  27841. * @param property The property to animate
  27842. * @param animationType The animation type to apply
  27843. * @param framePerSecond The frames per second of the animation
  27844. * @param easingFunction The easing function used in the animation
  27845. * @returns The created animation
  27846. */
  27847. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27848. /**
  27849. * Create and start an animation on a node
  27850. * @param name defines the name of the global animation that will be run on all nodes
  27851. * @param node defines the root node where the animation will take place
  27852. * @param targetProperty defines property to animate
  27853. * @param framePerSecond defines the number of frame per second yo use
  27854. * @param totalFrame defines the number of frames in total
  27855. * @param from defines the initial value
  27856. * @param to defines the final value
  27857. * @param loopMode defines which loop mode you want to use (off by default)
  27858. * @param easingFunction defines the easing function to use (linear by default)
  27859. * @param onAnimationEnd defines the callback to call when animation end
  27860. * @returns the animatable created for this animation
  27861. */
  27862. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27863. /**
  27864. * Create and start an animation on a node and its descendants
  27865. * @param name defines the name of the global animation that will be run on all nodes
  27866. * @param node defines the root node where the animation will take place
  27867. * @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
  27868. * @param targetProperty defines property to animate
  27869. * @param framePerSecond defines the number of frame per second to use
  27870. * @param totalFrame defines the number of frames in total
  27871. * @param from defines the initial value
  27872. * @param to defines the final value
  27873. * @param loopMode defines which loop mode you want to use (off by default)
  27874. * @param easingFunction defines the easing function to use (linear by default)
  27875. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27876. * @returns the list of animatables created for all nodes
  27877. * @example https://www.babylonjs-playground.com/#MH0VLI
  27878. */
  27879. 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[]>;
  27880. /**
  27881. * Creates a new animation, merges it with the existing animations and starts it
  27882. * @param name Name of the animation
  27883. * @param node Node which contains the scene that begins the animations
  27884. * @param targetProperty Specifies which property to animate
  27885. * @param framePerSecond The frames per second of the animation
  27886. * @param totalFrame The total number of frames
  27887. * @param from The frame at the beginning of the animation
  27888. * @param to The frame at the end of the animation
  27889. * @param loopMode Specifies the loop mode of the animation
  27890. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27891. * @param onAnimationEnd Callback to run once the animation is complete
  27892. * @returns Nullable animation
  27893. */
  27894. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27895. /**
  27896. * Transition property of an host to the target Value
  27897. * @param property The property to transition
  27898. * @param targetValue The target Value of the property
  27899. * @param host The object where the property to animate belongs
  27900. * @param scene Scene used to run the animation
  27901. * @param frameRate Framerate (in frame/s) to use
  27902. * @param transition The transition type we want to use
  27903. * @param duration The duration of the animation, in milliseconds
  27904. * @param onAnimationEnd Callback trigger at the end of the animation
  27905. * @returns Nullable animation
  27906. */
  27907. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27908. /**
  27909. * Return the array of runtime animations currently using this animation
  27910. */
  27911. readonly runtimeAnimations: RuntimeAnimation[];
  27912. /**
  27913. * Specifies if any of the runtime animations are currently running
  27914. */
  27915. readonly hasRunningRuntimeAnimations: boolean;
  27916. /**
  27917. * Initializes the animation
  27918. * @param name Name of the animation
  27919. * @param targetProperty Property to animate
  27920. * @param framePerSecond The frames per second of the animation
  27921. * @param dataType The data type of the animation
  27922. * @param loopMode The loop mode of the animation
  27923. * @param enableBlending Specifies if blending should be enabled
  27924. */
  27925. constructor(
  27926. /**Name of the animation */
  27927. name: string,
  27928. /**Property to animate */
  27929. targetProperty: string,
  27930. /**The frames per second of the animation */
  27931. framePerSecond: number,
  27932. /**The data type of the animation */
  27933. dataType: number,
  27934. /**The loop mode of the animation */
  27935. loopMode?: number | undefined,
  27936. /**Specifies if blending should be enabled */
  27937. enableBlending?: boolean | undefined);
  27938. /**
  27939. * Converts the animation to a string
  27940. * @param fullDetails support for multiple levels of logging within scene loading
  27941. * @returns String form of the animation
  27942. */
  27943. toString(fullDetails?: boolean): string;
  27944. /**
  27945. * Add an event to this animation
  27946. * @param event Event to add
  27947. */
  27948. addEvent(event: AnimationEvent): void;
  27949. /**
  27950. * Remove all events found at the given frame
  27951. * @param frame The frame to remove events from
  27952. */
  27953. removeEvents(frame: number): void;
  27954. /**
  27955. * Retrieves all the events from the animation
  27956. * @returns Events from the animation
  27957. */
  27958. getEvents(): AnimationEvent[];
  27959. /**
  27960. * Creates an animation range
  27961. * @param name Name of the animation range
  27962. * @param from Starting frame of the animation range
  27963. * @param to Ending frame of the animation
  27964. */
  27965. createRange(name: string, from: number, to: number): void;
  27966. /**
  27967. * Deletes an animation range by name
  27968. * @param name Name of the animation range to delete
  27969. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27970. */
  27971. deleteRange(name: string, deleteFrames?: boolean): void;
  27972. /**
  27973. * Gets the animation range by name, or null if not defined
  27974. * @param name Name of the animation range
  27975. * @returns Nullable animation range
  27976. */
  27977. getRange(name: string): Nullable<AnimationRange>;
  27978. /**
  27979. * Gets the key frames from the animation
  27980. * @returns The key frames of the animation
  27981. */
  27982. getKeys(): Array<IAnimationKey>;
  27983. /**
  27984. * Gets the highest frame rate of the animation
  27985. * @returns Highest frame rate of the animation
  27986. */
  27987. getHighestFrame(): number;
  27988. /**
  27989. * Gets the easing function of the animation
  27990. * @returns Easing function of the animation
  27991. */
  27992. getEasingFunction(): IEasingFunction;
  27993. /**
  27994. * Sets the easing function of the animation
  27995. * @param easingFunction A custom mathematical formula for animation
  27996. */
  27997. setEasingFunction(easingFunction: EasingFunction): void;
  27998. /**
  27999. * Interpolates a scalar linearly
  28000. * @param startValue Start value of the animation curve
  28001. * @param endValue End value of the animation curve
  28002. * @param gradient Scalar amount to interpolate
  28003. * @returns Interpolated scalar value
  28004. */
  28005. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28006. /**
  28007. * Interpolates a scalar cubically
  28008. * @param startValue Start value of the animation curve
  28009. * @param outTangent End tangent of the animation
  28010. * @param endValue End value of the animation curve
  28011. * @param inTangent Start tangent of the animation curve
  28012. * @param gradient Scalar amount to interpolate
  28013. * @returns Interpolated scalar value
  28014. */
  28015. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28016. /**
  28017. * Interpolates a quaternion using a spherical linear interpolation
  28018. * @param startValue Start value of the animation curve
  28019. * @param endValue End value of the animation curve
  28020. * @param gradient Scalar amount to interpolate
  28021. * @returns Interpolated quaternion value
  28022. */
  28023. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28024. /**
  28025. * Interpolates a quaternion cubically
  28026. * @param startValue Start value of the animation curve
  28027. * @param outTangent End tangent of the animation curve
  28028. * @param endValue End value of the animation curve
  28029. * @param inTangent Start tangent of the animation curve
  28030. * @param gradient Scalar amount to interpolate
  28031. * @returns Interpolated quaternion value
  28032. */
  28033. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28034. /**
  28035. * Interpolates a Vector3 linearl
  28036. * @param startValue Start value of the animation curve
  28037. * @param endValue End value of the animation curve
  28038. * @param gradient Scalar amount to interpolate
  28039. * @returns Interpolated scalar value
  28040. */
  28041. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28042. /**
  28043. * Interpolates a Vector3 cubically
  28044. * @param startValue Start value of the animation curve
  28045. * @param outTangent End tangent of the animation
  28046. * @param endValue End value of the animation curve
  28047. * @param inTangent Start tangent of the animation curve
  28048. * @param gradient Scalar amount to interpolate
  28049. * @returns InterpolatedVector3 value
  28050. */
  28051. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28052. /**
  28053. * Interpolates a Vector2 linearly
  28054. * @param startValue Start value of the animation curve
  28055. * @param endValue End value of the animation curve
  28056. * @param gradient Scalar amount to interpolate
  28057. * @returns Interpolated Vector2 value
  28058. */
  28059. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28060. /**
  28061. * Interpolates a Vector2 cubically
  28062. * @param startValue Start value of the animation curve
  28063. * @param outTangent End tangent of the animation
  28064. * @param endValue End value of the animation curve
  28065. * @param inTangent Start tangent of the animation curve
  28066. * @param gradient Scalar amount to interpolate
  28067. * @returns Interpolated Vector2 value
  28068. */
  28069. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28070. /**
  28071. * Interpolates a size linearly
  28072. * @param startValue Start value of the animation curve
  28073. * @param endValue End value of the animation curve
  28074. * @param gradient Scalar amount to interpolate
  28075. * @returns Interpolated Size value
  28076. */
  28077. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28078. /**
  28079. * Interpolates a Color3 linearly
  28080. * @param startValue Start value of the animation curve
  28081. * @param endValue End value of the animation curve
  28082. * @param gradient Scalar amount to interpolate
  28083. * @returns Interpolated Color3 value
  28084. */
  28085. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28086. /**
  28087. * @hidden Internal use only
  28088. */
  28089. _getKeyValue(value: any): any;
  28090. /**
  28091. * @hidden Internal use only
  28092. */
  28093. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28094. /**
  28095. * Defines the function to use to interpolate matrices
  28096. * @param startValue defines the start matrix
  28097. * @param endValue defines the end matrix
  28098. * @param gradient defines the gradient between both matrices
  28099. * @param result defines an optional target matrix where to store the interpolation
  28100. * @returns the interpolated matrix
  28101. */
  28102. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28103. /**
  28104. * Makes a copy of the animation
  28105. * @returns Cloned animation
  28106. */
  28107. clone(): Animation;
  28108. /**
  28109. * Sets the key frames of the animation
  28110. * @param values The animation key frames to set
  28111. */
  28112. setKeys(values: Array<IAnimationKey>): void;
  28113. /**
  28114. * Serializes the animation to an object
  28115. * @returns Serialized object
  28116. */
  28117. serialize(): any;
  28118. /**
  28119. * Float animation type
  28120. */
  28121. private static _ANIMATIONTYPE_FLOAT;
  28122. /**
  28123. * Vector3 animation type
  28124. */
  28125. private static _ANIMATIONTYPE_VECTOR3;
  28126. /**
  28127. * Quaternion animation type
  28128. */
  28129. private static _ANIMATIONTYPE_QUATERNION;
  28130. /**
  28131. * Matrix animation type
  28132. */
  28133. private static _ANIMATIONTYPE_MATRIX;
  28134. /**
  28135. * Color3 animation type
  28136. */
  28137. private static _ANIMATIONTYPE_COLOR3;
  28138. /**
  28139. * Vector2 animation type
  28140. */
  28141. private static _ANIMATIONTYPE_VECTOR2;
  28142. /**
  28143. * Size animation type
  28144. */
  28145. private static _ANIMATIONTYPE_SIZE;
  28146. /**
  28147. * Relative Loop Mode
  28148. */
  28149. private static _ANIMATIONLOOPMODE_RELATIVE;
  28150. /**
  28151. * Cycle Loop Mode
  28152. */
  28153. private static _ANIMATIONLOOPMODE_CYCLE;
  28154. /**
  28155. * Constant Loop Mode
  28156. */
  28157. private static _ANIMATIONLOOPMODE_CONSTANT;
  28158. /**
  28159. * Get the float animation type
  28160. */
  28161. static readonly ANIMATIONTYPE_FLOAT: number;
  28162. /**
  28163. * Get the Vector3 animation type
  28164. */
  28165. static readonly ANIMATIONTYPE_VECTOR3: number;
  28166. /**
  28167. * Get the Vector2 animation type
  28168. */
  28169. static readonly ANIMATIONTYPE_VECTOR2: number;
  28170. /**
  28171. * Get the Size animation type
  28172. */
  28173. static readonly ANIMATIONTYPE_SIZE: number;
  28174. /**
  28175. * Get the Quaternion animation type
  28176. */
  28177. static readonly ANIMATIONTYPE_QUATERNION: number;
  28178. /**
  28179. * Get the Matrix animation type
  28180. */
  28181. static readonly ANIMATIONTYPE_MATRIX: number;
  28182. /**
  28183. * Get the Color3 animation type
  28184. */
  28185. static readonly ANIMATIONTYPE_COLOR3: number;
  28186. /**
  28187. * Get the Relative Loop Mode
  28188. */
  28189. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28190. /**
  28191. * Get the Cycle Loop Mode
  28192. */
  28193. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28194. /**
  28195. * Get the Constant Loop Mode
  28196. */
  28197. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28198. /** @hidden */
  28199. static _UniversalLerp(left: any, right: any, amount: number): any;
  28200. /**
  28201. * Parses an animation object and creates an animation
  28202. * @param parsedAnimation Parsed animation object
  28203. * @returns Animation object
  28204. */
  28205. static Parse(parsedAnimation: any): Animation;
  28206. /**
  28207. * Appends the serialized animations from the source animations
  28208. * @param source Source containing the animations
  28209. * @param destination Target to store the animations
  28210. */
  28211. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28212. }
  28213. }
  28214. declare module "babylonjs/Animations/animatable.interface" {
  28215. import { Nullable } from "babylonjs/types";
  28216. import { Animation } from "babylonjs/Animations/animation";
  28217. /**
  28218. * Interface containing an array of animations
  28219. */
  28220. export interface IAnimatable {
  28221. /**
  28222. * Array of animations
  28223. */
  28224. animations: Nullable<Array<Animation>>;
  28225. }
  28226. }
  28227. declare module "babylonjs/Materials/fresnelParameters" {
  28228. import { Color3 } from "babylonjs/Maths/math.color";
  28229. /**
  28230. * This represents all the required information to add a fresnel effect on a material:
  28231. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28232. */
  28233. export class FresnelParameters {
  28234. private _isEnabled;
  28235. /**
  28236. * Define if the fresnel effect is enable or not.
  28237. */
  28238. isEnabled: boolean;
  28239. /**
  28240. * Define the color used on edges (grazing angle)
  28241. */
  28242. leftColor: Color3;
  28243. /**
  28244. * Define the color used on center
  28245. */
  28246. rightColor: Color3;
  28247. /**
  28248. * Define bias applied to computed fresnel term
  28249. */
  28250. bias: number;
  28251. /**
  28252. * Defined the power exponent applied to fresnel term
  28253. */
  28254. power: number;
  28255. /**
  28256. * Clones the current fresnel and its valuues
  28257. * @returns a clone fresnel configuration
  28258. */
  28259. clone(): FresnelParameters;
  28260. /**
  28261. * Serializes the current fresnel parameters to a JSON representation.
  28262. * @return the JSON serialization
  28263. */
  28264. serialize(): any;
  28265. /**
  28266. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28267. * @param parsedFresnelParameters Define the JSON representation
  28268. * @returns the parsed parameters
  28269. */
  28270. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28271. }
  28272. }
  28273. declare module "babylonjs/Misc/decorators" {
  28274. import { Nullable } from "babylonjs/types";
  28275. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28276. import { Scene } from "babylonjs/scene";
  28277. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28278. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28279. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28280. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28281. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28282. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28283. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28284. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28285. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28286. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28287. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28288. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28289. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28290. /**
  28291. * Decorator used to define property that can be serialized as reference to a camera
  28292. * @param sourceName defines the name of the property to decorate
  28293. */
  28294. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28295. /**
  28296. * Class used to help serialization objects
  28297. */
  28298. export class SerializationHelper {
  28299. /** @hidden */
  28300. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28301. /** @hidden */
  28302. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28303. /** @hidden */
  28304. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28305. /** @hidden */
  28306. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28307. /**
  28308. * Appends the serialized animations from the source animations
  28309. * @param source Source containing the animations
  28310. * @param destination Target to store the animations
  28311. */
  28312. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28313. /**
  28314. * Static function used to serialized a specific entity
  28315. * @param entity defines the entity to serialize
  28316. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28317. * @returns a JSON compatible object representing the serialization of the entity
  28318. */
  28319. static Serialize<T>(entity: T, serializationObject?: any): any;
  28320. /**
  28321. * Creates a new entity from a serialization data object
  28322. * @param creationFunction defines a function used to instanciated the new entity
  28323. * @param source defines the source serialization data
  28324. * @param scene defines the hosting scene
  28325. * @param rootUrl defines the root url for resources
  28326. * @returns a new entity
  28327. */
  28328. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28329. /**
  28330. * Clones an object
  28331. * @param creationFunction defines the function used to instanciate the new object
  28332. * @param source defines the source object
  28333. * @returns the cloned object
  28334. */
  28335. static Clone<T>(creationFunction: () => T, source: T): T;
  28336. /**
  28337. * Instanciates a new object based on a source one (some data will be shared between both object)
  28338. * @param creationFunction defines the function used to instanciate the new object
  28339. * @param source defines the source object
  28340. * @returns the new object
  28341. */
  28342. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28343. }
  28344. }
  28345. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28346. import { Nullable } from "babylonjs/types";
  28347. /**
  28348. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28349. */
  28350. export interface CubeMapInfo {
  28351. /**
  28352. * The pixel array for the front face.
  28353. * This is stored in format, left to right, up to down format.
  28354. */
  28355. front: Nullable<ArrayBufferView>;
  28356. /**
  28357. * The pixel array for the back face.
  28358. * This is stored in format, left to right, up to down format.
  28359. */
  28360. back: Nullable<ArrayBufferView>;
  28361. /**
  28362. * The pixel array for the left face.
  28363. * This is stored in format, left to right, up to down format.
  28364. */
  28365. left: Nullable<ArrayBufferView>;
  28366. /**
  28367. * The pixel array for the right face.
  28368. * This is stored in format, left to right, up to down format.
  28369. */
  28370. right: Nullable<ArrayBufferView>;
  28371. /**
  28372. * The pixel array for the up face.
  28373. * This is stored in format, left to right, up to down format.
  28374. */
  28375. up: Nullable<ArrayBufferView>;
  28376. /**
  28377. * The pixel array for the down face.
  28378. * This is stored in format, left to right, up to down format.
  28379. */
  28380. down: Nullable<ArrayBufferView>;
  28381. /**
  28382. * The size of the cubemap stored.
  28383. *
  28384. * Each faces will be size * size pixels.
  28385. */
  28386. size: number;
  28387. /**
  28388. * The format of the texture.
  28389. *
  28390. * RGBA, RGB.
  28391. */
  28392. format: number;
  28393. /**
  28394. * The type of the texture data.
  28395. *
  28396. * UNSIGNED_INT, FLOAT.
  28397. */
  28398. type: number;
  28399. /**
  28400. * Specifies whether the texture is in gamma space.
  28401. */
  28402. gammaSpace: boolean;
  28403. }
  28404. /**
  28405. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28406. */
  28407. export class PanoramaToCubeMapTools {
  28408. private static FACE_FRONT;
  28409. private static FACE_BACK;
  28410. private static FACE_RIGHT;
  28411. private static FACE_LEFT;
  28412. private static FACE_DOWN;
  28413. private static FACE_UP;
  28414. /**
  28415. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28416. *
  28417. * @param float32Array The source data.
  28418. * @param inputWidth The width of the input panorama.
  28419. * @param inputHeight The height of the input panorama.
  28420. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28421. * @return The cubemap data
  28422. */
  28423. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28424. private static CreateCubemapTexture;
  28425. private static CalcProjectionSpherical;
  28426. }
  28427. }
  28428. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28429. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28431. import { Nullable } from "babylonjs/types";
  28432. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28433. /**
  28434. * Helper class dealing with the extraction of spherical polynomial dataArray
  28435. * from a cube map.
  28436. */
  28437. export class CubeMapToSphericalPolynomialTools {
  28438. private static FileFaces;
  28439. /**
  28440. * Converts a texture to the according Spherical Polynomial data.
  28441. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28442. *
  28443. * @param texture The texture to extract the information from.
  28444. * @return The Spherical Polynomial data.
  28445. */
  28446. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28447. /**
  28448. * Converts a cubemap to the according Spherical Polynomial data.
  28449. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28450. *
  28451. * @param cubeInfo The Cube map to extract the information from.
  28452. * @return The Spherical Polynomial data.
  28453. */
  28454. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28455. }
  28456. }
  28457. declare module "babylonjs/Misc/guid" {
  28458. /**
  28459. * Class used to manipulate GUIDs
  28460. */
  28461. export class GUID {
  28462. /**
  28463. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28464. * Be aware Math.random() could cause collisions, but:
  28465. * "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"
  28466. * @returns a pseudo random id
  28467. */
  28468. static RandomId(): string;
  28469. }
  28470. }
  28471. declare module "babylonjs/Materials/Textures/baseTexture" {
  28472. import { Observable } from "babylonjs/Misc/observable";
  28473. import { Nullable } from "babylonjs/types";
  28474. import { Scene } from "babylonjs/scene";
  28475. import { Matrix } from "babylonjs/Maths/math.vector";
  28476. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28478. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28479. import { ISize } from "babylonjs/Maths/math.size";
  28480. /**
  28481. * Base class of all the textures in babylon.
  28482. * It groups all the common properties the materials, post process, lights... might need
  28483. * in order to make a correct use of the texture.
  28484. */
  28485. export class BaseTexture implements IAnimatable {
  28486. /**
  28487. * Default anisotropic filtering level for the application.
  28488. * It is set to 4 as a good tradeoff between perf and quality.
  28489. */
  28490. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28491. /**
  28492. * Gets or sets the unique id of the texture
  28493. */
  28494. uniqueId: number;
  28495. /**
  28496. * Define the name of the texture.
  28497. */
  28498. name: string;
  28499. /**
  28500. * Gets or sets an object used to store user defined information.
  28501. */
  28502. metadata: any;
  28503. /**
  28504. * For internal use only. Please do not use.
  28505. */
  28506. reservedDataStore: any;
  28507. private _hasAlpha;
  28508. /**
  28509. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28510. */
  28511. hasAlpha: boolean;
  28512. /**
  28513. * Defines if the alpha value should be determined via the rgb values.
  28514. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28515. */
  28516. getAlphaFromRGB: boolean;
  28517. /**
  28518. * Intensity or strength of the texture.
  28519. * It is commonly used by materials to fine tune the intensity of the texture
  28520. */
  28521. level: number;
  28522. /**
  28523. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28524. * This is part of the texture as textures usually maps to one uv set.
  28525. */
  28526. coordinatesIndex: number;
  28527. private _coordinatesMode;
  28528. /**
  28529. * How a texture is mapped.
  28530. *
  28531. * | Value | Type | Description |
  28532. * | ----- | ----------------------------------- | ----------- |
  28533. * | 0 | EXPLICIT_MODE | |
  28534. * | 1 | SPHERICAL_MODE | |
  28535. * | 2 | PLANAR_MODE | |
  28536. * | 3 | CUBIC_MODE | |
  28537. * | 4 | PROJECTION_MODE | |
  28538. * | 5 | SKYBOX_MODE | |
  28539. * | 6 | INVCUBIC_MODE | |
  28540. * | 7 | EQUIRECTANGULAR_MODE | |
  28541. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28542. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28543. */
  28544. coordinatesMode: number;
  28545. /**
  28546. * | Value | Type | Description |
  28547. * | ----- | ------------------ | ----------- |
  28548. * | 0 | CLAMP_ADDRESSMODE | |
  28549. * | 1 | WRAP_ADDRESSMODE | |
  28550. * | 2 | MIRROR_ADDRESSMODE | |
  28551. */
  28552. wrapU: number;
  28553. /**
  28554. * | Value | Type | Description |
  28555. * | ----- | ------------------ | ----------- |
  28556. * | 0 | CLAMP_ADDRESSMODE | |
  28557. * | 1 | WRAP_ADDRESSMODE | |
  28558. * | 2 | MIRROR_ADDRESSMODE | |
  28559. */
  28560. wrapV: number;
  28561. /**
  28562. * | Value | Type | Description |
  28563. * | ----- | ------------------ | ----------- |
  28564. * | 0 | CLAMP_ADDRESSMODE | |
  28565. * | 1 | WRAP_ADDRESSMODE | |
  28566. * | 2 | MIRROR_ADDRESSMODE | |
  28567. */
  28568. wrapR: number;
  28569. /**
  28570. * With compliant hardware and browser (supporting anisotropic filtering)
  28571. * this defines the level of anisotropic filtering in the texture.
  28572. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28573. */
  28574. anisotropicFilteringLevel: number;
  28575. /**
  28576. * Define if the texture is a cube texture or if false a 2d texture.
  28577. */
  28578. isCube: boolean;
  28579. /**
  28580. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28581. */
  28582. is3D: boolean;
  28583. /**
  28584. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28585. * HDR texture are usually stored in linear space.
  28586. * This only impacts the PBR and Background materials
  28587. */
  28588. gammaSpace: boolean;
  28589. /**
  28590. * Gets or sets whether or not the texture contains RGBD data.
  28591. */
  28592. isRGBD: boolean;
  28593. /**
  28594. * Is Z inverted in the texture (useful in a cube texture).
  28595. */
  28596. invertZ: boolean;
  28597. /**
  28598. * Are mip maps generated for this texture or not.
  28599. */
  28600. readonly noMipmap: boolean;
  28601. /**
  28602. * @hidden
  28603. */
  28604. lodLevelInAlpha: boolean;
  28605. /**
  28606. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28607. */
  28608. lodGenerationOffset: number;
  28609. /**
  28610. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28611. */
  28612. lodGenerationScale: number;
  28613. /**
  28614. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28615. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28616. * average roughness values.
  28617. */
  28618. linearSpecularLOD: boolean;
  28619. /**
  28620. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28621. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28622. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28623. */
  28624. irradianceTexture: Nullable<BaseTexture>;
  28625. /**
  28626. * Define if the texture is a render target.
  28627. */
  28628. isRenderTarget: boolean;
  28629. /**
  28630. * Define the unique id of the texture in the scene.
  28631. */
  28632. readonly uid: string;
  28633. /**
  28634. * Return a string representation of the texture.
  28635. * @returns the texture as a string
  28636. */
  28637. toString(): string;
  28638. /**
  28639. * Get the class name of the texture.
  28640. * @returns "BaseTexture"
  28641. */
  28642. getClassName(): string;
  28643. /**
  28644. * Define the list of animation attached to the texture.
  28645. */
  28646. animations: import("babylonjs/Animations/animation").Animation[];
  28647. /**
  28648. * An event triggered when the texture is disposed.
  28649. */
  28650. onDisposeObservable: Observable<BaseTexture>;
  28651. private _onDisposeObserver;
  28652. /**
  28653. * Callback triggered when the texture has been disposed.
  28654. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28655. */
  28656. onDispose: () => void;
  28657. /**
  28658. * Define the current state of the loading sequence when in delayed load mode.
  28659. */
  28660. delayLoadState: number;
  28661. private _scene;
  28662. /** @hidden */
  28663. _texture: Nullable<InternalTexture>;
  28664. private _uid;
  28665. /**
  28666. * Define if the texture is preventinga material to render or not.
  28667. * If not and the texture is not ready, the engine will use a default black texture instead.
  28668. */
  28669. readonly isBlocking: boolean;
  28670. /**
  28671. * Instantiates a new BaseTexture.
  28672. * Base class of all the textures in babylon.
  28673. * It groups all the common properties the materials, post process, lights... might need
  28674. * in order to make a correct use of the texture.
  28675. * @param scene Define the scene the texture blongs to
  28676. */
  28677. constructor(scene: Nullable<Scene>);
  28678. /**
  28679. * Get the scene the texture belongs to.
  28680. * @returns the scene or null if undefined
  28681. */
  28682. getScene(): Nullable<Scene>;
  28683. /**
  28684. * Get the texture transform matrix used to offset tile the texture for istance.
  28685. * @returns the transformation matrix
  28686. */
  28687. getTextureMatrix(): Matrix;
  28688. /**
  28689. * Get the texture reflection matrix used to rotate/transform the reflection.
  28690. * @returns the reflection matrix
  28691. */
  28692. getReflectionTextureMatrix(): Matrix;
  28693. /**
  28694. * Get the underlying lower level texture from Babylon.
  28695. * @returns the insternal texture
  28696. */
  28697. getInternalTexture(): Nullable<InternalTexture>;
  28698. /**
  28699. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28700. * @returns true if ready or not blocking
  28701. */
  28702. isReadyOrNotBlocking(): boolean;
  28703. /**
  28704. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28705. * @returns true if fully ready
  28706. */
  28707. isReady(): boolean;
  28708. private _cachedSize;
  28709. /**
  28710. * Get the size of the texture.
  28711. * @returns the texture size.
  28712. */
  28713. getSize(): ISize;
  28714. /**
  28715. * Get the base size of the texture.
  28716. * It can be different from the size if the texture has been resized for POT for instance
  28717. * @returns the base size
  28718. */
  28719. getBaseSize(): ISize;
  28720. /**
  28721. * Update the sampling mode of the texture.
  28722. * Default is Trilinear mode.
  28723. *
  28724. * | Value | Type | Description |
  28725. * | ----- | ------------------ | ----------- |
  28726. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28727. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28728. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28729. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28730. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28731. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28732. * | 7 | NEAREST_LINEAR | |
  28733. * | 8 | NEAREST_NEAREST | |
  28734. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28735. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28736. * | 11 | LINEAR_LINEAR | |
  28737. * | 12 | LINEAR_NEAREST | |
  28738. *
  28739. * > _mag_: magnification filter (close to the viewer)
  28740. * > _min_: minification filter (far from the viewer)
  28741. * > _mip_: filter used between mip map levels
  28742. *@param samplingMode Define the new sampling mode of the texture
  28743. */
  28744. updateSamplingMode(samplingMode: number): void;
  28745. /**
  28746. * Scales the texture if is `canRescale()`
  28747. * @param ratio the resize factor we want to use to rescale
  28748. */
  28749. scale(ratio: number): void;
  28750. /**
  28751. * Get if the texture can rescale.
  28752. */
  28753. readonly canRescale: boolean;
  28754. /** @hidden */
  28755. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28756. /** @hidden */
  28757. _rebuild(): void;
  28758. /**
  28759. * Triggers the load sequence in delayed load mode.
  28760. */
  28761. delayLoad(): void;
  28762. /**
  28763. * Clones the texture.
  28764. * @returns the cloned texture
  28765. */
  28766. clone(): Nullable<BaseTexture>;
  28767. /**
  28768. * Get the texture underlying type (INT, FLOAT...)
  28769. */
  28770. readonly textureType: number;
  28771. /**
  28772. * Get the texture underlying format (RGB, RGBA...)
  28773. */
  28774. readonly textureFormat: number;
  28775. /**
  28776. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28777. * This will returns an RGBA array buffer containing either in values (0-255) or
  28778. * float values (0-1) depending of the underlying buffer type.
  28779. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28780. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28781. * @param buffer defines a user defined buffer to fill with data (can be null)
  28782. * @returns The Array buffer containing the pixels data.
  28783. */
  28784. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28785. /**
  28786. * Release and destroy the underlying lower level texture aka internalTexture.
  28787. */
  28788. releaseInternalTexture(): void;
  28789. /**
  28790. * Get the polynomial representation of the texture data.
  28791. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28792. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28793. */
  28794. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28795. /** @hidden */
  28796. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28797. /** @hidden */
  28798. readonly _lodTextureMid: Nullable<BaseTexture>;
  28799. /** @hidden */
  28800. readonly _lodTextureLow: Nullable<BaseTexture>;
  28801. /**
  28802. * Dispose the texture and release its associated resources.
  28803. */
  28804. dispose(): void;
  28805. /**
  28806. * Serialize the texture into a JSON representation that can be parsed later on.
  28807. * @returns the JSON representation of the texture
  28808. */
  28809. serialize(): any;
  28810. /**
  28811. * Helper function to be called back once a list of texture contains only ready textures.
  28812. * @param textures Define the list of textures to wait for
  28813. * @param callback Define the callback triggered once the entire list will be ready
  28814. */
  28815. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28816. }
  28817. }
  28818. declare module "babylonjs/Materials/Textures/internalTexture" {
  28819. import { Observable } from "babylonjs/Misc/observable";
  28820. import { Nullable, int } from "babylonjs/types";
  28821. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28822. import { Engine } from "babylonjs/Engines/engine";
  28823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28824. /**
  28825. * Class used to store data associated with WebGL texture data for the engine
  28826. * This class should not be used directly
  28827. */
  28828. export class InternalTexture {
  28829. /** @hidden */
  28830. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28831. /**
  28832. * The source of the texture data is unknown
  28833. */
  28834. static DATASOURCE_UNKNOWN: number;
  28835. /**
  28836. * Texture data comes from an URL
  28837. */
  28838. static DATASOURCE_URL: number;
  28839. /**
  28840. * Texture data is only used for temporary storage
  28841. */
  28842. static DATASOURCE_TEMP: number;
  28843. /**
  28844. * Texture data comes from raw data (ArrayBuffer)
  28845. */
  28846. static DATASOURCE_RAW: number;
  28847. /**
  28848. * Texture content is dynamic (video or dynamic texture)
  28849. */
  28850. static DATASOURCE_DYNAMIC: number;
  28851. /**
  28852. * Texture content is generated by rendering to it
  28853. */
  28854. static DATASOURCE_RENDERTARGET: number;
  28855. /**
  28856. * Texture content is part of a multi render target process
  28857. */
  28858. static DATASOURCE_MULTIRENDERTARGET: number;
  28859. /**
  28860. * Texture data comes from a cube data file
  28861. */
  28862. static DATASOURCE_CUBE: number;
  28863. /**
  28864. * Texture data comes from a raw cube data
  28865. */
  28866. static DATASOURCE_CUBERAW: number;
  28867. /**
  28868. * Texture data come from a prefiltered cube data file
  28869. */
  28870. static DATASOURCE_CUBEPREFILTERED: number;
  28871. /**
  28872. * Texture content is raw 3D data
  28873. */
  28874. static DATASOURCE_RAW3D: number;
  28875. /**
  28876. * Texture content is a depth texture
  28877. */
  28878. static DATASOURCE_DEPTHTEXTURE: number;
  28879. /**
  28880. * Texture data comes from a raw cube data encoded with RGBD
  28881. */
  28882. static DATASOURCE_CUBERAW_RGBD: number;
  28883. /**
  28884. * Defines if the texture is ready
  28885. */
  28886. isReady: boolean;
  28887. /**
  28888. * Defines if the texture is a cube texture
  28889. */
  28890. isCube: boolean;
  28891. /**
  28892. * Defines if the texture contains 3D data
  28893. */
  28894. is3D: boolean;
  28895. /**
  28896. * Defines if the texture contains multiview data
  28897. */
  28898. isMultiview: boolean;
  28899. /**
  28900. * Gets the URL used to load this texture
  28901. */
  28902. url: string;
  28903. /**
  28904. * Gets the sampling mode of the texture
  28905. */
  28906. samplingMode: number;
  28907. /**
  28908. * Gets a boolean indicating if the texture needs mipmaps generation
  28909. */
  28910. generateMipMaps: boolean;
  28911. /**
  28912. * Gets the number of samples used by the texture (WebGL2+ only)
  28913. */
  28914. samples: number;
  28915. /**
  28916. * Gets the type of the texture (int, float...)
  28917. */
  28918. type: number;
  28919. /**
  28920. * Gets the format of the texture (RGB, RGBA...)
  28921. */
  28922. format: number;
  28923. /**
  28924. * Observable called when the texture is loaded
  28925. */
  28926. onLoadedObservable: Observable<InternalTexture>;
  28927. /**
  28928. * Gets the width of the texture
  28929. */
  28930. width: number;
  28931. /**
  28932. * Gets the height of the texture
  28933. */
  28934. height: number;
  28935. /**
  28936. * Gets the depth of the texture
  28937. */
  28938. depth: number;
  28939. /**
  28940. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28941. */
  28942. baseWidth: number;
  28943. /**
  28944. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28945. */
  28946. baseHeight: number;
  28947. /**
  28948. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28949. */
  28950. baseDepth: number;
  28951. /**
  28952. * Gets a boolean indicating if the texture is inverted on Y axis
  28953. */
  28954. invertY: boolean;
  28955. /** @hidden */
  28956. _invertVScale: boolean;
  28957. /** @hidden */
  28958. _associatedChannel: number;
  28959. /** @hidden */
  28960. _dataSource: number;
  28961. /** @hidden */
  28962. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28963. /** @hidden */
  28964. _bufferView: Nullable<ArrayBufferView>;
  28965. /** @hidden */
  28966. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28967. /** @hidden */
  28968. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28969. /** @hidden */
  28970. _size: number;
  28971. /** @hidden */
  28972. _extension: string;
  28973. /** @hidden */
  28974. _files: Nullable<string[]>;
  28975. /** @hidden */
  28976. _workingCanvas: Nullable<HTMLCanvasElement>;
  28977. /** @hidden */
  28978. _workingContext: Nullable<CanvasRenderingContext2D>;
  28979. /** @hidden */
  28980. _framebuffer: Nullable<WebGLFramebuffer>;
  28981. /** @hidden */
  28982. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28983. /** @hidden */
  28984. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28985. /** @hidden */
  28986. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28987. /** @hidden */
  28988. _attachments: Nullable<number[]>;
  28989. /** @hidden */
  28990. _cachedCoordinatesMode: Nullable<number>;
  28991. /** @hidden */
  28992. _cachedWrapU: Nullable<number>;
  28993. /** @hidden */
  28994. _cachedWrapV: Nullable<number>;
  28995. /** @hidden */
  28996. _cachedWrapR: Nullable<number>;
  28997. /** @hidden */
  28998. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28999. /** @hidden */
  29000. _isDisabled: boolean;
  29001. /** @hidden */
  29002. _compression: Nullable<string>;
  29003. /** @hidden */
  29004. _generateStencilBuffer: boolean;
  29005. /** @hidden */
  29006. _generateDepthBuffer: boolean;
  29007. /** @hidden */
  29008. _comparisonFunction: number;
  29009. /** @hidden */
  29010. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29011. /** @hidden */
  29012. _lodGenerationScale: number;
  29013. /** @hidden */
  29014. _lodGenerationOffset: number;
  29015. /** @hidden */
  29016. _colorTextureArray: Nullable<WebGLTexture>;
  29017. /** @hidden */
  29018. _depthStencilTextureArray: Nullable<WebGLTexture>;
  29019. /** @hidden */
  29020. _lodTextureHigh: Nullable<BaseTexture>;
  29021. /** @hidden */
  29022. _lodTextureMid: Nullable<BaseTexture>;
  29023. /** @hidden */
  29024. _lodTextureLow: Nullable<BaseTexture>;
  29025. /** @hidden */
  29026. _isRGBD: boolean;
  29027. /** @hidden */
  29028. _linearSpecularLOD: boolean;
  29029. /** @hidden */
  29030. _irradianceTexture: Nullable<BaseTexture>;
  29031. /** @hidden */
  29032. _webGLTexture: Nullable<WebGLTexture>;
  29033. /** @hidden */
  29034. _references: number;
  29035. private _engine;
  29036. /**
  29037. * Gets the Engine the texture belongs to.
  29038. * @returns The babylon engine
  29039. */
  29040. getEngine(): Engine;
  29041. /**
  29042. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  29043. */
  29044. readonly dataSource: number;
  29045. /**
  29046. * Creates a new InternalTexture
  29047. * @param engine defines the engine to use
  29048. * @param dataSource defines the type of data that will be used
  29049. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29050. */
  29051. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  29052. /**
  29053. * Increments the number of references (ie. the number of Texture that point to it)
  29054. */
  29055. incrementReferences(): void;
  29056. /**
  29057. * Change the size of the texture (not the size of the content)
  29058. * @param width defines the new width
  29059. * @param height defines the new height
  29060. * @param depth defines the new depth (1 by default)
  29061. */
  29062. updateSize(width: int, height: int, depth?: int): void;
  29063. /** @hidden */
  29064. _rebuild(): void;
  29065. /** @hidden */
  29066. _swapAndDie(target: InternalTexture): void;
  29067. /**
  29068. * Dispose the current allocated resources
  29069. */
  29070. dispose(): void;
  29071. }
  29072. }
  29073. declare module "babylonjs/Materials/effect" {
  29074. import { Observable } from "babylonjs/Misc/observable";
  29075. import { Nullable } from "babylonjs/types";
  29076. import { IDisposable } from "babylonjs/scene";
  29077. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29078. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29079. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29080. import { Engine } from "babylonjs/Engines/engine";
  29081. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29084. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29086. /**
  29087. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29088. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29089. */
  29090. export class EffectFallbacks {
  29091. private _defines;
  29092. private _currentRank;
  29093. private _maxRank;
  29094. private _mesh;
  29095. /**
  29096. * Removes the fallback from the bound mesh.
  29097. */
  29098. unBindMesh(): void;
  29099. /**
  29100. * Adds a fallback on the specified property.
  29101. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29102. * @param define The name of the define in the shader
  29103. */
  29104. addFallback(rank: number, define: string): void;
  29105. /**
  29106. * Sets the mesh to use CPU skinning when needing to fallback.
  29107. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29108. * @param mesh The mesh to use the fallbacks.
  29109. */
  29110. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29111. /**
  29112. * Checks to see if more fallbacks are still availible.
  29113. */
  29114. readonly hasMoreFallbacks: boolean;
  29115. /**
  29116. * Removes the defines that should be removed when falling back.
  29117. * @param currentDefines defines the current define statements for the shader.
  29118. * @param effect defines the current effect we try to compile
  29119. * @returns The resulting defines with defines of the current rank removed.
  29120. */
  29121. reduce(currentDefines: string, effect: Effect): string;
  29122. }
  29123. /**
  29124. * Options to be used when creating an effect.
  29125. */
  29126. export class EffectCreationOptions {
  29127. /**
  29128. * Atrributes that will be used in the shader.
  29129. */
  29130. attributes: string[];
  29131. /**
  29132. * Uniform varible names that will be set in the shader.
  29133. */
  29134. uniformsNames: string[];
  29135. /**
  29136. * Uniform buffer varible names that will be set in the shader.
  29137. */
  29138. uniformBuffersNames: string[];
  29139. /**
  29140. * Sampler texture variable names that will be set in the shader.
  29141. */
  29142. samplers: string[];
  29143. /**
  29144. * Define statements that will be set in the shader.
  29145. */
  29146. defines: any;
  29147. /**
  29148. * Possible fallbacks for this effect to improve performance when needed.
  29149. */
  29150. fallbacks: Nullable<EffectFallbacks>;
  29151. /**
  29152. * Callback that will be called when the shader is compiled.
  29153. */
  29154. onCompiled: Nullable<(effect: Effect) => void>;
  29155. /**
  29156. * Callback that will be called if an error occurs during shader compilation.
  29157. */
  29158. onError: Nullable<(effect: Effect, errors: string) => void>;
  29159. /**
  29160. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29161. */
  29162. indexParameters: any;
  29163. /**
  29164. * Max number of lights that can be used in the shader.
  29165. */
  29166. maxSimultaneousLights: number;
  29167. /**
  29168. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29169. */
  29170. transformFeedbackVaryings: Nullable<string[]>;
  29171. }
  29172. /**
  29173. * Effect containing vertex and fragment shader that can be executed on an object.
  29174. */
  29175. export class Effect implements IDisposable {
  29176. /**
  29177. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29178. */
  29179. static ShadersRepository: string;
  29180. /**
  29181. * Name of the effect.
  29182. */
  29183. name: any;
  29184. /**
  29185. * String container all the define statements that should be set on the shader.
  29186. */
  29187. defines: string;
  29188. /**
  29189. * Callback that will be called when the shader is compiled.
  29190. */
  29191. onCompiled: Nullable<(effect: Effect) => void>;
  29192. /**
  29193. * Callback that will be called if an error occurs during shader compilation.
  29194. */
  29195. onError: Nullable<(effect: Effect, errors: string) => void>;
  29196. /**
  29197. * Callback that will be called when effect is bound.
  29198. */
  29199. onBind: Nullable<(effect: Effect) => void>;
  29200. /**
  29201. * Unique ID of the effect.
  29202. */
  29203. uniqueId: number;
  29204. /**
  29205. * Observable that will be called when the shader is compiled.
  29206. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29207. */
  29208. onCompileObservable: Observable<Effect>;
  29209. /**
  29210. * Observable that will be called if an error occurs during shader compilation.
  29211. */
  29212. onErrorObservable: Observable<Effect>;
  29213. /** @hidden */
  29214. _onBindObservable: Nullable<Observable<Effect>>;
  29215. /**
  29216. * Observable that will be called when effect is bound.
  29217. */
  29218. readonly onBindObservable: Observable<Effect>;
  29219. /** @hidden */
  29220. _bonesComputationForcedToCPU: boolean;
  29221. private static _uniqueIdSeed;
  29222. private _engine;
  29223. private _uniformBuffersNames;
  29224. private _uniformsNames;
  29225. private _samplerList;
  29226. private _samplers;
  29227. private _isReady;
  29228. private _compilationError;
  29229. private _attributesNames;
  29230. private _attributes;
  29231. private _uniforms;
  29232. /**
  29233. * Key for the effect.
  29234. * @hidden
  29235. */
  29236. _key: string;
  29237. private _indexParameters;
  29238. private _fallbacks;
  29239. private _vertexSourceCode;
  29240. private _fragmentSourceCode;
  29241. private _vertexSourceCodeOverride;
  29242. private _fragmentSourceCodeOverride;
  29243. private _transformFeedbackVaryings;
  29244. /**
  29245. * Compiled shader to webGL program.
  29246. * @hidden
  29247. */
  29248. _pipelineContext: Nullable<IPipelineContext>;
  29249. private _valueCache;
  29250. private static _baseCache;
  29251. /**
  29252. * Instantiates an effect.
  29253. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29254. * @param baseName Name of the effect.
  29255. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29256. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29257. * @param samplers List of sampler variables that will be passed to the shader.
  29258. * @param engine Engine to be used to render the effect
  29259. * @param defines Define statements to be added to the shader.
  29260. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29261. * @param onCompiled Callback that will be called when the shader is compiled.
  29262. * @param onError Callback that will be called if an error occurs during shader compilation.
  29263. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29264. */
  29265. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29266. private _useFinalCode;
  29267. /**
  29268. * Unique key for this effect
  29269. */
  29270. readonly key: string;
  29271. /**
  29272. * If the effect has been compiled and prepared.
  29273. * @returns if the effect is compiled and prepared.
  29274. */
  29275. isReady(): boolean;
  29276. private _isReadyInternal;
  29277. /**
  29278. * The engine the effect was initialized with.
  29279. * @returns the engine.
  29280. */
  29281. getEngine(): Engine;
  29282. /**
  29283. * The pipeline context for this effect
  29284. * @returns the associated pipeline context
  29285. */
  29286. getPipelineContext(): Nullable<IPipelineContext>;
  29287. /**
  29288. * The set of names of attribute variables for the shader.
  29289. * @returns An array of attribute names.
  29290. */
  29291. getAttributesNames(): string[];
  29292. /**
  29293. * Returns the attribute at the given index.
  29294. * @param index The index of the attribute.
  29295. * @returns The location of the attribute.
  29296. */
  29297. getAttributeLocation(index: number): number;
  29298. /**
  29299. * Returns the attribute based on the name of the variable.
  29300. * @param name of the attribute to look up.
  29301. * @returns the attribute location.
  29302. */
  29303. getAttributeLocationByName(name: string): number;
  29304. /**
  29305. * The number of attributes.
  29306. * @returns the numnber of attributes.
  29307. */
  29308. getAttributesCount(): number;
  29309. /**
  29310. * Gets the index of a uniform variable.
  29311. * @param uniformName of the uniform to look up.
  29312. * @returns the index.
  29313. */
  29314. getUniformIndex(uniformName: string): number;
  29315. /**
  29316. * Returns the attribute based on the name of the variable.
  29317. * @param uniformName of the uniform to look up.
  29318. * @returns the location of the uniform.
  29319. */
  29320. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29321. /**
  29322. * Returns an array of sampler variable names
  29323. * @returns The array of sampler variable neames.
  29324. */
  29325. getSamplers(): string[];
  29326. /**
  29327. * The error from the last compilation.
  29328. * @returns the error string.
  29329. */
  29330. getCompilationError(): string;
  29331. /**
  29332. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29333. * @param func The callback to be used.
  29334. */
  29335. executeWhenCompiled(func: (effect: Effect) => void): void;
  29336. private _checkIsReady;
  29337. /** @hidden */
  29338. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29339. /** @hidden */
  29340. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29341. /** @hidden */
  29342. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29343. /**
  29344. * Recompiles the webGL program
  29345. * @param vertexSourceCode The source code for the vertex shader.
  29346. * @param fragmentSourceCode The source code for the fragment shader.
  29347. * @param onCompiled Callback called when completed.
  29348. * @param onError Callback called on error.
  29349. * @hidden
  29350. */
  29351. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29352. /**
  29353. * Prepares the effect
  29354. * @hidden
  29355. */
  29356. _prepareEffect(): void;
  29357. private _processCompilationErrors;
  29358. /**
  29359. * Checks if the effect is supported. (Must be called after compilation)
  29360. */
  29361. readonly isSupported: boolean;
  29362. /**
  29363. * Binds a texture to the engine to be used as output of the shader.
  29364. * @param channel Name of the output variable.
  29365. * @param texture Texture to bind.
  29366. * @hidden
  29367. */
  29368. _bindTexture(channel: string, texture: InternalTexture): void;
  29369. /**
  29370. * Sets a texture on the engine to be used in the shader.
  29371. * @param channel Name of the sampler variable.
  29372. * @param texture Texture to set.
  29373. */
  29374. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29375. /**
  29376. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29377. * @param channel Name of the sampler variable.
  29378. * @param texture Texture to set.
  29379. */
  29380. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29381. /**
  29382. * Sets an array of textures on the engine to be used in the shader.
  29383. * @param channel Name of the variable.
  29384. * @param textures Textures to set.
  29385. */
  29386. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29387. /**
  29388. * 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)
  29389. * @param channel Name of the sampler variable.
  29390. * @param postProcess Post process to get the input texture from.
  29391. */
  29392. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29393. /**
  29394. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29395. * 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)
  29396. * @param channel Name of the sampler variable.
  29397. * @param postProcess Post process to get the output texture from.
  29398. */
  29399. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29400. /** @hidden */
  29401. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29402. /** @hidden */
  29403. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29404. /** @hidden */
  29405. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29406. /** @hidden */
  29407. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29408. /**
  29409. * Binds a buffer to a uniform.
  29410. * @param buffer Buffer to bind.
  29411. * @param name Name of the uniform variable to bind to.
  29412. */
  29413. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29414. /**
  29415. * Binds block to a uniform.
  29416. * @param blockName Name of the block to bind.
  29417. * @param index Index to bind.
  29418. */
  29419. bindUniformBlock(blockName: string, index: number): void;
  29420. /**
  29421. * Sets an interger value on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param value Value to be set.
  29424. * @returns this effect.
  29425. */
  29426. setInt(uniformName: string, value: number): Effect;
  29427. /**
  29428. * Sets an int array on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param array array to be set.
  29431. * @returns this effect.
  29432. */
  29433. setIntArray(uniformName: string, array: Int32Array): Effect;
  29434. /**
  29435. * 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)
  29436. * @param uniformName Name of the variable.
  29437. * @param array array to be set.
  29438. * @returns this effect.
  29439. */
  29440. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29441. /**
  29442. * 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)
  29443. * @param uniformName Name of the variable.
  29444. * @param array array to be set.
  29445. * @returns this effect.
  29446. */
  29447. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29448. /**
  29449. * 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)
  29450. * @param uniformName Name of the variable.
  29451. * @param array array to be set.
  29452. * @returns this effect.
  29453. */
  29454. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29455. /**
  29456. * Sets an float array on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param array array to be set.
  29459. * @returns this effect.
  29460. */
  29461. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29462. /**
  29463. * 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)
  29464. * @param uniformName Name of the variable.
  29465. * @param array array to be set.
  29466. * @returns this effect.
  29467. */
  29468. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29469. /**
  29470. * 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)
  29471. * @param uniformName Name of the variable.
  29472. * @param array array to be set.
  29473. * @returns this effect.
  29474. */
  29475. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29476. /**
  29477. * 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)
  29478. * @param uniformName Name of the variable.
  29479. * @param array array to be set.
  29480. * @returns this effect.
  29481. */
  29482. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29483. /**
  29484. * Sets an array on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param array array to be set.
  29487. * @returns this effect.
  29488. */
  29489. setArray(uniformName: string, array: number[]): Effect;
  29490. /**
  29491. * 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)
  29492. * @param uniformName Name of the variable.
  29493. * @param array array to be set.
  29494. * @returns this effect.
  29495. */
  29496. setArray2(uniformName: string, array: number[]): Effect;
  29497. /**
  29498. * 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)
  29499. * @param uniformName Name of the variable.
  29500. * @param array array to be set.
  29501. * @returns this effect.
  29502. */
  29503. setArray3(uniformName: string, array: number[]): Effect;
  29504. /**
  29505. * 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)
  29506. * @param uniformName Name of the variable.
  29507. * @param array array to be set.
  29508. * @returns this effect.
  29509. */
  29510. setArray4(uniformName: string, array: number[]): Effect;
  29511. /**
  29512. * Sets matrices on a uniform variable.
  29513. * @param uniformName Name of the variable.
  29514. * @param matrices matrices to be set.
  29515. * @returns this effect.
  29516. */
  29517. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29518. /**
  29519. * Sets matrix on a uniform variable.
  29520. * @param uniformName Name of the variable.
  29521. * @param matrix matrix to be set.
  29522. * @returns this effect.
  29523. */
  29524. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29525. /**
  29526. * 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)
  29527. * @param uniformName Name of the variable.
  29528. * @param matrix matrix to be set.
  29529. * @returns this effect.
  29530. */
  29531. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29532. /**
  29533. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29534. * @param uniformName Name of the variable.
  29535. * @param matrix matrix to be set.
  29536. * @returns this effect.
  29537. */
  29538. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29539. /**
  29540. * Sets a float on a uniform variable.
  29541. * @param uniformName Name of the variable.
  29542. * @param value value to be set.
  29543. * @returns this effect.
  29544. */
  29545. setFloat(uniformName: string, value: number): Effect;
  29546. /**
  29547. * Sets a boolean on a uniform variable.
  29548. * @param uniformName Name of the variable.
  29549. * @param bool value to be set.
  29550. * @returns this effect.
  29551. */
  29552. setBool(uniformName: string, bool: boolean): Effect;
  29553. /**
  29554. * Sets a Vector2 on a uniform variable.
  29555. * @param uniformName Name of the variable.
  29556. * @param vector2 vector2 to be set.
  29557. * @returns this effect.
  29558. */
  29559. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29560. /**
  29561. * Sets a float2 on a uniform variable.
  29562. * @param uniformName Name of the variable.
  29563. * @param x First float in float2.
  29564. * @param y Second float in float2.
  29565. * @returns this effect.
  29566. */
  29567. setFloat2(uniformName: string, x: number, y: number): Effect;
  29568. /**
  29569. * Sets a Vector3 on a uniform variable.
  29570. * @param uniformName Name of the variable.
  29571. * @param vector3 Value to be set.
  29572. * @returns this effect.
  29573. */
  29574. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29575. /**
  29576. * Sets a float3 on a uniform variable.
  29577. * @param uniformName Name of the variable.
  29578. * @param x First float in float3.
  29579. * @param y Second float in float3.
  29580. * @param z Third float in float3.
  29581. * @returns this effect.
  29582. */
  29583. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29584. /**
  29585. * Sets a Vector4 on a uniform variable.
  29586. * @param uniformName Name of the variable.
  29587. * @param vector4 Value to be set.
  29588. * @returns this effect.
  29589. */
  29590. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29591. /**
  29592. * Sets a float4 on a uniform variable.
  29593. * @param uniformName Name of the variable.
  29594. * @param x First float in float4.
  29595. * @param y Second float in float4.
  29596. * @param z Third float in float4.
  29597. * @param w Fourth float in float4.
  29598. * @returns this effect.
  29599. */
  29600. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29601. /**
  29602. * Sets a Color3 on a uniform variable.
  29603. * @param uniformName Name of the variable.
  29604. * @param color3 Value to be set.
  29605. * @returns this effect.
  29606. */
  29607. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29608. /**
  29609. * Sets a Color4 on a uniform variable.
  29610. * @param uniformName Name of the variable.
  29611. * @param color3 Value to be set.
  29612. * @param alpha Alpha value to be set.
  29613. * @returns this effect.
  29614. */
  29615. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29616. /**
  29617. * Sets a Color4 on a uniform variable
  29618. * @param uniformName defines the name of the variable
  29619. * @param color4 defines the value to be set
  29620. * @returns this effect.
  29621. */
  29622. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29623. /** Release all associated resources */
  29624. dispose(): void;
  29625. /**
  29626. * This function will add a new shader to the shader store
  29627. * @param name the name of the shader
  29628. * @param pixelShader optional pixel shader content
  29629. * @param vertexShader optional vertex shader content
  29630. */
  29631. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29632. /**
  29633. * Store of each shader (The can be looked up using effect.key)
  29634. */
  29635. static ShadersStore: {
  29636. [key: string]: string;
  29637. };
  29638. /**
  29639. * Store of each included file for a shader (The can be looked up using effect.key)
  29640. */
  29641. static IncludesShadersStore: {
  29642. [key: string]: string;
  29643. };
  29644. /**
  29645. * Resets the cache of effects.
  29646. */
  29647. static ResetCache(): void;
  29648. }
  29649. }
  29650. declare module "babylonjs/Materials/uniformBuffer" {
  29651. import { Nullable, FloatArray } from "babylonjs/types";
  29652. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29653. import { Engine } from "babylonjs/Engines/engine";
  29654. import { Effect } from "babylonjs/Materials/effect";
  29655. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29656. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29657. import { Color3 } from "babylonjs/Maths/math.color";
  29658. /**
  29659. * Uniform buffer objects.
  29660. *
  29661. * Handles blocks of uniform on the GPU.
  29662. *
  29663. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29664. *
  29665. * For more information, please refer to :
  29666. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29667. */
  29668. export class UniformBuffer {
  29669. private _engine;
  29670. private _buffer;
  29671. private _data;
  29672. private _bufferData;
  29673. private _dynamic?;
  29674. private _uniformLocations;
  29675. private _uniformSizes;
  29676. private _uniformLocationPointer;
  29677. private _needSync;
  29678. private _noUBO;
  29679. private _currentEffect;
  29680. private static _MAX_UNIFORM_SIZE;
  29681. private static _tempBuffer;
  29682. /**
  29683. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29684. * This is dynamic to allow compat with webgl 1 and 2.
  29685. * You will need to pass the name of the uniform as well as the value.
  29686. */
  29687. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29688. /**
  29689. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29690. * This is dynamic to allow compat with webgl 1 and 2.
  29691. * You will need to pass the name of the uniform as well as the value.
  29692. */
  29693. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29694. /**
  29695. * Lambda to Update a single float in a uniform buffer.
  29696. * This is dynamic to allow compat with webgl 1 and 2.
  29697. * You will need to pass the name of the uniform as well as the value.
  29698. */
  29699. updateFloat: (name: string, x: number) => void;
  29700. /**
  29701. * Lambda to Update a vec2 of float in a uniform buffer.
  29702. * This is dynamic to allow compat with webgl 1 and 2.
  29703. * You will need to pass the name of the uniform as well as the value.
  29704. */
  29705. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29706. /**
  29707. * Lambda to Update a vec3 of float in a uniform buffer.
  29708. * This is dynamic to allow compat with webgl 1 and 2.
  29709. * You will need to pass the name of the uniform as well as the value.
  29710. */
  29711. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29712. /**
  29713. * Lambda to Update a vec4 of float in a uniform buffer.
  29714. * This is dynamic to allow compat with webgl 1 and 2.
  29715. * You will need to pass the name of the uniform as well as the value.
  29716. */
  29717. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29718. /**
  29719. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29720. * This is dynamic to allow compat with webgl 1 and 2.
  29721. * You will need to pass the name of the uniform as well as the value.
  29722. */
  29723. updateMatrix: (name: string, mat: Matrix) => void;
  29724. /**
  29725. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29726. * This is dynamic to allow compat with webgl 1 and 2.
  29727. * You will need to pass the name of the uniform as well as the value.
  29728. */
  29729. updateVector3: (name: string, vector: Vector3) => void;
  29730. /**
  29731. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29732. * This is dynamic to allow compat with webgl 1 and 2.
  29733. * You will need to pass the name of the uniform as well as the value.
  29734. */
  29735. updateVector4: (name: string, vector: Vector4) => void;
  29736. /**
  29737. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29738. * This is dynamic to allow compat with webgl 1 and 2.
  29739. * You will need to pass the name of the uniform as well as the value.
  29740. */
  29741. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29742. /**
  29743. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29744. * This is dynamic to allow compat with webgl 1 and 2.
  29745. * You will need to pass the name of the uniform as well as the value.
  29746. */
  29747. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29748. /**
  29749. * Instantiates a new Uniform buffer objects.
  29750. *
  29751. * Handles blocks of uniform on the GPU.
  29752. *
  29753. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29754. *
  29755. * For more information, please refer to :
  29756. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29757. * @param engine Define the engine the buffer is associated with
  29758. * @param data Define the data contained in the buffer
  29759. * @param dynamic Define if the buffer is updatable
  29760. */
  29761. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29762. /**
  29763. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29764. * or just falling back on setUniformXXX calls.
  29765. */
  29766. readonly useUbo: boolean;
  29767. /**
  29768. * Indicates if the WebGL underlying uniform buffer is in sync
  29769. * with the javascript cache data.
  29770. */
  29771. readonly isSync: boolean;
  29772. /**
  29773. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29774. * Also, a dynamic UniformBuffer will disable cache verification and always
  29775. * update the underlying WebGL uniform buffer to the GPU.
  29776. * @returns if Dynamic, otherwise false
  29777. */
  29778. isDynamic(): boolean;
  29779. /**
  29780. * The data cache on JS side.
  29781. * @returns the underlying data as a float array
  29782. */
  29783. getData(): Float32Array;
  29784. /**
  29785. * The underlying WebGL Uniform buffer.
  29786. * @returns the webgl buffer
  29787. */
  29788. getBuffer(): Nullable<DataBuffer>;
  29789. /**
  29790. * std140 layout specifies how to align data within an UBO structure.
  29791. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29792. * for specs.
  29793. */
  29794. private _fillAlignment;
  29795. /**
  29796. * Adds an uniform in the buffer.
  29797. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29798. * for the layout to be correct !
  29799. * @param name Name of the uniform, as used in the uniform block in the shader.
  29800. * @param size Data size, or data directly.
  29801. */
  29802. addUniform(name: string, size: number | number[]): void;
  29803. /**
  29804. * Adds a Matrix 4x4 to the uniform buffer.
  29805. * @param name Name of the uniform, as used in the uniform block in the shader.
  29806. * @param mat A 4x4 matrix.
  29807. */
  29808. addMatrix(name: string, mat: Matrix): void;
  29809. /**
  29810. * Adds a vec2 to the uniform buffer.
  29811. * @param name Name of the uniform, as used in the uniform block in the shader.
  29812. * @param x Define the x component value of the vec2
  29813. * @param y Define the y component value of the vec2
  29814. */
  29815. addFloat2(name: string, x: number, y: number): void;
  29816. /**
  29817. * Adds a vec3 to the uniform buffer.
  29818. * @param name Name of the uniform, as used in the uniform block in the shader.
  29819. * @param x Define the x component value of the vec3
  29820. * @param y Define the y component value of the vec3
  29821. * @param z Define the z component value of the vec3
  29822. */
  29823. addFloat3(name: string, x: number, y: number, z: number): void;
  29824. /**
  29825. * Adds a vec3 to the uniform buffer.
  29826. * @param name Name of the uniform, as used in the uniform block in the shader.
  29827. * @param color Define the vec3 from a Color
  29828. */
  29829. addColor3(name: string, color: Color3): void;
  29830. /**
  29831. * Adds a vec4 to the uniform buffer.
  29832. * @param name Name of the uniform, as used in the uniform block in the shader.
  29833. * @param color Define the rgb components from a Color
  29834. * @param alpha Define the a component of the vec4
  29835. */
  29836. addColor4(name: string, color: Color3, alpha: number): void;
  29837. /**
  29838. * Adds a vec3 to the uniform buffer.
  29839. * @param name Name of the uniform, as used in the uniform block in the shader.
  29840. * @param vector Define the vec3 components from a Vector
  29841. */
  29842. addVector3(name: string, vector: Vector3): void;
  29843. /**
  29844. * Adds a Matrix 3x3 to the uniform buffer.
  29845. * @param name Name of the uniform, as used in the uniform block in the shader.
  29846. */
  29847. addMatrix3x3(name: string): void;
  29848. /**
  29849. * Adds a Matrix 2x2 to the uniform buffer.
  29850. * @param name Name of the uniform, as used in the uniform block in the shader.
  29851. */
  29852. addMatrix2x2(name: string): void;
  29853. /**
  29854. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29855. */
  29856. create(): void;
  29857. /** @hidden */
  29858. _rebuild(): void;
  29859. /**
  29860. * Updates the WebGL Uniform Buffer on the GPU.
  29861. * If the `dynamic` flag is set to true, no cache comparison is done.
  29862. * Otherwise, the buffer will be updated only if the cache differs.
  29863. */
  29864. update(): void;
  29865. /**
  29866. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29867. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29868. * @param data Define the flattened data
  29869. * @param size Define the size of the data.
  29870. */
  29871. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29872. private _valueCache;
  29873. private _cacheMatrix;
  29874. private _updateMatrix3x3ForUniform;
  29875. private _updateMatrix3x3ForEffect;
  29876. private _updateMatrix2x2ForEffect;
  29877. private _updateMatrix2x2ForUniform;
  29878. private _updateFloatForEffect;
  29879. private _updateFloatForUniform;
  29880. private _updateFloat2ForEffect;
  29881. private _updateFloat2ForUniform;
  29882. private _updateFloat3ForEffect;
  29883. private _updateFloat3ForUniform;
  29884. private _updateFloat4ForEffect;
  29885. private _updateFloat4ForUniform;
  29886. private _updateMatrixForEffect;
  29887. private _updateMatrixForUniform;
  29888. private _updateVector3ForEffect;
  29889. private _updateVector3ForUniform;
  29890. private _updateVector4ForEffect;
  29891. private _updateVector4ForUniform;
  29892. private _updateColor3ForEffect;
  29893. private _updateColor3ForUniform;
  29894. private _updateColor4ForEffect;
  29895. private _updateColor4ForUniform;
  29896. /**
  29897. * Sets a sampler uniform on the effect.
  29898. * @param name Define the name of the sampler.
  29899. * @param texture Define the texture to set in the sampler
  29900. */
  29901. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29902. /**
  29903. * Directly updates the value of the uniform in the cache AND on the GPU.
  29904. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29905. * @param data Define the flattened data
  29906. */
  29907. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29908. /**
  29909. * Binds this uniform buffer to an effect.
  29910. * @param effect Define the effect to bind the buffer to
  29911. * @param name Name of the uniform block in the shader.
  29912. */
  29913. bindToEffect(effect: Effect, name: string): void;
  29914. /**
  29915. * Disposes the uniform buffer.
  29916. */
  29917. dispose(): void;
  29918. }
  29919. }
  29920. declare module "babylonjs/Audio/analyser" {
  29921. import { Scene } from "babylonjs/scene";
  29922. /**
  29923. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29925. */
  29926. export class Analyser {
  29927. /**
  29928. * Gets or sets the smoothing
  29929. * @ignorenaming
  29930. */
  29931. SMOOTHING: number;
  29932. /**
  29933. * Gets or sets the FFT table size
  29934. * @ignorenaming
  29935. */
  29936. FFT_SIZE: number;
  29937. /**
  29938. * Gets or sets the bar graph amplitude
  29939. * @ignorenaming
  29940. */
  29941. BARGRAPHAMPLITUDE: number;
  29942. /**
  29943. * Gets or sets the position of the debug canvas
  29944. * @ignorenaming
  29945. */
  29946. DEBUGCANVASPOS: {
  29947. x: number;
  29948. y: number;
  29949. };
  29950. /**
  29951. * Gets or sets the debug canvas size
  29952. * @ignorenaming
  29953. */
  29954. DEBUGCANVASSIZE: {
  29955. width: number;
  29956. height: number;
  29957. };
  29958. private _byteFreqs;
  29959. private _byteTime;
  29960. private _floatFreqs;
  29961. private _webAudioAnalyser;
  29962. private _debugCanvas;
  29963. private _debugCanvasContext;
  29964. private _scene;
  29965. private _registerFunc;
  29966. private _audioEngine;
  29967. /**
  29968. * Creates a new analyser
  29969. * @param scene defines hosting scene
  29970. */
  29971. constructor(scene: Scene);
  29972. /**
  29973. * Get the number of data values you will have to play with for the visualization
  29974. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29975. * @returns a number
  29976. */
  29977. getFrequencyBinCount(): number;
  29978. /**
  29979. * Gets the current frequency data as a byte array
  29980. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29981. * @returns a Uint8Array
  29982. */
  29983. getByteFrequencyData(): Uint8Array;
  29984. /**
  29985. * Gets the current waveform as a byte array
  29986. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29987. * @returns a Uint8Array
  29988. */
  29989. getByteTimeDomainData(): Uint8Array;
  29990. /**
  29991. * Gets the current frequency data as a float array
  29992. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29993. * @returns a Float32Array
  29994. */
  29995. getFloatFrequencyData(): Float32Array;
  29996. /**
  29997. * Renders the debug canvas
  29998. */
  29999. drawDebugCanvas(): void;
  30000. /**
  30001. * Stops rendering the debug canvas and removes it
  30002. */
  30003. stopDebugCanvas(): void;
  30004. /**
  30005. * Connects two audio nodes
  30006. * @param inputAudioNode defines first node to connect
  30007. * @param outputAudioNode defines second node to connect
  30008. */
  30009. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30010. /**
  30011. * Releases all associated resources
  30012. */
  30013. dispose(): void;
  30014. }
  30015. }
  30016. declare module "babylonjs/Audio/audioEngine" {
  30017. import { IDisposable } from "babylonjs/scene";
  30018. import { Analyser } from "babylonjs/Audio/analyser";
  30019. import { Nullable } from "babylonjs/types";
  30020. import { Observable } from "babylonjs/Misc/observable";
  30021. /**
  30022. * This represents an audio engine and it is responsible
  30023. * to play, synchronize and analyse sounds throughout the application.
  30024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30025. */
  30026. export interface IAudioEngine extends IDisposable {
  30027. /**
  30028. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30029. */
  30030. readonly canUseWebAudio: boolean;
  30031. /**
  30032. * Gets the current AudioContext if available.
  30033. */
  30034. readonly audioContext: Nullable<AudioContext>;
  30035. /**
  30036. * The master gain node defines the global audio volume of your audio engine.
  30037. */
  30038. readonly masterGain: GainNode;
  30039. /**
  30040. * Gets whether or not mp3 are supported by your browser.
  30041. */
  30042. readonly isMP3supported: boolean;
  30043. /**
  30044. * Gets whether or not ogg are supported by your browser.
  30045. */
  30046. readonly isOGGsupported: boolean;
  30047. /**
  30048. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30049. * @ignoreNaming
  30050. */
  30051. WarnedWebAudioUnsupported: boolean;
  30052. /**
  30053. * Defines if the audio engine relies on a custom unlocked button.
  30054. * In this case, the embedded button will not be displayed.
  30055. */
  30056. useCustomUnlockedButton: boolean;
  30057. /**
  30058. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30059. */
  30060. readonly unlocked: boolean;
  30061. /**
  30062. * Event raised when audio has been unlocked on the browser.
  30063. */
  30064. onAudioUnlockedObservable: Observable<AudioEngine>;
  30065. /**
  30066. * Event raised when audio has been locked on the browser.
  30067. */
  30068. onAudioLockedObservable: Observable<AudioEngine>;
  30069. /**
  30070. * Flags the audio engine in Locked state.
  30071. * This happens due to new browser policies preventing audio to autoplay.
  30072. */
  30073. lock(): void;
  30074. /**
  30075. * Unlocks the audio engine once a user action has been done on the dom.
  30076. * This is helpful to resume play once browser policies have been satisfied.
  30077. */
  30078. unlock(): void;
  30079. }
  30080. /**
  30081. * This represents the default audio engine used in babylon.
  30082. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30084. */
  30085. export class AudioEngine implements IAudioEngine {
  30086. private _audioContext;
  30087. private _audioContextInitialized;
  30088. private _muteButton;
  30089. private _hostElement;
  30090. /**
  30091. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30092. */
  30093. canUseWebAudio: boolean;
  30094. /**
  30095. * The master gain node defines the global audio volume of your audio engine.
  30096. */
  30097. masterGain: GainNode;
  30098. /**
  30099. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30100. * @ignoreNaming
  30101. */
  30102. WarnedWebAudioUnsupported: boolean;
  30103. /**
  30104. * Gets whether or not mp3 are supported by your browser.
  30105. */
  30106. isMP3supported: boolean;
  30107. /**
  30108. * Gets whether or not ogg are supported by your browser.
  30109. */
  30110. isOGGsupported: boolean;
  30111. /**
  30112. * Gets whether audio has been unlocked on the device.
  30113. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30114. * a user interaction has happened.
  30115. */
  30116. unlocked: boolean;
  30117. /**
  30118. * Defines if the audio engine relies on a custom unlocked button.
  30119. * In this case, the embedded button will not be displayed.
  30120. */
  30121. useCustomUnlockedButton: boolean;
  30122. /**
  30123. * Event raised when audio has been unlocked on the browser.
  30124. */
  30125. onAudioUnlockedObservable: Observable<AudioEngine>;
  30126. /**
  30127. * Event raised when audio has been locked on the browser.
  30128. */
  30129. onAudioLockedObservable: Observable<AudioEngine>;
  30130. /**
  30131. * Gets the current AudioContext if available.
  30132. */
  30133. readonly audioContext: Nullable<AudioContext>;
  30134. private _connectedAnalyser;
  30135. /**
  30136. * Instantiates a new audio engine.
  30137. *
  30138. * There should be only one per page as some browsers restrict the number
  30139. * of audio contexts you can create.
  30140. * @param hostElement defines the host element where to display the mute icon if necessary
  30141. */
  30142. constructor(hostElement?: Nullable<HTMLElement>);
  30143. /**
  30144. * Flags the audio engine in Locked state.
  30145. * This happens due to new browser policies preventing audio to autoplay.
  30146. */
  30147. lock(): void;
  30148. /**
  30149. * Unlocks the audio engine once a user action has been done on the dom.
  30150. * This is helpful to resume play once browser policies have been satisfied.
  30151. */
  30152. unlock(): void;
  30153. private _resumeAudioContext;
  30154. private _initializeAudioContext;
  30155. private _tryToRun;
  30156. private _triggerRunningState;
  30157. private _triggerSuspendedState;
  30158. private _displayMuteButton;
  30159. private _moveButtonToTopLeft;
  30160. private _onResize;
  30161. private _hideMuteButton;
  30162. /**
  30163. * Destroy and release the resources associated with the audio ccontext.
  30164. */
  30165. dispose(): void;
  30166. /**
  30167. * Gets the global volume sets on the master gain.
  30168. * @returns the global volume if set or -1 otherwise
  30169. */
  30170. getGlobalVolume(): number;
  30171. /**
  30172. * Sets the global volume of your experience (sets on the master gain).
  30173. * @param newVolume Defines the new global volume of the application
  30174. */
  30175. setGlobalVolume(newVolume: number): void;
  30176. /**
  30177. * Connect the audio engine to an audio analyser allowing some amazing
  30178. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30180. * @param analyser The analyser to connect to the engine
  30181. */
  30182. connectToAnalyser(analyser: Analyser): void;
  30183. }
  30184. }
  30185. declare module "babylonjs/Loading/loadingScreen" {
  30186. /**
  30187. * Interface used to present a loading screen while loading a scene
  30188. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30189. */
  30190. export interface ILoadingScreen {
  30191. /**
  30192. * Function called to display the loading screen
  30193. */
  30194. displayLoadingUI: () => void;
  30195. /**
  30196. * Function called to hide the loading screen
  30197. */
  30198. hideLoadingUI: () => void;
  30199. /**
  30200. * Gets or sets the color to use for the background
  30201. */
  30202. loadingUIBackgroundColor: string;
  30203. /**
  30204. * Gets or sets the text to display while loading
  30205. */
  30206. loadingUIText: string;
  30207. }
  30208. /**
  30209. * Class used for the default loading screen
  30210. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30211. */
  30212. export class DefaultLoadingScreen implements ILoadingScreen {
  30213. private _renderingCanvas;
  30214. private _loadingText;
  30215. private _loadingDivBackgroundColor;
  30216. private _loadingDiv;
  30217. private _loadingTextDiv;
  30218. /** Gets or sets the logo url to use for the default loading screen */
  30219. static DefaultLogoUrl: string;
  30220. /** Gets or sets the spinner url to use for the default loading screen */
  30221. static DefaultSpinnerUrl: string;
  30222. /**
  30223. * Creates a new default loading screen
  30224. * @param _renderingCanvas defines the canvas used to render the scene
  30225. * @param _loadingText defines the default text to display
  30226. * @param _loadingDivBackgroundColor defines the default background color
  30227. */
  30228. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30229. /**
  30230. * Function called to display the loading screen
  30231. */
  30232. displayLoadingUI(): void;
  30233. /**
  30234. * Function called to hide the loading screen
  30235. */
  30236. hideLoadingUI(): void;
  30237. /**
  30238. * Gets or sets the text to display while loading
  30239. */
  30240. loadingUIText: string;
  30241. /**
  30242. * Gets or sets the color to use for the background
  30243. */
  30244. loadingUIBackgroundColor: string;
  30245. private _resizeLoadingUI;
  30246. }
  30247. }
  30248. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30249. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30250. import { Engine } from "babylonjs/Engines/engine";
  30251. import { Nullable } from "babylonjs/types";
  30252. /** @hidden */
  30253. export class WebGLPipelineContext implements IPipelineContext {
  30254. engine: Engine;
  30255. program: Nullable<WebGLProgram>;
  30256. context?: WebGLRenderingContext;
  30257. vertexShader?: WebGLShader;
  30258. fragmentShader?: WebGLShader;
  30259. isParallelCompiled: boolean;
  30260. onCompiled?: () => void;
  30261. transformFeedback?: WebGLTransformFeedback | null;
  30262. readonly isAsync: boolean;
  30263. readonly isReady: boolean;
  30264. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30265. }
  30266. }
  30267. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30268. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30269. /** @hidden */
  30270. export class WebGLDataBuffer extends DataBuffer {
  30271. private _buffer;
  30272. constructor(resource: WebGLBuffer);
  30273. readonly underlyingResource: any;
  30274. }
  30275. }
  30276. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30277. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30278. /** @hidden */
  30279. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30280. attributeProcessor(attribute: string): string;
  30281. varyingProcessor(varying: string, isFragment: boolean): string;
  30282. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30283. }
  30284. }
  30285. declare module "babylonjs/Misc/perfCounter" {
  30286. /**
  30287. * This class is used to track a performance counter which is number based.
  30288. * The user has access to many properties which give statistics of different nature.
  30289. *
  30290. * The implementer can track two kinds of Performance Counter: time and count.
  30291. * 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.
  30292. * 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.
  30293. */
  30294. export class PerfCounter {
  30295. /**
  30296. * Gets or sets a global boolean to turn on and off all the counters
  30297. */
  30298. static Enabled: boolean;
  30299. /**
  30300. * Returns the smallest value ever
  30301. */
  30302. readonly min: number;
  30303. /**
  30304. * Returns the biggest value ever
  30305. */
  30306. readonly max: number;
  30307. /**
  30308. * Returns the average value since the performance counter is running
  30309. */
  30310. readonly average: number;
  30311. /**
  30312. * Returns the average value of the last second the counter was monitored
  30313. */
  30314. readonly lastSecAverage: number;
  30315. /**
  30316. * Returns the current value
  30317. */
  30318. readonly current: number;
  30319. /**
  30320. * Gets the accumulated total
  30321. */
  30322. readonly total: number;
  30323. /**
  30324. * Gets the total value count
  30325. */
  30326. readonly count: number;
  30327. /**
  30328. * Creates a new counter
  30329. */
  30330. constructor();
  30331. /**
  30332. * Call this method to start monitoring a new frame.
  30333. * 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.
  30334. */
  30335. fetchNewFrame(): void;
  30336. /**
  30337. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30338. * @param newCount the count value to add to the monitored count
  30339. * @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.
  30340. */
  30341. addCount(newCount: number, fetchResult: boolean): void;
  30342. /**
  30343. * Start monitoring this performance counter
  30344. */
  30345. beginMonitoring(): void;
  30346. /**
  30347. * Compute the time lapsed since the previous beginMonitoring() call.
  30348. * @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
  30349. */
  30350. endMonitoring(newFrame?: boolean): void;
  30351. private _fetchResult;
  30352. private _startMonitoringTime;
  30353. private _min;
  30354. private _max;
  30355. private _average;
  30356. private _current;
  30357. private _totalValueCount;
  30358. private _totalAccumulated;
  30359. private _lastSecAverage;
  30360. private _lastSecAccumulated;
  30361. private _lastSecTime;
  30362. private _lastSecValueCount;
  30363. }
  30364. }
  30365. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30366. /**
  30367. * Interface for any object that can request an animation frame
  30368. */
  30369. export interface ICustomAnimationFrameRequester {
  30370. /**
  30371. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30372. */
  30373. renderFunction?: Function;
  30374. /**
  30375. * Called to request the next frame to render to
  30376. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30377. */
  30378. requestAnimationFrame: Function;
  30379. /**
  30380. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30381. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30382. */
  30383. requestID?: number;
  30384. }
  30385. }
  30386. declare module "babylonjs/Materials/Textures/videoTexture" {
  30387. import { Observable } from "babylonjs/Misc/observable";
  30388. import { Nullable } from "babylonjs/types";
  30389. import { Scene } from "babylonjs/scene";
  30390. import { Texture } from "babylonjs/Materials/Textures/texture";
  30391. /**
  30392. * Settings for finer control over video usage
  30393. */
  30394. export interface VideoTextureSettings {
  30395. /**
  30396. * Applies `autoplay` to video, if specified
  30397. */
  30398. autoPlay?: boolean;
  30399. /**
  30400. * Applies `loop` to video, if specified
  30401. */
  30402. loop?: boolean;
  30403. /**
  30404. * Automatically updates internal texture from video at every frame in the render loop
  30405. */
  30406. autoUpdateTexture: boolean;
  30407. /**
  30408. * Image src displayed during the video loading or until the user interacts with the video.
  30409. */
  30410. poster?: string;
  30411. }
  30412. /**
  30413. * If you want to display a video in your scene, this is the special texture for that.
  30414. * This special texture works similar to other textures, with the exception of a few parameters.
  30415. * @see https://doc.babylonjs.com/how_to/video_texture
  30416. */
  30417. export class VideoTexture extends Texture {
  30418. /**
  30419. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30420. */
  30421. readonly autoUpdateTexture: boolean;
  30422. /**
  30423. * The video instance used by the texture internally
  30424. */
  30425. readonly video: HTMLVideoElement;
  30426. private _onUserActionRequestedObservable;
  30427. /**
  30428. * Event triggerd when a dom action is required by the user to play the video.
  30429. * This happens due to recent changes in browser policies preventing video to auto start.
  30430. */
  30431. readonly onUserActionRequestedObservable: Observable<Texture>;
  30432. private _generateMipMaps;
  30433. private _engine;
  30434. private _stillImageCaptured;
  30435. private _displayingPosterTexture;
  30436. private _settings;
  30437. private _createInternalTextureOnEvent;
  30438. private _frameId;
  30439. /**
  30440. * Creates a video texture.
  30441. * If you want to display a video in your scene, this is the special texture for that.
  30442. * This special texture works similar to other textures, with the exception of a few parameters.
  30443. * @see https://doc.babylonjs.com/how_to/video_texture
  30444. * @param name optional name, will detect from video source, if not defined
  30445. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30446. * @param scene is obviously the current scene.
  30447. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30448. * @param invertY is false by default but can be used to invert video on Y axis
  30449. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30450. * @param settings allows finer control over video usage
  30451. */
  30452. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30453. private _getName;
  30454. private _getVideo;
  30455. private _createInternalTexture;
  30456. private reset;
  30457. /**
  30458. * @hidden Internal method to initiate `update`.
  30459. */
  30460. _rebuild(): void;
  30461. /**
  30462. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30463. */
  30464. update(): void;
  30465. /**
  30466. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30467. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30468. */
  30469. updateTexture(isVisible: boolean): void;
  30470. protected _updateInternalTexture: () => void;
  30471. /**
  30472. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30473. * @param url New url.
  30474. */
  30475. updateURL(url: string): void;
  30476. /**
  30477. * Dispose the texture and release its associated resources.
  30478. */
  30479. dispose(): void;
  30480. /**
  30481. * Creates a video texture straight from a stream.
  30482. * @param scene Define the scene the texture should be created in
  30483. * @param stream Define the stream the texture should be created from
  30484. * @returns The created video texture as a promise
  30485. */
  30486. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30487. /**
  30488. * Creates a video texture straight from your WebCam video feed.
  30489. * @param scene Define the scene the texture should be created in
  30490. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30491. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30492. * @returns The created video texture as a promise
  30493. */
  30494. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30495. minWidth: number;
  30496. maxWidth: number;
  30497. minHeight: number;
  30498. maxHeight: number;
  30499. deviceId: string;
  30500. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30501. /**
  30502. * Creates a video texture straight from your WebCam video feed.
  30503. * @param scene Define the scene the texture should be created in
  30504. * @param onReady Define a callback to triggered once the texture will be ready
  30505. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30506. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30507. */
  30508. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30509. minWidth: number;
  30510. maxWidth: number;
  30511. minHeight: number;
  30512. maxHeight: number;
  30513. deviceId: string;
  30514. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30515. }
  30516. }
  30517. declare module "babylonjs/Engines/engine" {
  30518. import { Observable } from "babylonjs/Misc/observable";
  30519. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30520. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30521. import { Scene } from "babylonjs/scene";
  30522. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30523. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30524. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30525. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30526. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30528. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30529. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30530. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30531. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30532. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30533. import { WebRequest } from "babylonjs/Misc/webRequest";
  30534. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30536. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30537. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30538. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30539. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30540. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30541. import { Material } from "babylonjs/Materials/material";
  30542. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30543. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30544. /**
  30545. * Defines the interface used by objects containing a viewport (like a camera)
  30546. */
  30547. interface IViewportOwnerLike {
  30548. /**
  30549. * Gets or sets the viewport
  30550. */
  30551. viewport: IViewportLike;
  30552. }
  30553. /**
  30554. * Interface for attribute information associated with buffer instanciation
  30555. */
  30556. export class InstancingAttributeInfo {
  30557. /**
  30558. * Index/offset of the attribute in the vertex shader
  30559. */
  30560. index: number;
  30561. /**
  30562. * size of the attribute, 1, 2, 3 or 4
  30563. */
  30564. attributeSize: number;
  30565. /**
  30566. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30567. * default is FLOAT
  30568. */
  30569. attribyteType: number;
  30570. /**
  30571. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30572. */
  30573. normalized: boolean;
  30574. /**
  30575. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30576. */
  30577. offset: number;
  30578. /**
  30579. * Name of the GLSL attribute, for debugging purpose only
  30580. */
  30581. attributeName: string;
  30582. }
  30583. /**
  30584. * Define options used to create a depth texture
  30585. */
  30586. export class DepthTextureCreationOptions {
  30587. /** Specifies whether or not a stencil should be allocated in the texture */
  30588. generateStencil?: boolean;
  30589. /** Specifies whether or not bilinear filtering is enable on the texture */
  30590. bilinearFiltering?: boolean;
  30591. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30592. comparisonFunction?: number;
  30593. /** Specifies if the created texture is a cube texture */
  30594. isCube?: boolean;
  30595. }
  30596. /**
  30597. * Class used to describe the capabilities of the engine relatively to the current browser
  30598. */
  30599. export class EngineCapabilities {
  30600. /** Maximum textures units per fragment shader */
  30601. maxTexturesImageUnits: number;
  30602. /** Maximum texture units per vertex shader */
  30603. maxVertexTextureImageUnits: number;
  30604. /** Maximum textures units in the entire pipeline */
  30605. maxCombinedTexturesImageUnits: number;
  30606. /** Maximum texture size */
  30607. maxTextureSize: number;
  30608. /** Maximum cube texture size */
  30609. maxCubemapTextureSize: number;
  30610. /** Maximum render texture size */
  30611. maxRenderTextureSize: number;
  30612. /** Maximum number of vertex attributes */
  30613. maxVertexAttribs: number;
  30614. /** Maximum number of varyings */
  30615. maxVaryingVectors: number;
  30616. /** Maximum number of uniforms per vertex shader */
  30617. maxVertexUniformVectors: number;
  30618. /** Maximum number of uniforms per fragment shader */
  30619. maxFragmentUniformVectors: number;
  30620. /** Defines if standard derivates (dx/dy) are supported */
  30621. standardDerivatives: boolean;
  30622. /** Defines if s3tc texture compression is supported */
  30623. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30624. /** Defines if pvrtc texture compression is supported */
  30625. pvrtc: any;
  30626. /** Defines if etc1 texture compression is supported */
  30627. etc1: any;
  30628. /** Defines if etc2 texture compression is supported */
  30629. etc2: any;
  30630. /** Defines if astc texture compression is supported */
  30631. astc: any;
  30632. /** Defines if float textures are supported */
  30633. textureFloat: boolean;
  30634. /** Defines if vertex array objects are supported */
  30635. vertexArrayObject: boolean;
  30636. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30637. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30638. /** Gets the maximum level of anisotropy supported */
  30639. maxAnisotropy: number;
  30640. /** Defines if instancing is supported */
  30641. instancedArrays: boolean;
  30642. /** Defines if 32 bits indices are supported */
  30643. uintIndices: boolean;
  30644. /** Defines if high precision shaders are supported */
  30645. highPrecisionShaderSupported: boolean;
  30646. /** Defines if depth reading in the fragment shader is supported */
  30647. fragmentDepthSupported: boolean;
  30648. /** Defines if float texture linear filtering is supported*/
  30649. textureFloatLinearFiltering: boolean;
  30650. /** Defines if rendering to float textures is supported */
  30651. textureFloatRender: boolean;
  30652. /** Defines if half float textures are supported*/
  30653. textureHalfFloat: boolean;
  30654. /** Defines if half float texture linear filtering is supported*/
  30655. textureHalfFloatLinearFiltering: boolean;
  30656. /** Defines if rendering to half float textures is supported */
  30657. textureHalfFloatRender: boolean;
  30658. /** Defines if textureLOD shader command is supported */
  30659. textureLOD: boolean;
  30660. /** Defines if draw buffers extension is supported */
  30661. drawBuffersExtension: boolean;
  30662. /** Defines if depth textures are supported */
  30663. depthTextureExtension: boolean;
  30664. /** Defines if float color buffer are supported */
  30665. colorBufferFloat: boolean;
  30666. /** Gets disjoint timer query extension (null if not supported) */
  30667. timerQuery: EXT_disjoint_timer_query;
  30668. /** Defines if timestamp can be used with timer query */
  30669. canUseTimestampForTimerQuery: boolean;
  30670. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30671. multiview: any;
  30672. /** Function used to let the system compiles shaders in background */
  30673. parallelShaderCompile: {
  30674. COMPLETION_STATUS_KHR: number;
  30675. };
  30676. /** Max number of texture samples for MSAA */
  30677. maxMSAASamples: number;
  30678. }
  30679. /** Interface defining initialization parameters for Engine class */
  30680. export interface EngineOptions extends WebGLContextAttributes {
  30681. /**
  30682. * Defines if the engine should no exceed a specified device ratio
  30683. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30684. */
  30685. limitDeviceRatio?: number;
  30686. /**
  30687. * Defines if webvr should be enabled automatically
  30688. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30689. */
  30690. autoEnableWebVR?: boolean;
  30691. /**
  30692. * Defines if webgl2 should be turned off even if supported
  30693. * @see http://doc.babylonjs.com/features/webgl2
  30694. */
  30695. disableWebGL2Support?: boolean;
  30696. /**
  30697. * Defines if webaudio should be initialized as well
  30698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30699. */
  30700. audioEngine?: boolean;
  30701. /**
  30702. * Defines if animations should run using a deterministic lock step
  30703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30704. */
  30705. deterministicLockstep?: boolean;
  30706. /** Defines the maximum steps to use with deterministic lock step mode */
  30707. lockstepMaxSteps?: number;
  30708. /**
  30709. * Defines that engine should ignore context lost events
  30710. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30711. */
  30712. doNotHandleContextLost?: boolean;
  30713. /**
  30714. * Defines that engine should ignore modifying touch action attribute and style
  30715. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30716. */
  30717. doNotHandleTouchAction?: boolean;
  30718. /**
  30719. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30720. */
  30721. useHighPrecisionFloats?: boolean;
  30722. }
  30723. /**
  30724. * Defines the interface used by display changed events
  30725. */
  30726. export interface IDisplayChangedEventArgs {
  30727. /** Gets the vrDisplay object (if any) */
  30728. vrDisplay: Nullable<any>;
  30729. /** Gets a boolean indicating if webVR is supported */
  30730. vrSupported: boolean;
  30731. }
  30732. /**
  30733. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30734. */
  30735. export class Engine {
  30736. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30737. static ExceptionList: ({
  30738. key: string;
  30739. capture: string;
  30740. captureConstraint: number;
  30741. targets: string[];
  30742. } | {
  30743. key: string;
  30744. capture: null;
  30745. captureConstraint: null;
  30746. targets: string[];
  30747. })[];
  30748. /** Gets the list of created engines */
  30749. static readonly Instances: Engine[];
  30750. /**
  30751. * Gets the latest created engine
  30752. */
  30753. static readonly LastCreatedEngine: Nullable<Engine>;
  30754. /**
  30755. * Gets the latest created scene
  30756. */
  30757. static readonly LastCreatedScene: Nullable<Scene>;
  30758. /**
  30759. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30760. * @param flag defines which part of the materials must be marked as dirty
  30761. * @param predicate defines a predicate used to filter which materials should be affected
  30762. */
  30763. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30764. /** @hidden */
  30765. static _TextureLoaders: IInternalTextureLoader[];
  30766. /** Defines that alpha blending is disabled */
  30767. static readonly ALPHA_DISABLE: number;
  30768. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30769. static readonly ALPHA_ADD: number;
  30770. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30771. static readonly ALPHA_COMBINE: number;
  30772. /** Defines that alpha blending to DEST - SRC * DEST */
  30773. static readonly ALPHA_SUBTRACT: number;
  30774. /** Defines that alpha blending to SRC * DEST */
  30775. static readonly ALPHA_MULTIPLY: number;
  30776. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30777. static readonly ALPHA_MAXIMIZED: number;
  30778. /** Defines that alpha blending to SRC + DEST */
  30779. static readonly ALPHA_ONEONE: number;
  30780. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30781. static readonly ALPHA_PREMULTIPLIED: number;
  30782. /**
  30783. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30784. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30785. */
  30786. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30787. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30788. static readonly ALPHA_INTERPOLATE: number;
  30789. /**
  30790. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30791. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30792. */
  30793. static readonly ALPHA_SCREENMODE: number;
  30794. /** Defines that the ressource is not delayed*/
  30795. static readonly DELAYLOADSTATE_NONE: number;
  30796. /** Defines that the ressource was successfully delay loaded */
  30797. static readonly DELAYLOADSTATE_LOADED: number;
  30798. /** Defines that the ressource is currently delay loading */
  30799. static readonly DELAYLOADSTATE_LOADING: number;
  30800. /** Defines that the ressource is delayed and has not started loading */
  30801. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30802. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30803. static readonly NEVER: number;
  30804. /** 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 */
  30805. static readonly ALWAYS: number;
  30806. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30807. static readonly LESS: number;
  30808. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30809. static readonly EQUAL: number;
  30810. /** 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 */
  30811. static readonly LEQUAL: number;
  30812. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30813. static readonly GREATER: number;
  30814. /** 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 */
  30815. static readonly GEQUAL: number;
  30816. /** 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 */
  30817. static readonly NOTEQUAL: number;
  30818. /** Passed to stencilOperation to specify that stencil value must be kept */
  30819. static readonly KEEP: number;
  30820. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30821. static readonly REPLACE: number;
  30822. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30823. static readonly INCR: number;
  30824. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30825. static readonly DECR: number;
  30826. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30827. static readonly INVERT: number;
  30828. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30829. static readonly INCR_WRAP: number;
  30830. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30831. static readonly DECR_WRAP: number;
  30832. /** Texture is not repeating outside of 0..1 UVs */
  30833. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30834. /** Texture is repeating outside of 0..1 UVs */
  30835. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30836. /** Texture is repeating and mirrored */
  30837. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30838. /** ALPHA */
  30839. static readonly TEXTUREFORMAT_ALPHA: number;
  30840. /** LUMINANCE */
  30841. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30842. /** LUMINANCE_ALPHA */
  30843. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30844. /** RGB */
  30845. static readonly TEXTUREFORMAT_RGB: number;
  30846. /** RGBA */
  30847. static readonly TEXTUREFORMAT_RGBA: number;
  30848. /** RED */
  30849. static readonly TEXTUREFORMAT_RED: number;
  30850. /** RED (2nd reference) */
  30851. static readonly TEXTUREFORMAT_R: number;
  30852. /** RG */
  30853. static readonly TEXTUREFORMAT_RG: number;
  30854. /** RED_INTEGER */
  30855. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30856. /** RED_INTEGER (2nd reference) */
  30857. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30858. /** RG_INTEGER */
  30859. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30860. /** RGB_INTEGER */
  30861. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30862. /** RGBA_INTEGER */
  30863. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30864. /** UNSIGNED_BYTE */
  30865. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30866. /** UNSIGNED_BYTE (2nd reference) */
  30867. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30868. /** FLOAT */
  30869. static readonly TEXTURETYPE_FLOAT: number;
  30870. /** HALF_FLOAT */
  30871. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30872. /** BYTE */
  30873. static readonly TEXTURETYPE_BYTE: number;
  30874. /** SHORT */
  30875. static readonly TEXTURETYPE_SHORT: number;
  30876. /** UNSIGNED_SHORT */
  30877. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30878. /** INT */
  30879. static readonly TEXTURETYPE_INT: number;
  30880. /** UNSIGNED_INT */
  30881. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30882. /** UNSIGNED_SHORT_4_4_4_4 */
  30883. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30884. /** UNSIGNED_SHORT_5_5_5_1 */
  30885. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30886. /** UNSIGNED_SHORT_5_6_5 */
  30887. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30888. /** UNSIGNED_INT_2_10_10_10_REV */
  30889. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30890. /** UNSIGNED_INT_24_8 */
  30891. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30892. /** UNSIGNED_INT_10F_11F_11F_REV */
  30893. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30894. /** UNSIGNED_INT_5_9_9_9_REV */
  30895. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30896. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30897. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30898. /** nearest is mag = nearest and min = nearest and mip = linear */
  30899. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30900. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30901. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30902. /** Trilinear is mag = linear and min = linear and mip = linear */
  30903. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30904. /** nearest is mag = nearest and min = nearest and mip = linear */
  30905. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30906. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30907. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30908. /** Trilinear is mag = linear and min = linear and mip = linear */
  30909. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30910. /** mag = nearest and min = nearest and mip = nearest */
  30911. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30912. /** mag = nearest and min = linear and mip = nearest */
  30913. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30914. /** mag = nearest and min = linear and mip = linear */
  30915. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30916. /** mag = nearest and min = linear and mip = none */
  30917. static readonly TEXTURE_NEAREST_LINEAR: number;
  30918. /** mag = nearest and min = nearest and mip = none */
  30919. static readonly TEXTURE_NEAREST_NEAREST: number;
  30920. /** mag = linear and min = nearest and mip = nearest */
  30921. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30922. /** mag = linear and min = nearest and mip = linear */
  30923. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30924. /** mag = linear and min = linear and mip = none */
  30925. static readonly TEXTURE_LINEAR_LINEAR: number;
  30926. /** mag = linear and min = nearest and mip = none */
  30927. static readonly TEXTURE_LINEAR_NEAREST: number;
  30928. /** Explicit coordinates mode */
  30929. static readonly TEXTURE_EXPLICIT_MODE: number;
  30930. /** Spherical coordinates mode */
  30931. static readonly TEXTURE_SPHERICAL_MODE: number;
  30932. /** Planar coordinates mode */
  30933. static readonly TEXTURE_PLANAR_MODE: number;
  30934. /** Cubic coordinates mode */
  30935. static readonly TEXTURE_CUBIC_MODE: number;
  30936. /** Projection coordinates mode */
  30937. static readonly TEXTURE_PROJECTION_MODE: number;
  30938. /** Skybox coordinates mode */
  30939. static readonly TEXTURE_SKYBOX_MODE: number;
  30940. /** Inverse Cubic coordinates mode */
  30941. static readonly TEXTURE_INVCUBIC_MODE: number;
  30942. /** Equirectangular coordinates mode */
  30943. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30944. /** Equirectangular Fixed coordinates mode */
  30945. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30946. /** Equirectangular Fixed Mirrored coordinates mode */
  30947. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30948. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30949. static readonly SCALEMODE_FLOOR: number;
  30950. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30951. static readonly SCALEMODE_NEAREST: number;
  30952. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30953. static readonly SCALEMODE_CEILING: number;
  30954. /**
  30955. * Returns the current npm package of the sdk
  30956. */
  30957. static readonly NpmPackage: string;
  30958. /**
  30959. * Returns the current version of the framework
  30960. */
  30961. static readonly Version: string;
  30962. /**
  30963. * Returns a string describing the current engine
  30964. */
  30965. readonly description: string;
  30966. /**
  30967. * Gets or sets the epsilon value used by collision engine
  30968. */
  30969. static CollisionsEpsilon: number;
  30970. /**
  30971. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30972. */
  30973. static ShadersRepository: string;
  30974. /**
  30975. * Method called to create the default loading screen.
  30976. * This can be overriden in your own app.
  30977. * @param canvas The rendering canvas element
  30978. * @returns The loading screen
  30979. */
  30980. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30981. /**
  30982. * Method called to create the default rescale post process on each engine.
  30983. */
  30984. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30985. /** @hidden */
  30986. _shaderProcessor: IShaderProcessor;
  30987. /**
  30988. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30989. */
  30990. forcePOTTextures: boolean;
  30991. /**
  30992. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30993. */
  30994. isFullscreen: boolean;
  30995. /**
  30996. * Gets a boolean indicating if the pointer is currently locked
  30997. */
  30998. isPointerLock: boolean;
  30999. /**
  31000. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31001. */
  31002. cullBackFaces: boolean;
  31003. /**
  31004. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31005. */
  31006. renderEvenInBackground: boolean;
  31007. /**
  31008. * Gets or sets a boolean indicating that cache can be kept between frames
  31009. */
  31010. preventCacheWipeBetweenFrames: boolean;
  31011. /**
  31012. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31013. **/
  31014. enableOfflineSupport: boolean;
  31015. /**
  31016. * 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)
  31017. **/
  31018. disableManifestCheck: boolean;
  31019. /**
  31020. * Gets the list of created scenes
  31021. */
  31022. scenes: Scene[];
  31023. /**
  31024. * Event raised when a new scene is created
  31025. */
  31026. onNewSceneAddedObservable: Observable<Scene>;
  31027. /**
  31028. * Gets the list of created postprocesses
  31029. */
  31030. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  31031. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31032. validateShaderPrograms: boolean;
  31033. /**
  31034. * Observable event triggered each time the rendering canvas is resized
  31035. */
  31036. onResizeObservable: Observable<Engine>;
  31037. /**
  31038. * Observable event triggered each time the canvas loses focus
  31039. */
  31040. onCanvasBlurObservable: Observable<Engine>;
  31041. /**
  31042. * Observable event triggered each time the canvas gains focus
  31043. */
  31044. onCanvasFocusObservable: Observable<Engine>;
  31045. /**
  31046. * Observable event triggered each time the canvas receives pointerout event
  31047. */
  31048. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31049. /**
  31050. * Observable event triggered before each texture is initialized
  31051. */
  31052. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31053. /**
  31054. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31055. */
  31056. disableUniformBuffers: boolean;
  31057. /** @hidden */
  31058. _uniformBuffers: UniformBuffer[];
  31059. /**
  31060. * Gets a boolean indicating that the engine supports uniform buffers
  31061. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31062. */
  31063. readonly supportsUniformBuffers: boolean;
  31064. /**
  31065. * Observable raised when the engine begins a new frame
  31066. */
  31067. onBeginFrameObservable: Observable<Engine>;
  31068. /**
  31069. * If set, will be used to request the next animation frame for the render loop
  31070. */
  31071. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31072. /**
  31073. * Observable raised when the engine ends the current frame
  31074. */
  31075. onEndFrameObservable: Observable<Engine>;
  31076. /**
  31077. * Observable raised when the engine is about to compile a shader
  31078. */
  31079. onBeforeShaderCompilationObservable: Observable<Engine>;
  31080. /**
  31081. * Observable raised when the engine has jsut compiled a shader
  31082. */
  31083. onAfterShaderCompilationObservable: Observable<Engine>;
  31084. /** @hidden */
  31085. _gl: WebGLRenderingContext;
  31086. private _renderingCanvas;
  31087. private _windowIsBackground;
  31088. protected _webGLVersion: number;
  31089. protected _highPrecisionShadersAllowed: boolean;
  31090. /** @hidden */
  31091. readonly _shouldUseHighPrecisionShader: boolean;
  31092. /**
  31093. * Gets a boolean indicating that only power of 2 textures are supported
  31094. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31095. */
  31096. readonly needPOTTextures: boolean;
  31097. /** @hidden */
  31098. _badOS: boolean;
  31099. /** @hidden */
  31100. _badDesktopOS: boolean;
  31101. /**
  31102. * Gets the audio engine
  31103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31104. * @ignorenaming
  31105. */
  31106. static audioEngine: IAudioEngine;
  31107. /**
  31108. * Default AudioEngine factory responsible of creating the Audio Engine.
  31109. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31110. */
  31111. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31112. /**
  31113. * Default offline support factory responsible of creating a tool used to store data locally.
  31114. * By default, this will create a Database object if the workload has been embedded.
  31115. */
  31116. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31117. private _onFocus;
  31118. private _onBlur;
  31119. private _onCanvasPointerOut;
  31120. private _onCanvasBlur;
  31121. private _onCanvasFocus;
  31122. private _onFullscreenChange;
  31123. private _onPointerLockChange;
  31124. private _hardwareScalingLevel;
  31125. /** @hidden */
  31126. _caps: EngineCapabilities;
  31127. private _pointerLockRequested;
  31128. private _isStencilEnable;
  31129. protected _colorWrite: boolean;
  31130. private _loadingScreen;
  31131. /** @hidden */
  31132. _drawCalls: PerfCounter;
  31133. private _glVersion;
  31134. private _glRenderer;
  31135. private _glVendor;
  31136. private _videoTextureSupported;
  31137. private _renderingQueueLaunched;
  31138. private _activeRenderLoops;
  31139. private _deterministicLockstep;
  31140. private _lockstepMaxSteps;
  31141. /**
  31142. * Observable signaled when a context lost event is raised
  31143. */
  31144. onContextLostObservable: Observable<Engine>;
  31145. /**
  31146. * Observable signaled when a context restored event is raised
  31147. */
  31148. onContextRestoredObservable: Observable<Engine>;
  31149. private _onContextLost;
  31150. private _onContextRestored;
  31151. private _contextWasLost;
  31152. /** @hidden */
  31153. _doNotHandleContextLost: boolean;
  31154. /**
  31155. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31157. */
  31158. doNotHandleContextLost: boolean;
  31159. private _performanceMonitor;
  31160. private _fps;
  31161. private _deltaTime;
  31162. /**
  31163. * Turn this value on if you want to pause FPS computation when in background
  31164. */
  31165. disablePerformanceMonitorInBackground: boolean;
  31166. /**
  31167. * Gets the performance monitor attached to this engine
  31168. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31169. */
  31170. readonly performanceMonitor: PerformanceMonitor;
  31171. /**
  31172. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31173. */
  31174. disableVertexArrayObjects: boolean;
  31175. /** @hidden */
  31176. protected _depthCullingState: _DepthCullingState;
  31177. /** @hidden */
  31178. protected _stencilState: _StencilState;
  31179. /** @hidden */
  31180. protected _alphaState: _AlphaState;
  31181. /** @hidden */
  31182. protected _alphaMode: number;
  31183. /** @hidden */
  31184. _internalTexturesCache: InternalTexture[];
  31185. /** @hidden */
  31186. protected _activeChannel: number;
  31187. private _currentTextureChannel;
  31188. /** @hidden */
  31189. protected _boundTexturesCache: {
  31190. [key: string]: Nullable<InternalTexture>;
  31191. };
  31192. /** @hidden */
  31193. protected _currentEffect: Nullable<Effect>;
  31194. /** @hidden */
  31195. protected _currentProgram: Nullable<WebGLProgram>;
  31196. private _compiledEffects;
  31197. private _vertexAttribArraysEnabled;
  31198. /** @hidden */
  31199. protected _cachedViewport: Nullable<IViewportLike>;
  31200. private _cachedVertexArrayObject;
  31201. /** @hidden */
  31202. protected _cachedVertexBuffers: any;
  31203. /** @hidden */
  31204. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31205. /** @hidden */
  31206. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31207. /** @hidden */
  31208. _currentRenderTarget: Nullable<InternalTexture>;
  31209. private _uintIndicesCurrentlySet;
  31210. private _currentBoundBuffer;
  31211. /** @hidden */
  31212. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31213. private _currentBufferPointers;
  31214. private _currentInstanceLocations;
  31215. private _currentInstanceBuffers;
  31216. private _textureUnits;
  31217. /** @hidden */
  31218. _workingCanvas: Nullable<HTMLCanvasElement>;
  31219. /** @hidden */
  31220. _workingContext: Nullable<CanvasRenderingContext2D>;
  31221. private _rescalePostProcess;
  31222. private _dummyFramebuffer;
  31223. private _externalData;
  31224. /** @hidden */
  31225. _bindedRenderFunction: any;
  31226. private _vaoRecordInProgress;
  31227. private _mustWipeVertexAttributes;
  31228. private _emptyTexture;
  31229. private _emptyCubeTexture;
  31230. private _emptyTexture3D;
  31231. /** @hidden */
  31232. _frameHandler: number;
  31233. private _nextFreeTextureSlots;
  31234. private _maxSimultaneousTextures;
  31235. private _activeRequests;
  31236. private _texturesSupported;
  31237. /** @hidden */
  31238. _textureFormatInUse: Nullable<string>;
  31239. /**
  31240. * Gets the list of texture formats supported
  31241. */
  31242. readonly texturesSupported: Array<string>;
  31243. /**
  31244. * Gets the list of texture formats in use
  31245. */
  31246. readonly textureFormatInUse: Nullable<string>;
  31247. /**
  31248. * Gets the current viewport
  31249. */
  31250. readonly currentViewport: Nullable<IViewportLike>;
  31251. /**
  31252. * Gets the default empty texture
  31253. */
  31254. readonly emptyTexture: InternalTexture;
  31255. /**
  31256. * Gets the default empty 3D texture
  31257. */
  31258. readonly emptyTexture3D: InternalTexture;
  31259. /**
  31260. * Gets the default empty cube texture
  31261. */
  31262. readonly emptyCubeTexture: InternalTexture;
  31263. /**
  31264. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31265. */
  31266. readonly premultipliedAlpha: boolean;
  31267. /**
  31268. * Creates a new engine
  31269. * @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
  31270. * @param antialias defines enable antialiasing (default: false)
  31271. * @param options defines further options to be sent to the getContext() function
  31272. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31273. */
  31274. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31275. /**
  31276. * Initializes a webVR display and starts listening to display change events
  31277. * The onVRDisplayChangedObservable will be notified upon these changes
  31278. * @returns The onVRDisplayChangedObservable
  31279. */
  31280. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31281. /** @hidden */
  31282. _prepareVRComponent(): void;
  31283. /** @hidden */
  31284. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31285. /** @hidden */
  31286. _submitVRFrame(): void;
  31287. /**
  31288. * Call this function to leave webVR mode
  31289. * Will do nothing if webVR is not supported or if there is no webVR device
  31290. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31291. */
  31292. disableVR(): void;
  31293. /**
  31294. * Gets a boolean indicating that the system is in VR mode and is presenting
  31295. * @returns true if VR mode is engaged
  31296. */
  31297. isVRPresenting(): boolean;
  31298. /** @hidden */
  31299. _requestVRFrame(): void;
  31300. private _disableTouchAction;
  31301. private _rebuildInternalTextures;
  31302. private _rebuildEffects;
  31303. /**
  31304. * Gets a boolean indicating if all created effects are ready
  31305. * @returns true if all effects are ready
  31306. */
  31307. areAllEffectsReady(): boolean;
  31308. private _rebuildBuffers;
  31309. private _initGLContext;
  31310. /**
  31311. * Gets version of the current webGL context
  31312. */
  31313. readonly webGLVersion: number;
  31314. /**
  31315. * Gets a string idenfifying the name of the class
  31316. * @returns "Engine" string
  31317. */
  31318. getClassName(): string;
  31319. /**
  31320. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31321. */
  31322. readonly isStencilEnable: boolean;
  31323. /** @hidden */
  31324. _prepareWorkingCanvas(): void;
  31325. /**
  31326. * Reset the texture cache to empty state
  31327. */
  31328. resetTextureCache(): void;
  31329. /**
  31330. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31331. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31332. * @returns true if engine is in deterministic lock step mode
  31333. */
  31334. isDeterministicLockStep(): boolean;
  31335. /**
  31336. * Gets the max steps when engine is running in deterministic lock step
  31337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31338. * @returns the max steps
  31339. */
  31340. getLockstepMaxSteps(): number;
  31341. /**
  31342. * Gets an object containing information about the current webGL context
  31343. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31344. */
  31345. getGlInfo(): {
  31346. vendor: string;
  31347. renderer: string;
  31348. version: string;
  31349. };
  31350. /**
  31351. * Gets current aspect ratio
  31352. * @param viewportOwner defines the camera to use to get the aspect ratio
  31353. * @param useScreen defines if screen size must be used (or the current render target if any)
  31354. * @returns a number defining the aspect ratio
  31355. */
  31356. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31357. /**
  31358. * Gets current screen aspect ratio
  31359. * @returns a number defining the aspect ratio
  31360. */
  31361. getScreenAspectRatio(): number;
  31362. /**
  31363. * Gets the current render width
  31364. * @param useScreen defines if screen size must be used (or the current render target if any)
  31365. * @returns a number defining the current render width
  31366. */
  31367. getRenderWidth(useScreen?: boolean): number;
  31368. /**
  31369. * Gets the current render height
  31370. * @param useScreen defines if screen size must be used (or the current render target if any)
  31371. * @returns a number defining the current render height
  31372. */
  31373. getRenderHeight(useScreen?: boolean): number;
  31374. /**
  31375. * Gets the HTML canvas attached with the current webGL context
  31376. * @returns a HTML canvas
  31377. */
  31378. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31379. /**
  31380. * Gets host window
  31381. * @returns the host window object
  31382. */
  31383. getHostWindow(): Window;
  31384. /**
  31385. * Gets host document
  31386. * @returns the host document object
  31387. */
  31388. getHostDocument(): Document;
  31389. /**
  31390. * Gets the client rect of the HTML canvas attached with the current webGL context
  31391. * @returns a client rectanglee
  31392. */
  31393. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31394. /**
  31395. * Defines the hardware scaling level.
  31396. * By default the hardware scaling level is computed from the window device ratio.
  31397. * 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.
  31398. * @param level defines the level to use
  31399. */
  31400. setHardwareScalingLevel(level: number): void;
  31401. /**
  31402. * Gets the current hardware scaling level.
  31403. * By default the hardware scaling level is computed from the window device ratio.
  31404. * 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.
  31405. * @returns a number indicating the current hardware scaling level
  31406. */
  31407. getHardwareScalingLevel(): number;
  31408. /**
  31409. * Gets the list of loaded textures
  31410. * @returns an array containing all loaded textures
  31411. */
  31412. getLoadedTexturesCache(): InternalTexture[];
  31413. /**
  31414. * Gets the object containing all engine capabilities
  31415. * @returns the EngineCapabilities object
  31416. */
  31417. getCaps(): EngineCapabilities;
  31418. /**
  31419. * Gets the current depth function
  31420. * @returns a number defining the depth function
  31421. */
  31422. getDepthFunction(): Nullable<number>;
  31423. /**
  31424. * Sets the current depth function
  31425. * @param depthFunc defines the function to use
  31426. */
  31427. setDepthFunction(depthFunc: number): void;
  31428. /**
  31429. * Sets the current depth function to GREATER
  31430. */
  31431. setDepthFunctionToGreater(): void;
  31432. /**
  31433. * Sets the current depth function to GEQUAL
  31434. */
  31435. setDepthFunctionToGreaterOrEqual(): void;
  31436. /**
  31437. * Sets the current depth function to LESS
  31438. */
  31439. setDepthFunctionToLess(): void;
  31440. private _cachedStencilBuffer;
  31441. private _cachedStencilFunction;
  31442. private _cachedStencilMask;
  31443. private _cachedStencilOperationPass;
  31444. private _cachedStencilOperationFail;
  31445. private _cachedStencilOperationDepthFail;
  31446. private _cachedStencilReference;
  31447. /**
  31448. * Caches the the state of the stencil buffer
  31449. */
  31450. cacheStencilState(): void;
  31451. /**
  31452. * Restores the state of the stencil buffer
  31453. */
  31454. restoreStencilState(): void;
  31455. /**
  31456. * Sets the current depth function to LEQUAL
  31457. */
  31458. setDepthFunctionToLessOrEqual(): void;
  31459. /**
  31460. * Gets a boolean indicating if stencil buffer is enabled
  31461. * @returns the current stencil buffer state
  31462. */
  31463. getStencilBuffer(): boolean;
  31464. /**
  31465. * Enable or disable the stencil buffer
  31466. * @param enable defines if the stencil buffer must be enabled or disabled
  31467. */
  31468. setStencilBuffer(enable: boolean): void;
  31469. /**
  31470. * Gets the current stencil mask
  31471. * @returns a number defining the new stencil mask to use
  31472. */
  31473. getStencilMask(): number;
  31474. /**
  31475. * Sets the current stencil mask
  31476. * @param mask defines the new stencil mask to use
  31477. */
  31478. setStencilMask(mask: number): void;
  31479. /**
  31480. * Gets the current stencil function
  31481. * @returns a number defining the stencil function to use
  31482. */
  31483. getStencilFunction(): number;
  31484. /**
  31485. * Gets the current stencil reference value
  31486. * @returns a number defining the stencil reference value to use
  31487. */
  31488. getStencilFunctionReference(): number;
  31489. /**
  31490. * Gets the current stencil mask
  31491. * @returns a number defining the stencil mask to use
  31492. */
  31493. getStencilFunctionMask(): number;
  31494. /**
  31495. * Sets the current stencil function
  31496. * @param stencilFunc defines the new stencil function to use
  31497. */
  31498. setStencilFunction(stencilFunc: number): void;
  31499. /**
  31500. * Sets the current stencil reference
  31501. * @param reference defines the new stencil reference to use
  31502. */
  31503. setStencilFunctionReference(reference: number): void;
  31504. /**
  31505. * Sets the current stencil mask
  31506. * @param mask defines the new stencil mask to use
  31507. */
  31508. setStencilFunctionMask(mask: number): void;
  31509. /**
  31510. * Gets the current stencil operation when stencil fails
  31511. * @returns a number defining stencil operation to use when stencil fails
  31512. */
  31513. getStencilOperationFail(): number;
  31514. /**
  31515. * Gets the current stencil operation when depth fails
  31516. * @returns a number defining stencil operation to use when depth fails
  31517. */
  31518. getStencilOperationDepthFail(): number;
  31519. /**
  31520. * Gets the current stencil operation when stencil passes
  31521. * @returns a number defining stencil operation to use when stencil passes
  31522. */
  31523. getStencilOperationPass(): number;
  31524. /**
  31525. * Sets the stencil operation to use when stencil fails
  31526. * @param operation defines the stencil operation to use when stencil fails
  31527. */
  31528. setStencilOperationFail(operation: number): void;
  31529. /**
  31530. * Sets the stencil operation to use when depth fails
  31531. * @param operation defines the stencil operation to use when depth fails
  31532. */
  31533. setStencilOperationDepthFail(operation: number): void;
  31534. /**
  31535. * Sets the stencil operation to use when stencil passes
  31536. * @param operation defines the stencil operation to use when stencil passes
  31537. */
  31538. setStencilOperationPass(operation: number): void;
  31539. /**
  31540. * Sets a boolean indicating if the dithering state is enabled or disabled
  31541. * @param value defines the dithering state
  31542. */
  31543. setDitheringState(value: boolean): void;
  31544. /**
  31545. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31546. * @param value defines the rasterizer state
  31547. */
  31548. setRasterizerState(value: boolean): void;
  31549. /**
  31550. * stop executing a render loop function and remove it from the execution array
  31551. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31552. */
  31553. stopRenderLoop(renderFunction?: () => void): void;
  31554. /** @hidden */
  31555. _renderLoop(): void;
  31556. /**
  31557. * Can be used to override the current requestAnimationFrame requester.
  31558. * @hidden
  31559. */
  31560. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31561. /**
  31562. * Register and execute a render loop. The engine can have more than one render function
  31563. * @param renderFunction defines the function to continuously execute
  31564. */
  31565. runRenderLoop(renderFunction: () => void): void;
  31566. /**
  31567. * Toggle full screen mode
  31568. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31569. */
  31570. switchFullscreen(requestPointerLock: boolean): void;
  31571. /**
  31572. * Enters full screen mode
  31573. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31574. */
  31575. enterFullscreen(requestPointerLock: boolean): void;
  31576. /**
  31577. * Exits full screen mode
  31578. */
  31579. exitFullscreen(): void;
  31580. /**
  31581. * Enters Pointerlock mode
  31582. */
  31583. enterPointerlock(): void;
  31584. /**
  31585. * Exits Pointerlock mode
  31586. */
  31587. exitPointerlock(): void;
  31588. /**
  31589. * Clear the current render buffer or the current render target (if any is set up)
  31590. * @param color defines the color to use
  31591. * @param backBuffer defines if the back buffer must be cleared
  31592. * @param depth defines if the depth buffer must be cleared
  31593. * @param stencil defines if the stencil buffer must be cleared
  31594. */
  31595. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31596. /**
  31597. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31598. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31599. * @param y defines the y-coordinate of the corner of the clear rectangle
  31600. * @param width defines the width of the clear rectangle
  31601. * @param height defines the height of the clear rectangle
  31602. * @param clearColor defines the clear color
  31603. */
  31604. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31605. /**
  31606. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31607. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31608. * @param y defines the y-coordinate of the corner of the clear rectangle
  31609. * @param width defines the width of the clear rectangle
  31610. * @param height defines the height of the clear rectangle
  31611. */
  31612. enableScissor(x: number, y: number, width: number, height: number): void;
  31613. /**
  31614. * Disable previously set scissor test rectangle
  31615. */
  31616. disableScissor(): void;
  31617. private _viewportCached;
  31618. /** @hidden */
  31619. _viewport(x: number, y: number, width: number, height: number): void;
  31620. /**
  31621. * Set the WebGL's viewport
  31622. * @param viewport defines the viewport element to be used
  31623. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31624. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31625. */
  31626. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31627. /**
  31628. * Directly set the WebGL Viewport
  31629. * @param x defines the x coordinate of the viewport (in screen space)
  31630. * @param y defines the y coordinate of the viewport (in screen space)
  31631. * @param width defines the width of the viewport (in screen space)
  31632. * @param height defines the height of the viewport (in screen space)
  31633. * @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
  31634. */
  31635. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31636. /**
  31637. * Begin a new frame
  31638. */
  31639. beginFrame(): void;
  31640. /**
  31641. * Enf the current frame
  31642. */
  31643. endFrame(): void;
  31644. /**
  31645. * Resize the view according to the canvas' size
  31646. */
  31647. resize(): void;
  31648. /**
  31649. * Force a specific size of the canvas
  31650. * @param width defines the new canvas' width
  31651. * @param height defines the new canvas' height
  31652. */
  31653. setSize(width: number, height: number): void;
  31654. /**
  31655. * Binds the frame buffer to the specified texture.
  31656. * @param texture The texture to render to or null for the default canvas
  31657. * @param faceIndex The face of the texture to render to in case of cube texture
  31658. * @param requiredWidth The width of the target to render to
  31659. * @param requiredHeight The height of the target to render to
  31660. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31661. * @param depthStencilTexture The depth stencil texture to use to render
  31662. * @param lodLevel defines le lod level to bind to the frame buffer
  31663. */
  31664. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31665. /** @hidden */
  31666. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31667. /**
  31668. * Unbind the current render target texture from the webGL context
  31669. * @param texture defines the render target texture to unbind
  31670. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31671. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31672. */
  31673. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31674. /**
  31675. * Force the mipmap generation for the given render target texture
  31676. * @param texture defines the render target texture to use
  31677. */
  31678. generateMipMapsForCubemap(texture: InternalTexture): void;
  31679. /**
  31680. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31681. */
  31682. flushFramebuffer(): void;
  31683. /**
  31684. * Unbind the current render target and bind the default framebuffer
  31685. */
  31686. restoreDefaultFramebuffer(): void;
  31687. /**
  31688. * Create an uniform buffer
  31689. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31690. * @param elements defines the content of the uniform buffer
  31691. * @returns the webGL uniform buffer
  31692. */
  31693. createUniformBuffer(elements: FloatArray): DataBuffer;
  31694. /**
  31695. * Create a dynamic uniform buffer
  31696. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31697. * @param elements defines the content of the uniform buffer
  31698. * @returns the webGL uniform buffer
  31699. */
  31700. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31701. /**
  31702. * Update an existing uniform buffer
  31703. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31704. * @param uniformBuffer defines the target uniform buffer
  31705. * @param elements defines the content to update
  31706. * @param offset defines the offset in the uniform buffer where update should start
  31707. * @param count defines the size of the data to update
  31708. */
  31709. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31710. private _resetVertexBufferBinding;
  31711. /**
  31712. * Creates a vertex buffer
  31713. * @param data the data for the vertex buffer
  31714. * @returns the new WebGL static buffer
  31715. */
  31716. createVertexBuffer(data: DataArray): DataBuffer;
  31717. /**
  31718. * Creates a dynamic vertex buffer
  31719. * @param data the data for the dynamic vertex buffer
  31720. * @returns the new WebGL dynamic buffer
  31721. */
  31722. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31723. /**
  31724. * Update a dynamic index buffer
  31725. * @param indexBuffer defines the target index buffer
  31726. * @param indices defines the data to update
  31727. * @param offset defines the offset in the target index buffer where update should start
  31728. */
  31729. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31730. /**
  31731. * Updates a dynamic vertex buffer.
  31732. * @param vertexBuffer the vertex buffer to update
  31733. * @param data the data used to update the vertex buffer
  31734. * @param byteOffset the byte offset of the data
  31735. * @param byteLength the byte length of the data
  31736. */
  31737. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31738. private _resetIndexBufferBinding;
  31739. /**
  31740. * Creates a new index buffer
  31741. * @param indices defines the content of the index buffer
  31742. * @param updatable defines if the index buffer must be updatable
  31743. * @returns a new webGL buffer
  31744. */
  31745. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31746. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31747. /**
  31748. * Bind a webGL buffer to the webGL context
  31749. * @param buffer defines the buffer to bind
  31750. */
  31751. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31752. /**
  31753. * Bind an uniform buffer to the current webGL context
  31754. * @param buffer defines the buffer to bind
  31755. */
  31756. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31757. /**
  31758. * Bind a buffer to the current webGL context at a given location
  31759. * @param buffer defines the buffer to bind
  31760. * @param location defines the index where to bind the buffer
  31761. */
  31762. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31763. /**
  31764. * Bind a specific block at a given index in a specific shader program
  31765. * @param pipelineContext defines the pipeline context to use
  31766. * @param blockName defines the block name
  31767. * @param index defines the index where to bind the block
  31768. */
  31769. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31770. private bindIndexBuffer;
  31771. private bindBuffer;
  31772. /**
  31773. * update the bound buffer with the given data
  31774. * @param data defines the data to update
  31775. */
  31776. updateArrayBuffer(data: Float32Array): void;
  31777. private _vertexAttribPointer;
  31778. private _bindIndexBufferWithCache;
  31779. private _bindVertexBuffersAttributes;
  31780. /**
  31781. * Records a vertex array object
  31782. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31783. * @param vertexBuffers defines the list of vertex buffers to store
  31784. * @param indexBuffer defines the index buffer to store
  31785. * @param effect defines the effect to store
  31786. * @returns the new vertex array object
  31787. */
  31788. recordVertexArrayObject(vertexBuffers: {
  31789. [key: string]: VertexBuffer;
  31790. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31791. /**
  31792. * Bind a specific vertex array object
  31793. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31794. * @param vertexArrayObject defines the vertex array object to bind
  31795. * @param indexBuffer defines the index buffer to bind
  31796. */
  31797. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31798. /**
  31799. * Bind webGl buffers directly to the webGL context
  31800. * @param vertexBuffer defines the vertex buffer to bind
  31801. * @param indexBuffer defines the index buffer to bind
  31802. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31803. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31804. * @param effect defines the effect associated with the vertex buffer
  31805. */
  31806. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31807. private _unbindVertexArrayObject;
  31808. /**
  31809. * Bind a list of vertex buffers to the webGL context
  31810. * @param vertexBuffers defines the list of vertex buffers to bind
  31811. * @param indexBuffer defines the index buffer to bind
  31812. * @param effect defines the effect associated with the vertex buffers
  31813. */
  31814. bindBuffers(vertexBuffers: {
  31815. [key: string]: Nullable<VertexBuffer>;
  31816. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31817. /**
  31818. * Unbind all instance attributes
  31819. */
  31820. unbindInstanceAttributes(): void;
  31821. /**
  31822. * Release and free the memory of a vertex array object
  31823. * @param vao defines the vertex array object to delete
  31824. */
  31825. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31826. /** @hidden */
  31827. _releaseBuffer(buffer: DataBuffer): boolean;
  31828. protected _deleteBuffer(buffer: DataBuffer): void;
  31829. /**
  31830. * Creates a webGL buffer to use with instanciation
  31831. * @param capacity defines the size of the buffer
  31832. * @returns the webGL buffer
  31833. */
  31834. createInstancesBuffer(capacity: number): DataBuffer;
  31835. /**
  31836. * Delete a webGL buffer used with instanciation
  31837. * @param buffer defines the webGL buffer to delete
  31838. */
  31839. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31840. /**
  31841. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31842. * @param instancesBuffer defines the webGL buffer to update and bind
  31843. * @param data defines the data to store in the buffer
  31844. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31845. */
  31846. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31847. /**
  31848. * Apply all cached states (depth, culling, stencil and alpha)
  31849. */
  31850. applyStates(): void;
  31851. /**
  31852. * Send a draw order
  31853. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31854. * @param indexStart defines the starting index
  31855. * @param indexCount defines the number of index to draw
  31856. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31857. */
  31858. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31859. /**
  31860. * Draw a list of points
  31861. * @param verticesStart defines the index of first vertex to draw
  31862. * @param verticesCount defines the count of vertices to draw
  31863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31864. */
  31865. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31866. /**
  31867. * Draw a list of unindexed primitives
  31868. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31869. * @param verticesStart defines the index of first vertex to draw
  31870. * @param verticesCount defines the count of vertices to draw
  31871. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31872. */
  31873. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31874. /**
  31875. * Draw a list of indexed primitives
  31876. * @param fillMode defines the primitive to use
  31877. * @param indexStart defines the starting index
  31878. * @param indexCount defines the number of index to draw
  31879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31880. */
  31881. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31882. /**
  31883. * Draw a list of unindexed primitives
  31884. * @param fillMode defines the primitive to use
  31885. * @param verticesStart defines the index of first vertex to draw
  31886. * @param verticesCount defines the count of vertices to draw
  31887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31888. */
  31889. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31890. private _drawMode;
  31891. /** @hidden */
  31892. _releaseEffect(effect: Effect): void;
  31893. /** @hidden */
  31894. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31895. /**
  31896. * Create a new effect (used to store vertex/fragment shaders)
  31897. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31898. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31899. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31900. * @param samplers defines an array of string used to represent textures
  31901. * @param defines defines the string containing the defines to use to compile the shaders
  31902. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31903. * @param onCompiled defines a function to call when the effect creation is successful
  31904. * @param onError defines a function to call when the effect creation has failed
  31905. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31906. * @returns the new Effect
  31907. */
  31908. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31909. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31910. private _compileShader;
  31911. private _compileRawShader;
  31912. /**
  31913. * Directly creates a webGL program
  31914. * @param pipelineContext defines the pipeline context to attach to
  31915. * @param vertexCode defines the vertex shader code to use
  31916. * @param fragmentCode defines the fragment shader code to use
  31917. * @param context defines the webGL context to use (if not set, the current one will be used)
  31918. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31919. * @returns the new webGL program
  31920. */
  31921. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31922. /**
  31923. * Creates a webGL program
  31924. * @param pipelineContext defines the pipeline context to attach to
  31925. * @param vertexCode defines the vertex shader code to use
  31926. * @param fragmentCode defines the fragment shader code to use
  31927. * @param defines defines the string containing the defines to use to compile the shaders
  31928. * @param context defines the webGL context to use (if not set, the current one will be used)
  31929. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31930. * @returns the new webGL program
  31931. */
  31932. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31933. /**
  31934. * Creates a new pipeline context
  31935. * @returns the new pipeline
  31936. */
  31937. createPipelineContext(): IPipelineContext;
  31938. private _createShaderProgram;
  31939. private _finalizePipelineContext;
  31940. /** @hidden */
  31941. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31942. /** @hidden */
  31943. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31944. /** @hidden */
  31945. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31946. /**
  31947. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31948. * @param pipelineContext defines the pipeline context to use
  31949. * @param uniformsNames defines the list of uniform names
  31950. * @returns an array of webGL uniform locations
  31951. */
  31952. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31953. /**
  31954. * Gets the lsit of active attributes for a given webGL program
  31955. * @param pipelineContext defines the pipeline context to use
  31956. * @param attributesNames defines the list of attribute names to get
  31957. * @returns an array of indices indicating the offset of each attribute
  31958. */
  31959. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31960. /**
  31961. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31962. * @param effect defines the effect to activate
  31963. */
  31964. enableEffect(effect: Nullable<Effect>): void;
  31965. /**
  31966. * Set the value of an uniform to an array of int32
  31967. * @param uniform defines the webGL uniform location where to store the value
  31968. * @param array defines the array of int32 to store
  31969. */
  31970. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31971. /**
  31972. * Set the value of an uniform to an array of int32 (stored as vec2)
  31973. * @param uniform defines the webGL uniform location where to store the value
  31974. * @param array defines the array of int32 to store
  31975. */
  31976. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31977. /**
  31978. * Set the value of an uniform to an array of int32 (stored as vec3)
  31979. * @param uniform defines the webGL uniform location where to store the value
  31980. * @param array defines the array of int32 to store
  31981. */
  31982. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31983. /**
  31984. * Set the value of an uniform to an array of int32 (stored as vec4)
  31985. * @param uniform defines the webGL uniform location where to store the value
  31986. * @param array defines the array of int32 to store
  31987. */
  31988. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31989. /**
  31990. * Set the value of an uniform to an array of float32
  31991. * @param uniform defines the webGL uniform location where to store the value
  31992. * @param array defines the array of float32 to store
  31993. */
  31994. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31995. /**
  31996. * Set the value of an uniform to an array of float32 (stored as vec2)
  31997. * @param uniform defines the webGL uniform location where to store the value
  31998. * @param array defines the array of float32 to store
  31999. */
  32000. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32001. /**
  32002. * Set the value of an uniform to an array of float32 (stored as vec3)
  32003. * @param uniform defines the webGL uniform location where to store the value
  32004. * @param array defines the array of float32 to store
  32005. */
  32006. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32007. /**
  32008. * Set the value of an uniform to an array of float32 (stored as vec4)
  32009. * @param uniform defines the webGL uniform location where to store the value
  32010. * @param array defines the array of float32 to store
  32011. */
  32012. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32013. /**
  32014. * Set the value of an uniform to an array of number
  32015. * @param uniform defines the webGL uniform location where to store the value
  32016. * @param array defines the array of number to store
  32017. */
  32018. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32019. /**
  32020. * Set the value of an uniform to an array of number (stored as vec2)
  32021. * @param uniform defines the webGL uniform location where to store the value
  32022. * @param array defines the array of number to store
  32023. */
  32024. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32025. /**
  32026. * Set the value of an uniform to an array of number (stored as vec3)
  32027. * @param uniform defines the webGL uniform location where to store the value
  32028. * @param array defines the array of number to store
  32029. */
  32030. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32031. /**
  32032. * Set the value of an uniform to an array of number (stored as vec4)
  32033. * @param uniform defines the webGL uniform location where to store the value
  32034. * @param array defines the array of number to store
  32035. */
  32036. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32037. /**
  32038. * Set the value of an uniform to an array of float32 (stored as matrices)
  32039. * @param uniform defines the webGL uniform location where to store the value
  32040. * @param matrices defines the array of float32 to store
  32041. */
  32042. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32043. /**
  32044. * Set the value of an uniform to a matrix (3x3)
  32045. * @param uniform defines the webGL uniform location where to store the value
  32046. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32047. */
  32048. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32049. /**
  32050. * Set the value of an uniform to a matrix (2x2)
  32051. * @param uniform defines the webGL uniform location where to store the value
  32052. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32053. */
  32054. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32055. /**
  32056. * Set the value of an uniform to a number (int)
  32057. * @param uniform defines the webGL uniform location where to store the value
  32058. * @param value defines the int number to store
  32059. */
  32060. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32061. /**
  32062. * Set the value of an uniform to a number (float)
  32063. * @param uniform defines the webGL uniform location where to store the value
  32064. * @param value defines the float number to store
  32065. */
  32066. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32067. /**
  32068. * Set the value of an uniform to a vec2
  32069. * @param uniform defines the webGL uniform location where to store the value
  32070. * @param x defines the 1st component of the value
  32071. * @param y defines the 2nd component of the value
  32072. */
  32073. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32074. /**
  32075. * Set the value of an uniform to a vec3
  32076. * @param uniform defines the webGL uniform location where to store the value
  32077. * @param x defines the 1st component of the value
  32078. * @param y defines the 2nd component of the value
  32079. * @param z defines the 3rd component of the value
  32080. */
  32081. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32082. /**
  32083. * Set the value of an uniform to a boolean
  32084. * @param uniform defines the webGL uniform location where to store the value
  32085. * @param bool defines the boolean to store
  32086. */
  32087. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  32088. /**
  32089. * Set the value of an uniform to a vec4
  32090. * @param uniform defines the webGL uniform location where to store the value
  32091. * @param x defines the 1st component of the value
  32092. * @param y defines the 2nd component of the value
  32093. * @param z defines the 3rd component of the value
  32094. * @param w defines the 4th component of the value
  32095. */
  32096. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32097. /**
  32098. * Sets a Color4 on a uniform variable
  32099. * @param uniform defines the uniform location
  32100. * @param color4 defines the value to be set
  32101. */
  32102. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32103. /**
  32104. * Set various states to the webGL context
  32105. * @param culling defines backface culling state
  32106. * @param zOffset defines the value to apply to zOffset (0 by default)
  32107. * @param force defines if states must be applied even if cache is up to date
  32108. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32109. */
  32110. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32111. /**
  32112. * Set the z offset to apply to current rendering
  32113. * @param value defines the offset to apply
  32114. */
  32115. setZOffset(value: number): void;
  32116. /**
  32117. * Gets the current value of the zOffset
  32118. * @returns the current zOffset state
  32119. */
  32120. getZOffset(): number;
  32121. /**
  32122. * Enable or disable depth buffering
  32123. * @param enable defines the state to set
  32124. */
  32125. setDepthBuffer(enable: boolean): void;
  32126. /**
  32127. * Gets a boolean indicating if depth writing is enabled
  32128. * @returns the current depth writing state
  32129. */
  32130. getDepthWrite(): boolean;
  32131. /**
  32132. * Enable or disable depth writing
  32133. * @param enable defines the state to set
  32134. */
  32135. setDepthWrite(enable: boolean): void;
  32136. /**
  32137. * Enable or disable color writing
  32138. * @param enable defines the state to set
  32139. */
  32140. setColorWrite(enable: boolean): void;
  32141. /**
  32142. * Gets a boolean indicating if color writing is enabled
  32143. * @returns the current color writing state
  32144. */
  32145. getColorWrite(): boolean;
  32146. /**
  32147. * Sets alpha constants used by some alpha blending modes
  32148. * @param r defines the red component
  32149. * @param g defines the green component
  32150. * @param b defines the blue component
  32151. * @param a defines the alpha component
  32152. */
  32153. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32154. /**
  32155. * Sets the current alpha mode
  32156. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32157. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32158. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32159. */
  32160. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32161. /**
  32162. * Gets the current alpha mode
  32163. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32164. * @returns the current alpha mode
  32165. */
  32166. getAlphaMode(): number;
  32167. /**
  32168. * Clears the list of texture accessible through engine.
  32169. * This can help preventing texture load conflict due to name collision.
  32170. */
  32171. clearInternalTexturesCache(): void;
  32172. /**
  32173. * Force the entire cache to be cleared
  32174. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32175. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32176. */
  32177. wipeCaches(bruteForce?: boolean): void;
  32178. /**
  32179. * Set the compressed texture format to use, based on the formats you have, and the formats
  32180. * supported by the hardware / browser.
  32181. *
  32182. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32183. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32184. * to API arguments needed to compressed textures. This puts the burden on the container
  32185. * generator to house the arcane code for determining these for current & future formats.
  32186. *
  32187. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32188. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32189. *
  32190. * Note: The result of this call is not taken into account when a texture is base64.
  32191. *
  32192. * @param formatsAvailable defines the list of those format families you have created
  32193. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32194. *
  32195. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32196. * @returns The extension selected.
  32197. */
  32198. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32199. /** @hidden */
  32200. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32201. min: number;
  32202. mag: number;
  32203. };
  32204. /** @hidden */
  32205. _createTexture(): WebGLTexture;
  32206. /**
  32207. * Usually called from Texture.ts.
  32208. * Passed information to create a WebGLTexture
  32209. * @param urlArg defines a value which contains one of the following:
  32210. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32211. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32212. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32213. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32214. * @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)
  32215. * @param scene needed for loading to the correct scene
  32216. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32217. * @param onLoad optional callback to be called upon successful completion
  32218. * @param onError optional callback to be called upon failure
  32219. * @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
  32220. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32221. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32222. * @param forcedExtension defines the extension to use to pick the right loader
  32223. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32224. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32225. */
  32226. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32227. /**
  32228. * @hidden
  32229. * Rescales a texture
  32230. * @param source input texutre
  32231. * @param destination destination texture
  32232. * @param scene scene to use to render the resize
  32233. * @param internalFormat format to use when resizing
  32234. * @param onComplete callback to be called when resize has completed
  32235. */
  32236. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32237. private _unpackFlipYCached;
  32238. /**
  32239. * In case you are sharing the context with other applications, it might
  32240. * be interested to not cache the unpack flip y state to ensure a consistent
  32241. * value would be set.
  32242. */
  32243. enableUnpackFlipYCached: boolean;
  32244. /** @hidden */
  32245. _unpackFlipY(value: boolean): void;
  32246. /** @hidden */
  32247. _getUnpackAlignement(): number;
  32248. /**
  32249. * Creates a dynamic texture
  32250. * @param width defines the width of the texture
  32251. * @param height defines the height of the texture
  32252. * @param generateMipMaps defines if the engine should generate the mip levels
  32253. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32254. * @returns the dynamic texture inside an InternalTexture
  32255. */
  32256. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32257. /**
  32258. * Update the sampling mode of a given texture
  32259. * @param samplingMode defines the required sampling mode
  32260. * @param texture defines the texture to update
  32261. */
  32262. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32263. /**
  32264. * Update the content of a dynamic texture
  32265. * @param texture defines the texture to update
  32266. * @param canvas defines the canvas containing the source
  32267. * @param invertY defines if data must be stored with Y axis inverted
  32268. * @param premulAlpha defines if alpha is stored as premultiplied
  32269. * @param format defines the format of the data
  32270. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32271. */
  32272. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32273. /**
  32274. * Update a video texture
  32275. * @param texture defines the texture to update
  32276. * @param video defines the video element to use
  32277. * @param invertY defines if data must be stored with Y axis inverted
  32278. */
  32279. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32280. /**
  32281. * Updates a depth texture Comparison Mode and Function.
  32282. * If the comparison Function is equal to 0, the mode will be set to none.
  32283. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32284. * @param texture The texture to set the comparison function for
  32285. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32286. */
  32287. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32288. /** @hidden */
  32289. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32290. width: number;
  32291. height: number;
  32292. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32293. /**
  32294. * Creates a depth stencil texture.
  32295. * This is only available in WebGL 2 or with the depth texture extension available.
  32296. * @param size The size of face edge in the texture.
  32297. * @param options The options defining the texture.
  32298. * @returns The texture
  32299. */
  32300. createDepthStencilTexture(size: number | {
  32301. width: number;
  32302. height: number;
  32303. }, options: DepthTextureCreationOptions): InternalTexture;
  32304. /**
  32305. * Creates a depth stencil texture.
  32306. * This is only available in WebGL 2 or with the depth texture extension available.
  32307. * @param size The size of face edge in the texture.
  32308. * @param options The options defining the texture.
  32309. * @returns The texture
  32310. */
  32311. private _createDepthStencilTexture;
  32312. /**
  32313. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32314. * @param renderTarget The render target to set the frame buffer for
  32315. */
  32316. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32317. /**
  32318. * Creates a new render target texture
  32319. * @param size defines the size of the texture
  32320. * @param options defines the options used to create the texture
  32321. * @returns a new render target texture stored in an InternalTexture
  32322. */
  32323. createRenderTargetTexture(size: number | {
  32324. width: number;
  32325. height: number;
  32326. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32327. /** @hidden */
  32328. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32329. /**
  32330. * Updates the sample count of a render target texture
  32331. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32332. * @param texture defines the texture to update
  32333. * @param samples defines the sample count to set
  32334. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32335. */
  32336. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32337. /** @hidden */
  32338. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32339. /** @hidden */
  32340. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32341. /** @hidden */
  32342. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32343. /** @hidden */
  32344. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32345. /**
  32346. * @hidden
  32347. */
  32348. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32349. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32350. private _prepareWebGLTexture;
  32351. /** @hidden */
  32352. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32353. /** @hidden */
  32354. _releaseFramebufferObjects(texture: InternalTexture): void;
  32355. /** @hidden */
  32356. _releaseTexture(texture: InternalTexture): void;
  32357. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32358. protected _setProgram(program: WebGLProgram): void;
  32359. protected _boundUniforms: {
  32360. [key: number]: WebGLUniformLocation;
  32361. };
  32362. /**
  32363. * Binds an effect to the webGL context
  32364. * @param effect defines the effect to bind
  32365. */
  32366. bindSamplers(effect: Effect): void;
  32367. private _activateCurrentTexture;
  32368. /** @hidden */
  32369. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32370. /** @hidden */
  32371. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32372. /**
  32373. * Sets a texture to the webGL context from a postprocess
  32374. * @param channel defines the channel to use
  32375. * @param postProcess defines the source postprocess
  32376. */
  32377. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32378. /**
  32379. * Binds the output of the passed in post process to the texture channel specified
  32380. * @param channel The channel the texture should be bound to
  32381. * @param postProcess The post process which's output should be bound
  32382. */
  32383. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32384. /**
  32385. * Unbind all textures from the webGL context
  32386. */
  32387. unbindAllTextures(): void;
  32388. /**
  32389. * Sets a texture to the according uniform.
  32390. * @param channel The texture channel
  32391. * @param uniform The uniform to set
  32392. * @param texture The texture to apply
  32393. */
  32394. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32395. /**
  32396. * Sets a depth stencil texture from a render target to the according uniform.
  32397. * @param channel The texture channel
  32398. * @param uniform The uniform to set
  32399. * @param texture The render target texture containing the depth stencil texture to apply
  32400. */
  32401. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32402. private _bindSamplerUniformToChannel;
  32403. private _getTextureWrapMode;
  32404. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32405. /**
  32406. * Sets an array of texture to the webGL context
  32407. * @param channel defines the channel where the texture array must be set
  32408. * @param uniform defines the associated uniform location
  32409. * @param textures defines the array of textures to bind
  32410. */
  32411. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32412. /** @hidden */
  32413. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32414. private _setTextureParameterFloat;
  32415. private _setTextureParameterInteger;
  32416. /**
  32417. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32418. * @param x defines the x coordinate of the rectangle where pixels must be read
  32419. * @param y defines the y coordinate of the rectangle where pixels must be read
  32420. * @param width defines the width of the rectangle where pixels must be read
  32421. * @param height defines the height of the rectangle where pixels must be read
  32422. * @returns a Uint8Array containing RGBA colors
  32423. */
  32424. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32425. /**
  32426. * Add an externaly attached data from its key.
  32427. * This method call will fail and return false, if such key already exists.
  32428. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32429. * @param key the unique key that identifies the data
  32430. * @param data the data object to associate to the key for this Engine instance
  32431. * @return true if no such key were already present and the data was added successfully, false otherwise
  32432. */
  32433. addExternalData<T>(key: string, data: T): boolean;
  32434. /**
  32435. * Get an externaly attached data from its key
  32436. * @param key the unique key that identifies the data
  32437. * @return the associated data, if present (can be null), or undefined if not present
  32438. */
  32439. getExternalData<T>(key: string): T;
  32440. /**
  32441. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32442. * @param key the unique key that identifies the data
  32443. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32444. * @return the associated data, can be null if the factory returned null.
  32445. */
  32446. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32447. /**
  32448. * Remove an externaly attached data from the Engine instance
  32449. * @param key the unique key that identifies the data
  32450. * @return true if the data was successfully removed, false if it doesn't exist
  32451. */
  32452. removeExternalData(key: string): boolean;
  32453. /**
  32454. * Unbind all vertex attributes from the webGL context
  32455. */
  32456. unbindAllAttributes(): void;
  32457. /**
  32458. * 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
  32459. */
  32460. releaseEffects(): void;
  32461. /**
  32462. * Dispose and release all associated resources
  32463. */
  32464. dispose(): void;
  32465. /**
  32466. * Display the loading screen
  32467. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32468. */
  32469. displayLoadingUI(): void;
  32470. /**
  32471. * Hide the loading screen
  32472. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32473. */
  32474. hideLoadingUI(): void;
  32475. /**
  32476. * Gets the current loading screen object
  32477. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32478. */
  32479. /**
  32480. * Sets the current loading screen object
  32481. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32482. */
  32483. loadingScreen: ILoadingScreen;
  32484. /**
  32485. * Sets the current loading screen text
  32486. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32487. */
  32488. loadingUIText: string;
  32489. /**
  32490. * Sets the current loading screen background color
  32491. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32492. */
  32493. loadingUIBackgroundColor: string;
  32494. /**
  32495. * Attach a new callback raised when context lost event is fired
  32496. * @param callback defines the callback to call
  32497. */
  32498. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32499. /**
  32500. * Attach a new callback raised when context restored event is fired
  32501. * @param callback defines the callback to call
  32502. */
  32503. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32504. /**
  32505. * Gets the source code of the vertex shader associated with a specific webGL program
  32506. * @param program defines the program to use
  32507. * @returns a string containing the source code of the vertex shader associated with the program
  32508. */
  32509. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32510. /**
  32511. * Gets the source code of the fragment shader associated with a specific webGL program
  32512. * @param program defines the program to use
  32513. * @returns a string containing the source code of the fragment shader associated with the program
  32514. */
  32515. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32516. /**
  32517. * Get the current error code of the webGL context
  32518. * @returns the error code
  32519. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32520. */
  32521. getError(): number;
  32522. /**
  32523. * Gets the current framerate
  32524. * @returns a number representing the framerate
  32525. */
  32526. getFps(): number;
  32527. /**
  32528. * Gets the time spent between current and previous frame
  32529. * @returns a number representing the delta time in ms
  32530. */
  32531. getDeltaTime(): number;
  32532. private _measureFps;
  32533. /** @hidden */
  32534. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32535. private _canRenderToFloatFramebuffer;
  32536. private _canRenderToHalfFloatFramebuffer;
  32537. private _canRenderToFramebuffer;
  32538. /** @hidden */
  32539. _getWebGLTextureType(type: number): number;
  32540. /** @hidden */
  32541. _getInternalFormat(format: number): number;
  32542. /** @hidden */
  32543. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32544. /** @hidden */
  32545. _getRGBAMultiSampleBufferFormat(type: number): number;
  32546. /** @hidden */
  32547. _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;
  32548. /** @hidden */
  32549. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32550. /**
  32551. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32552. * @returns true if the engine can be created
  32553. * @ignorenaming
  32554. */
  32555. static isSupported(): boolean;
  32556. /**
  32557. * Find the next highest power of two.
  32558. * @param x Number to start search from.
  32559. * @return Next highest power of two.
  32560. */
  32561. static CeilingPOT(x: number): number;
  32562. /**
  32563. * Find the next lowest power of two.
  32564. * @param x Number to start search from.
  32565. * @return Next lowest power of two.
  32566. */
  32567. static FloorPOT(x: number): number;
  32568. /**
  32569. * Find the nearest power of two.
  32570. * @param x Number to start search from.
  32571. * @return Next nearest power of two.
  32572. */
  32573. static NearestPOT(x: number): number;
  32574. /**
  32575. * Get the closest exponent of two
  32576. * @param value defines the value to approximate
  32577. * @param max defines the maximum value to return
  32578. * @param mode defines how to define the closest value
  32579. * @returns closest exponent of two of the given value
  32580. */
  32581. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32582. /**
  32583. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32584. * @param func - the function to be called
  32585. * @param requester - the object that will request the next frame. Falls back to window.
  32586. * @returns frame number
  32587. */
  32588. static QueueNewFrame(func: () => void, requester?: any): number;
  32589. /**
  32590. * Ask the browser to promote the current element to pointerlock mode
  32591. * @param element defines the DOM element to promote
  32592. */
  32593. static _RequestPointerlock(element: HTMLElement): void;
  32594. /**
  32595. * Asks the browser to exit pointerlock mode
  32596. */
  32597. static _ExitPointerlock(): void;
  32598. /**
  32599. * Ask the browser to promote the current element to fullscreen rendering mode
  32600. * @param element defines the DOM element to promote
  32601. */
  32602. static _RequestFullscreen(element: HTMLElement): void;
  32603. /**
  32604. * Asks the browser to exit fullscreen mode
  32605. */
  32606. static _ExitFullscreen(): void;
  32607. }
  32608. }
  32609. declare module "babylonjs/Engines/engineStore" {
  32610. import { Nullable } from "babylonjs/types";
  32611. import { Engine } from "babylonjs/Engines/engine";
  32612. import { Scene } from "babylonjs/scene";
  32613. /**
  32614. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32615. * during the life time of the application.
  32616. */
  32617. export class EngineStore {
  32618. /** Gets the list of created engines */
  32619. static Instances: import("babylonjs/Engines/engine").Engine[];
  32620. /** @hidden */
  32621. static _LastCreatedScene: Nullable<Scene>;
  32622. /**
  32623. * Gets the latest created engine
  32624. */
  32625. static readonly LastCreatedEngine: Nullable<Engine>;
  32626. /**
  32627. * Gets the latest created scene
  32628. */
  32629. static readonly LastCreatedScene: Nullable<Scene>;
  32630. /**
  32631. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32632. * @ignorenaming
  32633. */
  32634. static UseFallbackTexture: boolean;
  32635. /**
  32636. * Texture content used if a texture cannot loaded
  32637. * @ignorenaming
  32638. */
  32639. static FallbackTexture: string;
  32640. }
  32641. }
  32642. declare module "babylonjs/Misc/promise" {
  32643. /**
  32644. * Helper class that provides a small promise polyfill
  32645. */
  32646. export class PromisePolyfill {
  32647. /**
  32648. * Static function used to check if the polyfill is required
  32649. * If this is the case then the function will inject the polyfill to window.Promise
  32650. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32651. */
  32652. static Apply(force?: boolean): void;
  32653. }
  32654. }
  32655. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32656. /**
  32657. * Interface for screenshot methods with describe argument called `size` as object with options
  32658. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32659. */
  32660. export interface IScreenshotSize {
  32661. /**
  32662. * number in pixels for canvas height
  32663. */
  32664. height?: number;
  32665. /**
  32666. * multiplier allowing render at a higher or lower resolution
  32667. * If value is defined then height and width will be ignored and taken from camera
  32668. */
  32669. precision?: number;
  32670. /**
  32671. * number in pixels for canvas width
  32672. */
  32673. width?: number;
  32674. }
  32675. }
  32676. declare module "babylonjs/Misc/tools" {
  32677. import { Nullable, float } from "babylonjs/types";
  32678. import { DomManagement } from "babylonjs/Misc/domManagement";
  32679. import { WebRequest } from "babylonjs/Misc/webRequest";
  32680. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32681. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32682. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32683. import { Camera } from "babylonjs/Cameras/camera";
  32684. import { Engine } from "babylonjs/Engines/engine";
  32685. interface IColor4Like {
  32686. r: float;
  32687. g: float;
  32688. b: float;
  32689. a: float;
  32690. }
  32691. /**
  32692. * Class containing a set of static utilities functions
  32693. */
  32694. export class Tools {
  32695. /**
  32696. * Gets or sets the base URL to use to load assets
  32697. */
  32698. static BaseUrl: string;
  32699. /**
  32700. * Enable/Disable Custom HTTP Request Headers globally.
  32701. * default = false
  32702. * @see CustomRequestHeaders
  32703. */
  32704. static UseCustomRequestHeaders: boolean;
  32705. /**
  32706. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32707. * i.e. when loading files, where the server/service expects an Authorization header
  32708. */
  32709. static CustomRequestHeaders: {
  32710. [key: string]: string;
  32711. };
  32712. /**
  32713. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32714. */
  32715. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32716. /**
  32717. * Default behaviour for cors in the application.
  32718. * It can be a string if the expected behavior is identical in the entire app.
  32719. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32720. */
  32721. static CorsBehavior: string | ((url: string | string[]) => string);
  32722. /**
  32723. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32724. * @ignorenaming
  32725. */
  32726. static UseFallbackTexture: boolean;
  32727. /**
  32728. * Use this object to register external classes like custom textures or material
  32729. * to allow the laoders to instantiate them
  32730. */
  32731. static RegisteredExternalClasses: {
  32732. [key: string]: Object;
  32733. };
  32734. /**
  32735. * Texture content used if a texture cannot loaded
  32736. * @ignorenaming
  32737. */
  32738. static fallbackTexture: string;
  32739. /**
  32740. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32741. * @param u defines the coordinate on X axis
  32742. * @param v defines the coordinate on Y axis
  32743. * @param width defines the width of the source data
  32744. * @param height defines the height of the source data
  32745. * @param pixels defines the source byte array
  32746. * @param color defines the output color
  32747. */
  32748. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32749. /**
  32750. * Interpolates between a and b via alpha
  32751. * @param a The lower value (returned when alpha = 0)
  32752. * @param b The upper value (returned when alpha = 1)
  32753. * @param alpha The interpolation-factor
  32754. * @return The mixed value
  32755. */
  32756. static Mix(a: number, b: number, alpha: number): number;
  32757. /**
  32758. * Tries to instantiate a new object from a given class name
  32759. * @param className defines the class name to instantiate
  32760. * @returns the new object or null if the system was not able to do the instantiation
  32761. */
  32762. static Instantiate(className: string): any;
  32763. /**
  32764. * Provides a slice function that will work even on IE
  32765. * @param data defines the array to slice
  32766. * @param start defines the start of the data (optional)
  32767. * @param end defines the end of the data (optional)
  32768. * @returns the new sliced array
  32769. */
  32770. static Slice<T>(data: T, start?: number, end?: number): T;
  32771. /**
  32772. * Polyfill for setImmediate
  32773. * @param action defines the action to execute after the current execution block
  32774. */
  32775. static SetImmediate(action: () => void): void;
  32776. /**
  32777. * Function indicating if a number is an exponent of 2
  32778. * @param value defines the value to test
  32779. * @returns true if the value is an exponent of 2
  32780. */
  32781. static IsExponentOfTwo(value: number): boolean;
  32782. private static _tmpFloatArray;
  32783. /**
  32784. * Returns the nearest 32-bit single precision float representation of a Number
  32785. * @param value A Number. If the parameter is of a different type, it will get converted
  32786. * to a number or to NaN if it cannot be converted
  32787. * @returns number
  32788. */
  32789. static FloatRound(value: number): number;
  32790. /**
  32791. * Extracts the filename from a path
  32792. * @param path defines the path to use
  32793. * @returns the filename
  32794. */
  32795. static GetFilename(path: string): string;
  32796. /**
  32797. * Extracts the "folder" part of a path (everything before the filename).
  32798. * @param uri The URI to extract the info from
  32799. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32800. * @returns The "folder" part of the path
  32801. */
  32802. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32803. /**
  32804. * Extracts text content from a DOM element hierarchy
  32805. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32806. */
  32807. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32808. /**
  32809. * Convert an angle in radians to degrees
  32810. * @param angle defines the angle to convert
  32811. * @returns the angle in degrees
  32812. */
  32813. static ToDegrees(angle: number): number;
  32814. /**
  32815. * Convert an angle in degrees to radians
  32816. * @param angle defines the angle to convert
  32817. * @returns the angle in radians
  32818. */
  32819. static ToRadians(angle: number): number;
  32820. /**
  32821. * Encode a buffer to a base64 string
  32822. * @param buffer defines the buffer to encode
  32823. * @returns the encoded string
  32824. */
  32825. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32826. /**
  32827. * Returns an array if obj is not an array
  32828. * @param obj defines the object to evaluate as an array
  32829. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32830. * @returns either obj directly if obj is an array or a new array containing obj
  32831. */
  32832. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32833. /**
  32834. * Gets the pointer prefix to use
  32835. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32836. */
  32837. static GetPointerPrefix(): string;
  32838. /**
  32839. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32840. * @param url define the url we are trying
  32841. * @param element define the dom element where to configure the cors policy
  32842. */
  32843. static SetCorsBehavior(url: string | string[], element: {
  32844. crossOrigin: string | null;
  32845. }): void;
  32846. /**
  32847. * Removes unwanted characters from an url
  32848. * @param url defines the url to clean
  32849. * @returns the cleaned url
  32850. */
  32851. static CleanUrl(url: string): string;
  32852. /**
  32853. * Gets or sets a function used to pre-process url before using them to load assets
  32854. */
  32855. static PreprocessUrl: (url: string) => string;
  32856. /**
  32857. * Loads an image as an HTMLImageElement.
  32858. * @param input url string, ArrayBuffer, or Blob to load
  32859. * @param onLoad callback called when the image successfully loads
  32860. * @param onError callback called when the image fails to load
  32861. * @param offlineProvider offline provider for caching
  32862. * @returns the HTMLImageElement of the loaded image
  32863. */
  32864. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32865. /**
  32866. * Loads a file
  32867. * @param url url string, ArrayBuffer, or Blob to load
  32868. * @param onSuccess callback called when the file successfully loads
  32869. * @param onProgress callback called while file is loading (if the server supports this mode)
  32870. * @param offlineProvider defines the offline provider for caching
  32871. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32872. * @param onError callback called when the file fails to load
  32873. * @returns a file request object
  32874. */
  32875. 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;
  32876. /**
  32877. * Loads a file from a url
  32878. * @param url the file url to load
  32879. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32880. */
  32881. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32882. /**
  32883. * Load a script (identified by an url). When the url returns, the
  32884. * content of this file is added into a new script element, attached to the DOM (body element)
  32885. * @param scriptUrl defines the url of the script to laod
  32886. * @param onSuccess defines the callback called when the script is loaded
  32887. * @param onError defines the callback to call if an error occurs
  32888. * @param scriptId defines the id of the script element
  32889. */
  32890. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32891. /**
  32892. * Load an asynchronous script (identified by an url). When the url returns, the
  32893. * content of this file is added into a new script element, attached to the DOM (body element)
  32894. * @param scriptUrl defines the url of the script to laod
  32895. * @param scriptId defines the id of the script element
  32896. * @returns a promise request object
  32897. */
  32898. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32899. /**
  32900. * Loads a file from a blob
  32901. * @param fileToLoad defines the blob to use
  32902. * @param callback defines the callback to call when data is loaded
  32903. * @param progressCallback defines the callback to call during loading process
  32904. * @returns a file request object
  32905. */
  32906. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32907. /**
  32908. * Loads a file
  32909. * @param fileToLoad defines the file to load
  32910. * @param callback defines the callback to call when data is loaded
  32911. * @param progressCallBack defines the callback to call during loading process
  32912. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32913. * @returns a file request object
  32914. */
  32915. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32916. /**
  32917. * Creates a data url from a given string content
  32918. * @param content defines the content to convert
  32919. * @returns the new data url link
  32920. */
  32921. static FileAsURL(content: string): string;
  32922. /**
  32923. * Format the given number to a specific decimal format
  32924. * @param value defines the number to format
  32925. * @param decimals defines the number of decimals to use
  32926. * @returns the formatted string
  32927. */
  32928. static Format(value: number, decimals?: number): string;
  32929. /**
  32930. * Tries to copy an object by duplicating every property
  32931. * @param source defines the source object
  32932. * @param destination defines the target object
  32933. * @param doNotCopyList defines a list of properties to avoid
  32934. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32935. */
  32936. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32937. /**
  32938. * Gets a boolean indicating if the given object has no own property
  32939. * @param obj defines the object to test
  32940. * @returns true if object has no own property
  32941. */
  32942. static IsEmpty(obj: any): boolean;
  32943. /**
  32944. * Function used to register events at window level
  32945. * @param windowElement defines the Window object to use
  32946. * @param events defines the events to register
  32947. */
  32948. static RegisterTopRootEvents(windowElement: Window, events: {
  32949. name: string;
  32950. handler: Nullable<(e: FocusEvent) => any>;
  32951. }[]): void;
  32952. /**
  32953. * Function used to unregister events from window level
  32954. * @param windowElement defines the Window object to use
  32955. * @param events defines the events to unregister
  32956. */
  32957. static UnregisterTopRootEvents(windowElement: Window, events: {
  32958. name: string;
  32959. handler: Nullable<(e: FocusEvent) => any>;
  32960. }[]): void;
  32961. /**
  32962. * @ignore
  32963. */
  32964. static _ScreenshotCanvas: HTMLCanvasElement;
  32965. /**
  32966. * Dumps the current bound framebuffer
  32967. * @param width defines the rendering width
  32968. * @param height defines the rendering height
  32969. * @param engine defines the hosting engine
  32970. * @param successCallback defines the callback triggered once the data are available
  32971. * @param mimeType defines the mime type of the result
  32972. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32973. */
  32974. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32975. /**
  32976. * Converts the canvas data to blob.
  32977. * This acts as a polyfill for browsers not supporting the to blob function.
  32978. * @param canvas Defines the canvas to extract the data from
  32979. * @param successCallback Defines the callback triggered once the data are available
  32980. * @param mimeType Defines the mime type of the result
  32981. */
  32982. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32983. /**
  32984. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32985. * @param successCallback defines the callback triggered once the data are available
  32986. * @param mimeType defines the mime type of the result
  32987. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32988. */
  32989. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32990. /**
  32991. * Downloads a blob in the browser
  32992. * @param blob defines the blob to download
  32993. * @param fileName defines the name of the downloaded file
  32994. */
  32995. static Download(blob: Blob, fileName: string): void;
  32996. /**
  32997. * Captures a screenshot of the current rendering
  32998. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32999. * @param engine defines the rendering engine
  33000. * @param camera defines the source camera
  33001. * @param size This parameter can be set to a single number or to an object with the
  33002. * following (optional) properties: precision, width, height. If a single number is passed,
  33003. * it will be used for both width and height. If an object is passed, the screenshot size
  33004. * will be derived from the parameters. The precision property is a multiplier allowing
  33005. * rendering at a higher or lower resolution
  33006. * @param successCallback defines the callback receives a single parameter which contains the
  33007. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33008. * src parameter of an <img> to display it
  33009. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33010. * Check your browser for supported MIME types
  33011. */
  33012. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33013. /**
  33014. * Captures a screenshot of the current rendering
  33015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33016. * @param engine defines the rendering engine
  33017. * @param camera defines the source camera
  33018. * @param size This parameter can be set to a single number or to an object with the
  33019. * following (optional) properties: precision, width, height. If a single number is passed,
  33020. * it will be used for both width and height. If an object is passed, the screenshot size
  33021. * will be derived from the parameters. The precision property is a multiplier allowing
  33022. * rendering at a higher or lower resolution
  33023. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33024. * Check your browser for supported MIME types
  33025. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33026. * to the src parameter of an <img> to display it
  33027. */
  33028. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33029. /**
  33030. * Generates an image screenshot from the specified camera.
  33031. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33032. * @param engine The engine to use for rendering
  33033. * @param camera The camera to use for rendering
  33034. * @param size This parameter can be set to a single number or to an object with the
  33035. * following (optional) properties: precision, width, height. If a single number is passed,
  33036. * it will be used for both width and height. If an object is passed, the screenshot size
  33037. * will be derived from the parameters. The precision property is a multiplier allowing
  33038. * rendering at a higher or lower resolution
  33039. * @param successCallback The callback receives a single parameter which contains the
  33040. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33041. * src parameter of an <img> to display it
  33042. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33043. * Check your browser for supported MIME types
  33044. * @param samples Texture samples (default: 1)
  33045. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33046. * @param fileName A name for for the downloaded file.
  33047. */
  33048. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33049. /**
  33050. * Generates an image screenshot from the specified camera.
  33051. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33052. * @param engine The engine to use for rendering
  33053. * @param camera The camera to use for rendering
  33054. * @param size This parameter can be set to a single number or to an object with the
  33055. * following (optional) properties: precision, width, height. If a single number is passed,
  33056. * it will be used for both width and height. If an object is passed, the screenshot size
  33057. * will be derived from the parameters. The precision property is a multiplier allowing
  33058. * rendering at a higher or lower resolution
  33059. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33060. * Check your browser for supported MIME types
  33061. * @param samples Texture samples (default: 1)
  33062. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33063. * @param fileName A name for for the downloaded file.
  33064. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33065. * to the src parameter of an <img> to display it
  33066. */
  33067. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33068. /**
  33069. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33070. * Be aware Math.random() could cause collisions, but:
  33071. * "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"
  33072. * @returns a pseudo random id
  33073. */
  33074. static RandomId(): string;
  33075. /**
  33076. * Test if the given uri is a base64 string
  33077. * @param uri The uri to test
  33078. * @return True if the uri is a base64 string or false otherwise
  33079. */
  33080. static IsBase64(uri: string): boolean;
  33081. /**
  33082. * Decode the given base64 uri.
  33083. * @param uri The uri to decode
  33084. * @return The decoded base64 data.
  33085. */
  33086. static DecodeBase64(uri: string): ArrayBuffer;
  33087. /**
  33088. * Gets the absolute url.
  33089. * @param url the input url
  33090. * @return the absolute url
  33091. */
  33092. static GetAbsoluteUrl(url: string): string;
  33093. /**
  33094. * No log
  33095. */
  33096. static readonly NoneLogLevel: number;
  33097. /**
  33098. * Only message logs
  33099. */
  33100. static readonly MessageLogLevel: number;
  33101. /**
  33102. * Only warning logs
  33103. */
  33104. static readonly WarningLogLevel: number;
  33105. /**
  33106. * Only error logs
  33107. */
  33108. static readonly ErrorLogLevel: number;
  33109. /**
  33110. * All logs
  33111. */
  33112. static readonly AllLogLevel: number;
  33113. /**
  33114. * Gets a value indicating the number of loading errors
  33115. * @ignorenaming
  33116. */
  33117. static readonly errorsCount: number;
  33118. /**
  33119. * Callback called when a new log is added
  33120. */
  33121. static OnNewCacheEntry: (entry: string) => void;
  33122. /**
  33123. * Log a message to the console
  33124. * @param message defines the message to log
  33125. */
  33126. static Log(message: string): void;
  33127. /**
  33128. * Write a warning message to the console
  33129. * @param message defines the message to log
  33130. */
  33131. static Warn(message: string): void;
  33132. /**
  33133. * Write an error message to the console
  33134. * @param message defines the message to log
  33135. */
  33136. static Error(message: string): void;
  33137. /**
  33138. * Gets current log cache (list of logs)
  33139. */
  33140. static readonly LogCache: string;
  33141. /**
  33142. * Clears the log cache
  33143. */
  33144. static ClearLogCache(): void;
  33145. /**
  33146. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33147. */
  33148. static LogLevels: number;
  33149. /**
  33150. * Checks if the window object exists
  33151. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33152. */
  33153. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33154. /**
  33155. * No performance log
  33156. */
  33157. static readonly PerformanceNoneLogLevel: number;
  33158. /**
  33159. * Use user marks to log performance
  33160. */
  33161. static readonly PerformanceUserMarkLogLevel: number;
  33162. /**
  33163. * Log performance to the console
  33164. */
  33165. static readonly PerformanceConsoleLogLevel: number;
  33166. private static _performance;
  33167. /**
  33168. * Sets the current performance log level
  33169. */
  33170. static PerformanceLogLevel: number;
  33171. private static _StartPerformanceCounterDisabled;
  33172. private static _EndPerformanceCounterDisabled;
  33173. private static _StartUserMark;
  33174. private static _EndUserMark;
  33175. private static _StartPerformanceConsole;
  33176. private static _EndPerformanceConsole;
  33177. /**
  33178. * Starts a performance counter
  33179. */
  33180. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33181. /**
  33182. * Ends a specific performance coutner
  33183. */
  33184. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33185. /**
  33186. * Gets either window.performance.now() if supported or Date.now() else
  33187. */
  33188. static readonly Now: number;
  33189. /**
  33190. * This method will return the name of the class used to create the instance of the given object.
  33191. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33192. * @param object the object to get the class name from
  33193. * @param isType defines if the object is actually a type
  33194. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33195. */
  33196. static GetClassName(object: any, isType?: boolean): string;
  33197. /**
  33198. * Gets the first element of an array satisfying a given predicate
  33199. * @param array defines the array to browse
  33200. * @param predicate defines the predicate to use
  33201. * @returns null if not found or the element
  33202. */
  33203. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33204. /**
  33205. * This method will return the name of the full name of the class, including its owning module (if any).
  33206. * 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).
  33207. * @param object the object to get the class name from
  33208. * @param isType defines if the object is actually a type
  33209. * @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.
  33210. * @ignorenaming
  33211. */
  33212. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33213. /**
  33214. * Returns a promise that resolves after the given amount of time.
  33215. * @param delay Number of milliseconds to delay
  33216. * @returns Promise that resolves after the given amount of time
  33217. */
  33218. static DelayAsync(delay: number): Promise<void>;
  33219. }
  33220. /**
  33221. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33222. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33223. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33224. * @param name The name of the class, case should be preserved
  33225. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33226. */
  33227. export function className(name: string, module?: string): (target: Object) => void;
  33228. /**
  33229. * An implementation of a loop for asynchronous functions.
  33230. */
  33231. export class AsyncLoop {
  33232. /**
  33233. * Defines the number of iterations for the loop
  33234. */
  33235. iterations: number;
  33236. /**
  33237. * Defines the current index of the loop.
  33238. */
  33239. index: number;
  33240. private _done;
  33241. private _fn;
  33242. private _successCallback;
  33243. /**
  33244. * Constructor.
  33245. * @param iterations the number of iterations.
  33246. * @param func the function to run each iteration
  33247. * @param successCallback the callback that will be called upon succesful execution
  33248. * @param offset starting offset.
  33249. */
  33250. constructor(
  33251. /**
  33252. * Defines the number of iterations for the loop
  33253. */
  33254. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33255. /**
  33256. * Execute the next iteration. Must be called after the last iteration was finished.
  33257. */
  33258. executeNext(): void;
  33259. /**
  33260. * Break the loop and run the success callback.
  33261. */
  33262. breakLoop(): void;
  33263. /**
  33264. * Create and run an async loop.
  33265. * @param iterations the number of iterations.
  33266. * @param fn the function to run each iteration
  33267. * @param successCallback the callback that will be called upon succesful execution
  33268. * @param offset starting offset.
  33269. * @returns the created async loop object
  33270. */
  33271. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33272. /**
  33273. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33274. * @param iterations total number of iterations
  33275. * @param syncedIterations number of synchronous iterations in each async iteration.
  33276. * @param fn the function to call each iteration.
  33277. * @param callback a success call back that will be called when iterating stops.
  33278. * @param breakFunction a break condition (optional)
  33279. * @param timeout timeout settings for the setTimeout function. default - 0.
  33280. * @returns the created async loop object
  33281. */
  33282. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33283. }
  33284. }
  33285. declare module "babylonjs/Collisions/collisionCoordinator" {
  33286. import { Nullable } from "babylonjs/types";
  33287. import { Scene } from "babylonjs/scene";
  33288. import { Vector3 } from "babylonjs/Maths/math.vector";
  33289. import { Collider } from "babylonjs/Collisions/collider";
  33290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33291. /** @hidden */
  33292. export interface ICollisionCoordinator {
  33293. createCollider(): Collider;
  33294. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33295. init(scene: Scene): void;
  33296. }
  33297. /** @hidden */
  33298. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33299. private _scene;
  33300. private _scaledPosition;
  33301. private _scaledVelocity;
  33302. private _finalPosition;
  33303. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33304. createCollider(): Collider;
  33305. init(scene: Scene): void;
  33306. private _collideWithWorld;
  33307. }
  33308. }
  33309. declare module "babylonjs/Inputs/scene.inputManager" {
  33310. import { Nullable } from "babylonjs/types";
  33311. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33312. import { Vector2 } from "babylonjs/Maths/math.vector";
  33313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33314. import { Scene } from "babylonjs/scene";
  33315. /**
  33316. * Class used to manage all inputs for the scene.
  33317. */
  33318. export class InputManager {
  33319. /** The distance in pixel that you have to move to prevent some events */
  33320. static DragMovementThreshold: number;
  33321. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33322. static LongPressDelay: number;
  33323. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33324. static DoubleClickDelay: number;
  33325. /** If you need to check double click without raising a single click at first click, enable this flag */
  33326. static ExclusiveDoubleClickMode: boolean;
  33327. private _wheelEventName;
  33328. private _onPointerMove;
  33329. private _onPointerDown;
  33330. private _onPointerUp;
  33331. private _initClickEvent;
  33332. private _initActionManager;
  33333. private _delayedSimpleClick;
  33334. private _delayedSimpleClickTimeout;
  33335. private _previousDelayedSimpleClickTimeout;
  33336. private _meshPickProceed;
  33337. private _previousButtonPressed;
  33338. private _currentPickResult;
  33339. private _previousPickResult;
  33340. private _totalPointersPressed;
  33341. private _doubleClickOccured;
  33342. private _pointerOverMesh;
  33343. private _pickedDownMesh;
  33344. private _pickedUpMesh;
  33345. private _pointerX;
  33346. private _pointerY;
  33347. private _unTranslatedPointerX;
  33348. private _unTranslatedPointerY;
  33349. private _startingPointerPosition;
  33350. private _previousStartingPointerPosition;
  33351. private _startingPointerTime;
  33352. private _previousStartingPointerTime;
  33353. private _pointerCaptures;
  33354. private _onKeyDown;
  33355. private _onKeyUp;
  33356. private _onCanvasFocusObserver;
  33357. private _onCanvasBlurObserver;
  33358. private _scene;
  33359. /**
  33360. * Creates a new InputManager
  33361. * @param scene defines the hosting scene
  33362. */
  33363. constructor(scene: Scene);
  33364. /**
  33365. * Gets the mesh that is currently under the pointer
  33366. */
  33367. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33368. /**
  33369. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33370. */
  33371. readonly unTranslatedPointer: Vector2;
  33372. /**
  33373. * Gets or sets the current on-screen X position of the pointer
  33374. */
  33375. pointerX: number;
  33376. /**
  33377. * Gets or sets the current on-screen Y position of the pointer
  33378. */
  33379. pointerY: number;
  33380. private _updatePointerPosition;
  33381. private _processPointerMove;
  33382. private _setRayOnPointerInfo;
  33383. private _checkPrePointerObservable;
  33384. /**
  33385. * Use this method to simulate a pointer move on a mesh
  33386. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33387. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33388. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33389. */
  33390. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33391. /**
  33392. * Use this method to simulate a pointer down on a mesh
  33393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33396. */
  33397. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33398. private _processPointerDown;
  33399. /** @hidden */
  33400. _isPointerSwiping(): boolean;
  33401. /**
  33402. * Use this method to simulate a pointer up on a mesh
  33403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33406. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33407. */
  33408. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33409. private _processPointerUp;
  33410. /**
  33411. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33412. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33413. * @returns true if the pointer was captured
  33414. */
  33415. isPointerCaptured(pointerId?: number): boolean;
  33416. /**
  33417. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33418. * @param attachUp defines if you want to attach events to pointerup
  33419. * @param attachDown defines if you want to attach events to pointerdown
  33420. * @param attachMove defines if you want to attach events to pointermove
  33421. */
  33422. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33423. /**
  33424. * Detaches all event handlers
  33425. */
  33426. detachControl(): void;
  33427. /**
  33428. * Force the value of meshUnderPointer
  33429. * @param mesh defines the mesh to use
  33430. */
  33431. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33432. /**
  33433. * Gets the mesh under the pointer
  33434. * @returns a Mesh or null if no mesh is under the pointer
  33435. */
  33436. getPointerOverMesh(): Nullable<AbstractMesh>;
  33437. }
  33438. }
  33439. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33440. /**
  33441. * Helper class used to generate session unique ID
  33442. */
  33443. export class UniqueIdGenerator {
  33444. private static _UniqueIdCounter;
  33445. /**
  33446. * Gets an unique (relatively to the current scene) Id
  33447. */
  33448. static readonly UniqueId: number;
  33449. }
  33450. }
  33451. declare module "babylonjs/Animations/animationGroup" {
  33452. import { Animatable } from "babylonjs/Animations/animatable";
  33453. import { Animation } from "babylonjs/Animations/animation";
  33454. import { Scene, IDisposable } from "babylonjs/scene";
  33455. import { Observable } from "babylonjs/Misc/observable";
  33456. import { Nullable } from "babylonjs/types";
  33457. import "babylonjs/Animations/animatable";
  33458. /**
  33459. * This class defines the direct association between an animation and a target
  33460. */
  33461. export class TargetedAnimation {
  33462. /**
  33463. * Animation to perform
  33464. */
  33465. animation: Animation;
  33466. /**
  33467. * Target to animate
  33468. */
  33469. target: any;
  33470. /**
  33471. * Serialize the object
  33472. * @returns the JSON object representing the current entity
  33473. */
  33474. serialize(): any;
  33475. }
  33476. /**
  33477. * Use this class to create coordinated animations on multiple targets
  33478. */
  33479. export class AnimationGroup implements IDisposable {
  33480. /** The name of the animation group */
  33481. name: string;
  33482. private _scene;
  33483. private _targetedAnimations;
  33484. private _animatables;
  33485. private _from;
  33486. private _to;
  33487. private _isStarted;
  33488. private _isPaused;
  33489. private _speedRatio;
  33490. private _loopAnimation;
  33491. /**
  33492. * Gets or sets the unique id of the node
  33493. */
  33494. uniqueId: number;
  33495. /**
  33496. * This observable will notify when one animation have ended
  33497. */
  33498. onAnimationEndObservable: Observable<TargetedAnimation>;
  33499. /**
  33500. * Observer raised when one animation loops
  33501. */
  33502. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33503. /**
  33504. * This observable will notify when all animations have ended.
  33505. */
  33506. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33507. /**
  33508. * This observable will notify when all animations have paused.
  33509. */
  33510. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33511. /**
  33512. * This observable will notify when all animations are playing.
  33513. */
  33514. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33515. /**
  33516. * Gets the first frame
  33517. */
  33518. readonly from: number;
  33519. /**
  33520. * Gets the last frame
  33521. */
  33522. readonly to: number;
  33523. /**
  33524. * Define if the animations are started
  33525. */
  33526. readonly isStarted: boolean;
  33527. /**
  33528. * Gets a value indicating that the current group is playing
  33529. */
  33530. readonly isPlaying: boolean;
  33531. /**
  33532. * Gets or sets the speed ratio to use for all animations
  33533. */
  33534. /**
  33535. * Gets or sets the speed ratio to use for all animations
  33536. */
  33537. speedRatio: number;
  33538. /**
  33539. * Gets or sets if all animations should loop or not
  33540. */
  33541. loopAnimation: boolean;
  33542. /**
  33543. * Gets the targeted animations for this animation group
  33544. */
  33545. readonly targetedAnimations: Array<TargetedAnimation>;
  33546. /**
  33547. * returning the list of animatables controlled by this animation group.
  33548. */
  33549. readonly animatables: Array<Animatable>;
  33550. /**
  33551. * Instantiates a new Animation Group.
  33552. * This helps managing several animations at once.
  33553. * @see http://doc.babylonjs.com/how_to/group
  33554. * @param name Defines the name of the group
  33555. * @param scene Defines the scene the group belongs to
  33556. */
  33557. constructor(
  33558. /** The name of the animation group */
  33559. name: string, scene?: Nullable<Scene>);
  33560. /**
  33561. * Add an animation (with its target) in the group
  33562. * @param animation defines the animation we want to add
  33563. * @param target defines the target of the animation
  33564. * @returns the TargetedAnimation object
  33565. */
  33566. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33567. /**
  33568. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33569. * It can add constant keys at begin or end
  33570. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33571. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33572. * @returns the animation group
  33573. */
  33574. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33575. /**
  33576. * Start all animations on given targets
  33577. * @param loop defines if animations must loop
  33578. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33579. * @param from defines the from key (optional)
  33580. * @param to defines the to key (optional)
  33581. * @returns the current animation group
  33582. */
  33583. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33584. /**
  33585. * Pause all animations
  33586. * @returns the animation group
  33587. */
  33588. pause(): AnimationGroup;
  33589. /**
  33590. * Play all animations to initial state
  33591. * This function will start() the animations if they were not started or will restart() them if they were paused
  33592. * @param loop defines if animations must loop
  33593. * @returns the animation group
  33594. */
  33595. play(loop?: boolean): AnimationGroup;
  33596. /**
  33597. * Reset all animations to initial state
  33598. * @returns the animation group
  33599. */
  33600. reset(): AnimationGroup;
  33601. /**
  33602. * Restart animations from key 0
  33603. * @returns the animation group
  33604. */
  33605. restart(): AnimationGroup;
  33606. /**
  33607. * Stop all animations
  33608. * @returns the animation group
  33609. */
  33610. stop(): AnimationGroup;
  33611. /**
  33612. * Set animation weight for all animatables
  33613. * @param weight defines the weight to use
  33614. * @return the animationGroup
  33615. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33616. */
  33617. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33618. /**
  33619. * Synchronize and normalize all animatables with a source animatable
  33620. * @param root defines the root animatable to synchronize with
  33621. * @return the animationGroup
  33622. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33623. */
  33624. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33625. /**
  33626. * Goes to a specific frame in this animation group
  33627. * @param frame the frame number to go to
  33628. * @return the animationGroup
  33629. */
  33630. goToFrame(frame: number): AnimationGroup;
  33631. /**
  33632. * Dispose all associated resources
  33633. */
  33634. dispose(): void;
  33635. private _checkAnimationGroupEnded;
  33636. /**
  33637. * Clone the current animation group and returns a copy
  33638. * @param newName defines the name of the new group
  33639. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33640. * @returns the new aniamtion group
  33641. */
  33642. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33643. /**
  33644. * Serializes the animationGroup to an object
  33645. * @returns Serialized object
  33646. */
  33647. serialize(): any;
  33648. /**
  33649. * Returns a new AnimationGroup object parsed from the source provided.
  33650. * @param parsedAnimationGroup defines the source
  33651. * @param scene defines the scene that will receive the animationGroup
  33652. * @returns a new AnimationGroup
  33653. */
  33654. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33655. /**
  33656. * Returns the string "AnimationGroup"
  33657. * @returns "AnimationGroup"
  33658. */
  33659. getClassName(): string;
  33660. /**
  33661. * Creates a detailled string about the object
  33662. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33663. * @returns a string representing the object
  33664. */
  33665. toString(fullDetails?: boolean): string;
  33666. }
  33667. }
  33668. declare module "babylonjs/scene" {
  33669. import { Nullable } from "babylonjs/types";
  33670. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33671. import { Observable } from "babylonjs/Misc/observable";
  33672. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33673. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33674. import { Geometry } from "babylonjs/Meshes/geometry";
  33675. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33676. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33678. import { Mesh } from "babylonjs/Meshes/mesh";
  33679. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33680. import { Bone } from "babylonjs/Bones/bone";
  33681. import { Skeleton } from "babylonjs/Bones/skeleton";
  33682. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33683. import { Camera } from "babylonjs/Cameras/camera";
  33684. import { AbstractScene } from "babylonjs/abstractScene";
  33685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33686. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33687. import { Material } from "babylonjs/Materials/material";
  33688. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33689. import { Effect } from "babylonjs/Materials/effect";
  33690. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33691. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33692. import { Light } from "babylonjs/Lights/light";
  33693. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33694. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33695. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33696. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33697. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33698. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33699. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33700. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33701. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33702. import { Engine } from "babylonjs/Engines/engine";
  33703. import { Node } from "babylonjs/node";
  33704. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33705. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33706. import { WebRequest } from "babylonjs/Misc/webRequest";
  33707. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33708. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33709. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33710. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33711. import { Plane } from "babylonjs/Maths/math.plane";
  33712. import { Ray } from "babylonjs/Culling/ray";
  33713. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33714. import { Animation } from "babylonjs/Animations/animation";
  33715. import { Animatable } from "babylonjs/Animations/animatable";
  33716. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33717. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33718. import { Collider } from "babylonjs/Collisions/collider";
  33719. /**
  33720. * Define an interface for all classes that will hold resources
  33721. */
  33722. export interface IDisposable {
  33723. /**
  33724. * Releases all held resources
  33725. */
  33726. dispose(): void;
  33727. }
  33728. /** Interface defining initialization parameters for Scene class */
  33729. export interface SceneOptions {
  33730. /**
  33731. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33732. * It will improve performance when the number of geometries becomes important.
  33733. */
  33734. useGeometryUniqueIdsMap?: boolean;
  33735. /**
  33736. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33737. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33738. */
  33739. useMaterialMeshMap?: boolean;
  33740. /**
  33741. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33742. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33743. */
  33744. useClonedMeshhMap?: boolean;
  33745. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33746. virtual?: boolean;
  33747. }
  33748. /**
  33749. * Represents a scene to be rendered by the engine.
  33750. * @see http://doc.babylonjs.com/features/scene
  33751. */
  33752. export class Scene extends AbstractScene implements IAnimatable {
  33753. /** The fog is deactivated */
  33754. static readonly FOGMODE_NONE: number;
  33755. /** The fog density is following an exponential function */
  33756. static readonly FOGMODE_EXP: number;
  33757. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33758. static readonly FOGMODE_EXP2: number;
  33759. /** The fog density is following a linear function. */
  33760. static readonly FOGMODE_LINEAR: number;
  33761. /**
  33762. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33763. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33764. */
  33765. static MinDeltaTime: number;
  33766. /**
  33767. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33768. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33769. */
  33770. static MaxDeltaTime: number;
  33771. /**
  33772. * Factory used to create the default material.
  33773. * @param name The name of the material to create
  33774. * @param scene The scene to create the material for
  33775. * @returns The default material
  33776. */
  33777. static DefaultMaterialFactory(scene: Scene): Material;
  33778. /**
  33779. * Factory used to create the a collision coordinator.
  33780. * @returns The collision coordinator
  33781. */
  33782. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33783. /** @hidden */
  33784. _inputManager: InputManager;
  33785. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33786. cameraToUseForPointers: Nullable<Camera>;
  33787. /** @hidden */
  33788. readonly _isScene: boolean;
  33789. /**
  33790. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33791. */
  33792. autoClear: boolean;
  33793. /**
  33794. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33795. */
  33796. autoClearDepthAndStencil: boolean;
  33797. /**
  33798. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33799. */
  33800. clearColor: Color4;
  33801. /**
  33802. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33803. */
  33804. ambientColor: Color3;
  33805. /**
  33806. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33807. * It should only be one of the following (if not the default embedded one):
  33808. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33809. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33810. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33811. * The material properties need to be setup according to the type of texture in use.
  33812. */
  33813. environmentBRDFTexture: BaseTexture;
  33814. /** @hidden */
  33815. protected _environmentTexture: Nullable<BaseTexture>;
  33816. /**
  33817. * Texture used in all pbr material as the reflection texture.
  33818. * As in the majority of the scene they are the same (exception for multi room and so on),
  33819. * this is easier to reference from here than from all the materials.
  33820. */
  33821. /**
  33822. * Texture used in all pbr material as the reflection texture.
  33823. * As in the majority of the scene they are the same (exception for multi room and so on),
  33824. * this is easier to set here than in all the materials.
  33825. */
  33826. environmentTexture: Nullable<BaseTexture>;
  33827. /** @hidden */
  33828. protected _environmentIntensity: number;
  33829. /**
  33830. * Intensity of the environment in all pbr material.
  33831. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33832. * As in the majority of the scene they are the same (exception for multi room and so on),
  33833. * this is easier to reference from here than from all the materials.
  33834. */
  33835. /**
  33836. * Intensity of the environment in all pbr material.
  33837. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33838. * As in the majority of the scene they are the same (exception for multi room and so on),
  33839. * this is easier to set here than in all the materials.
  33840. */
  33841. environmentIntensity: number;
  33842. /** @hidden */
  33843. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33844. /**
  33845. * Default image processing configuration used either in the rendering
  33846. * Forward main pass or through the imageProcessingPostProcess if present.
  33847. * As in the majority of the scene they are the same (exception for multi camera),
  33848. * this is easier to reference from here than from all the materials and post process.
  33849. *
  33850. * No setter as we it is a shared configuration, you can set the values instead.
  33851. */
  33852. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33853. private _forceWireframe;
  33854. /**
  33855. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33856. */
  33857. forceWireframe: boolean;
  33858. private _forcePointsCloud;
  33859. /**
  33860. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33861. */
  33862. forcePointsCloud: boolean;
  33863. /**
  33864. * Gets or sets the active clipplane 1
  33865. */
  33866. clipPlane: Nullable<Plane>;
  33867. /**
  33868. * Gets or sets the active clipplane 2
  33869. */
  33870. clipPlane2: Nullable<Plane>;
  33871. /**
  33872. * Gets or sets the active clipplane 3
  33873. */
  33874. clipPlane3: Nullable<Plane>;
  33875. /**
  33876. * Gets or sets the active clipplane 4
  33877. */
  33878. clipPlane4: Nullable<Plane>;
  33879. /**
  33880. * Gets or sets a boolean indicating if animations are enabled
  33881. */
  33882. animationsEnabled: boolean;
  33883. private _animationPropertiesOverride;
  33884. /**
  33885. * Gets or sets the animation properties override
  33886. */
  33887. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33888. /**
  33889. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33890. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33891. */
  33892. useConstantAnimationDeltaTime: boolean;
  33893. /**
  33894. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33895. * Please note that it requires to run a ray cast through the scene on every frame
  33896. */
  33897. constantlyUpdateMeshUnderPointer: boolean;
  33898. /**
  33899. * Defines the HTML cursor to use when hovering over interactive elements
  33900. */
  33901. hoverCursor: string;
  33902. /**
  33903. * Defines the HTML default cursor to use (empty by default)
  33904. */
  33905. defaultCursor: string;
  33906. /**
  33907. * This is used to call preventDefault() on pointer down
  33908. * in order to block unwanted artifacts like system double clicks
  33909. */
  33910. preventDefaultOnPointerDown: boolean;
  33911. /**
  33912. * This is used to call preventDefault() on pointer up
  33913. * in order to block unwanted artifacts like system double clicks
  33914. */
  33915. preventDefaultOnPointerUp: boolean;
  33916. /**
  33917. * Gets or sets user defined metadata
  33918. */
  33919. metadata: any;
  33920. /**
  33921. * For internal use only. Please do not use.
  33922. */
  33923. reservedDataStore: any;
  33924. /**
  33925. * Gets the name of the plugin used to load this scene (null by default)
  33926. */
  33927. loadingPluginName: string;
  33928. /**
  33929. * Use this array to add regular expressions used to disable offline support for specific urls
  33930. */
  33931. disableOfflineSupportExceptionRules: RegExp[];
  33932. /**
  33933. * An event triggered when the scene is disposed.
  33934. */
  33935. onDisposeObservable: Observable<Scene>;
  33936. private _onDisposeObserver;
  33937. /** Sets a function to be executed when this scene is disposed. */
  33938. onDispose: () => void;
  33939. /**
  33940. * An event triggered before rendering the scene (right after animations and physics)
  33941. */
  33942. onBeforeRenderObservable: Observable<Scene>;
  33943. private _onBeforeRenderObserver;
  33944. /** Sets a function to be executed before rendering this scene */
  33945. beforeRender: Nullable<() => void>;
  33946. /**
  33947. * An event triggered after rendering the scene
  33948. */
  33949. onAfterRenderObservable: Observable<Scene>;
  33950. /**
  33951. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33952. */
  33953. onAfterRenderCameraObservable: Observable<Camera>;
  33954. private _onAfterRenderObserver;
  33955. /** Sets a function to be executed after rendering this scene */
  33956. afterRender: Nullable<() => void>;
  33957. /**
  33958. * An event triggered before animating the scene
  33959. */
  33960. onBeforeAnimationsObservable: Observable<Scene>;
  33961. /**
  33962. * An event triggered after animations processing
  33963. */
  33964. onAfterAnimationsObservable: Observable<Scene>;
  33965. /**
  33966. * An event triggered before draw calls are ready to be sent
  33967. */
  33968. onBeforeDrawPhaseObservable: Observable<Scene>;
  33969. /**
  33970. * An event triggered after draw calls have been sent
  33971. */
  33972. onAfterDrawPhaseObservable: Observable<Scene>;
  33973. /**
  33974. * An event triggered when the scene is ready
  33975. */
  33976. onReadyObservable: Observable<Scene>;
  33977. /**
  33978. * An event triggered before rendering a camera
  33979. */
  33980. onBeforeCameraRenderObservable: Observable<Camera>;
  33981. private _onBeforeCameraRenderObserver;
  33982. /** Sets a function to be executed before rendering a camera*/
  33983. beforeCameraRender: () => void;
  33984. /**
  33985. * An event triggered after rendering a camera
  33986. */
  33987. onAfterCameraRenderObservable: Observable<Camera>;
  33988. private _onAfterCameraRenderObserver;
  33989. /** Sets a function to be executed after rendering a camera*/
  33990. afterCameraRender: () => void;
  33991. /**
  33992. * An event triggered when active meshes evaluation is about to start
  33993. */
  33994. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33995. /**
  33996. * An event triggered when active meshes evaluation is done
  33997. */
  33998. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33999. /**
  34000. * An event triggered when particles rendering is about to start
  34001. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34002. */
  34003. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34004. /**
  34005. * An event triggered when particles rendering is done
  34006. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34007. */
  34008. onAfterParticlesRenderingObservable: Observable<Scene>;
  34009. /**
  34010. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34011. */
  34012. onDataLoadedObservable: Observable<Scene>;
  34013. /**
  34014. * An event triggered when a camera is created
  34015. */
  34016. onNewCameraAddedObservable: Observable<Camera>;
  34017. /**
  34018. * An event triggered when a camera is removed
  34019. */
  34020. onCameraRemovedObservable: Observable<Camera>;
  34021. /**
  34022. * An event triggered when a light is created
  34023. */
  34024. onNewLightAddedObservable: Observable<Light>;
  34025. /**
  34026. * An event triggered when a light is removed
  34027. */
  34028. onLightRemovedObservable: Observable<Light>;
  34029. /**
  34030. * An event triggered when a geometry is created
  34031. */
  34032. onNewGeometryAddedObservable: Observable<Geometry>;
  34033. /**
  34034. * An event triggered when a geometry is removed
  34035. */
  34036. onGeometryRemovedObservable: Observable<Geometry>;
  34037. /**
  34038. * An event triggered when a transform node is created
  34039. */
  34040. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34041. /**
  34042. * An event triggered when a transform node is removed
  34043. */
  34044. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34045. /**
  34046. * An event triggered when a mesh is created
  34047. */
  34048. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34049. /**
  34050. * An event triggered when a mesh is removed
  34051. */
  34052. onMeshRemovedObservable: Observable<AbstractMesh>;
  34053. /**
  34054. * An event triggered when a skeleton is created
  34055. */
  34056. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34057. /**
  34058. * An event triggered when a skeleton is removed
  34059. */
  34060. onSkeletonRemovedObservable: Observable<Skeleton>;
  34061. /**
  34062. * An event triggered when a material is created
  34063. */
  34064. onNewMaterialAddedObservable: Observable<Material>;
  34065. /**
  34066. * An event triggered when a material is removed
  34067. */
  34068. onMaterialRemovedObservable: Observable<Material>;
  34069. /**
  34070. * An event triggered when a texture is created
  34071. */
  34072. onNewTextureAddedObservable: Observable<BaseTexture>;
  34073. /**
  34074. * An event triggered when a texture is removed
  34075. */
  34076. onTextureRemovedObservable: Observable<BaseTexture>;
  34077. /**
  34078. * An event triggered when render targets are about to be rendered
  34079. * Can happen multiple times per frame.
  34080. */
  34081. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34082. /**
  34083. * An event triggered when render targets were rendered.
  34084. * Can happen multiple times per frame.
  34085. */
  34086. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34087. /**
  34088. * An event triggered before calculating deterministic simulation step
  34089. */
  34090. onBeforeStepObservable: Observable<Scene>;
  34091. /**
  34092. * An event triggered after calculating deterministic simulation step
  34093. */
  34094. onAfterStepObservable: Observable<Scene>;
  34095. /**
  34096. * An event triggered when the activeCamera property is updated
  34097. */
  34098. onActiveCameraChanged: Observable<Scene>;
  34099. /**
  34100. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34101. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34102. * 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)
  34103. */
  34104. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34105. /**
  34106. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34107. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34108. * 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)
  34109. */
  34110. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34111. /**
  34112. * This Observable will when a mesh has been imported into the scene.
  34113. */
  34114. onMeshImportedObservable: Observable<AbstractMesh>;
  34115. /**
  34116. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34117. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34118. */
  34119. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34120. /** @hidden */
  34121. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34122. /**
  34123. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34124. */
  34125. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34126. /**
  34127. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34128. */
  34129. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34130. /**
  34131. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34132. */
  34133. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34134. /** Callback called when a pointer move is detected */
  34135. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34136. /** Callback called when a pointer down is detected */
  34137. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34138. /** Callback called when a pointer up is detected */
  34139. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34140. /** Callback called when a pointer pick is detected */
  34141. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34142. /**
  34143. * 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).
  34144. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34145. */
  34146. onPrePointerObservable: Observable<PointerInfoPre>;
  34147. /**
  34148. * Observable event triggered each time an input event is received from the rendering canvas
  34149. */
  34150. onPointerObservable: Observable<PointerInfo>;
  34151. /**
  34152. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34153. */
  34154. readonly unTranslatedPointer: Vector2;
  34155. /**
  34156. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34157. */
  34158. static DragMovementThreshold: number;
  34159. /**
  34160. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34161. */
  34162. static LongPressDelay: number;
  34163. /**
  34164. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34165. */
  34166. static DoubleClickDelay: number;
  34167. /** If you need to check double click without raising a single click at first click, enable this flag */
  34168. static ExclusiveDoubleClickMode: boolean;
  34169. /** @hidden */
  34170. _mirroredCameraPosition: Nullable<Vector3>;
  34171. /**
  34172. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34173. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34174. */
  34175. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34176. /**
  34177. * Observable event triggered each time an keyboard event is received from the hosting window
  34178. */
  34179. onKeyboardObservable: Observable<KeyboardInfo>;
  34180. private _useRightHandedSystem;
  34181. /**
  34182. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34183. */
  34184. useRightHandedSystem: boolean;
  34185. private _timeAccumulator;
  34186. private _currentStepId;
  34187. private _currentInternalStep;
  34188. /**
  34189. * Sets the step Id used by deterministic lock step
  34190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34191. * @param newStepId defines the step Id
  34192. */
  34193. setStepId(newStepId: number): void;
  34194. /**
  34195. * Gets the step Id used by deterministic lock step
  34196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34197. * @returns the step Id
  34198. */
  34199. getStepId(): number;
  34200. /**
  34201. * Gets the internal step used by deterministic lock step
  34202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34203. * @returns the internal step
  34204. */
  34205. getInternalStep(): number;
  34206. private _fogEnabled;
  34207. /**
  34208. * Gets or sets a boolean indicating if fog is enabled on this scene
  34209. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34210. * (Default is true)
  34211. */
  34212. fogEnabled: boolean;
  34213. private _fogMode;
  34214. /**
  34215. * Gets or sets the fog mode to use
  34216. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34217. * | mode | value |
  34218. * | --- | --- |
  34219. * | FOGMODE_NONE | 0 |
  34220. * | FOGMODE_EXP | 1 |
  34221. * | FOGMODE_EXP2 | 2 |
  34222. * | FOGMODE_LINEAR | 3 |
  34223. */
  34224. fogMode: number;
  34225. /**
  34226. * Gets or sets the fog color to use
  34227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34228. * (Default is Color3(0.2, 0.2, 0.3))
  34229. */
  34230. fogColor: Color3;
  34231. /**
  34232. * Gets or sets the fog density to use
  34233. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34234. * (Default is 0.1)
  34235. */
  34236. fogDensity: number;
  34237. /**
  34238. * Gets or sets the fog start distance to use
  34239. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34240. * (Default is 0)
  34241. */
  34242. fogStart: number;
  34243. /**
  34244. * Gets or sets the fog end distance to use
  34245. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34246. * (Default is 1000)
  34247. */
  34248. fogEnd: number;
  34249. private _shadowsEnabled;
  34250. /**
  34251. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34252. */
  34253. shadowsEnabled: boolean;
  34254. private _lightsEnabled;
  34255. /**
  34256. * Gets or sets a boolean indicating if lights are enabled on this scene
  34257. */
  34258. lightsEnabled: boolean;
  34259. /** All of the active cameras added to this scene. */
  34260. activeCameras: Camera[];
  34261. /** @hidden */
  34262. _activeCamera: Nullable<Camera>;
  34263. /** Gets or sets the current active camera */
  34264. activeCamera: Nullable<Camera>;
  34265. private _defaultMaterial;
  34266. /** The default material used on meshes when no material is affected */
  34267. /** The default material used on meshes when no material is affected */
  34268. defaultMaterial: Material;
  34269. private _texturesEnabled;
  34270. /**
  34271. * Gets or sets a boolean indicating if textures are enabled on this scene
  34272. */
  34273. texturesEnabled: boolean;
  34274. /**
  34275. * Gets or sets a boolean indicating if particles are enabled on this scene
  34276. */
  34277. particlesEnabled: boolean;
  34278. /**
  34279. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34280. */
  34281. spritesEnabled: boolean;
  34282. private _skeletonsEnabled;
  34283. /**
  34284. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34285. */
  34286. skeletonsEnabled: boolean;
  34287. /**
  34288. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34289. */
  34290. lensFlaresEnabled: boolean;
  34291. /**
  34292. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34294. */
  34295. collisionsEnabled: boolean;
  34296. private _collisionCoordinator;
  34297. /** @hidden */
  34298. readonly collisionCoordinator: ICollisionCoordinator;
  34299. /**
  34300. * Defines the gravity applied to this scene (used only for collisions)
  34301. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34302. */
  34303. gravity: Vector3;
  34304. /**
  34305. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34306. */
  34307. postProcessesEnabled: boolean;
  34308. /**
  34309. * The list of postprocesses added to the scene
  34310. */
  34311. postProcesses: PostProcess[];
  34312. /**
  34313. * Gets the current postprocess manager
  34314. */
  34315. postProcessManager: PostProcessManager;
  34316. /**
  34317. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34318. */
  34319. renderTargetsEnabled: boolean;
  34320. /**
  34321. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34322. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34323. */
  34324. dumpNextRenderTargets: boolean;
  34325. /**
  34326. * The list of user defined render targets added to the scene
  34327. */
  34328. customRenderTargets: RenderTargetTexture[];
  34329. /**
  34330. * Defines if texture loading must be delayed
  34331. * If true, textures will only be loaded when they need to be rendered
  34332. */
  34333. useDelayedTextureLoading: boolean;
  34334. /**
  34335. * Gets the list of meshes imported to the scene through SceneLoader
  34336. */
  34337. importedMeshesFiles: String[];
  34338. /**
  34339. * Gets or sets a boolean indicating if probes are enabled on this scene
  34340. */
  34341. probesEnabled: boolean;
  34342. /**
  34343. * Gets or sets the current offline provider to use to store scene data
  34344. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34345. */
  34346. offlineProvider: IOfflineProvider;
  34347. /**
  34348. * Gets or sets the action manager associated with the scene
  34349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34350. */
  34351. actionManager: AbstractActionManager;
  34352. private _meshesForIntersections;
  34353. /**
  34354. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34355. */
  34356. proceduralTexturesEnabled: boolean;
  34357. private _engine;
  34358. private _totalVertices;
  34359. /** @hidden */
  34360. _activeIndices: PerfCounter;
  34361. /** @hidden */
  34362. _activeParticles: PerfCounter;
  34363. /** @hidden */
  34364. _activeBones: PerfCounter;
  34365. private _animationRatio;
  34366. /** @hidden */
  34367. _animationTimeLast: number;
  34368. /** @hidden */
  34369. _animationTime: number;
  34370. /**
  34371. * Gets or sets a general scale for animation speed
  34372. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34373. */
  34374. animationTimeScale: number;
  34375. /** @hidden */
  34376. _cachedMaterial: Nullable<Material>;
  34377. /** @hidden */
  34378. _cachedEffect: Nullable<Effect>;
  34379. /** @hidden */
  34380. _cachedVisibility: Nullable<number>;
  34381. private _renderId;
  34382. private _frameId;
  34383. private _executeWhenReadyTimeoutId;
  34384. private _intermediateRendering;
  34385. private _viewUpdateFlag;
  34386. private _projectionUpdateFlag;
  34387. /** @hidden */
  34388. _toBeDisposed: Nullable<IDisposable>[];
  34389. private _activeRequests;
  34390. /** @hidden */
  34391. _pendingData: any[];
  34392. private _isDisposed;
  34393. /**
  34394. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34395. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34396. */
  34397. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34398. private _activeMeshes;
  34399. private _processedMaterials;
  34400. private _renderTargets;
  34401. /** @hidden */
  34402. _activeParticleSystems: SmartArray<IParticleSystem>;
  34403. private _activeSkeletons;
  34404. private _softwareSkinnedMeshes;
  34405. private _renderingManager;
  34406. /** @hidden */
  34407. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34408. private _transformMatrix;
  34409. private _sceneUbo;
  34410. /** @hidden */
  34411. _viewMatrix: Matrix;
  34412. private _projectionMatrix;
  34413. /** @hidden */
  34414. _forcedViewPosition: Nullable<Vector3>;
  34415. /** @hidden */
  34416. _frustumPlanes: Plane[];
  34417. /**
  34418. * Gets the list of frustum planes (built from the active camera)
  34419. */
  34420. readonly frustumPlanes: Plane[];
  34421. /**
  34422. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34423. * This is useful if there are more lights that the maximum simulteanous authorized
  34424. */
  34425. requireLightSorting: boolean;
  34426. /** @hidden */
  34427. readonly useMaterialMeshMap: boolean;
  34428. /** @hidden */
  34429. readonly useClonedMeshhMap: boolean;
  34430. private _externalData;
  34431. private _uid;
  34432. /**
  34433. * @hidden
  34434. * Backing store of defined scene components.
  34435. */
  34436. _components: ISceneComponent[];
  34437. /**
  34438. * @hidden
  34439. * Backing store of defined scene components.
  34440. */
  34441. _serializableComponents: ISceneSerializableComponent[];
  34442. /**
  34443. * List of components to register on the next registration step.
  34444. */
  34445. private _transientComponents;
  34446. /**
  34447. * Registers the transient components if needed.
  34448. */
  34449. private _registerTransientComponents;
  34450. /**
  34451. * @hidden
  34452. * Add a component to the scene.
  34453. * Note that the ccomponent could be registered on th next frame if this is called after
  34454. * the register component stage.
  34455. * @param component Defines the component to add to the scene
  34456. */
  34457. _addComponent(component: ISceneComponent): void;
  34458. /**
  34459. * @hidden
  34460. * Gets a component from the scene.
  34461. * @param name defines the name of the component to retrieve
  34462. * @returns the component or null if not present
  34463. */
  34464. _getComponent(name: string): Nullable<ISceneComponent>;
  34465. /**
  34466. * @hidden
  34467. * Defines the actions happening before camera updates.
  34468. */
  34469. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34470. /**
  34471. * @hidden
  34472. * Defines the actions happening before clear the canvas.
  34473. */
  34474. _beforeClearStage: Stage<SimpleStageAction>;
  34475. /**
  34476. * @hidden
  34477. * Defines the actions when collecting render targets for the frame.
  34478. */
  34479. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34480. /**
  34481. * @hidden
  34482. * Defines the actions happening for one camera in the frame.
  34483. */
  34484. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34485. /**
  34486. * @hidden
  34487. * Defines the actions happening during the per mesh ready checks.
  34488. */
  34489. _isReadyForMeshStage: Stage<MeshStageAction>;
  34490. /**
  34491. * @hidden
  34492. * Defines the actions happening before evaluate active mesh checks.
  34493. */
  34494. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34495. /**
  34496. * @hidden
  34497. * Defines the actions happening during the evaluate sub mesh checks.
  34498. */
  34499. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34500. /**
  34501. * @hidden
  34502. * Defines the actions happening during the active mesh stage.
  34503. */
  34504. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34505. /**
  34506. * @hidden
  34507. * Defines the actions happening during the per camera render target step.
  34508. */
  34509. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34510. /**
  34511. * @hidden
  34512. * Defines the actions happening just before the active camera is drawing.
  34513. */
  34514. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34515. /**
  34516. * @hidden
  34517. * Defines the actions happening just before a render target is drawing.
  34518. */
  34519. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34520. /**
  34521. * @hidden
  34522. * Defines the actions happening just before a rendering group is drawing.
  34523. */
  34524. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34525. /**
  34526. * @hidden
  34527. * Defines the actions happening just before a mesh is drawing.
  34528. */
  34529. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34530. /**
  34531. * @hidden
  34532. * Defines the actions happening just after a mesh has been drawn.
  34533. */
  34534. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34535. /**
  34536. * @hidden
  34537. * Defines the actions happening just after a rendering group has been drawn.
  34538. */
  34539. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34540. /**
  34541. * @hidden
  34542. * Defines the actions happening just after the active camera has been drawn.
  34543. */
  34544. _afterCameraDrawStage: Stage<CameraStageAction>;
  34545. /**
  34546. * @hidden
  34547. * Defines the actions happening just after a render target has been drawn.
  34548. */
  34549. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34550. /**
  34551. * @hidden
  34552. * Defines the actions happening just after rendering all cameras and computing intersections.
  34553. */
  34554. _afterRenderStage: Stage<SimpleStageAction>;
  34555. /**
  34556. * @hidden
  34557. * Defines the actions happening when a pointer move event happens.
  34558. */
  34559. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34560. /**
  34561. * @hidden
  34562. * Defines the actions happening when a pointer down event happens.
  34563. */
  34564. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34565. /**
  34566. * @hidden
  34567. * Defines the actions happening when a pointer up event happens.
  34568. */
  34569. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34570. /**
  34571. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34572. */
  34573. private geometriesByUniqueId;
  34574. /**
  34575. * Creates a new Scene
  34576. * @param engine defines the engine to use to render this scene
  34577. * @param options defines the scene options
  34578. */
  34579. constructor(engine: Engine, options?: SceneOptions);
  34580. /**
  34581. * Gets a string idenfifying the name of the class
  34582. * @returns "Scene" string
  34583. */
  34584. getClassName(): string;
  34585. private _defaultMeshCandidates;
  34586. /**
  34587. * @hidden
  34588. */
  34589. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34590. private _defaultSubMeshCandidates;
  34591. /**
  34592. * @hidden
  34593. */
  34594. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34595. /**
  34596. * Sets the default candidate providers for the scene.
  34597. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34598. * and getCollidingSubMeshCandidates to their default function
  34599. */
  34600. setDefaultCandidateProviders(): void;
  34601. /**
  34602. * Gets the mesh that is currently under the pointer
  34603. */
  34604. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34605. /**
  34606. * Gets or sets the current on-screen X position of the pointer
  34607. */
  34608. pointerX: number;
  34609. /**
  34610. * Gets or sets the current on-screen Y position of the pointer
  34611. */
  34612. pointerY: number;
  34613. /**
  34614. * Gets the cached material (ie. the latest rendered one)
  34615. * @returns the cached material
  34616. */
  34617. getCachedMaterial(): Nullable<Material>;
  34618. /**
  34619. * Gets the cached effect (ie. the latest rendered one)
  34620. * @returns the cached effect
  34621. */
  34622. getCachedEffect(): Nullable<Effect>;
  34623. /**
  34624. * Gets the cached visibility state (ie. the latest rendered one)
  34625. * @returns the cached visibility state
  34626. */
  34627. getCachedVisibility(): Nullable<number>;
  34628. /**
  34629. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34630. * @param material defines the current material
  34631. * @param effect defines the current effect
  34632. * @param visibility defines the current visibility state
  34633. * @returns true if one parameter is not cached
  34634. */
  34635. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34636. /**
  34637. * Gets the engine associated with the scene
  34638. * @returns an Engine
  34639. */
  34640. getEngine(): Engine;
  34641. /**
  34642. * Gets the total number of vertices rendered per frame
  34643. * @returns the total number of vertices rendered per frame
  34644. */
  34645. getTotalVertices(): number;
  34646. /**
  34647. * Gets the performance counter for total vertices
  34648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34649. */
  34650. readonly totalVerticesPerfCounter: PerfCounter;
  34651. /**
  34652. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34653. * @returns the total number of active indices rendered per frame
  34654. */
  34655. getActiveIndices(): number;
  34656. /**
  34657. * Gets the performance counter for active indices
  34658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34659. */
  34660. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34661. /**
  34662. * Gets the total number of active particles rendered per frame
  34663. * @returns the total number of active particles rendered per frame
  34664. */
  34665. getActiveParticles(): number;
  34666. /**
  34667. * Gets the performance counter for active particles
  34668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34669. */
  34670. readonly activeParticlesPerfCounter: PerfCounter;
  34671. /**
  34672. * Gets the total number of active bones rendered per frame
  34673. * @returns the total number of active bones rendered per frame
  34674. */
  34675. getActiveBones(): number;
  34676. /**
  34677. * Gets the performance counter for active bones
  34678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34679. */
  34680. readonly activeBonesPerfCounter: PerfCounter;
  34681. /**
  34682. * Gets the array of active meshes
  34683. * @returns an array of AbstractMesh
  34684. */
  34685. getActiveMeshes(): SmartArray<AbstractMesh>;
  34686. /**
  34687. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34688. * @returns a number
  34689. */
  34690. getAnimationRatio(): number;
  34691. /**
  34692. * Gets an unique Id for the current render phase
  34693. * @returns a number
  34694. */
  34695. getRenderId(): number;
  34696. /**
  34697. * Gets an unique Id for the current frame
  34698. * @returns a number
  34699. */
  34700. getFrameId(): number;
  34701. /** Call this function if you want to manually increment the render Id*/
  34702. incrementRenderId(): void;
  34703. private _createUbo;
  34704. /**
  34705. * Use this method to simulate a pointer move on a mesh
  34706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34709. * @returns the current scene
  34710. */
  34711. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34712. /**
  34713. * Use this method to simulate a pointer down on a mesh
  34714. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34715. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34716. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34717. * @returns the current scene
  34718. */
  34719. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34720. /**
  34721. * Use this method to simulate a pointer up on a mesh
  34722. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34723. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34724. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34725. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34726. * @returns the current scene
  34727. */
  34728. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34729. /**
  34730. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34731. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34732. * @returns true if the pointer was captured
  34733. */
  34734. isPointerCaptured(pointerId?: number): boolean;
  34735. /**
  34736. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34737. * @param attachUp defines if you want to attach events to pointerup
  34738. * @param attachDown defines if you want to attach events to pointerdown
  34739. * @param attachMove defines if you want to attach events to pointermove
  34740. */
  34741. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34742. /** Detaches all event handlers*/
  34743. detachControl(): void;
  34744. /**
  34745. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34746. * Delay loaded resources are not taking in account
  34747. * @return true if all required resources are ready
  34748. */
  34749. isReady(): boolean;
  34750. /** Resets all cached information relative to material (including effect and visibility) */
  34751. resetCachedMaterial(): void;
  34752. /**
  34753. * Registers a function to be called before every frame render
  34754. * @param func defines the function to register
  34755. */
  34756. registerBeforeRender(func: () => void): void;
  34757. /**
  34758. * Unregisters a function called before every frame render
  34759. * @param func defines the function to unregister
  34760. */
  34761. unregisterBeforeRender(func: () => void): void;
  34762. /**
  34763. * Registers a function to be called after every frame render
  34764. * @param func defines the function to register
  34765. */
  34766. registerAfterRender(func: () => void): void;
  34767. /**
  34768. * Unregisters a function called after every frame render
  34769. * @param func defines the function to unregister
  34770. */
  34771. unregisterAfterRender(func: () => void): void;
  34772. private _executeOnceBeforeRender;
  34773. /**
  34774. * The provided function will run before render once and will be disposed afterwards.
  34775. * A timeout delay can be provided so that the function will be executed in N ms.
  34776. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34777. * @param func The function to be executed.
  34778. * @param timeout optional delay in ms
  34779. */
  34780. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34781. /** @hidden */
  34782. _addPendingData(data: any): void;
  34783. /** @hidden */
  34784. _removePendingData(data: any): void;
  34785. /**
  34786. * Returns the number of items waiting to be loaded
  34787. * @returns the number of items waiting to be loaded
  34788. */
  34789. getWaitingItemsCount(): number;
  34790. /**
  34791. * Returns a boolean indicating if the scene is still loading data
  34792. */
  34793. readonly isLoading: boolean;
  34794. /**
  34795. * Registers a function to be executed when the scene is ready
  34796. * @param {Function} func - the function to be executed
  34797. */
  34798. executeWhenReady(func: () => void): void;
  34799. /**
  34800. * Returns a promise that resolves when the scene is ready
  34801. * @returns A promise that resolves when the scene is ready
  34802. */
  34803. whenReadyAsync(): Promise<void>;
  34804. /** @hidden */
  34805. _checkIsReady(): void;
  34806. /**
  34807. * Gets all animatable attached to the scene
  34808. */
  34809. readonly animatables: Animatable[];
  34810. /**
  34811. * Resets the last animation time frame.
  34812. * Useful to override when animations start running when loading a scene for the first time.
  34813. */
  34814. resetLastAnimationTimeFrame(): void;
  34815. /**
  34816. * Gets the current view matrix
  34817. * @returns a Matrix
  34818. */
  34819. getViewMatrix(): Matrix;
  34820. /**
  34821. * Gets the current projection matrix
  34822. * @returns a Matrix
  34823. */
  34824. getProjectionMatrix(): Matrix;
  34825. /**
  34826. * Gets the current transform matrix
  34827. * @returns a Matrix made of View * Projection
  34828. */
  34829. getTransformMatrix(): Matrix;
  34830. /**
  34831. * Sets the current transform matrix
  34832. * @param viewL defines the View matrix to use
  34833. * @param projectionL defines the Projection matrix to use
  34834. * @param viewR defines the right View matrix to use (if provided)
  34835. * @param projectionR defines the right Projection matrix to use (if provided)
  34836. */
  34837. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34838. /**
  34839. * Gets the uniform buffer used to store scene data
  34840. * @returns a UniformBuffer
  34841. */
  34842. getSceneUniformBuffer(): UniformBuffer;
  34843. /**
  34844. * Gets an unique (relatively to the current scene) Id
  34845. * @returns an unique number for the scene
  34846. */
  34847. getUniqueId(): number;
  34848. /**
  34849. * Add a mesh to the list of scene's meshes
  34850. * @param newMesh defines the mesh to add
  34851. * @param recursive if all child meshes should also be added to the scene
  34852. */
  34853. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34854. /**
  34855. * Remove a mesh for the list of scene's meshes
  34856. * @param toRemove defines the mesh to remove
  34857. * @param recursive if all child meshes should also be removed from the scene
  34858. * @returns the index where the mesh was in the mesh list
  34859. */
  34860. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34861. /**
  34862. * Add a transform node to the list of scene's transform nodes
  34863. * @param newTransformNode defines the transform node to add
  34864. */
  34865. addTransformNode(newTransformNode: TransformNode): void;
  34866. /**
  34867. * Remove a transform node for the list of scene's transform nodes
  34868. * @param toRemove defines the transform node to remove
  34869. * @returns the index where the transform node was in the transform node list
  34870. */
  34871. removeTransformNode(toRemove: TransformNode): number;
  34872. /**
  34873. * Remove a skeleton for the list of scene's skeletons
  34874. * @param toRemove defines the skeleton to remove
  34875. * @returns the index where the skeleton was in the skeleton list
  34876. */
  34877. removeSkeleton(toRemove: Skeleton): number;
  34878. /**
  34879. * Remove a morph target for the list of scene's morph targets
  34880. * @param toRemove defines the morph target to remove
  34881. * @returns the index where the morph target was in the morph target list
  34882. */
  34883. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34884. /**
  34885. * Remove a light for the list of scene's lights
  34886. * @param toRemove defines the light to remove
  34887. * @returns the index where the light was in the light list
  34888. */
  34889. removeLight(toRemove: Light): number;
  34890. /**
  34891. * Remove a camera for the list of scene's cameras
  34892. * @param toRemove defines the camera to remove
  34893. * @returns the index where the camera was in the camera list
  34894. */
  34895. removeCamera(toRemove: Camera): number;
  34896. /**
  34897. * Remove a particle system for the list of scene's particle systems
  34898. * @param toRemove defines the particle system to remove
  34899. * @returns the index where the particle system was in the particle system list
  34900. */
  34901. removeParticleSystem(toRemove: IParticleSystem): number;
  34902. /**
  34903. * Remove a animation for the list of scene's animations
  34904. * @param toRemove defines the animation to remove
  34905. * @returns the index where the animation was in the animation list
  34906. */
  34907. removeAnimation(toRemove: Animation): number;
  34908. /**
  34909. * Will stop the animation of the given target
  34910. * @param target - the target
  34911. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34912. * @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)
  34913. */
  34914. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34915. /**
  34916. * Removes the given animation group from this scene.
  34917. * @param toRemove The animation group to remove
  34918. * @returns The index of the removed animation group
  34919. */
  34920. removeAnimationGroup(toRemove: AnimationGroup): number;
  34921. /**
  34922. * Removes the given multi-material from this scene.
  34923. * @param toRemove The multi-material to remove
  34924. * @returns The index of the removed multi-material
  34925. */
  34926. removeMultiMaterial(toRemove: MultiMaterial): number;
  34927. /**
  34928. * Removes the given material from this scene.
  34929. * @param toRemove The material to remove
  34930. * @returns The index of the removed material
  34931. */
  34932. removeMaterial(toRemove: Material): number;
  34933. /**
  34934. * Removes the given action manager from this scene.
  34935. * @param toRemove The action manager to remove
  34936. * @returns The index of the removed action manager
  34937. */
  34938. removeActionManager(toRemove: AbstractActionManager): number;
  34939. /**
  34940. * Removes the given texture from this scene.
  34941. * @param toRemove The texture to remove
  34942. * @returns The index of the removed texture
  34943. */
  34944. removeTexture(toRemove: BaseTexture): number;
  34945. /**
  34946. * Adds the given light to this scene
  34947. * @param newLight The light to add
  34948. */
  34949. addLight(newLight: Light): void;
  34950. /**
  34951. * Sorts the list list based on light priorities
  34952. */
  34953. sortLightsByPriority(): void;
  34954. /**
  34955. * Adds the given camera to this scene
  34956. * @param newCamera The camera to add
  34957. */
  34958. addCamera(newCamera: Camera): void;
  34959. /**
  34960. * Adds the given skeleton to this scene
  34961. * @param newSkeleton The skeleton to add
  34962. */
  34963. addSkeleton(newSkeleton: Skeleton): void;
  34964. /**
  34965. * Adds the given particle system to this scene
  34966. * @param newParticleSystem The particle system to add
  34967. */
  34968. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34969. /**
  34970. * Adds the given animation to this scene
  34971. * @param newAnimation The animation to add
  34972. */
  34973. addAnimation(newAnimation: Animation): void;
  34974. /**
  34975. * Adds the given animation group to this scene.
  34976. * @param newAnimationGroup The animation group to add
  34977. */
  34978. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34979. /**
  34980. * Adds the given multi-material to this scene
  34981. * @param newMultiMaterial The multi-material to add
  34982. */
  34983. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34984. /**
  34985. * Adds the given material to this scene
  34986. * @param newMaterial The material to add
  34987. */
  34988. addMaterial(newMaterial: Material): void;
  34989. /**
  34990. * Adds the given morph target to this scene
  34991. * @param newMorphTargetManager The morph target to add
  34992. */
  34993. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34994. /**
  34995. * Adds the given geometry to this scene
  34996. * @param newGeometry The geometry to add
  34997. */
  34998. addGeometry(newGeometry: Geometry): void;
  34999. /**
  35000. * Adds the given action manager to this scene
  35001. * @param newActionManager The action manager to add
  35002. */
  35003. addActionManager(newActionManager: AbstractActionManager): void;
  35004. /**
  35005. * Adds the given texture to this scene.
  35006. * @param newTexture The texture to add
  35007. */
  35008. addTexture(newTexture: BaseTexture): void;
  35009. /**
  35010. * Switch active camera
  35011. * @param newCamera defines the new active camera
  35012. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35013. */
  35014. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35015. /**
  35016. * sets the active camera of the scene using its ID
  35017. * @param id defines the camera's ID
  35018. * @return the new active camera or null if none found.
  35019. */
  35020. setActiveCameraByID(id: string): Nullable<Camera>;
  35021. /**
  35022. * sets the active camera of the scene using its name
  35023. * @param name defines the camera's name
  35024. * @returns the new active camera or null if none found.
  35025. */
  35026. setActiveCameraByName(name: string): Nullable<Camera>;
  35027. /**
  35028. * get an animation group using its name
  35029. * @param name defines the material's name
  35030. * @return the animation group or null if none found.
  35031. */
  35032. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35033. /**
  35034. * Get a material using its unique id
  35035. * @param uniqueId defines the material's unique id
  35036. * @return the material or null if none found.
  35037. */
  35038. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35039. /**
  35040. * get a material using its id
  35041. * @param id defines the material's ID
  35042. * @return the material or null if none found.
  35043. */
  35044. getMaterialByID(id: string): Nullable<Material>;
  35045. /**
  35046. * Gets a the last added material using a given id
  35047. * @param id defines the material's ID
  35048. * @return the last material with the given id or null if none found.
  35049. */
  35050. getLastMaterialByID(id: string): Nullable<Material>;
  35051. /**
  35052. * Gets a material using its name
  35053. * @param name defines the material's name
  35054. * @return the material or null if none found.
  35055. */
  35056. getMaterialByName(name: string): Nullable<Material>;
  35057. /**
  35058. * Get a texture using its unique id
  35059. * @param uniqueId defines the texture's unique id
  35060. * @return the texture or null if none found.
  35061. */
  35062. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35063. /**
  35064. * Gets a camera using its id
  35065. * @param id defines the id to look for
  35066. * @returns the camera or null if not found
  35067. */
  35068. getCameraByID(id: string): Nullable<Camera>;
  35069. /**
  35070. * Gets a camera using its unique id
  35071. * @param uniqueId defines the unique id to look for
  35072. * @returns the camera or null if not found
  35073. */
  35074. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35075. /**
  35076. * Gets a camera using its name
  35077. * @param name defines the camera's name
  35078. * @return the camera or null if none found.
  35079. */
  35080. getCameraByName(name: string): Nullable<Camera>;
  35081. /**
  35082. * Gets a bone using its id
  35083. * @param id defines the bone's id
  35084. * @return the bone or null if not found
  35085. */
  35086. getBoneByID(id: string): Nullable<Bone>;
  35087. /**
  35088. * Gets a bone using its id
  35089. * @param name defines the bone's name
  35090. * @return the bone or null if not found
  35091. */
  35092. getBoneByName(name: string): Nullable<Bone>;
  35093. /**
  35094. * Gets a light node using its name
  35095. * @param name defines the the light's name
  35096. * @return the light or null if none found.
  35097. */
  35098. getLightByName(name: string): Nullable<Light>;
  35099. /**
  35100. * Gets a light node using its id
  35101. * @param id defines the light's id
  35102. * @return the light or null if none found.
  35103. */
  35104. getLightByID(id: string): Nullable<Light>;
  35105. /**
  35106. * Gets a light node using its scene-generated unique ID
  35107. * @param uniqueId defines the light's unique id
  35108. * @return the light or null if none found.
  35109. */
  35110. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35111. /**
  35112. * Gets a particle system by id
  35113. * @param id defines the particle system id
  35114. * @return the corresponding system or null if none found
  35115. */
  35116. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35117. /**
  35118. * Gets a geometry using its ID
  35119. * @param id defines the geometry's id
  35120. * @return the geometry or null if none found.
  35121. */
  35122. getGeometryByID(id: string): Nullable<Geometry>;
  35123. private _getGeometryByUniqueID;
  35124. /**
  35125. * Add a new geometry to this scene
  35126. * @param geometry defines the geometry to be added to the scene.
  35127. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35128. * @return a boolean defining if the geometry was added or not
  35129. */
  35130. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35131. /**
  35132. * Removes an existing geometry
  35133. * @param geometry defines the geometry to be removed from the scene
  35134. * @return a boolean defining if the geometry was removed or not
  35135. */
  35136. removeGeometry(geometry: Geometry): boolean;
  35137. /**
  35138. * Gets the list of geometries attached to the scene
  35139. * @returns an array of Geometry
  35140. */
  35141. getGeometries(): Geometry[];
  35142. /**
  35143. * Gets the first added mesh found of a given ID
  35144. * @param id defines the id to search for
  35145. * @return the mesh found or null if not found at all
  35146. */
  35147. getMeshByID(id: string): Nullable<AbstractMesh>;
  35148. /**
  35149. * Gets a list of meshes using their id
  35150. * @param id defines the id to search for
  35151. * @returns a list of meshes
  35152. */
  35153. getMeshesByID(id: string): Array<AbstractMesh>;
  35154. /**
  35155. * Gets the first added transform node found of a given ID
  35156. * @param id defines the id to search for
  35157. * @return the found transform node or null if not found at all.
  35158. */
  35159. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35160. /**
  35161. * Gets a transform node with its auto-generated unique id
  35162. * @param uniqueId efines the unique id to search for
  35163. * @return the found transform node or null if not found at all.
  35164. */
  35165. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35166. /**
  35167. * Gets a list of transform nodes using their id
  35168. * @param id defines the id to search for
  35169. * @returns a list of transform nodes
  35170. */
  35171. getTransformNodesByID(id: string): Array<TransformNode>;
  35172. /**
  35173. * Gets a mesh with its auto-generated unique id
  35174. * @param uniqueId defines the unique id to search for
  35175. * @return the found mesh or null if not found at all.
  35176. */
  35177. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35178. /**
  35179. * Gets a the last added mesh using a given id
  35180. * @param id defines the id to search for
  35181. * @return the found mesh or null if not found at all.
  35182. */
  35183. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35184. /**
  35185. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35186. * @param id defines the id to search for
  35187. * @return the found node or null if not found at all
  35188. */
  35189. getLastEntryByID(id: string): Nullable<Node>;
  35190. /**
  35191. * Gets a node (Mesh, Camera, Light) using a given id
  35192. * @param id defines the id to search for
  35193. * @return the found node or null if not found at all
  35194. */
  35195. getNodeByID(id: string): Nullable<Node>;
  35196. /**
  35197. * Gets a node (Mesh, Camera, Light) using a given name
  35198. * @param name defines the name to search for
  35199. * @return the found node or null if not found at all.
  35200. */
  35201. getNodeByName(name: string): Nullable<Node>;
  35202. /**
  35203. * Gets a mesh using a given name
  35204. * @param name defines the name to search for
  35205. * @return the found mesh or null if not found at all.
  35206. */
  35207. getMeshByName(name: string): Nullable<AbstractMesh>;
  35208. /**
  35209. * Gets a transform node using a given name
  35210. * @param name defines the name to search for
  35211. * @return the found transform node or null if not found at all.
  35212. */
  35213. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35214. /**
  35215. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35216. * @param id defines the id to search for
  35217. * @return the found skeleton or null if not found at all.
  35218. */
  35219. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35220. /**
  35221. * Gets a skeleton using a given auto generated unique id
  35222. * @param uniqueId defines the unique id to search for
  35223. * @return the found skeleton or null if not found at all.
  35224. */
  35225. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35226. /**
  35227. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35228. * @param id defines the id to search for
  35229. * @return the found skeleton or null if not found at all.
  35230. */
  35231. getSkeletonById(id: string): Nullable<Skeleton>;
  35232. /**
  35233. * Gets a skeleton using a given name
  35234. * @param name defines the name to search for
  35235. * @return the found skeleton or null if not found at all.
  35236. */
  35237. getSkeletonByName(name: string): Nullable<Skeleton>;
  35238. /**
  35239. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35240. * @param id defines the id to search for
  35241. * @return the found morph target manager or null if not found at all.
  35242. */
  35243. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35244. /**
  35245. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35246. * @param id defines the id to search for
  35247. * @return the found morph target or null if not found at all.
  35248. */
  35249. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35250. /**
  35251. * Gets a boolean indicating if the given mesh is active
  35252. * @param mesh defines the mesh to look for
  35253. * @returns true if the mesh is in the active list
  35254. */
  35255. isActiveMesh(mesh: AbstractMesh): boolean;
  35256. /**
  35257. * Return a unique id as a string which can serve as an identifier for the scene
  35258. */
  35259. readonly uid: string;
  35260. /**
  35261. * Add an externaly attached data from its key.
  35262. * This method call will fail and return false, if such key already exists.
  35263. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35264. * @param key the unique key that identifies the data
  35265. * @param data the data object to associate to the key for this Engine instance
  35266. * @return true if no such key were already present and the data was added successfully, false otherwise
  35267. */
  35268. addExternalData<T>(key: string, data: T): boolean;
  35269. /**
  35270. * Get an externaly attached data from its key
  35271. * @param key the unique key that identifies the data
  35272. * @return the associated data, if present (can be null), or undefined if not present
  35273. */
  35274. getExternalData<T>(key: string): Nullable<T>;
  35275. /**
  35276. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35277. * @param key the unique key that identifies the data
  35278. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35279. * @return the associated data, can be null if the factory returned null.
  35280. */
  35281. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35282. /**
  35283. * Remove an externaly attached data from the Engine instance
  35284. * @param key the unique key that identifies the data
  35285. * @return true if the data was successfully removed, false if it doesn't exist
  35286. */
  35287. removeExternalData(key: string): boolean;
  35288. private _evaluateSubMesh;
  35289. /**
  35290. * Clear the processed materials smart array preventing retention point in material dispose.
  35291. */
  35292. freeProcessedMaterials(): void;
  35293. private _preventFreeActiveMeshesAndRenderingGroups;
  35294. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35295. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35296. * when disposing several meshes in a row or a hierarchy of meshes.
  35297. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35298. */
  35299. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35300. /**
  35301. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35302. */
  35303. freeActiveMeshes(): void;
  35304. /**
  35305. * Clear the info related to rendering groups preventing retention points during dispose.
  35306. */
  35307. freeRenderingGroups(): void;
  35308. /** @hidden */
  35309. _isInIntermediateRendering(): boolean;
  35310. /**
  35311. * Lambda returning the list of potentially active meshes.
  35312. */
  35313. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35314. /**
  35315. * Lambda returning the list of potentially active sub meshes.
  35316. */
  35317. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35318. /**
  35319. * Lambda returning the list of potentially intersecting sub meshes.
  35320. */
  35321. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35322. /**
  35323. * Lambda returning the list of potentially colliding sub meshes.
  35324. */
  35325. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35326. private _activeMeshesFrozen;
  35327. /**
  35328. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35329. * @returns the current scene
  35330. */
  35331. freezeActiveMeshes(): Scene;
  35332. /**
  35333. * Use this function to restart evaluating active meshes on every frame
  35334. * @returns the current scene
  35335. */
  35336. unfreezeActiveMeshes(): Scene;
  35337. private _evaluateActiveMeshes;
  35338. private _activeMesh;
  35339. /**
  35340. * Update the transform matrix to update from the current active camera
  35341. * @param force defines a boolean used to force the update even if cache is up to date
  35342. */
  35343. updateTransformMatrix(force?: boolean): void;
  35344. private _bindFrameBuffer;
  35345. /** @hidden */
  35346. _allowPostProcessClearColor: boolean;
  35347. /** @hidden */
  35348. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35349. private _processSubCameras;
  35350. private _checkIntersections;
  35351. /** @hidden */
  35352. _advancePhysicsEngineStep(step: number): void;
  35353. /**
  35354. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35355. */
  35356. getDeterministicFrameTime: () => number;
  35357. /** @hidden */
  35358. _animate(): void;
  35359. /** Execute all animations (for a frame) */
  35360. animate(): void;
  35361. /**
  35362. * Render the scene
  35363. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35364. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35365. */
  35366. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35367. /**
  35368. * Freeze all materials
  35369. * A frozen material will not be updatable but should be faster to render
  35370. */
  35371. freezeMaterials(): void;
  35372. /**
  35373. * Unfreeze all materials
  35374. * A frozen material will not be updatable but should be faster to render
  35375. */
  35376. unfreezeMaterials(): void;
  35377. /**
  35378. * Releases all held ressources
  35379. */
  35380. dispose(): void;
  35381. /**
  35382. * Gets if the scene is already disposed
  35383. */
  35384. readonly isDisposed: boolean;
  35385. /**
  35386. * Call this function to reduce memory footprint of the scene.
  35387. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35388. */
  35389. clearCachedVertexData(): void;
  35390. /**
  35391. * This function will remove the local cached buffer data from texture.
  35392. * It will save memory but will prevent the texture from being rebuilt
  35393. */
  35394. cleanCachedTextureBuffer(): void;
  35395. /**
  35396. * Get the world extend vectors with an optional filter
  35397. *
  35398. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35399. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35400. */
  35401. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35402. min: Vector3;
  35403. max: Vector3;
  35404. };
  35405. /**
  35406. * Creates a ray that can be used to pick in the scene
  35407. * @param x defines the x coordinate of the origin (on-screen)
  35408. * @param y defines the y coordinate of the origin (on-screen)
  35409. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35410. * @param camera defines the camera to use for the picking
  35411. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35412. * @returns a Ray
  35413. */
  35414. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35415. /**
  35416. * Creates a ray that can be used to pick in the scene
  35417. * @param x defines the x coordinate of the origin (on-screen)
  35418. * @param y defines the y coordinate of the origin (on-screen)
  35419. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35420. * @param result defines the ray where to store the picking ray
  35421. * @param camera defines the camera to use for the picking
  35422. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35423. * @returns the current scene
  35424. */
  35425. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35426. /**
  35427. * Creates a ray that can be used to pick in the scene
  35428. * @param x defines the x coordinate of the origin (on-screen)
  35429. * @param y defines the y coordinate of the origin (on-screen)
  35430. * @param camera defines the camera to use for the picking
  35431. * @returns a Ray
  35432. */
  35433. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35434. /**
  35435. * Creates a ray that can be used to pick in the scene
  35436. * @param x defines the x coordinate of the origin (on-screen)
  35437. * @param y defines the y coordinate of the origin (on-screen)
  35438. * @param result defines the ray where to store the picking ray
  35439. * @param camera defines the camera to use for the picking
  35440. * @returns the current scene
  35441. */
  35442. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35443. /** Launch a ray to try to pick a mesh in the scene
  35444. * @param x position on screen
  35445. * @param y position on screen
  35446. * @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
  35447. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35448. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35449. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35450. * @returns a PickingInfo
  35451. */
  35452. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35453. /** Use the given ray to pick a mesh in the scene
  35454. * @param ray The ray to use to pick meshes
  35455. * @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
  35456. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35457. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35458. * @returns a PickingInfo
  35459. */
  35460. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35461. /**
  35462. * Launch a ray to try to pick a mesh in the scene
  35463. * @param x X position on screen
  35464. * @param y Y position on screen
  35465. * @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
  35466. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35467. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35468. * @returns an array of PickingInfo
  35469. */
  35470. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35471. /**
  35472. * Launch a ray to try to pick a mesh in the scene
  35473. * @param ray Ray to use
  35474. * @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
  35475. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35476. * @returns an array of PickingInfo
  35477. */
  35478. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35479. /**
  35480. * Force the value of meshUnderPointer
  35481. * @param mesh defines the mesh to use
  35482. */
  35483. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35484. /**
  35485. * Gets the mesh under the pointer
  35486. * @returns a Mesh or null if no mesh is under the pointer
  35487. */
  35488. getPointerOverMesh(): Nullable<AbstractMesh>;
  35489. /** @hidden */
  35490. _rebuildGeometries(): void;
  35491. /** @hidden */
  35492. _rebuildTextures(): void;
  35493. private _getByTags;
  35494. /**
  35495. * Get a list of meshes by tags
  35496. * @param tagsQuery defines the tags query to use
  35497. * @param forEach defines a predicate used to filter results
  35498. * @returns an array of Mesh
  35499. */
  35500. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35501. /**
  35502. * Get a list of cameras by tags
  35503. * @param tagsQuery defines the tags query to use
  35504. * @param forEach defines a predicate used to filter results
  35505. * @returns an array of Camera
  35506. */
  35507. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35508. /**
  35509. * Get a list of lights by tags
  35510. * @param tagsQuery defines the tags query to use
  35511. * @param forEach defines a predicate used to filter results
  35512. * @returns an array of Light
  35513. */
  35514. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35515. /**
  35516. * Get a list of materials by tags
  35517. * @param tagsQuery defines the tags query to use
  35518. * @param forEach defines a predicate used to filter results
  35519. * @returns an array of Material
  35520. */
  35521. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35522. /**
  35523. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35524. * This allowed control for front to back rendering or reversly depending of the special needs.
  35525. *
  35526. * @param renderingGroupId The rendering group id corresponding to its index
  35527. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35528. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35529. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35530. */
  35531. 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;
  35532. /**
  35533. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35534. *
  35535. * @param renderingGroupId The rendering group id corresponding to its index
  35536. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35537. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35538. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35539. */
  35540. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35541. /**
  35542. * Gets the current auto clear configuration for one rendering group of the rendering
  35543. * manager.
  35544. * @param index the rendering group index to get the information for
  35545. * @returns The auto clear setup for the requested rendering group
  35546. */
  35547. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35548. private _blockMaterialDirtyMechanism;
  35549. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35550. blockMaterialDirtyMechanism: boolean;
  35551. /**
  35552. * Will flag all materials as dirty to trigger new shader compilation
  35553. * @param flag defines the flag used to specify which material part must be marked as dirty
  35554. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35555. */
  35556. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35557. /** @hidden */
  35558. _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;
  35559. /** @hidden */
  35560. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35561. }
  35562. }
  35563. declare module "babylonjs/assetContainer" {
  35564. import { AbstractScene } from "babylonjs/abstractScene";
  35565. import { Scene } from "babylonjs/scene";
  35566. import { Mesh } from "babylonjs/Meshes/mesh";
  35567. /**
  35568. * Set of assets to keep when moving a scene into an asset container.
  35569. */
  35570. export class KeepAssets extends AbstractScene {
  35571. }
  35572. /**
  35573. * Container with a set of assets that can be added or removed from a scene.
  35574. */
  35575. export class AssetContainer extends AbstractScene {
  35576. /**
  35577. * The scene the AssetContainer belongs to.
  35578. */
  35579. scene: Scene;
  35580. /**
  35581. * Instantiates an AssetContainer.
  35582. * @param scene The scene the AssetContainer belongs to.
  35583. */
  35584. constructor(scene: Scene);
  35585. /**
  35586. * Adds all the assets from the container to the scene.
  35587. */
  35588. addAllToScene(): void;
  35589. /**
  35590. * Removes all the assets in the container from the scene
  35591. */
  35592. removeAllFromScene(): void;
  35593. /**
  35594. * Disposes all the assets in the container
  35595. */
  35596. dispose(): void;
  35597. private _moveAssets;
  35598. /**
  35599. * Removes all the assets contained in the scene and adds them to the container.
  35600. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35601. */
  35602. moveAllFromScene(keepAssets?: KeepAssets): void;
  35603. /**
  35604. * 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.
  35605. * @returns the root mesh
  35606. */
  35607. createRootMesh(): Mesh;
  35608. }
  35609. }
  35610. declare module "babylonjs/abstractScene" {
  35611. import { Scene } from "babylonjs/scene";
  35612. import { Nullable } from "babylonjs/types";
  35613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35614. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35615. import { Geometry } from "babylonjs/Meshes/geometry";
  35616. import { Skeleton } from "babylonjs/Bones/skeleton";
  35617. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35618. import { AssetContainer } from "babylonjs/assetContainer";
  35619. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35620. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35622. import { Material } from "babylonjs/Materials/material";
  35623. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35624. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35625. import { Camera } from "babylonjs/Cameras/camera";
  35626. import { Light } from "babylonjs/Lights/light";
  35627. import { Node } from "babylonjs/node";
  35628. import { Animation } from "babylonjs/Animations/animation";
  35629. /**
  35630. * Defines how the parser contract is defined.
  35631. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35632. */
  35633. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35634. /**
  35635. * Defines how the individual parser contract is defined.
  35636. * These parser can parse an individual asset
  35637. */
  35638. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35639. /**
  35640. * Base class of the scene acting as a container for the different elements composing a scene.
  35641. * This class is dynamically extended by the different components of the scene increasing
  35642. * flexibility and reducing coupling
  35643. */
  35644. export abstract class AbstractScene {
  35645. /**
  35646. * Stores the list of available parsers in the application.
  35647. */
  35648. private static _BabylonFileParsers;
  35649. /**
  35650. * Stores the list of available individual parsers in the application.
  35651. */
  35652. private static _IndividualBabylonFileParsers;
  35653. /**
  35654. * Adds a parser in the list of available ones
  35655. * @param name Defines the name of the parser
  35656. * @param parser Defines the parser to add
  35657. */
  35658. static AddParser(name: string, parser: BabylonFileParser): void;
  35659. /**
  35660. * Gets a general parser from the list of avaialble ones
  35661. * @param name Defines the name of the parser
  35662. * @returns the requested parser or null
  35663. */
  35664. static GetParser(name: string): Nullable<BabylonFileParser>;
  35665. /**
  35666. * Adds n individual parser in the list of available ones
  35667. * @param name Defines the name of the parser
  35668. * @param parser Defines the parser to add
  35669. */
  35670. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35671. /**
  35672. * Gets an individual parser from the list of avaialble ones
  35673. * @param name Defines the name of the parser
  35674. * @returns the requested parser or null
  35675. */
  35676. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35677. /**
  35678. * Parser json data and populate both a scene and its associated container object
  35679. * @param jsonData Defines the data to parse
  35680. * @param scene Defines the scene to parse the data for
  35681. * @param container Defines the container attached to the parsing sequence
  35682. * @param rootUrl Defines the root url of the data
  35683. */
  35684. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35685. /**
  35686. * Gets the list of root nodes (ie. nodes with no parent)
  35687. */
  35688. rootNodes: Node[];
  35689. /** All of the cameras added to this scene
  35690. * @see http://doc.babylonjs.com/babylon101/cameras
  35691. */
  35692. cameras: Camera[];
  35693. /**
  35694. * All of the lights added to this scene
  35695. * @see http://doc.babylonjs.com/babylon101/lights
  35696. */
  35697. lights: Light[];
  35698. /**
  35699. * All of the (abstract) meshes added to this scene
  35700. */
  35701. meshes: AbstractMesh[];
  35702. /**
  35703. * The list of skeletons added to the scene
  35704. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35705. */
  35706. skeletons: Skeleton[];
  35707. /**
  35708. * All of the particle systems added to this scene
  35709. * @see http://doc.babylonjs.com/babylon101/particles
  35710. */
  35711. particleSystems: IParticleSystem[];
  35712. /**
  35713. * Gets a list of Animations associated with the scene
  35714. */
  35715. animations: Animation[];
  35716. /**
  35717. * All of the animation groups added to this scene
  35718. * @see http://doc.babylonjs.com/how_to/group
  35719. */
  35720. animationGroups: AnimationGroup[];
  35721. /**
  35722. * All of the multi-materials added to this scene
  35723. * @see http://doc.babylonjs.com/how_to/multi_materials
  35724. */
  35725. multiMaterials: MultiMaterial[];
  35726. /**
  35727. * All of the materials added to this scene
  35728. * In the context of a Scene, it is not supposed to be modified manually.
  35729. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35730. * Note also that the order of the Material wihin the array is not significant and might change.
  35731. * @see http://doc.babylonjs.com/babylon101/materials
  35732. */
  35733. materials: Material[];
  35734. /**
  35735. * The list of morph target managers added to the scene
  35736. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35737. */
  35738. morphTargetManagers: MorphTargetManager[];
  35739. /**
  35740. * The list of geometries used in the scene.
  35741. */
  35742. geometries: Geometry[];
  35743. /**
  35744. * All of the tranform nodes added to this scene
  35745. * In the context of a Scene, it is not supposed to be modified manually.
  35746. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35747. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35748. * @see http://doc.babylonjs.com/how_to/transformnode
  35749. */
  35750. transformNodes: TransformNode[];
  35751. /**
  35752. * ActionManagers available on the scene.
  35753. */
  35754. actionManagers: AbstractActionManager[];
  35755. /**
  35756. * Textures to keep.
  35757. */
  35758. textures: BaseTexture[];
  35759. /**
  35760. * Environment texture for the scene
  35761. */
  35762. environmentTexture: Nullable<BaseTexture>;
  35763. }
  35764. }
  35765. declare module "babylonjs/Audio/sound" {
  35766. import { Observable } from "babylonjs/Misc/observable";
  35767. import { Vector3 } from "babylonjs/Maths/math.vector";
  35768. import { Nullable } from "babylonjs/types";
  35769. import { Scene } from "babylonjs/scene";
  35770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35771. /**
  35772. * Interface used to define options for Sound class
  35773. */
  35774. export interface ISoundOptions {
  35775. /**
  35776. * Does the sound autoplay once loaded.
  35777. */
  35778. autoplay?: boolean;
  35779. /**
  35780. * Does the sound loop after it finishes playing once.
  35781. */
  35782. loop?: boolean;
  35783. /**
  35784. * Sound's volume
  35785. */
  35786. volume?: number;
  35787. /**
  35788. * Is it a spatial sound?
  35789. */
  35790. spatialSound?: boolean;
  35791. /**
  35792. * Maximum distance to hear that sound
  35793. */
  35794. maxDistance?: number;
  35795. /**
  35796. * Uses user defined attenuation function
  35797. */
  35798. useCustomAttenuation?: boolean;
  35799. /**
  35800. * Define the roll off factor of spatial sounds.
  35801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35802. */
  35803. rolloffFactor?: number;
  35804. /**
  35805. * Define the reference distance the sound should be heard perfectly.
  35806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35807. */
  35808. refDistance?: number;
  35809. /**
  35810. * Define the distance attenuation model the sound will follow.
  35811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35812. */
  35813. distanceModel?: string;
  35814. /**
  35815. * Defines the playback speed (1 by default)
  35816. */
  35817. playbackRate?: number;
  35818. /**
  35819. * Defines if the sound is from a streaming source
  35820. */
  35821. streaming?: boolean;
  35822. /**
  35823. * Defines an optional length (in seconds) inside the sound file
  35824. */
  35825. length?: number;
  35826. /**
  35827. * Defines an optional offset (in seconds) inside the sound file
  35828. */
  35829. offset?: number;
  35830. /**
  35831. * If true, URLs will not be required to state the audio file codec to use.
  35832. */
  35833. skipCodecCheck?: boolean;
  35834. }
  35835. /**
  35836. * Defines a sound that can be played in the application.
  35837. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35839. */
  35840. export class Sound {
  35841. /**
  35842. * The name of the sound in the scene.
  35843. */
  35844. name: string;
  35845. /**
  35846. * Does the sound autoplay once loaded.
  35847. */
  35848. autoplay: boolean;
  35849. /**
  35850. * Does the sound loop after it finishes playing once.
  35851. */
  35852. loop: boolean;
  35853. /**
  35854. * Does the sound use a custom attenuation curve to simulate the falloff
  35855. * happening when the source gets further away from the camera.
  35856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35857. */
  35858. useCustomAttenuation: boolean;
  35859. /**
  35860. * The sound track id this sound belongs to.
  35861. */
  35862. soundTrackId: number;
  35863. /**
  35864. * Is this sound currently played.
  35865. */
  35866. isPlaying: boolean;
  35867. /**
  35868. * Is this sound currently paused.
  35869. */
  35870. isPaused: boolean;
  35871. /**
  35872. * Does this sound enables spatial sound.
  35873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35874. */
  35875. spatialSound: boolean;
  35876. /**
  35877. * Define the reference distance the sound should be heard perfectly.
  35878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35879. */
  35880. refDistance: number;
  35881. /**
  35882. * Define the roll off factor of spatial sounds.
  35883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35884. */
  35885. rolloffFactor: number;
  35886. /**
  35887. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35889. */
  35890. maxDistance: number;
  35891. /**
  35892. * Define the distance attenuation model the sound will follow.
  35893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35894. */
  35895. distanceModel: string;
  35896. /**
  35897. * @hidden
  35898. * Back Compat
  35899. **/
  35900. onended: () => any;
  35901. /**
  35902. * Observable event when the current playing sound finishes.
  35903. */
  35904. onEndedObservable: Observable<Sound>;
  35905. private _panningModel;
  35906. private _playbackRate;
  35907. private _streaming;
  35908. private _startTime;
  35909. private _startOffset;
  35910. private _position;
  35911. /** @hidden */
  35912. _positionInEmitterSpace: boolean;
  35913. private _localDirection;
  35914. private _volume;
  35915. private _isReadyToPlay;
  35916. private _isDirectional;
  35917. private _readyToPlayCallback;
  35918. private _audioBuffer;
  35919. private _soundSource;
  35920. private _streamingSource;
  35921. private _soundPanner;
  35922. private _soundGain;
  35923. private _inputAudioNode;
  35924. private _outputAudioNode;
  35925. private _coneInnerAngle;
  35926. private _coneOuterAngle;
  35927. private _coneOuterGain;
  35928. private _scene;
  35929. private _connectedTransformNode;
  35930. private _customAttenuationFunction;
  35931. private _registerFunc;
  35932. private _isOutputConnected;
  35933. private _htmlAudioElement;
  35934. private _urlType;
  35935. private _length?;
  35936. private _offset?;
  35937. /** @hidden */
  35938. static _SceneComponentInitialization: (scene: Scene) => void;
  35939. /**
  35940. * Create a sound and attach it to a scene
  35941. * @param name Name of your sound
  35942. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35943. * @param scene defines the scene the sound belongs to
  35944. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35945. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35946. */
  35947. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35948. /**
  35949. * Release the sound and its associated resources
  35950. */
  35951. dispose(): void;
  35952. /**
  35953. * Gets if the sounds is ready to be played or not.
  35954. * @returns true if ready, otherwise false
  35955. */
  35956. isReady(): boolean;
  35957. private _soundLoaded;
  35958. /**
  35959. * Sets the data of the sound from an audiobuffer
  35960. * @param audioBuffer The audioBuffer containing the data
  35961. */
  35962. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35963. /**
  35964. * Updates the current sounds options such as maxdistance, loop...
  35965. * @param options A JSON object containing values named as the object properties
  35966. */
  35967. updateOptions(options: ISoundOptions): void;
  35968. private _createSpatialParameters;
  35969. private _updateSpatialParameters;
  35970. /**
  35971. * Switch the panning model to HRTF:
  35972. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35974. */
  35975. switchPanningModelToHRTF(): void;
  35976. /**
  35977. * Switch the panning model to Equal Power:
  35978. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35980. */
  35981. switchPanningModelToEqualPower(): void;
  35982. private _switchPanningModel;
  35983. /**
  35984. * Connect this sound to a sound track audio node like gain...
  35985. * @param soundTrackAudioNode the sound track audio node to connect to
  35986. */
  35987. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35988. /**
  35989. * Transform this sound into a directional source
  35990. * @param coneInnerAngle Size of the inner cone in degree
  35991. * @param coneOuterAngle Size of the outer cone in degree
  35992. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35993. */
  35994. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35995. /**
  35996. * Gets or sets the inner angle for the directional cone.
  35997. */
  35998. /**
  35999. * Gets or sets the inner angle for the directional cone.
  36000. */
  36001. directionalConeInnerAngle: number;
  36002. /**
  36003. * Gets or sets the outer angle for the directional cone.
  36004. */
  36005. /**
  36006. * Gets or sets the outer angle for the directional cone.
  36007. */
  36008. directionalConeOuterAngle: number;
  36009. /**
  36010. * Sets the position of the emitter if spatial sound is enabled
  36011. * @param newPosition Defines the new posisiton
  36012. */
  36013. setPosition(newPosition: Vector3): void;
  36014. /**
  36015. * Sets the local direction of the emitter if spatial sound is enabled
  36016. * @param newLocalDirection Defines the new local direction
  36017. */
  36018. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36019. private _updateDirection;
  36020. /** @hidden */
  36021. updateDistanceFromListener(): void;
  36022. /**
  36023. * Sets a new custom attenuation function for the sound.
  36024. * @param callback Defines the function used for the attenuation
  36025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36026. */
  36027. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36028. /**
  36029. * Play the sound
  36030. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36031. * @param offset (optional) Start the sound at a specific time in seconds
  36032. * @param length (optional) Sound duration (in seconds)
  36033. */
  36034. play(time?: number, offset?: number, length?: number): void;
  36035. private _onended;
  36036. /**
  36037. * Stop the sound
  36038. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36039. */
  36040. stop(time?: number): void;
  36041. /**
  36042. * Put the sound in pause
  36043. */
  36044. pause(): void;
  36045. /**
  36046. * Sets a dedicated volume for this sounds
  36047. * @param newVolume Define the new volume of the sound
  36048. * @param time Define time for gradual change to new volume
  36049. */
  36050. setVolume(newVolume: number, time?: number): void;
  36051. /**
  36052. * Set the sound play back rate
  36053. * @param newPlaybackRate Define the playback rate the sound should be played at
  36054. */
  36055. setPlaybackRate(newPlaybackRate: number): void;
  36056. /**
  36057. * Gets the volume of the sound.
  36058. * @returns the volume of the sound
  36059. */
  36060. getVolume(): number;
  36061. /**
  36062. * Attach the sound to a dedicated mesh
  36063. * @param transformNode The transform node to connect the sound with
  36064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36065. */
  36066. attachToMesh(transformNode: TransformNode): void;
  36067. /**
  36068. * Detach the sound from the previously attached mesh
  36069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36070. */
  36071. detachFromMesh(): void;
  36072. private _onRegisterAfterWorldMatrixUpdate;
  36073. /**
  36074. * Clone the current sound in the scene.
  36075. * @returns the new sound clone
  36076. */
  36077. clone(): Nullable<Sound>;
  36078. /**
  36079. * Gets the current underlying audio buffer containing the data
  36080. * @returns the audio buffer
  36081. */
  36082. getAudioBuffer(): Nullable<AudioBuffer>;
  36083. /**
  36084. * Serializes the Sound in a JSON representation
  36085. * @returns the JSON representation of the sound
  36086. */
  36087. serialize(): any;
  36088. /**
  36089. * Parse a JSON representation of a sound to innstantiate in a given scene
  36090. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36091. * @param scene Define the scene the new parsed sound should be created in
  36092. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36093. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36094. * @returns the newly parsed sound
  36095. */
  36096. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36097. }
  36098. }
  36099. declare module "babylonjs/Actions/directAudioActions" {
  36100. import { Action } from "babylonjs/Actions/action";
  36101. import { Condition } from "babylonjs/Actions/condition";
  36102. import { Sound } from "babylonjs/Audio/sound";
  36103. /**
  36104. * This defines an action helpful to play a defined sound on a triggered action.
  36105. */
  36106. export class PlaySoundAction extends Action {
  36107. private _sound;
  36108. /**
  36109. * Instantiate the action
  36110. * @param triggerOptions defines the trigger options
  36111. * @param sound defines the sound to play
  36112. * @param condition defines the trigger related conditions
  36113. */
  36114. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36115. /** @hidden */
  36116. _prepare(): void;
  36117. /**
  36118. * Execute the action and play the sound.
  36119. */
  36120. execute(): void;
  36121. /**
  36122. * Serializes the actions and its related information.
  36123. * @param parent defines the object to serialize in
  36124. * @returns the serialized object
  36125. */
  36126. serialize(parent: any): any;
  36127. }
  36128. /**
  36129. * This defines an action helpful to stop a defined sound on a triggered action.
  36130. */
  36131. export class StopSoundAction extends Action {
  36132. private _sound;
  36133. /**
  36134. * Instantiate the action
  36135. * @param triggerOptions defines the trigger options
  36136. * @param sound defines the sound to stop
  36137. * @param condition defines the trigger related conditions
  36138. */
  36139. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36140. /** @hidden */
  36141. _prepare(): void;
  36142. /**
  36143. * Execute the action and stop the sound.
  36144. */
  36145. execute(): void;
  36146. /**
  36147. * Serializes the actions and its related information.
  36148. * @param parent defines the object to serialize in
  36149. * @returns the serialized object
  36150. */
  36151. serialize(parent: any): any;
  36152. }
  36153. }
  36154. declare module "babylonjs/Actions/interpolateValueAction" {
  36155. import { Action } from "babylonjs/Actions/action";
  36156. import { Condition } from "babylonjs/Actions/condition";
  36157. import { Observable } from "babylonjs/Misc/observable";
  36158. /**
  36159. * This defines an action responsible to change the value of a property
  36160. * by interpolating between its current value and the newly set one once triggered.
  36161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36162. */
  36163. export class InterpolateValueAction extends Action {
  36164. /**
  36165. * Defines the path of the property where the value should be interpolated
  36166. */
  36167. propertyPath: string;
  36168. /**
  36169. * Defines the target value at the end of the interpolation.
  36170. */
  36171. value: any;
  36172. /**
  36173. * Defines the time it will take for the property to interpolate to the value.
  36174. */
  36175. duration: number;
  36176. /**
  36177. * Defines if the other scene animations should be stopped when the action has been triggered
  36178. */
  36179. stopOtherAnimations?: boolean;
  36180. /**
  36181. * Defines a callback raised once the interpolation animation has been done.
  36182. */
  36183. onInterpolationDone?: () => void;
  36184. /**
  36185. * Observable triggered once the interpolation animation has been done.
  36186. */
  36187. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36188. private _target;
  36189. private _effectiveTarget;
  36190. private _property;
  36191. /**
  36192. * Instantiate the action
  36193. * @param triggerOptions defines the trigger options
  36194. * @param target defines the object containing the value to interpolate
  36195. * @param propertyPath defines the path to the property in the target object
  36196. * @param value defines the target value at the end of the interpolation
  36197. * @param duration deines the time it will take for the property to interpolate to the value.
  36198. * @param condition defines the trigger related conditions
  36199. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36200. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36201. */
  36202. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36203. /** @hidden */
  36204. _prepare(): void;
  36205. /**
  36206. * Execute the action starts the value interpolation.
  36207. */
  36208. execute(): void;
  36209. /**
  36210. * Serializes the actions and its related information.
  36211. * @param parent defines the object to serialize in
  36212. * @returns the serialized object
  36213. */
  36214. serialize(parent: any): any;
  36215. }
  36216. }
  36217. declare module "babylonjs/Actions/index" {
  36218. export * from "babylonjs/Actions/abstractActionManager";
  36219. export * from "babylonjs/Actions/action";
  36220. export * from "babylonjs/Actions/actionEvent";
  36221. export * from "babylonjs/Actions/actionManager";
  36222. export * from "babylonjs/Actions/condition";
  36223. export * from "babylonjs/Actions/directActions";
  36224. export * from "babylonjs/Actions/directAudioActions";
  36225. export * from "babylonjs/Actions/interpolateValueAction";
  36226. }
  36227. declare module "babylonjs/Animations/index" {
  36228. export * from "babylonjs/Animations/animatable";
  36229. export * from "babylonjs/Animations/animation";
  36230. export * from "babylonjs/Animations/animationGroup";
  36231. export * from "babylonjs/Animations/animationPropertiesOverride";
  36232. export * from "babylonjs/Animations/easing";
  36233. export * from "babylonjs/Animations/runtimeAnimation";
  36234. export * from "babylonjs/Animations/animationEvent";
  36235. export * from "babylonjs/Animations/animationGroup";
  36236. export * from "babylonjs/Animations/animationKey";
  36237. export * from "babylonjs/Animations/animationRange";
  36238. export * from "babylonjs/Animations/animatable.interface";
  36239. }
  36240. declare module "babylonjs/Audio/soundTrack" {
  36241. import { Sound } from "babylonjs/Audio/sound";
  36242. import { Analyser } from "babylonjs/Audio/analyser";
  36243. import { Scene } from "babylonjs/scene";
  36244. /**
  36245. * Options allowed during the creation of a sound track.
  36246. */
  36247. export interface ISoundTrackOptions {
  36248. /**
  36249. * The volume the sound track should take during creation
  36250. */
  36251. volume?: number;
  36252. /**
  36253. * Define if the sound track is the main sound track of the scene
  36254. */
  36255. mainTrack?: boolean;
  36256. }
  36257. /**
  36258. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36259. * It will be also used in a future release to apply effects on a specific track.
  36260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36261. */
  36262. export class SoundTrack {
  36263. /**
  36264. * The unique identifier of the sound track in the scene.
  36265. */
  36266. id: number;
  36267. /**
  36268. * The list of sounds included in the sound track.
  36269. */
  36270. soundCollection: Array<Sound>;
  36271. private _outputAudioNode;
  36272. private _scene;
  36273. private _isMainTrack;
  36274. private _connectedAnalyser;
  36275. private _options;
  36276. private _isInitialized;
  36277. /**
  36278. * Creates a new sound track.
  36279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36280. * @param scene Define the scene the sound track belongs to
  36281. * @param options
  36282. */
  36283. constructor(scene: Scene, options?: ISoundTrackOptions);
  36284. private _initializeSoundTrackAudioGraph;
  36285. /**
  36286. * Release the sound track and its associated resources
  36287. */
  36288. dispose(): void;
  36289. /**
  36290. * Adds a sound to this sound track
  36291. * @param sound define the cound to add
  36292. * @ignoreNaming
  36293. */
  36294. AddSound(sound: Sound): void;
  36295. /**
  36296. * Removes a sound to this sound track
  36297. * @param sound define the cound to remove
  36298. * @ignoreNaming
  36299. */
  36300. RemoveSound(sound: Sound): void;
  36301. /**
  36302. * Set a global volume for the full sound track.
  36303. * @param newVolume Define the new volume of the sound track
  36304. */
  36305. setVolume(newVolume: number): void;
  36306. /**
  36307. * Switch the panning model to HRTF:
  36308. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36310. */
  36311. switchPanningModelToHRTF(): void;
  36312. /**
  36313. * Switch the panning model to Equal Power:
  36314. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36316. */
  36317. switchPanningModelToEqualPower(): void;
  36318. /**
  36319. * Connect the sound track to an audio analyser allowing some amazing
  36320. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36322. * @param analyser The analyser to connect to the engine
  36323. */
  36324. connectToAnalyser(analyser: Analyser): void;
  36325. }
  36326. }
  36327. declare module "babylonjs/Audio/audioSceneComponent" {
  36328. import { Sound } from "babylonjs/Audio/sound";
  36329. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36330. import { Nullable } from "babylonjs/types";
  36331. import { Vector3 } from "babylonjs/Maths/math.vector";
  36332. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36333. import { Scene } from "babylonjs/scene";
  36334. import { AbstractScene } from "babylonjs/abstractScene";
  36335. import "babylonjs/Audio/audioEngine";
  36336. module "babylonjs/abstractScene" {
  36337. interface AbstractScene {
  36338. /**
  36339. * The list of sounds used in the scene.
  36340. */
  36341. sounds: Nullable<Array<Sound>>;
  36342. }
  36343. }
  36344. module "babylonjs/scene" {
  36345. interface Scene {
  36346. /**
  36347. * @hidden
  36348. * Backing field
  36349. */
  36350. _mainSoundTrack: SoundTrack;
  36351. /**
  36352. * The main sound track played by the scene.
  36353. * It cotains your primary collection of sounds.
  36354. */
  36355. mainSoundTrack: SoundTrack;
  36356. /**
  36357. * The list of sound tracks added to the scene
  36358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36359. */
  36360. soundTracks: Nullable<Array<SoundTrack>>;
  36361. /**
  36362. * Gets a sound using a given name
  36363. * @param name defines the name to search for
  36364. * @return the found sound or null if not found at all.
  36365. */
  36366. getSoundByName(name: string): Nullable<Sound>;
  36367. /**
  36368. * Gets or sets if audio support is enabled
  36369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36370. */
  36371. audioEnabled: boolean;
  36372. /**
  36373. * Gets or sets if audio will be output to headphones
  36374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36375. */
  36376. headphone: boolean;
  36377. /**
  36378. * Gets or sets custom audio listener position provider
  36379. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36380. */
  36381. audioListenerPositionProvider: Nullable<() => Vector3>;
  36382. }
  36383. }
  36384. /**
  36385. * Defines the sound scene component responsible to manage any sounds
  36386. * in a given scene.
  36387. */
  36388. export class AudioSceneComponent implements ISceneSerializableComponent {
  36389. /**
  36390. * The component name helpfull to identify the component in the list of scene components.
  36391. */
  36392. readonly name: string;
  36393. /**
  36394. * The scene the component belongs to.
  36395. */
  36396. scene: Scene;
  36397. private _audioEnabled;
  36398. /**
  36399. * Gets whether audio is enabled or not.
  36400. * Please use related enable/disable method to switch state.
  36401. */
  36402. readonly audioEnabled: boolean;
  36403. private _headphone;
  36404. /**
  36405. * Gets whether audio is outputing to headphone or not.
  36406. * Please use the according Switch methods to change output.
  36407. */
  36408. readonly headphone: boolean;
  36409. private _audioListenerPositionProvider;
  36410. /**
  36411. * Gets the current audio listener position provider
  36412. */
  36413. /**
  36414. * Sets a custom listener position for all sounds in the scene
  36415. * By default, this is the position of the first active camera
  36416. */
  36417. audioListenerPositionProvider: Nullable<() => Vector3>;
  36418. /**
  36419. * Creates a new instance of the component for the given scene
  36420. * @param scene Defines the scene to register the component in
  36421. */
  36422. constructor(scene: Scene);
  36423. /**
  36424. * Registers the component in a given scene
  36425. */
  36426. register(): void;
  36427. /**
  36428. * Rebuilds the elements related to this component in case of
  36429. * context lost for instance.
  36430. */
  36431. rebuild(): void;
  36432. /**
  36433. * Serializes the component data to the specified json object
  36434. * @param serializationObject The object to serialize to
  36435. */
  36436. serialize(serializationObject: any): void;
  36437. /**
  36438. * Adds all the elements from the container to the scene
  36439. * @param container the container holding the elements
  36440. */
  36441. addFromContainer(container: AbstractScene): void;
  36442. /**
  36443. * Removes all the elements in the container from the scene
  36444. * @param container contains the elements to remove
  36445. * @param dispose if the removed element should be disposed (default: false)
  36446. */
  36447. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36448. /**
  36449. * Disposes the component and the associated ressources.
  36450. */
  36451. dispose(): void;
  36452. /**
  36453. * Disables audio in the associated scene.
  36454. */
  36455. disableAudio(): void;
  36456. /**
  36457. * Enables audio in the associated scene.
  36458. */
  36459. enableAudio(): void;
  36460. /**
  36461. * Switch audio to headphone output.
  36462. */
  36463. switchAudioModeForHeadphones(): void;
  36464. /**
  36465. * Switch audio to normal speakers.
  36466. */
  36467. switchAudioModeForNormalSpeakers(): void;
  36468. private _afterRender;
  36469. }
  36470. }
  36471. declare module "babylonjs/Audio/weightedsound" {
  36472. import { Sound } from "babylonjs/Audio/sound";
  36473. /**
  36474. * Wraps one or more Sound objects and selects one with random weight for playback.
  36475. */
  36476. export class WeightedSound {
  36477. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36478. loop: boolean;
  36479. private _coneInnerAngle;
  36480. private _coneOuterAngle;
  36481. private _volume;
  36482. /** A Sound is currently playing. */
  36483. isPlaying: boolean;
  36484. /** A Sound is currently paused. */
  36485. isPaused: boolean;
  36486. private _sounds;
  36487. private _weights;
  36488. private _currentIndex?;
  36489. /**
  36490. * Creates a new WeightedSound from the list of sounds given.
  36491. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36492. * @param sounds Array of Sounds that will be selected from.
  36493. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36494. */
  36495. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36496. /**
  36497. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36498. */
  36499. /**
  36500. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36501. */
  36502. directionalConeInnerAngle: number;
  36503. /**
  36504. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36505. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36506. */
  36507. /**
  36508. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36509. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36510. */
  36511. directionalConeOuterAngle: number;
  36512. /**
  36513. * Playback volume.
  36514. */
  36515. /**
  36516. * Playback volume.
  36517. */
  36518. volume: number;
  36519. private _onended;
  36520. /**
  36521. * Suspend playback
  36522. */
  36523. pause(): void;
  36524. /**
  36525. * Stop playback
  36526. */
  36527. stop(): void;
  36528. /**
  36529. * Start playback.
  36530. * @param startOffset Position the clip head at a specific time in seconds.
  36531. */
  36532. play(startOffset?: number): void;
  36533. }
  36534. }
  36535. declare module "babylonjs/Audio/index" {
  36536. export * from "babylonjs/Audio/analyser";
  36537. export * from "babylonjs/Audio/audioEngine";
  36538. export * from "babylonjs/Audio/audioSceneComponent";
  36539. export * from "babylonjs/Audio/sound";
  36540. export * from "babylonjs/Audio/soundTrack";
  36541. export * from "babylonjs/Audio/weightedsound";
  36542. }
  36543. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36544. import { Behavior } from "babylonjs/Behaviors/behavior";
  36545. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36546. import { BackEase } from "babylonjs/Animations/easing";
  36547. /**
  36548. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36549. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36550. */
  36551. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36552. /**
  36553. * Gets the name of the behavior.
  36554. */
  36555. readonly name: string;
  36556. /**
  36557. * The easing function used by animations
  36558. */
  36559. static EasingFunction: BackEase;
  36560. /**
  36561. * The easing mode used by animations
  36562. */
  36563. static EasingMode: number;
  36564. /**
  36565. * The duration of the animation, in milliseconds
  36566. */
  36567. transitionDuration: number;
  36568. /**
  36569. * Length of the distance animated by the transition when lower radius is reached
  36570. */
  36571. lowerRadiusTransitionRange: number;
  36572. /**
  36573. * Length of the distance animated by the transition when upper radius is reached
  36574. */
  36575. upperRadiusTransitionRange: number;
  36576. private _autoTransitionRange;
  36577. /**
  36578. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36579. */
  36580. /**
  36581. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36582. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36583. */
  36584. autoTransitionRange: boolean;
  36585. private _attachedCamera;
  36586. private _onAfterCheckInputsObserver;
  36587. private _onMeshTargetChangedObserver;
  36588. /**
  36589. * Initializes the behavior.
  36590. */
  36591. init(): void;
  36592. /**
  36593. * Attaches the behavior to its arc rotate camera.
  36594. * @param camera Defines the camera to attach the behavior to
  36595. */
  36596. attach(camera: ArcRotateCamera): void;
  36597. /**
  36598. * Detaches the behavior from its current arc rotate camera.
  36599. */
  36600. detach(): void;
  36601. private _radiusIsAnimating;
  36602. private _radiusBounceTransition;
  36603. private _animatables;
  36604. private _cachedWheelPrecision;
  36605. /**
  36606. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36607. * @param radiusLimit The limit to check against.
  36608. * @return Bool to indicate if at limit.
  36609. */
  36610. private _isRadiusAtLimit;
  36611. /**
  36612. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36613. * @param radiusDelta The delta by which to animate to. Can be negative.
  36614. */
  36615. private _applyBoundRadiusAnimation;
  36616. /**
  36617. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36618. */
  36619. protected _clearAnimationLocks(): void;
  36620. /**
  36621. * Stops and removes all animations that have been applied to the camera
  36622. */
  36623. stopAllAnimations(): void;
  36624. }
  36625. }
  36626. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36627. import { Behavior } from "babylonjs/Behaviors/behavior";
  36628. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36629. import { ExponentialEase } from "babylonjs/Animations/easing";
  36630. import { Nullable } from "babylonjs/types";
  36631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36632. import { Vector3 } from "babylonjs/Maths/math.vector";
  36633. /**
  36634. * 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.
  36635. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36636. */
  36637. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36638. /**
  36639. * Gets the name of the behavior.
  36640. */
  36641. readonly name: string;
  36642. private _mode;
  36643. private _radiusScale;
  36644. private _positionScale;
  36645. private _defaultElevation;
  36646. private _elevationReturnTime;
  36647. private _elevationReturnWaitTime;
  36648. private _zoomStopsAnimation;
  36649. private _framingTime;
  36650. /**
  36651. * The easing function used by animations
  36652. */
  36653. static EasingFunction: ExponentialEase;
  36654. /**
  36655. * The easing mode used by animations
  36656. */
  36657. static EasingMode: number;
  36658. /**
  36659. * Sets the current mode used by the behavior
  36660. */
  36661. /**
  36662. * Gets current mode used by the behavior.
  36663. */
  36664. mode: number;
  36665. /**
  36666. * Sets the scale applied to the radius (1 by default)
  36667. */
  36668. /**
  36669. * Gets the scale applied to the radius
  36670. */
  36671. radiusScale: number;
  36672. /**
  36673. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36674. */
  36675. /**
  36676. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36677. */
  36678. positionScale: number;
  36679. /**
  36680. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36681. * behaviour is triggered, in radians.
  36682. */
  36683. /**
  36684. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36685. * behaviour is triggered, in radians.
  36686. */
  36687. defaultElevation: number;
  36688. /**
  36689. * Sets the time (in milliseconds) taken to return to the default beta position.
  36690. * Negative value indicates camera should not return to default.
  36691. */
  36692. /**
  36693. * Gets the time (in milliseconds) taken to return to the default beta position.
  36694. * Negative value indicates camera should not return to default.
  36695. */
  36696. elevationReturnTime: number;
  36697. /**
  36698. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36699. */
  36700. /**
  36701. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36702. */
  36703. elevationReturnWaitTime: number;
  36704. /**
  36705. * Sets the flag that indicates if user zooming should stop animation.
  36706. */
  36707. /**
  36708. * Gets the flag that indicates if user zooming should stop animation.
  36709. */
  36710. zoomStopsAnimation: boolean;
  36711. /**
  36712. * Sets the transition time when framing the mesh, in milliseconds
  36713. */
  36714. /**
  36715. * Gets the transition time when framing the mesh, in milliseconds
  36716. */
  36717. framingTime: number;
  36718. /**
  36719. * Define if the behavior should automatically change the configured
  36720. * camera limits and sensibilities.
  36721. */
  36722. autoCorrectCameraLimitsAndSensibility: boolean;
  36723. private _onPrePointerObservableObserver;
  36724. private _onAfterCheckInputsObserver;
  36725. private _onMeshTargetChangedObserver;
  36726. private _attachedCamera;
  36727. private _isPointerDown;
  36728. private _lastInteractionTime;
  36729. /**
  36730. * Initializes the behavior.
  36731. */
  36732. init(): void;
  36733. /**
  36734. * Attaches the behavior to its arc rotate camera.
  36735. * @param camera Defines the camera to attach the behavior to
  36736. */
  36737. attach(camera: ArcRotateCamera): void;
  36738. /**
  36739. * Detaches the behavior from its current arc rotate camera.
  36740. */
  36741. detach(): void;
  36742. private _animatables;
  36743. private _betaIsAnimating;
  36744. private _betaTransition;
  36745. private _radiusTransition;
  36746. private _vectorTransition;
  36747. /**
  36748. * Targets the given mesh and updates zoom level accordingly.
  36749. * @param mesh The mesh to target.
  36750. * @param radius Optional. If a cached radius position already exists, overrides default.
  36751. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36752. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36753. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36754. */
  36755. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36756. /**
  36757. * Targets the given mesh with its children and updates zoom level accordingly.
  36758. * @param mesh The mesh to target.
  36759. * @param radius Optional. If a cached radius position already exists, overrides default.
  36760. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36761. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36762. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36763. */
  36764. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36765. /**
  36766. * Targets the given meshes with their children and updates zoom level accordingly.
  36767. * @param meshes The mesh to target.
  36768. * @param radius Optional. If a cached radius position already exists, overrides default.
  36769. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36770. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36771. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36772. */
  36773. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36774. /**
  36775. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36776. * @param minimumWorld Determines the smaller position of the bounding box extend
  36777. * @param maximumWorld Determines the bigger position of the bounding box extend
  36778. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36779. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36780. */
  36781. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36782. /**
  36783. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36784. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36785. * frustum width.
  36786. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36787. * to fully enclose the mesh in the viewing frustum.
  36788. */
  36789. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36790. /**
  36791. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36792. * is automatically returned to its default position (expected to be above ground plane).
  36793. */
  36794. private _maintainCameraAboveGround;
  36795. /**
  36796. * Returns the frustum slope based on the canvas ratio and camera FOV
  36797. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36798. */
  36799. private _getFrustumSlope;
  36800. /**
  36801. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36802. */
  36803. private _clearAnimationLocks;
  36804. /**
  36805. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36806. */
  36807. private _applyUserInteraction;
  36808. /**
  36809. * Stops and removes all animations that have been applied to the camera
  36810. */
  36811. stopAllAnimations(): void;
  36812. /**
  36813. * Gets a value indicating if the user is moving the camera
  36814. */
  36815. readonly isUserIsMoving: boolean;
  36816. /**
  36817. * The camera can move all the way towards the mesh.
  36818. */
  36819. static IgnoreBoundsSizeMode: number;
  36820. /**
  36821. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36822. */
  36823. static FitFrustumSidesMode: number;
  36824. }
  36825. }
  36826. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36827. import { Nullable } from "babylonjs/types";
  36828. import { Camera } from "babylonjs/Cameras/camera";
  36829. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36830. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36831. /**
  36832. * Base class for Camera Pointer Inputs.
  36833. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36834. * for example usage.
  36835. */
  36836. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36837. /**
  36838. * Defines the camera the input is attached to.
  36839. */
  36840. abstract camera: Camera;
  36841. /**
  36842. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36843. */
  36844. protected _altKey: boolean;
  36845. protected _ctrlKey: boolean;
  36846. protected _metaKey: boolean;
  36847. protected _shiftKey: boolean;
  36848. /**
  36849. * Which mouse buttons were pressed at time of last mouse event.
  36850. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36851. */
  36852. protected _buttonsPressed: number;
  36853. /**
  36854. * Defines the buttons associated with the input to handle camera move.
  36855. */
  36856. buttons: number[];
  36857. /**
  36858. * Attach the input controls to a specific dom element to get the input from.
  36859. * @param element Defines the element the controls should be listened from
  36860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36861. */
  36862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36863. /**
  36864. * Detach the current controls from the specified dom element.
  36865. * @param element Defines the element to stop listening the inputs from
  36866. */
  36867. detachControl(element: Nullable<HTMLElement>): void;
  36868. /**
  36869. * Gets the class name of the current input.
  36870. * @returns the class name
  36871. */
  36872. getClassName(): string;
  36873. /**
  36874. * Get the friendly name associated with the input class.
  36875. * @returns the input friendly name
  36876. */
  36877. getSimpleName(): string;
  36878. /**
  36879. * Called on pointer POINTERDOUBLETAP event.
  36880. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36881. */
  36882. protected onDoubleTap(type: string): void;
  36883. /**
  36884. * Called on pointer POINTERMOVE event if only a single touch is active.
  36885. * Override this method to provide functionality.
  36886. */
  36887. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36888. /**
  36889. * Called on pointer POINTERMOVE event if multiple touches are active.
  36890. * Override this method to provide functionality.
  36891. */
  36892. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36893. /**
  36894. * Called on JS contextmenu event.
  36895. * Override this method to provide functionality.
  36896. */
  36897. protected onContextMenu(evt: PointerEvent): void;
  36898. /**
  36899. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36900. * press.
  36901. * Override this method to provide functionality.
  36902. */
  36903. protected onButtonDown(evt: PointerEvent): void;
  36904. /**
  36905. * Called each time a new POINTERUP event occurs. Ie, for each button
  36906. * release.
  36907. * Override this method to provide functionality.
  36908. */
  36909. protected onButtonUp(evt: PointerEvent): void;
  36910. /**
  36911. * Called when window becomes inactive.
  36912. * Override this method to provide functionality.
  36913. */
  36914. protected onLostFocus(): void;
  36915. private _pointerInput;
  36916. private _observer;
  36917. private _onLostFocus;
  36918. private pointA;
  36919. private pointB;
  36920. }
  36921. }
  36922. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36923. import { Nullable } from "babylonjs/types";
  36924. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36925. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36926. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36927. /**
  36928. * Manage the pointers inputs to control an arc rotate camera.
  36929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36930. */
  36931. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36932. /**
  36933. * Defines the camera the input is attached to.
  36934. */
  36935. camera: ArcRotateCamera;
  36936. /**
  36937. * Gets the class name of the current input.
  36938. * @returns the class name
  36939. */
  36940. getClassName(): string;
  36941. /**
  36942. * Defines the buttons associated with the input to handle camera move.
  36943. */
  36944. buttons: number[];
  36945. /**
  36946. * Defines the pointer angular sensibility along the X axis or how fast is
  36947. * the camera rotating.
  36948. */
  36949. angularSensibilityX: number;
  36950. /**
  36951. * Defines the pointer angular sensibility along the Y axis or how fast is
  36952. * the camera rotating.
  36953. */
  36954. angularSensibilityY: number;
  36955. /**
  36956. * Defines the pointer pinch precision or how fast is the camera zooming.
  36957. */
  36958. pinchPrecision: number;
  36959. /**
  36960. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36961. * from 0.
  36962. * It defines the percentage of current camera.radius to use as delta when
  36963. * pinch zoom is used.
  36964. */
  36965. pinchDeltaPercentage: number;
  36966. /**
  36967. * Defines the pointer panning sensibility or how fast is the camera moving.
  36968. */
  36969. panningSensibility: number;
  36970. /**
  36971. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36972. */
  36973. multiTouchPanning: boolean;
  36974. /**
  36975. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36976. * zoom (pinch) through multitouch.
  36977. */
  36978. multiTouchPanAndZoom: boolean;
  36979. /**
  36980. * Revers pinch action direction.
  36981. */
  36982. pinchInwards: boolean;
  36983. private _isPanClick;
  36984. private _twoFingerActivityCount;
  36985. private _isPinching;
  36986. /**
  36987. * Called on pointer POINTERMOVE event if only a single touch is active.
  36988. */
  36989. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36990. /**
  36991. * Called on pointer POINTERDOUBLETAP event.
  36992. */
  36993. protected onDoubleTap(type: string): void;
  36994. /**
  36995. * Called on pointer POINTERMOVE event if multiple touches are active.
  36996. */
  36997. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36998. /**
  36999. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37000. * press.
  37001. */
  37002. protected onButtonDown(evt: PointerEvent): void;
  37003. /**
  37004. * Called each time a new POINTERUP event occurs. Ie, for each button
  37005. * release.
  37006. */
  37007. protected onButtonUp(evt: PointerEvent): void;
  37008. /**
  37009. * Called when window becomes inactive.
  37010. */
  37011. protected onLostFocus(): void;
  37012. }
  37013. }
  37014. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37015. import { Nullable } from "babylonjs/types";
  37016. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37017. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37018. /**
  37019. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37021. */
  37022. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37023. /**
  37024. * Defines the camera the input is attached to.
  37025. */
  37026. camera: ArcRotateCamera;
  37027. /**
  37028. * Defines the list of key codes associated with the up action (increase alpha)
  37029. */
  37030. keysUp: number[];
  37031. /**
  37032. * Defines the list of key codes associated with the down action (decrease alpha)
  37033. */
  37034. keysDown: number[];
  37035. /**
  37036. * Defines the list of key codes associated with the left action (increase beta)
  37037. */
  37038. keysLeft: number[];
  37039. /**
  37040. * Defines the list of key codes associated with the right action (decrease beta)
  37041. */
  37042. keysRight: number[];
  37043. /**
  37044. * Defines the list of key codes associated with the reset action.
  37045. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37046. */
  37047. keysReset: number[];
  37048. /**
  37049. * Defines the panning sensibility of the inputs.
  37050. * (How fast is the camera paning)
  37051. */
  37052. panningSensibility: number;
  37053. /**
  37054. * Defines the zooming sensibility of the inputs.
  37055. * (How fast is the camera zooming)
  37056. */
  37057. zoomingSensibility: number;
  37058. /**
  37059. * Defines wether maintaining the alt key down switch the movement mode from
  37060. * orientation to zoom.
  37061. */
  37062. useAltToZoom: boolean;
  37063. /**
  37064. * Rotation speed of the camera
  37065. */
  37066. angularSpeed: number;
  37067. private _keys;
  37068. private _ctrlPressed;
  37069. private _altPressed;
  37070. private _onCanvasBlurObserver;
  37071. private _onKeyboardObserver;
  37072. private _engine;
  37073. private _scene;
  37074. /**
  37075. * Attach the input controls to a specific dom element to get the input from.
  37076. * @param element Defines the element the controls should be listened from
  37077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37078. */
  37079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37080. /**
  37081. * Detach the current controls from the specified dom element.
  37082. * @param element Defines the element to stop listening the inputs from
  37083. */
  37084. detachControl(element: Nullable<HTMLElement>): void;
  37085. /**
  37086. * Update the current camera state depending on the inputs that have been used this frame.
  37087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37088. */
  37089. checkInputs(): void;
  37090. /**
  37091. * Gets the class name of the current intput.
  37092. * @returns the class name
  37093. */
  37094. getClassName(): string;
  37095. /**
  37096. * Get the friendly name associated with the input class.
  37097. * @returns the input friendly name
  37098. */
  37099. getSimpleName(): string;
  37100. }
  37101. }
  37102. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37103. import { Nullable } from "babylonjs/types";
  37104. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37105. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37106. /**
  37107. * Manage the mouse wheel inputs to control an arc rotate camera.
  37108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37109. */
  37110. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37111. /**
  37112. * Defines the camera the input is attached to.
  37113. */
  37114. camera: ArcRotateCamera;
  37115. /**
  37116. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37117. */
  37118. wheelPrecision: number;
  37119. /**
  37120. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37121. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37122. */
  37123. wheelDeltaPercentage: number;
  37124. private _wheel;
  37125. private _observer;
  37126. private computeDeltaFromMouseWheelLegacyEvent;
  37127. /**
  37128. * Attach the input controls to a specific dom element to get the input from.
  37129. * @param element Defines the element the controls should be listened from
  37130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37131. */
  37132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37133. /**
  37134. * Detach the current controls from the specified dom element.
  37135. * @param element Defines the element to stop listening the inputs from
  37136. */
  37137. detachControl(element: Nullable<HTMLElement>): void;
  37138. /**
  37139. * Gets the class name of the current intput.
  37140. * @returns the class name
  37141. */
  37142. getClassName(): string;
  37143. /**
  37144. * Get the friendly name associated with the input class.
  37145. * @returns the input friendly name
  37146. */
  37147. getSimpleName(): string;
  37148. }
  37149. }
  37150. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37151. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37152. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37153. /**
  37154. * Default Inputs manager for the ArcRotateCamera.
  37155. * It groups all the default supported inputs for ease of use.
  37156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37157. */
  37158. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37159. /**
  37160. * Instantiates a new ArcRotateCameraInputsManager.
  37161. * @param camera Defines the camera the inputs belong to
  37162. */
  37163. constructor(camera: ArcRotateCamera);
  37164. /**
  37165. * Add mouse wheel input support to the input manager.
  37166. * @returns the current input manager
  37167. */
  37168. addMouseWheel(): ArcRotateCameraInputsManager;
  37169. /**
  37170. * Add pointers input support to the input manager.
  37171. * @returns the current input manager
  37172. */
  37173. addPointers(): ArcRotateCameraInputsManager;
  37174. /**
  37175. * Add keyboard input support to the input manager.
  37176. * @returns the current input manager
  37177. */
  37178. addKeyboard(): ArcRotateCameraInputsManager;
  37179. }
  37180. }
  37181. declare module "babylonjs/Cameras/arcRotateCamera" {
  37182. import { Observable } from "babylonjs/Misc/observable";
  37183. import { Nullable } from "babylonjs/types";
  37184. import { Scene } from "babylonjs/scene";
  37185. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37187. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37188. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37189. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37190. import { Camera } from "babylonjs/Cameras/camera";
  37191. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37192. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37193. import { Collider } from "babylonjs/Collisions/collider";
  37194. /**
  37195. * This represents an orbital type of camera.
  37196. *
  37197. * 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.
  37198. * 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.
  37199. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37200. */
  37201. export class ArcRotateCamera extends TargetCamera {
  37202. /**
  37203. * Defines the rotation angle of the camera along the longitudinal axis.
  37204. */
  37205. alpha: number;
  37206. /**
  37207. * Defines the rotation angle of the camera along the latitudinal axis.
  37208. */
  37209. beta: number;
  37210. /**
  37211. * Defines the radius of the camera from it s target point.
  37212. */
  37213. radius: number;
  37214. protected _target: Vector3;
  37215. protected _targetHost: Nullable<AbstractMesh>;
  37216. /**
  37217. * Defines the target point of the camera.
  37218. * The camera looks towards it form the radius distance.
  37219. */
  37220. target: Vector3;
  37221. /**
  37222. * Define the current local position of the camera in the scene
  37223. */
  37224. position: Vector3;
  37225. protected _upVector: Vector3;
  37226. protected _upToYMatrix: Matrix;
  37227. protected _YToUpMatrix: Matrix;
  37228. /**
  37229. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37230. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37231. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37232. */
  37233. upVector: Vector3;
  37234. /**
  37235. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37236. */
  37237. setMatUp(): void;
  37238. /**
  37239. * Current inertia value on the longitudinal axis.
  37240. * The bigger this number the longer it will take for the camera to stop.
  37241. */
  37242. inertialAlphaOffset: number;
  37243. /**
  37244. * Current inertia value on the latitudinal axis.
  37245. * The bigger this number the longer it will take for the camera to stop.
  37246. */
  37247. inertialBetaOffset: number;
  37248. /**
  37249. * Current inertia value on the radius axis.
  37250. * The bigger this number the longer it will take for the camera to stop.
  37251. */
  37252. inertialRadiusOffset: number;
  37253. /**
  37254. * Minimum allowed angle on the longitudinal axis.
  37255. * This can help limiting how the Camera is able to move in the scene.
  37256. */
  37257. lowerAlphaLimit: Nullable<number>;
  37258. /**
  37259. * Maximum allowed angle on the longitudinal axis.
  37260. * This can help limiting how the Camera is able to move in the scene.
  37261. */
  37262. upperAlphaLimit: Nullable<number>;
  37263. /**
  37264. * Minimum allowed angle on the latitudinal axis.
  37265. * This can help limiting how the Camera is able to move in the scene.
  37266. */
  37267. lowerBetaLimit: number;
  37268. /**
  37269. * Maximum allowed angle on the latitudinal axis.
  37270. * This can help limiting how the Camera is able to move in the scene.
  37271. */
  37272. upperBetaLimit: number;
  37273. /**
  37274. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37275. * This can help limiting how the Camera is able to move in the scene.
  37276. */
  37277. lowerRadiusLimit: Nullable<number>;
  37278. /**
  37279. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37280. * This can help limiting how the Camera is able to move in the scene.
  37281. */
  37282. upperRadiusLimit: Nullable<number>;
  37283. /**
  37284. * Defines the current inertia value used during panning of the camera along the X axis.
  37285. */
  37286. inertialPanningX: number;
  37287. /**
  37288. * Defines the current inertia value used during panning of the camera along the Y axis.
  37289. */
  37290. inertialPanningY: number;
  37291. /**
  37292. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37293. * Basically if your fingers moves away from more than this distance you will be considered
  37294. * in pinch mode.
  37295. */
  37296. pinchToPanMaxDistance: number;
  37297. /**
  37298. * Defines the maximum distance the camera can pan.
  37299. * This could help keeping the cammera always in your scene.
  37300. */
  37301. panningDistanceLimit: Nullable<number>;
  37302. /**
  37303. * Defines the target of the camera before paning.
  37304. */
  37305. panningOriginTarget: Vector3;
  37306. /**
  37307. * Defines the value of the inertia used during panning.
  37308. * 0 would mean stop inertia and one would mean no decelleration at all.
  37309. */
  37310. panningInertia: number;
  37311. /**
  37312. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37313. */
  37314. angularSensibilityX: number;
  37315. /**
  37316. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37317. */
  37318. angularSensibilityY: number;
  37319. /**
  37320. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37321. */
  37322. pinchPrecision: number;
  37323. /**
  37324. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37325. * It will be used instead of pinchDeltaPrecision if different from 0.
  37326. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37327. */
  37328. pinchDeltaPercentage: number;
  37329. /**
  37330. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37331. */
  37332. panningSensibility: number;
  37333. /**
  37334. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37335. */
  37336. keysUp: number[];
  37337. /**
  37338. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37339. */
  37340. keysDown: number[];
  37341. /**
  37342. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37343. */
  37344. keysLeft: number[];
  37345. /**
  37346. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37347. */
  37348. keysRight: number[];
  37349. /**
  37350. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37351. */
  37352. wheelPrecision: number;
  37353. /**
  37354. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37355. * It will be used instead of pinchDeltaPrecision if different from 0.
  37356. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37357. */
  37358. wheelDeltaPercentage: number;
  37359. /**
  37360. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37361. */
  37362. zoomOnFactor: number;
  37363. /**
  37364. * Defines a screen offset for the camera position.
  37365. */
  37366. targetScreenOffset: Vector2;
  37367. /**
  37368. * Allows the camera to be completely reversed.
  37369. * If false the camera can not arrive upside down.
  37370. */
  37371. allowUpsideDown: boolean;
  37372. /**
  37373. * Define if double tap/click is used to restore the previously saved state of the camera.
  37374. */
  37375. useInputToRestoreState: boolean;
  37376. /** @hidden */
  37377. _viewMatrix: Matrix;
  37378. /** @hidden */
  37379. _useCtrlForPanning: boolean;
  37380. /** @hidden */
  37381. _panningMouseButton: number;
  37382. /**
  37383. * Defines the input associated to the camera.
  37384. */
  37385. inputs: ArcRotateCameraInputsManager;
  37386. /** @hidden */
  37387. _reset: () => void;
  37388. /**
  37389. * Defines the allowed panning axis.
  37390. */
  37391. panningAxis: Vector3;
  37392. protected _localDirection: Vector3;
  37393. protected _transformedDirection: Vector3;
  37394. private _bouncingBehavior;
  37395. /**
  37396. * Gets the bouncing behavior of the camera if it has been enabled.
  37397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37398. */
  37399. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37400. /**
  37401. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37403. */
  37404. useBouncingBehavior: boolean;
  37405. private _framingBehavior;
  37406. /**
  37407. * Gets the framing behavior of the camera if it has been enabled.
  37408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37409. */
  37410. readonly framingBehavior: Nullable<FramingBehavior>;
  37411. /**
  37412. * Defines if the framing behavior of the camera is enabled on the camera.
  37413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37414. */
  37415. useFramingBehavior: boolean;
  37416. private _autoRotationBehavior;
  37417. /**
  37418. * Gets the auto rotation behavior of the camera if it has been enabled.
  37419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37420. */
  37421. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37422. /**
  37423. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37424. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37425. */
  37426. useAutoRotationBehavior: boolean;
  37427. /**
  37428. * Observable triggered when the mesh target has been changed on the camera.
  37429. */
  37430. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37431. /**
  37432. * Event raised when the camera is colliding with a mesh.
  37433. */
  37434. onCollide: (collidedMesh: AbstractMesh) => void;
  37435. /**
  37436. * Defines whether the camera should check collision with the objects oh the scene.
  37437. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37438. */
  37439. checkCollisions: boolean;
  37440. /**
  37441. * Defines the collision radius of the camera.
  37442. * This simulates a sphere around the camera.
  37443. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37444. */
  37445. collisionRadius: Vector3;
  37446. protected _collider: Collider;
  37447. protected _previousPosition: Vector3;
  37448. protected _collisionVelocity: Vector3;
  37449. protected _newPosition: Vector3;
  37450. protected _previousAlpha: number;
  37451. protected _previousBeta: number;
  37452. protected _previousRadius: number;
  37453. protected _collisionTriggered: boolean;
  37454. protected _targetBoundingCenter: Nullable<Vector3>;
  37455. private _computationVector;
  37456. /**
  37457. * Instantiates a new ArcRotateCamera in a given scene
  37458. * @param name Defines the name of the camera
  37459. * @param alpha Defines the camera rotation along the logitudinal axis
  37460. * @param beta Defines the camera rotation along the latitudinal axis
  37461. * @param radius Defines the camera distance from its target
  37462. * @param target Defines the camera target
  37463. * @param scene Defines the scene the camera belongs to
  37464. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37465. */
  37466. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37467. /** @hidden */
  37468. _initCache(): void;
  37469. /** @hidden */
  37470. _updateCache(ignoreParentClass?: boolean): void;
  37471. protected _getTargetPosition(): Vector3;
  37472. private _storedAlpha;
  37473. private _storedBeta;
  37474. private _storedRadius;
  37475. private _storedTarget;
  37476. private _storedTargetScreenOffset;
  37477. /**
  37478. * Stores the current state of the camera (alpha, beta, radius and target)
  37479. * @returns the camera itself
  37480. */
  37481. storeState(): Camera;
  37482. /**
  37483. * @hidden
  37484. * Restored camera state. You must call storeState() first
  37485. */
  37486. _restoreStateValues(): boolean;
  37487. /** @hidden */
  37488. _isSynchronizedViewMatrix(): boolean;
  37489. /**
  37490. * Attached controls to the current camera.
  37491. * @param element Defines the element the controls should be listened from
  37492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37493. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37494. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37495. */
  37496. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37497. /**
  37498. * Detach the current controls from the camera.
  37499. * The camera will stop reacting to inputs.
  37500. * @param element Defines the element to stop listening the inputs from
  37501. */
  37502. detachControl(element: HTMLElement): void;
  37503. /** @hidden */
  37504. _checkInputs(): void;
  37505. protected _checkLimits(): void;
  37506. /**
  37507. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37508. */
  37509. rebuildAnglesAndRadius(): void;
  37510. /**
  37511. * Use a position to define the current camera related information like aplha, beta and radius
  37512. * @param position Defines the position to set the camera at
  37513. */
  37514. setPosition(position: Vector3): void;
  37515. /**
  37516. * Defines the target the camera should look at.
  37517. * This will automatically adapt alpha beta and radius to fit within the new target.
  37518. * @param target Defines the new target as a Vector or a mesh
  37519. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37520. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37521. */
  37522. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37523. /** @hidden */
  37524. _getViewMatrix(): Matrix;
  37525. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37526. /**
  37527. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37528. * @param meshes Defines the mesh to zoom on
  37529. * @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)
  37530. */
  37531. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37532. /**
  37533. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37534. * The target will be changed but the radius
  37535. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37536. * @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)
  37537. */
  37538. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37539. min: Vector3;
  37540. max: Vector3;
  37541. distance: number;
  37542. }, doNotUpdateMaxZ?: boolean): void;
  37543. /**
  37544. * @override
  37545. * Override Camera.createRigCamera
  37546. */
  37547. createRigCamera(name: string, cameraIndex: number): Camera;
  37548. /**
  37549. * @hidden
  37550. * @override
  37551. * Override Camera._updateRigCameras
  37552. */
  37553. _updateRigCameras(): void;
  37554. /**
  37555. * Destroy the camera and release the current resources hold by it.
  37556. */
  37557. dispose(): void;
  37558. /**
  37559. * Gets the current object class name.
  37560. * @return the class name
  37561. */
  37562. getClassName(): string;
  37563. }
  37564. }
  37565. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37566. import { Behavior } from "babylonjs/Behaviors/behavior";
  37567. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37568. /**
  37569. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37570. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37571. */
  37572. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37573. /**
  37574. * Gets the name of the behavior.
  37575. */
  37576. readonly name: string;
  37577. private _zoomStopsAnimation;
  37578. private _idleRotationSpeed;
  37579. private _idleRotationWaitTime;
  37580. private _idleRotationSpinupTime;
  37581. /**
  37582. * Sets the flag that indicates if user zooming should stop animation.
  37583. */
  37584. /**
  37585. * Gets the flag that indicates if user zooming should stop animation.
  37586. */
  37587. zoomStopsAnimation: boolean;
  37588. /**
  37589. * Sets the default speed at which the camera rotates around the model.
  37590. */
  37591. /**
  37592. * Gets the default speed at which the camera rotates around the model.
  37593. */
  37594. idleRotationSpeed: number;
  37595. /**
  37596. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37597. */
  37598. /**
  37599. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37600. */
  37601. idleRotationWaitTime: number;
  37602. /**
  37603. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37604. */
  37605. /**
  37606. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37607. */
  37608. idleRotationSpinupTime: number;
  37609. /**
  37610. * Gets a value indicating if the camera is currently rotating because of this behavior
  37611. */
  37612. readonly rotationInProgress: boolean;
  37613. private _onPrePointerObservableObserver;
  37614. private _onAfterCheckInputsObserver;
  37615. private _attachedCamera;
  37616. private _isPointerDown;
  37617. private _lastFrameTime;
  37618. private _lastInteractionTime;
  37619. private _cameraRotationSpeed;
  37620. /**
  37621. * Initializes the behavior.
  37622. */
  37623. init(): void;
  37624. /**
  37625. * Attaches the behavior to its arc rotate camera.
  37626. * @param camera Defines the camera to attach the behavior to
  37627. */
  37628. attach(camera: ArcRotateCamera): void;
  37629. /**
  37630. * Detaches the behavior from its current arc rotate camera.
  37631. */
  37632. detach(): void;
  37633. /**
  37634. * Returns true if user is scrolling.
  37635. * @return true if user is scrolling.
  37636. */
  37637. private _userIsZooming;
  37638. private _lastFrameRadius;
  37639. private _shouldAnimationStopForInteraction;
  37640. /**
  37641. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37642. */
  37643. private _applyUserInteraction;
  37644. private _userIsMoving;
  37645. }
  37646. }
  37647. declare module "babylonjs/Behaviors/Cameras/index" {
  37648. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37649. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37650. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37651. }
  37652. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37653. import { Mesh } from "babylonjs/Meshes/mesh";
  37654. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37655. import { Behavior } from "babylonjs/Behaviors/behavior";
  37656. /**
  37657. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37658. */
  37659. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37660. private ui;
  37661. /**
  37662. * The name of the behavior
  37663. */
  37664. name: string;
  37665. /**
  37666. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37667. */
  37668. distanceAwayFromFace: number;
  37669. /**
  37670. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37671. */
  37672. distanceAwayFromBottomOfFace: number;
  37673. private _faceVectors;
  37674. private _target;
  37675. private _scene;
  37676. private _onRenderObserver;
  37677. private _tmpMatrix;
  37678. private _tmpVector;
  37679. /**
  37680. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37681. * @param ui The transform node that should be attched to the mesh
  37682. */
  37683. constructor(ui: TransformNode);
  37684. /**
  37685. * Initializes the behavior
  37686. */
  37687. init(): void;
  37688. private _closestFace;
  37689. private _zeroVector;
  37690. private _lookAtTmpMatrix;
  37691. private _lookAtToRef;
  37692. /**
  37693. * Attaches the AttachToBoxBehavior to the passed in mesh
  37694. * @param target The mesh that the specified node will be attached to
  37695. */
  37696. attach(target: Mesh): void;
  37697. /**
  37698. * Detaches the behavior from the mesh
  37699. */
  37700. detach(): void;
  37701. }
  37702. }
  37703. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37704. import { Behavior } from "babylonjs/Behaviors/behavior";
  37705. import { Mesh } from "babylonjs/Meshes/mesh";
  37706. /**
  37707. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37708. */
  37709. export class FadeInOutBehavior implements Behavior<Mesh> {
  37710. /**
  37711. * Time in milliseconds to delay before fading in (Default: 0)
  37712. */
  37713. delay: number;
  37714. /**
  37715. * Time in milliseconds for the mesh to fade in (Default: 300)
  37716. */
  37717. fadeInTime: number;
  37718. private _millisecondsPerFrame;
  37719. private _hovered;
  37720. private _hoverValue;
  37721. private _ownerNode;
  37722. /**
  37723. * Instatiates the FadeInOutBehavior
  37724. */
  37725. constructor();
  37726. /**
  37727. * The name of the behavior
  37728. */
  37729. readonly name: string;
  37730. /**
  37731. * Initializes the behavior
  37732. */
  37733. init(): void;
  37734. /**
  37735. * Attaches the fade behavior on the passed in mesh
  37736. * @param ownerNode The mesh that will be faded in/out once attached
  37737. */
  37738. attach(ownerNode: Mesh): void;
  37739. /**
  37740. * Detaches the behavior from the mesh
  37741. */
  37742. detach(): void;
  37743. /**
  37744. * Triggers the mesh to begin fading in or out
  37745. * @param value if the object should fade in or out (true to fade in)
  37746. */
  37747. fadeIn(value: boolean): void;
  37748. private _update;
  37749. private _setAllVisibility;
  37750. }
  37751. }
  37752. declare module "babylonjs/Misc/pivotTools" {
  37753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37754. /**
  37755. * Class containing a set of static utilities functions for managing Pivots
  37756. * @hidden
  37757. */
  37758. export class PivotTools {
  37759. private static _PivotCached;
  37760. private static _OldPivotPoint;
  37761. private static _PivotTranslation;
  37762. private static _PivotTmpVector;
  37763. /** @hidden */
  37764. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37765. /** @hidden */
  37766. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37767. }
  37768. }
  37769. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37770. import { Scene } from "babylonjs/scene";
  37771. import { Vector4 } from "babylonjs/Maths/math.vector";
  37772. import { Mesh } from "babylonjs/Meshes/mesh";
  37773. import { Nullable } from "babylonjs/types";
  37774. import { Plane } from "babylonjs/Maths/math.plane";
  37775. /**
  37776. * Class containing static functions to help procedurally build meshes
  37777. */
  37778. export class PlaneBuilder {
  37779. /**
  37780. * Creates a plane mesh
  37781. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37782. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37783. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37787. * @param name defines the name of the mesh
  37788. * @param options defines the options used to create the mesh
  37789. * @param scene defines the hosting scene
  37790. * @returns the plane mesh
  37791. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37792. */
  37793. static CreatePlane(name: string, options: {
  37794. size?: number;
  37795. width?: number;
  37796. height?: number;
  37797. sideOrientation?: number;
  37798. frontUVs?: Vector4;
  37799. backUVs?: Vector4;
  37800. updatable?: boolean;
  37801. sourcePlane?: Plane;
  37802. }, scene?: Nullable<Scene>): Mesh;
  37803. }
  37804. }
  37805. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37806. import { Behavior } from "babylonjs/Behaviors/behavior";
  37807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37808. import { Observable } from "babylonjs/Misc/observable";
  37809. import { Vector3 } from "babylonjs/Maths/math.vector";
  37810. import { Ray } from "babylonjs/Culling/ray";
  37811. import "babylonjs/Meshes/Builders/planeBuilder";
  37812. /**
  37813. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37814. */
  37815. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37816. private static _AnyMouseID;
  37817. /**
  37818. * Abstract mesh the behavior is set on
  37819. */
  37820. attachedNode: AbstractMesh;
  37821. private _dragPlane;
  37822. private _scene;
  37823. private _pointerObserver;
  37824. private _beforeRenderObserver;
  37825. private static _planeScene;
  37826. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37827. /**
  37828. * 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)
  37829. */
  37830. maxDragAngle: number;
  37831. /**
  37832. * @hidden
  37833. */
  37834. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37835. /**
  37836. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37837. */
  37838. currentDraggingPointerID: number;
  37839. /**
  37840. * The last position where the pointer hit the drag plane in world space
  37841. */
  37842. lastDragPosition: Vector3;
  37843. /**
  37844. * If the behavior is currently in a dragging state
  37845. */
  37846. dragging: boolean;
  37847. /**
  37848. * 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)
  37849. */
  37850. dragDeltaRatio: number;
  37851. /**
  37852. * If the drag plane orientation should be updated during the dragging (Default: true)
  37853. */
  37854. updateDragPlane: boolean;
  37855. private _debugMode;
  37856. private _moving;
  37857. /**
  37858. * Fires each time the attached mesh is dragged with the pointer
  37859. * * delta between last drag position and current drag position in world space
  37860. * * dragDistance along the drag axis
  37861. * * dragPlaneNormal normal of the current drag plane used during the drag
  37862. * * dragPlanePoint in world space where the drag intersects the drag plane
  37863. */
  37864. onDragObservable: Observable<{
  37865. delta: Vector3;
  37866. dragPlanePoint: Vector3;
  37867. dragPlaneNormal: Vector3;
  37868. dragDistance: number;
  37869. pointerId: number;
  37870. }>;
  37871. /**
  37872. * Fires each time a drag begins (eg. mouse down on mesh)
  37873. */
  37874. onDragStartObservable: Observable<{
  37875. dragPlanePoint: Vector3;
  37876. pointerId: number;
  37877. }>;
  37878. /**
  37879. * Fires each time a drag ends (eg. mouse release after drag)
  37880. */
  37881. onDragEndObservable: Observable<{
  37882. dragPlanePoint: Vector3;
  37883. pointerId: number;
  37884. }>;
  37885. /**
  37886. * If the attached mesh should be moved when dragged
  37887. */
  37888. moveAttached: boolean;
  37889. /**
  37890. * If the drag behavior will react to drag events (Default: true)
  37891. */
  37892. enabled: boolean;
  37893. /**
  37894. * If pointer events should start and release the drag (Default: true)
  37895. */
  37896. startAndReleaseDragOnPointerEvents: boolean;
  37897. /**
  37898. * If camera controls should be detached during the drag
  37899. */
  37900. detachCameraControls: boolean;
  37901. /**
  37902. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37903. */
  37904. useObjectOrienationForDragging: boolean;
  37905. private _options;
  37906. /**
  37907. * Creates a pointer drag behavior that can be attached to a mesh
  37908. * @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)
  37909. */
  37910. constructor(options?: {
  37911. dragAxis?: Vector3;
  37912. dragPlaneNormal?: Vector3;
  37913. });
  37914. /**
  37915. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37916. */
  37917. validateDrag: (targetPosition: Vector3) => boolean;
  37918. /**
  37919. * The name of the behavior
  37920. */
  37921. readonly name: string;
  37922. /**
  37923. * Initializes the behavior
  37924. */
  37925. init(): void;
  37926. private _tmpVector;
  37927. private _alternatePickedPoint;
  37928. private _worldDragAxis;
  37929. private _targetPosition;
  37930. private _attachedElement;
  37931. /**
  37932. * Attaches the drag behavior the passed in mesh
  37933. * @param ownerNode The mesh that will be dragged around once attached
  37934. * @param predicate Predicate to use for pick filtering
  37935. */
  37936. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37937. /**
  37938. * Force relase the drag action by code.
  37939. */
  37940. releaseDrag(): void;
  37941. private _startDragRay;
  37942. private _lastPointerRay;
  37943. /**
  37944. * Simulates the start of a pointer drag event on the behavior
  37945. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37946. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37947. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37948. */
  37949. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37950. private _startDrag;
  37951. private _dragDelta;
  37952. private _moveDrag;
  37953. private _pickWithRayOnDragPlane;
  37954. private _pointA;
  37955. private _pointB;
  37956. private _pointC;
  37957. private _lineA;
  37958. private _lineB;
  37959. private _localAxis;
  37960. private _lookAt;
  37961. private _updateDragPlanePosition;
  37962. /**
  37963. * Detaches the behavior from the mesh
  37964. */
  37965. detach(): void;
  37966. }
  37967. }
  37968. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37969. import { Mesh } from "babylonjs/Meshes/mesh";
  37970. import { Behavior } from "babylonjs/Behaviors/behavior";
  37971. /**
  37972. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37973. */
  37974. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37975. private _dragBehaviorA;
  37976. private _dragBehaviorB;
  37977. private _startDistance;
  37978. private _initialScale;
  37979. private _targetScale;
  37980. private _ownerNode;
  37981. private _sceneRenderObserver;
  37982. /**
  37983. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37984. */
  37985. constructor();
  37986. /**
  37987. * The name of the behavior
  37988. */
  37989. readonly name: string;
  37990. /**
  37991. * Initializes the behavior
  37992. */
  37993. init(): void;
  37994. private _getCurrentDistance;
  37995. /**
  37996. * Attaches the scale behavior the passed in mesh
  37997. * @param ownerNode The mesh that will be scaled around once attached
  37998. */
  37999. attach(ownerNode: Mesh): void;
  38000. /**
  38001. * Detaches the behavior from the mesh
  38002. */
  38003. detach(): void;
  38004. }
  38005. }
  38006. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38007. import { Behavior } from "babylonjs/Behaviors/behavior";
  38008. import { Mesh } from "babylonjs/Meshes/mesh";
  38009. import { Observable } from "babylonjs/Misc/observable";
  38010. /**
  38011. * 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
  38012. */
  38013. export class SixDofDragBehavior implements Behavior<Mesh> {
  38014. private static _virtualScene;
  38015. private _ownerNode;
  38016. private _sceneRenderObserver;
  38017. private _scene;
  38018. private _targetPosition;
  38019. private _virtualOriginMesh;
  38020. private _virtualDragMesh;
  38021. private _pointerObserver;
  38022. private _moving;
  38023. private _startingOrientation;
  38024. /**
  38025. * 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)
  38026. */
  38027. private zDragFactor;
  38028. /**
  38029. * If the object should rotate to face the drag origin
  38030. */
  38031. rotateDraggedObject: boolean;
  38032. /**
  38033. * If the behavior is currently in a dragging state
  38034. */
  38035. dragging: boolean;
  38036. /**
  38037. * 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)
  38038. */
  38039. dragDeltaRatio: number;
  38040. /**
  38041. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38042. */
  38043. currentDraggingPointerID: number;
  38044. /**
  38045. * If camera controls should be detached during the drag
  38046. */
  38047. detachCameraControls: boolean;
  38048. /**
  38049. * Fires each time a drag starts
  38050. */
  38051. onDragStartObservable: Observable<{}>;
  38052. /**
  38053. * Fires each time a drag ends (eg. mouse release after drag)
  38054. */
  38055. onDragEndObservable: Observable<{}>;
  38056. /**
  38057. * 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
  38058. */
  38059. constructor();
  38060. /**
  38061. * The name of the behavior
  38062. */
  38063. readonly name: string;
  38064. /**
  38065. * Initializes the behavior
  38066. */
  38067. init(): void;
  38068. /**
  38069. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38070. */
  38071. private readonly _pointerCamera;
  38072. /**
  38073. * Attaches the scale behavior the passed in mesh
  38074. * @param ownerNode The mesh that will be scaled around once attached
  38075. */
  38076. attach(ownerNode: Mesh): void;
  38077. /**
  38078. * Detaches the behavior from the mesh
  38079. */
  38080. detach(): void;
  38081. }
  38082. }
  38083. declare module "babylonjs/Behaviors/Meshes/index" {
  38084. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38085. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38086. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38087. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38088. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38089. }
  38090. declare module "babylonjs/Behaviors/index" {
  38091. export * from "babylonjs/Behaviors/behavior";
  38092. export * from "babylonjs/Behaviors/Cameras/index";
  38093. export * from "babylonjs/Behaviors/Meshes/index";
  38094. }
  38095. declare module "babylonjs/Bones/boneIKController" {
  38096. import { Bone } from "babylonjs/Bones/bone";
  38097. import { Vector3 } from "babylonjs/Maths/math.vector";
  38098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38099. import { Nullable } from "babylonjs/types";
  38100. /**
  38101. * Class used to apply inverse kinematics to bones
  38102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38103. */
  38104. export class BoneIKController {
  38105. private static _tmpVecs;
  38106. private static _tmpQuat;
  38107. private static _tmpMats;
  38108. /**
  38109. * Gets or sets the target mesh
  38110. */
  38111. targetMesh: AbstractMesh;
  38112. /** Gets or sets the mesh used as pole */
  38113. poleTargetMesh: AbstractMesh;
  38114. /**
  38115. * Gets or sets the bone used as pole
  38116. */
  38117. poleTargetBone: Nullable<Bone>;
  38118. /**
  38119. * Gets or sets the target position
  38120. */
  38121. targetPosition: Vector3;
  38122. /**
  38123. * Gets or sets the pole target position
  38124. */
  38125. poleTargetPosition: Vector3;
  38126. /**
  38127. * Gets or sets the pole target local offset
  38128. */
  38129. poleTargetLocalOffset: Vector3;
  38130. /**
  38131. * Gets or sets the pole angle
  38132. */
  38133. poleAngle: number;
  38134. /**
  38135. * Gets or sets the mesh associated with the controller
  38136. */
  38137. mesh: AbstractMesh;
  38138. /**
  38139. * 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)
  38140. */
  38141. slerpAmount: number;
  38142. private _bone1Quat;
  38143. private _bone1Mat;
  38144. private _bone2Ang;
  38145. private _bone1;
  38146. private _bone2;
  38147. private _bone1Length;
  38148. private _bone2Length;
  38149. private _maxAngle;
  38150. private _maxReach;
  38151. private _rightHandedSystem;
  38152. private _bendAxis;
  38153. private _slerping;
  38154. private _adjustRoll;
  38155. /**
  38156. * Gets or sets maximum allowed angle
  38157. */
  38158. maxAngle: number;
  38159. /**
  38160. * Creates a new BoneIKController
  38161. * @param mesh defines the mesh to control
  38162. * @param bone defines the bone to control
  38163. * @param options defines options to set up the controller
  38164. */
  38165. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38166. targetMesh?: AbstractMesh;
  38167. poleTargetMesh?: AbstractMesh;
  38168. poleTargetBone?: Bone;
  38169. poleTargetLocalOffset?: Vector3;
  38170. poleAngle?: number;
  38171. bendAxis?: Vector3;
  38172. maxAngle?: number;
  38173. slerpAmount?: number;
  38174. });
  38175. private _setMaxAngle;
  38176. /**
  38177. * Force the controller to update the bones
  38178. */
  38179. update(): void;
  38180. }
  38181. }
  38182. declare module "babylonjs/Bones/boneLookController" {
  38183. import { Vector3 } from "babylonjs/Maths/math.vector";
  38184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38185. import { Bone } from "babylonjs/Bones/bone";
  38186. import { Space } from "babylonjs/Maths/math.axis";
  38187. /**
  38188. * Class used to make a bone look toward a point in space
  38189. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38190. */
  38191. export class BoneLookController {
  38192. private static _tmpVecs;
  38193. private static _tmpQuat;
  38194. private static _tmpMats;
  38195. /**
  38196. * The target Vector3 that the bone will look at
  38197. */
  38198. target: Vector3;
  38199. /**
  38200. * The mesh that the bone is attached to
  38201. */
  38202. mesh: AbstractMesh;
  38203. /**
  38204. * The bone that will be looking to the target
  38205. */
  38206. bone: Bone;
  38207. /**
  38208. * The up axis of the coordinate system that is used when the bone is rotated
  38209. */
  38210. upAxis: Vector3;
  38211. /**
  38212. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38213. */
  38214. upAxisSpace: Space;
  38215. /**
  38216. * Used to make an adjustment to the yaw of the bone
  38217. */
  38218. adjustYaw: number;
  38219. /**
  38220. * Used to make an adjustment to the pitch of the bone
  38221. */
  38222. adjustPitch: number;
  38223. /**
  38224. * Used to make an adjustment to the roll of the bone
  38225. */
  38226. adjustRoll: number;
  38227. /**
  38228. * 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)
  38229. */
  38230. slerpAmount: number;
  38231. private _minYaw;
  38232. private _maxYaw;
  38233. private _minPitch;
  38234. private _maxPitch;
  38235. private _minYawSin;
  38236. private _minYawCos;
  38237. private _maxYawSin;
  38238. private _maxYawCos;
  38239. private _midYawConstraint;
  38240. private _minPitchTan;
  38241. private _maxPitchTan;
  38242. private _boneQuat;
  38243. private _slerping;
  38244. private _transformYawPitch;
  38245. private _transformYawPitchInv;
  38246. private _firstFrameSkipped;
  38247. private _yawRange;
  38248. private _fowardAxis;
  38249. /**
  38250. * Gets or sets the minimum yaw angle that the bone can look to
  38251. */
  38252. minYaw: number;
  38253. /**
  38254. * Gets or sets the maximum yaw angle that the bone can look to
  38255. */
  38256. maxYaw: number;
  38257. /**
  38258. * Gets or sets the minimum pitch angle that the bone can look to
  38259. */
  38260. minPitch: number;
  38261. /**
  38262. * Gets or sets the maximum pitch angle that the bone can look to
  38263. */
  38264. maxPitch: number;
  38265. /**
  38266. * Create a BoneLookController
  38267. * @param mesh the mesh that the bone belongs to
  38268. * @param bone the bone that will be looking to the target
  38269. * @param target the target Vector3 to look at
  38270. * @param options optional settings:
  38271. * * maxYaw: the maximum angle the bone will yaw to
  38272. * * minYaw: the minimum angle the bone will yaw to
  38273. * * maxPitch: the maximum angle the bone will pitch to
  38274. * * minPitch: the minimum angle the bone will yaw to
  38275. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38276. * * upAxis: the up axis of the coordinate system
  38277. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38278. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38279. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38280. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38281. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38282. * * adjustRoll: used to make an adjustment to the roll of the bone
  38283. **/
  38284. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38285. maxYaw?: number;
  38286. minYaw?: number;
  38287. maxPitch?: number;
  38288. minPitch?: number;
  38289. slerpAmount?: number;
  38290. upAxis?: Vector3;
  38291. upAxisSpace?: Space;
  38292. yawAxis?: Vector3;
  38293. pitchAxis?: Vector3;
  38294. adjustYaw?: number;
  38295. adjustPitch?: number;
  38296. adjustRoll?: number;
  38297. });
  38298. /**
  38299. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38300. */
  38301. update(): void;
  38302. private _getAngleDiff;
  38303. private _getAngleBetween;
  38304. private _isAngleBetween;
  38305. }
  38306. }
  38307. declare module "babylonjs/Bones/index" {
  38308. export * from "babylonjs/Bones/bone";
  38309. export * from "babylonjs/Bones/boneIKController";
  38310. export * from "babylonjs/Bones/boneLookController";
  38311. export * from "babylonjs/Bones/skeleton";
  38312. }
  38313. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38314. import { Nullable } from "babylonjs/types";
  38315. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38316. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38317. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38318. /**
  38319. * Manage the gamepad inputs to control an arc rotate camera.
  38320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38321. */
  38322. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38323. /**
  38324. * Defines the camera the input is attached to.
  38325. */
  38326. camera: ArcRotateCamera;
  38327. /**
  38328. * Defines the gamepad the input is gathering event from.
  38329. */
  38330. gamepad: Nullable<Gamepad>;
  38331. /**
  38332. * Defines the gamepad rotation sensiblity.
  38333. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38334. */
  38335. gamepadRotationSensibility: number;
  38336. /**
  38337. * Defines the gamepad move sensiblity.
  38338. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38339. */
  38340. gamepadMoveSensibility: number;
  38341. private _onGamepadConnectedObserver;
  38342. private _onGamepadDisconnectedObserver;
  38343. /**
  38344. * Attach the input controls to a specific dom element to get the input from.
  38345. * @param element Defines the element the controls should be listened from
  38346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38347. */
  38348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38349. /**
  38350. * Detach the current controls from the specified dom element.
  38351. * @param element Defines the element to stop listening the inputs from
  38352. */
  38353. detachControl(element: Nullable<HTMLElement>): void;
  38354. /**
  38355. * Update the current camera state depending on the inputs that have been used this frame.
  38356. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38357. */
  38358. checkInputs(): void;
  38359. /**
  38360. * Gets the class name of the current intput.
  38361. * @returns the class name
  38362. */
  38363. getClassName(): string;
  38364. /**
  38365. * Get the friendly name associated with the input class.
  38366. * @returns the input friendly name
  38367. */
  38368. getSimpleName(): string;
  38369. }
  38370. }
  38371. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38372. import { Nullable } from "babylonjs/types";
  38373. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38374. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38375. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38376. interface ArcRotateCameraInputsManager {
  38377. /**
  38378. * Add orientation input support to the input manager.
  38379. * @returns the current input manager
  38380. */
  38381. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38382. }
  38383. }
  38384. /**
  38385. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38387. */
  38388. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38389. /**
  38390. * Defines the camera the input is attached to.
  38391. */
  38392. camera: ArcRotateCamera;
  38393. /**
  38394. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38395. */
  38396. alphaCorrection: number;
  38397. /**
  38398. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38399. */
  38400. gammaCorrection: number;
  38401. private _alpha;
  38402. private _gamma;
  38403. private _dirty;
  38404. private _deviceOrientationHandler;
  38405. /**
  38406. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38407. */
  38408. constructor();
  38409. /**
  38410. * Attach the input controls to a specific dom element to get the input from.
  38411. * @param element Defines the element the controls should be listened from
  38412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38413. */
  38414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38415. /** @hidden */
  38416. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38417. /**
  38418. * Update the current camera state depending on the inputs that have been used this frame.
  38419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38420. */
  38421. checkInputs(): void;
  38422. /**
  38423. * Detach the current controls from the specified dom element.
  38424. * @param element Defines the element to stop listening the inputs from
  38425. */
  38426. detachControl(element: Nullable<HTMLElement>): void;
  38427. /**
  38428. * Gets the class name of the current intput.
  38429. * @returns the class name
  38430. */
  38431. getClassName(): string;
  38432. /**
  38433. * Get the friendly name associated with the input class.
  38434. * @returns the input friendly name
  38435. */
  38436. getSimpleName(): string;
  38437. }
  38438. }
  38439. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38440. import { Nullable } from "babylonjs/types";
  38441. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38442. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38443. /**
  38444. * Listen to mouse events to control the camera.
  38445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38446. */
  38447. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38448. /**
  38449. * Defines the camera the input is attached to.
  38450. */
  38451. camera: FlyCamera;
  38452. /**
  38453. * Defines if touch is enabled. (Default is true.)
  38454. */
  38455. touchEnabled: boolean;
  38456. /**
  38457. * Defines the buttons associated with the input to handle camera rotation.
  38458. */
  38459. buttons: number[];
  38460. /**
  38461. * Assign buttons for Yaw control.
  38462. */
  38463. buttonsYaw: number[];
  38464. /**
  38465. * Assign buttons for Pitch control.
  38466. */
  38467. buttonsPitch: number[];
  38468. /**
  38469. * Assign buttons for Roll control.
  38470. */
  38471. buttonsRoll: number[];
  38472. /**
  38473. * Detect if any button is being pressed while mouse is moved.
  38474. * -1 = Mouse locked.
  38475. * 0 = Left button.
  38476. * 1 = Middle Button.
  38477. * 2 = Right Button.
  38478. */
  38479. activeButton: number;
  38480. /**
  38481. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38482. * Higher values reduce its sensitivity.
  38483. */
  38484. angularSensibility: number;
  38485. private _mousemoveCallback;
  38486. private _observer;
  38487. private _rollObserver;
  38488. private previousPosition;
  38489. private noPreventDefault;
  38490. private element;
  38491. /**
  38492. * Listen to mouse events to control the camera.
  38493. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38494. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38495. */
  38496. constructor(touchEnabled?: boolean);
  38497. /**
  38498. * Attach the mouse control to the HTML DOM element.
  38499. * @param element Defines the element that listens to the input events.
  38500. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38501. */
  38502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38503. /**
  38504. * Detach the current controls from the specified dom element.
  38505. * @param element Defines the element to stop listening the inputs from
  38506. */
  38507. detachControl(element: Nullable<HTMLElement>): void;
  38508. /**
  38509. * Gets the class name of the current input.
  38510. * @returns the class name.
  38511. */
  38512. getClassName(): string;
  38513. /**
  38514. * Get the friendly name associated with the input class.
  38515. * @returns the input's friendly name.
  38516. */
  38517. getSimpleName(): string;
  38518. private _pointerInput;
  38519. private _onMouseMove;
  38520. /**
  38521. * Rotate camera by mouse offset.
  38522. */
  38523. private rotateCamera;
  38524. }
  38525. }
  38526. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38527. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38528. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38529. /**
  38530. * Default Inputs manager for the FlyCamera.
  38531. * It groups all the default supported inputs for ease of use.
  38532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38533. */
  38534. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38535. /**
  38536. * Instantiates a new FlyCameraInputsManager.
  38537. * @param camera Defines the camera the inputs belong to.
  38538. */
  38539. constructor(camera: FlyCamera);
  38540. /**
  38541. * Add keyboard input support to the input manager.
  38542. * @returns the new FlyCameraKeyboardMoveInput().
  38543. */
  38544. addKeyboard(): FlyCameraInputsManager;
  38545. /**
  38546. * Add mouse input support to the input manager.
  38547. * @param touchEnabled Enable touch screen support.
  38548. * @returns the new FlyCameraMouseInput().
  38549. */
  38550. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38551. }
  38552. }
  38553. declare module "babylonjs/Cameras/flyCamera" {
  38554. import { Scene } from "babylonjs/scene";
  38555. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38557. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38558. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38559. /**
  38560. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38561. * such as in a 3D Space Shooter or a Flight Simulator.
  38562. */
  38563. export class FlyCamera extends TargetCamera {
  38564. /**
  38565. * Define the collision ellipsoid of the camera.
  38566. * This is helpful for simulating a camera body, like a player's body.
  38567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38568. */
  38569. ellipsoid: Vector3;
  38570. /**
  38571. * Define an offset for the position of the ellipsoid around the camera.
  38572. * This can be helpful if the camera is attached away from the player's body center,
  38573. * such as at its head.
  38574. */
  38575. ellipsoidOffset: Vector3;
  38576. /**
  38577. * Enable or disable collisions of the camera with the rest of the scene objects.
  38578. */
  38579. checkCollisions: boolean;
  38580. /**
  38581. * Enable or disable gravity on the camera.
  38582. */
  38583. applyGravity: boolean;
  38584. /**
  38585. * Define the current direction the camera is moving to.
  38586. */
  38587. cameraDirection: Vector3;
  38588. /**
  38589. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38590. * This overrides and empties cameraRotation.
  38591. */
  38592. rotationQuaternion: Quaternion;
  38593. /**
  38594. * Track Roll to maintain the wanted Rolling when looking around.
  38595. */
  38596. _trackRoll: number;
  38597. /**
  38598. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38599. */
  38600. rollCorrect: number;
  38601. /**
  38602. * Mimic a banked turn, Rolling the camera when Yawing.
  38603. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38604. */
  38605. bankedTurn: boolean;
  38606. /**
  38607. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38608. */
  38609. bankedTurnLimit: number;
  38610. /**
  38611. * Value of 0 disables the banked Roll.
  38612. * Value of 1 is equal to the Yaw angle in radians.
  38613. */
  38614. bankedTurnMultiplier: number;
  38615. /**
  38616. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38617. */
  38618. inputs: FlyCameraInputsManager;
  38619. /**
  38620. * Gets the input sensibility for mouse input.
  38621. * Higher values reduce sensitivity.
  38622. */
  38623. /**
  38624. * Sets the input sensibility for a mouse input.
  38625. * Higher values reduce sensitivity.
  38626. */
  38627. angularSensibility: number;
  38628. /**
  38629. * Get the keys for camera movement forward.
  38630. */
  38631. /**
  38632. * Set the keys for camera movement forward.
  38633. */
  38634. keysForward: number[];
  38635. /**
  38636. * Get the keys for camera movement backward.
  38637. */
  38638. keysBackward: number[];
  38639. /**
  38640. * Get the keys for camera movement up.
  38641. */
  38642. /**
  38643. * Set the keys for camera movement up.
  38644. */
  38645. keysUp: number[];
  38646. /**
  38647. * Get the keys for camera movement down.
  38648. */
  38649. /**
  38650. * Set the keys for camera movement down.
  38651. */
  38652. keysDown: number[];
  38653. /**
  38654. * Get the keys for camera movement left.
  38655. */
  38656. /**
  38657. * Set the keys for camera movement left.
  38658. */
  38659. keysLeft: number[];
  38660. /**
  38661. * Set the keys for camera movement right.
  38662. */
  38663. /**
  38664. * Set the keys for camera movement right.
  38665. */
  38666. keysRight: number[];
  38667. /**
  38668. * Event raised when the camera collides with a mesh in the scene.
  38669. */
  38670. onCollide: (collidedMesh: AbstractMesh) => void;
  38671. private _collider;
  38672. private _needMoveForGravity;
  38673. private _oldPosition;
  38674. private _diffPosition;
  38675. private _newPosition;
  38676. /** @hidden */
  38677. _localDirection: Vector3;
  38678. /** @hidden */
  38679. _transformedDirection: Vector3;
  38680. /**
  38681. * Instantiates a FlyCamera.
  38682. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38683. * such as in a 3D Space Shooter or a Flight Simulator.
  38684. * @param name Define the name of the camera in the scene.
  38685. * @param position Define the starting position of the camera in the scene.
  38686. * @param scene Define the scene the camera belongs to.
  38687. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38688. */
  38689. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38690. /**
  38691. * Attach a control to the HTML DOM element.
  38692. * @param element Defines the element that listens to the input events.
  38693. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38694. */
  38695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38696. /**
  38697. * Detach a control from the HTML DOM element.
  38698. * The camera will stop reacting to that input.
  38699. * @param element Defines the element that listens to the input events.
  38700. */
  38701. detachControl(element: HTMLElement): void;
  38702. private _collisionMask;
  38703. /**
  38704. * Get the mask that the camera ignores in collision events.
  38705. */
  38706. /**
  38707. * Set the mask that the camera ignores in collision events.
  38708. */
  38709. collisionMask: number;
  38710. /** @hidden */
  38711. _collideWithWorld(displacement: Vector3): void;
  38712. /** @hidden */
  38713. private _onCollisionPositionChange;
  38714. /** @hidden */
  38715. _checkInputs(): void;
  38716. /** @hidden */
  38717. _decideIfNeedsToMove(): boolean;
  38718. /** @hidden */
  38719. _updatePosition(): void;
  38720. /**
  38721. * Restore the Roll to its target value at the rate specified.
  38722. * @param rate - Higher means slower restoring.
  38723. * @hidden
  38724. */
  38725. restoreRoll(rate: number): void;
  38726. /**
  38727. * Destroy the camera and release the current resources held by it.
  38728. */
  38729. dispose(): void;
  38730. /**
  38731. * Get the current object class name.
  38732. * @returns the class name.
  38733. */
  38734. getClassName(): string;
  38735. }
  38736. }
  38737. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38738. import { Nullable } from "babylonjs/types";
  38739. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38740. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38741. /**
  38742. * Listen to keyboard events to control the camera.
  38743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38744. */
  38745. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38746. /**
  38747. * Defines the camera the input is attached to.
  38748. */
  38749. camera: FlyCamera;
  38750. /**
  38751. * The list of keyboard keys used to control the forward move of the camera.
  38752. */
  38753. keysForward: number[];
  38754. /**
  38755. * The list of keyboard keys used to control the backward move of the camera.
  38756. */
  38757. keysBackward: number[];
  38758. /**
  38759. * The list of keyboard keys used to control the forward move of the camera.
  38760. */
  38761. keysUp: number[];
  38762. /**
  38763. * The list of keyboard keys used to control the backward move of the camera.
  38764. */
  38765. keysDown: number[];
  38766. /**
  38767. * The list of keyboard keys used to control the right strafe move of the camera.
  38768. */
  38769. keysRight: number[];
  38770. /**
  38771. * The list of keyboard keys used to control the left strafe move of the camera.
  38772. */
  38773. keysLeft: number[];
  38774. private _keys;
  38775. private _onCanvasBlurObserver;
  38776. private _onKeyboardObserver;
  38777. private _engine;
  38778. private _scene;
  38779. /**
  38780. * Attach the input controls to a specific dom element to get the input from.
  38781. * @param element Defines the element the controls should be listened from
  38782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38783. */
  38784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38785. /**
  38786. * Detach the current controls from the specified dom element.
  38787. * @param element Defines the element to stop listening the inputs from
  38788. */
  38789. detachControl(element: Nullable<HTMLElement>): void;
  38790. /**
  38791. * Gets the class name of the current intput.
  38792. * @returns the class name
  38793. */
  38794. getClassName(): string;
  38795. /** @hidden */
  38796. _onLostFocus(e: FocusEvent): void;
  38797. /**
  38798. * Get the friendly name associated with the input class.
  38799. * @returns the input friendly name
  38800. */
  38801. getSimpleName(): string;
  38802. /**
  38803. * Update the current camera state depending on the inputs that have been used this frame.
  38804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38805. */
  38806. checkInputs(): void;
  38807. }
  38808. }
  38809. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38810. import { Nullable } from "babylonjs/types";
  38811. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38812. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38813. /**
  38814. * Manage the mouse wheel inputs to control a follow camera.
  38815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38816. */
  38817. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38818. /**
  38819. * Defines the camera the input is attached to.
  38820. */
  38821. camera: FollowCamera;
  38822. /**
  38823. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38824. */
  38825. axisControlRadius: boolean;
  38826. /**
  38827. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38828. */
  38829. axisControlHeight: boolean;
  38830. /**
  38831. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38832. */
  38833. axisControlRotation: boolean;
  38834. /**
  38835. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38836. * relation to mouseWheel events.
  38837. */
  38838. wheelPrecision: number;
  38839. /**
  38840. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38841. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38842. */
  38843. wheelDeltaPercentage: number;
  38844. private _wheel;
  38845. private _observer;
  38846. /**
  38847. * Attach the input controls to a specific dom element to get the input from.
  38848. * @param element Defines the element the controls should be listened from
  38849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38850. */
  38851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38852. /**
  38853. * Detach the current controls from the specified dom element.
  38854. * @param element Defines the element to stop listening the inputs from
  38855. */
  38856. detachControl(element: Nullable<HTMLElement>): void;
  38857. /**
  38858. * Gets the class name of the current intput.
  38859. * @returns the class name
  38860. */
  38861. getClassName(): string;
  38862. /**
  38863. * Get the friendly name associated with the input class.
  38864. * @returns the input friendly name
  38865. */
  38866. getSimpleName(): string;
  38867. }
  38868. }
  38869. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38870. import { Nullable } from "babylonjs/types";
  38871. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38872. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38873. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38874. /**
  38875. * Manage the pointers inputs to control an follow camera.
  38876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38877. */
  38878. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38879. /**
  38880. * Defines the camera the input is attached to.
  38881. */
  38882. camera: FollowCamera;
  38883. /**
  38884. * Gets the class name of the current input.
  38885. * @returns the class name
  38886. */
  38887. getClassName(): string;
  38888. /**
  38889. * Defines the pointer angular sensibility along the X axis or how fast is
  38890. * the camera rotating.
  38891. * A negative number will reverse the axis direction.
  38892. */
  38893. angularSensibilityX: number;
  38894. /**
  38895. * Defines the pointer angular sensibility along the Y axis or how fast is
  38896. * the camera rotating.
  38897. * A negative number will reverse the axis direction.
  38898. */
  38899. angularSensibilityY: number;
  38900. /**
  38901. * Defines the pointer pinch precision or how fast is the camera zooming.
  38902. * A negative number will reverse the axis direction.
  38903. */
  38904. pinchPrecision: number;
  38905. /**
  38906. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38907. * from 0.
  38908. * It defines the percentage of current camera.radius to use as delta when
  38909. * pinch zoom is used.
  38910. */
  38911. pinchDeltaPercentage: number;
  38912. /**
  38913. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38914. */
  38915. axisXControlRadius: boolean;
  38916. /**
  38917. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38918. */
  38919. axisXControlHeight: boolean;
  38920. /**
  38921. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38922. */
  38923. axisXControlRotation: boolean;
  38924. /**
  38925. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38926. */
  38927. axisYControlRadius: boolean;
  38928. /**
  38929. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38930. */
  38931. axisYControlHeight: boolean;
  38932. /**
  38933. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38934. */
  38935. axisYControlRotation: boolean;
  38936. /**
  38937. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38938. */
  38939. axisPinchControlRadius: boolean;
  38940. /**
  38941. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38942. */
  38943. axisPinchControlHeight: boolean;
  38944. /**
  38945. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38946. */
  38947. axisPinchControlRotation: boolean;
  38948. /**
  38949. * Log error messages if basic misconfiguration has occurred.
  38950. */
  38951. warningEnable: boolean;
  38952. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38953. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38954. private _warningCounter;
  38955. private _warning;
  38956. }
  38957. }
  38958. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38959. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38960. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38961. /**
  38962. * Default Inputs manager for the FollowCamera.
  38963. * It groups all the default supported inputs for ease of use.
  38964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38965. */
  38966. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38967. /**
  38968. * Instantiates a new FollowCameraInputsManager.
  38969. * @param camera Defines the camera the inputs belong to
  38970. */
  38971. constructor(camera: FollowCamera);
  38972. /**
  38973. * Add keyboard input support to the input manager.
  38974. * @returns the current input manager
  38975. */
  38976. addKeyboard(): FollowCameraInputsManager;
  38977. /**
  38978. * Add mouse wheel input support to the input manager.
  38979. * @returns the current input manager
  38980. */
  38981. addMouseWheel(): FollowCameraInputsManager;
  38982. /**
  38983. * Add pointers input support to the input manager.
  38984. * @returns the current input manager
  38985. */
  38986. addPointers(): FollowCameraInputsManager;
  38987. /**
  38988. * Add orientation input support to the input manager.
  38989. * @returns the current input manager
  38990. */
  38991. addVRDeviceOrientation(): FollowCameraInputsManager;
  38992. }
  38993. }
  38994. declare module "babylonjs/Cameras/followCamera" {
  38995. import { Nullable } from "babylonjs/types";
  38996. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38997. import { Scene } from "babylonjs/scene";
  38998. import { Vector3 } from "babylonjs/Maths/math.vector";
  38999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39000. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39001. /**
  39002. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39003. * an arc rotate version arcFollowCamera are available.
  39004. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39005. */
  39006. export class FollowCamera extends TargetCamera {
  39007. /**
  39008. * Distance the follow camera should follow an object at
  39009. */
  39010. radius: number;
  39011. /**
  39012. * Minimum allowed distance of the camera to the axis of rotation
  39013. * (The camera can not get closer).
  39014. * This can help limiting how the Camera is able to move in the scene.
  39015. */
  39016. lowerRadiusLimit: Nullable<number>;
  39017. /**
  39018. * Maximum allowed distance of the camera to the axis of rotation
  39019. * (The camera can not get further).
  39020. * This can help limiting how the Camera is able to move in the scene.
  39021. */
  39022. upperRadiusLimit: Nullable<number>;
  39023. /**
  39024. * Define a rotation offset between the camera and the object it follows
  39025. */
  39026. rotationOffset: number;
  39027. /**
  39028. * Minimum allowed angle to camera position relative to target object.
  39029. * This can help limiting how the Camera is able to move in the scene.
  39030. */
  39031. lowerRotationOffsetLimit: Nullable<number>;
  39032. /**
  39033. * Maximum allowed angle to camera position relative to target object.
  39034. * This can help limiting how the Camera is able to move in the scene.
  39035. */
  39036. upperRotationOffsetLimit: Nullable<number>;
  39037. /**
  39038. * Define a height offset between the camera and the object it follows.
  39039. * It can help following an object from the top (like a car chaing a plane)
  39040. */
  39041. heightOffset: number;
  39042. /**
  39043. * Minimum allowed height of camera position relative to target object.
  39044. * This can help limiting how the Camera is able to move in the scene.
  39045. */
  39046. lowerHeightOffsetLimit: Nullable<number>;
  39047. /**
  39048. * Maximum allowed height of camera position relative to target object.
  39049. * This can help limiting how the Camera is able to move in the scene.
  39050. */
  39051. upperHeightOffsetLimit: Nullable<number>;
  39052. /**
  39053. * Define how fast the camera can accelerate to follow it s target.
  39054. */
  39055. cameraAcceleration: number;
  39056. /**
  39057. * Define the speed limit of the camera following an object.
  39058. */
  39059. maxCameraSpeed: number;
  39060. /**
  39061. * Define the target of the camera.
  39062. */
  39063. lockedTarget: Nullable<AbstractMesh>;
  39064. /**
  39065. * Defines the input associated with the camera.
  39066. */
  39067. inputs: FollowCameraInputsManager;
  39068. /**
  39069. * Instantiates the follow camera.
  39070. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39071. * @param name Define the name of the camera in the scene
  39072. * @param position Define the position of the camera
  39073. * @param scene Define the scene the camera belong to
  39074. * @param lockedTarget Define the target of the camera
  39075. */
  39076. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39077. private _follow;
  39078. /**
  39079. * Attached controls to the current camera.
  39080. * @param element Defines the element the controls should be listened from
  39081. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39082. */
  39083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39084. /**
  39085. * Detach the current controls from the camera.
  39086. * The camera will stop reacting to inputs.
  39087. * @param element Defines the element to stop listening the inputs from
  39088. */
  39089. detachControl(element: HTMLElement): void;
  39090. /** @hidden */
  39091. _checkInputs(): void;
  39092. private _checkLimits;
  39093. /**
  39094. * Gets the camera class name.
  39095. * @returns the class name
  39096. */
  39097. getClassName(): string;
  39098. }
  39099. /**
  39100. * Arc Rotate version of the follow camera.
  39101. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39102. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39103. */
  39104. export class ArcFollowCamera extends TargetCamera {
  39105. /** The longitudinal angle of the camera */
  39106. alpha: number;
  39107. /** The latitudinal angle of the camera */
  39108. beta: number;
  39109. /** The radius of the camera from its target */
  39110. radius: number;
  39111. /** Define the camera target (the messh it should follow) */
  39112. target: Nullable<AbstractMesh>;
  39113. private _cartesianCoordinates;
  39114. /**
  39115. * Instantiates a new ArcFollowCamera
  39116. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39117. * @param name Define the name of the camera
  39118. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39119. * @param beta Define the rotation angle of the camera around the elevation axis
  39120. * @param radius Define the radius of the camera from its target point
  39121. * @param target Define the target of the camera
  39122. * @param scene Define the scene the camera belongs to
  39123. */
  39124. constructor(name: string,
  39125. /** The longitudinal angle of the camera */
  39126. alpha: number,
  39127. /** The latitudinal angle of the camera */
  39128. beta: number,
  39129. /** The radius of the camera from its target */
  39130. radius: number,
  39131. /** Define the camera target (the messh it should follow) */
  39132. target: Nullable<AbstractMesh>, scene: Scene);
  39133. private _follow;
  39134. /** @hidden */
  39135. _checkInputs(): void;
  39136. /**
  39137. * Returns the class name of the object.
  39138. * It is mostly used internally for serialization purposes.
  39139. */
  39140. getClassName(): string;
  39141. }
  39142. }
  39143. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39144. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39145. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39146. import { Nullable } from "babylonjs/types";
  39147. /**
  39148. * Manage the keyboard inputs to control the movement of a follow camera.
  39149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39150. */
  39151. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39152. /**
  39153. * Defines the camera the input is attached to.
  39154. */
  39155. camera: FollowCamera;
  39156. /**
  39157. * Defines the list of key codes associated with the up action (increase heightOffset)
  39158. */
  39159. keysHeightOffsetIncr: number[];
  39160. /**
  39161. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39162. */
  39163. keysHeightOffsetDecr: number[];
  39164. /**
  39165. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39166. */
  39167. keysHeightOffsetModifierAlt: boolean;
  39168. /**
  39169. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39170. */
  39171. keysHeightOffsetModifierCtrl: boolean;
  39172. /**
  39173. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39174. */
  39175. keysHeightOffsetModifierShift: boolean;
  39176. /**
  39177. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39178. */
  39179. keysRotationOffsetIncr: number[];
  39180. /**
  39181. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39182. */
  39183. keysRotationOffsetDecr: number[];
  39184. /**
  39185. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39186. */
  39187. keysRotationOffsetModifierAlt: boolean;
  39188. /**
  39189. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39190. */
  39191. keysRotationOffsetModifierCtrl: boolean;
  39192. /**
  39193. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39194. */
  39195. keysRotationOffsetModifierShift: boolean;
  39196. /**
  39197. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39198. */
  39199. keysRadiusIncr: number[];
  39200. /**
  39201. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39202. */
  39203. keysRadiusDecr: number[];
  39204. /**
  39205. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39206. */
  39207. keysRadiusModifierAlt: boolean;
  39208. /**
  39209. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39210. */
  39211. keysRadiusModifierCtrl: boolean;
  39212. /**
  39213. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39214. */
  39215. keysRadiusModifierShift: boolean;
  39216. /**
  39217. * Defines the rate of change of heightOffset.
  39218. */
  39219. heightSensibility: number;
  39220. /**
  39221. * Defines the rate of change of rotationOffset.
  39222. */
  39223. rotationSensibility: number;
  39224. /**
  39225. * Defines the rate of change of radius.
  39226. */
  39227. radiusSensibility: number;
  39228. private _keys;
  39229. private _ctrlPressed;
  39230. private _altPressed;
  39231. private _shiftPressed;
  39232. private _onCanvasBlurObserver;
  39233. private _onKeyboardObserver;
  39234. private _engine;
  39235. private _scene;
  39236. /**
  39237. * Attach the input controls to a specific dom element to get the input from.
  39238. * @param element Defines the element the controls should be listened from
  39239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39240. */
  39241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39242. /**
  39243. * Detach the current controls from the specified dom element.
  39244. * @param element Defines the element to stop listening the inputs from
  39245. */
  39246. detachControl(element: Nullable<HTMLElement>): void;
  39247. /**
  39248. * Update the current camera state depending on the inputs that have been used this frame.
  39249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39250. */
  39251. checkInputs(): void;
  39252. /**
  39253. * Gets the class name of the current input.
  39254. * @returns the class name
  39255. */
  39256. getClassName(): string;
  39257. /**
  39258. * Get the friendly name associated with the input class.
  39259. * @returns the input friendly name
  39260. */
  39261. getSimpleName(): string;
  39262. /**
  39263. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39264. * allow modification of the heightOffset value.
  39265. */
  39266. private _modifierHeightOffset;
  39267. /**
  39268. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39269. * allow modification of the rotationOffset value.
  39270. */
  39271. private _modifierRotationOffset;
  39272. /**
  39273. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39274. * allow modification of the radius value.
  39275. */
  39276. private _modifierRadius;
  39277. }
  39278. }
  39279. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39280. import { Nullable } from "babylonjs/types";
  39281. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39282. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39283. import { Observable } from "babylonjs/Misc/observable";
  39284. module "babylonjs/Cameras/freeCameraInputsManager" {
  39285. interface FreeCameraInputsManager {
  39286. /**
  39287. * @hidden
  39288. */
  39289. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39290. /**
  39291. * Add orientation input support to the input manager.
  39292. * @returns the current input manager
  39293. */
  39294. addDeviceOrientation(): FreeCameraInputsManager;
  39295. }
  39296. }
  39297. /**
  39298. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39299. * Screen rotation is taken into account.
  39300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39301. */
  39302. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39303. private _camera;
  39304. private _screenOrientationAngle;
  39305. private _constantTranform;
  39306. private _screenQuaternion;
  39307. private _alpha;
  39308. private _beta;
  39309. private _gamma;
  39310. /**
  39311. * Can be used to detect if a device orientation sensor is availible on a device
  39312. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39313. * @returns a promise that will resolve on orientation change
  39314. */
  39315. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39316. /**
  39317. * @hidden
  39318. */
  39319. _onDeviceOrientationChangedObservable: Observable<void>;
  39320. /**
  39321. * Instantiates a new input
  39322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39323. */
  39324. constructor();
  39325. /**
  39326. * Define the camera controlled by the input.
  39327. */
  39328. camera: FreeCamera;
  39329. /**
  39330. * Attach the input controls to a specific dom element to get the input from.
  39331. * @param element Defines the element the controls should be listened from
  39332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39333. */
  39334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39335. private _orientationChanged;
  39336. private _deviceOrientation;
  39337. /**
  39338. * Detach the current controls from the specified dom element.
  39339. * @param element Defines the element to stop listening the inputs from
  39340. */
  39341. detachControl(element: Nullable<HTMLElement>): void;
  39342. /**
  39343. * Update the current camera state depending on the inputs that have been used this frame.
  39344. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39345. */
  39346. checkInputs(): void;
  39347. /**
  39348. * Gets the class name of the current intput.
  39349. * @returns the class name
  39350. */
  39351. getClassName(): string;
  39352. /**
  39353. * Get the friendly name associated with the input class.
  39354. * @returns the input friendly name
  39355. */
  39356. getSimpleName(): string;
  39357. }
  39358. }
  39359. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39360. import { Nullable } from "babylonjs/types";
  39361. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39362. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39363. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39364. /**
  39365. * Manage the gamepad inputs to control a free camera.
  39366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39367. */
  39368. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39369. /**
  39370. * Define the camera the input is attached to.
  39371. */
  39372. camera: FreeCamera;
  39373. /**
  39374. * Define the Gamepad controlling the input
  39375. */
  39376. gamepad: Nullable<Gamepad>;
  39377. /**
  39378. * Defines the gamepad rotation sensiblity.
  39379. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39380. */
  39381. gamepadAngularSensibility: number;
  39382. /**
  39383. * Defines the gamepad move sensiblity.
  39384. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39385. */
  39386. gamepadMoveSensibility: number;
  39387. private _onGamepadConnectedObserver;
  39388. private _onGamepadDisconnectedObserver;
  39389. private _cameraTransform;
  39390. private _deltaTransform;
  39391. private _vector3;
  39392. private _vector2;
  39393. /**
  39394. * Attach the input controls to a specific dom element to get the input from.
  39395. * @param element Defines the element the controls should be listened from
  39396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39397. */
  39398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39399. /**
  39400. * Detach the current controls from the specified dom element.
  39401. * @param element Defines the element to stop listening the inputs from
  39402. */
  39403. detachControl(element: Nullable<HTMLElement>): void;
  39404. /**
  39405. * Update the current camera state depending on the inputs that have been used this frame.
  39406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39407. */
  39408. checkInputs(): void;
  39409. /**
  39410. * Gets the class name of the current intput.
  39411. * @returns the class name
  39412. */
  39413. getClassName(): string;
  39414. /**
  39415. * Get the friendly name associated with the input class.
  39416. * @returns the input friendly name
  39417. */
  39418. getSimpleName(): string;
  39419. }
  39420. }
  39421. declare module "babylonjs/Misc/virtualJoystick" {
  39422. import { Nullable } from "babylonjs/types";
  39423. import { Vector3 } from "babylonjs/Maths/math.vector";
  39424. /**
  39425. * Defines the potential axis of a Joystick
  39426. */
  39427. export enum JoystickAxis {
  39428. /** X axis */
  39429. X = 0,
  39430. /** Y axis */
  39431. Y = 1,
  39432. /** Z axis */
  39433. Z = 2
  39434. }
  39435. /**
  39436. * Class used to define virtual joystick (used in touch mode)
  39437. */
  39438. export class VirtualJoystick {
  39439. /**
  39440. * Gets or sets a boolean indicating that left and right values must be inverted
  39441. */
  39442. reverseLeftRight: boolean;
  39443. /**
  39444. * Gets or sets a boolean indicating that up and down values must be inverted
  39445. */
  39446. reverseUpDown: boolean;
  39447. /**
  39448. * Gets the offset value for the position (ie. the change of the position value)
  39449. */
  39450. deltaPosition: Vector3;
  39451. /**
  39452. * Gets a boolean indicating if the virtual joystick was pressed
  39453. */
  39454. pressed: boolean;
  39455. /**
  39456. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39457. */
  39458. static Canvas: Nullable<HTMLCanvasElement>;
  39459. private static _globalJoystickIndex;
  39460. private static vjCanvasContext;
  39461. private static vjCanvasWidth;
  39462. private static vjCanvasHeight;
  39463. private static halfWidth;
  39464. private _action;
  39465. private _axisTargetedByLeftAndRight;
  39466. private _axisTargetedByUpAndDown;
  39467. private _joystickSensibility;
  39468. private _inversedSensibility;
  39469. private _joystickPointerID;
  39470. private _joystickColor;
  39471. private _joystickPointerPos;
  39472. private _joystickPreviousPointerPos;
  39473. private _joystickPointerStartPos;
  39474. private _deltaJoystickVector;
  39475. private _leftJoystick;
  39476. private _touches;
  39477. private _onPointerDownHandlerRef;
  39478. private _onPointerMoveHandlerRef;
  39479. private _onPointerUpHandlerRef;
  39480. private _onResize;
  39481. /**
  39482. * Creates a new virtual joystick
  39483. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39484. */
  39485. constructor(leftJoystick?: boolean);
  39486. /**
  39487. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39488. * @param newJoystickSensibility defines the new sensibility
  39489. */
  39490. setJoystickSensibility(newJoystickSensibility: number): void;
  39491. private _onPointerDown;
  39492. private _onPointerMove;
  39493. private _onPointerUp;
  39494. /**
  39495. * Change the color of the virtual joystick
  39496. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39497. */
  39498. setJoystickColor(newColor: string): void;
  39499. /**
  39500. * Defines a callback to call when the joystick is touched
  39501. * @param action defines the callback
  39502. */
  39503. setActionOnTouch(action: () => any): void;
  39504. /**
  39505. * Defines which axis you'd like to control for left & right
  39506. * @param axis defines the axis to use
  39507. */
  39508. setAxisForLeftRight(axis: JoystickAxis): void;
  39509. /**
  39510. * Defines which axis you'd like to control for up & down
  39511. * @param axis defines the axis to use
  39512. */
  39513. setAxisForUpDown(axis: JoystickAxis): void;
  39514. private _drawVirtualJoystick;
  39515. /**
  39516. * Release internal HTML canvas
  39517. */
  39518. releaseCanvas(): void;
  39519. }
  39520. }
  39521. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39522. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39523. import { Nullable } from "babylonjs/types";
  39524. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39525. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39526. module "babylonjs/Cameras/freeCameraInputsManager" {
  39527. interface FreeCameraInputsManager {
  39528. /**
  39529. * Add virtual joystick input support to the input manager.
  39530. * @returns the current input manager
  39531. */
  39532. addVirtualJoystick(): FreeCameraInputsManager;
  39533. }
  39534. }
  39535. /**
  39536. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39538. */
  39539. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39540. /**
  39541. * Defines the camera the input is attached to.
  39542. */
  39543. camera: FreeCamera;
  39544. private _leftjoystick;
  39545. private _rightjoystick;
  39546. /**
  39547. * Gets the left stick of the virtual joystick.
  39548. * @returns The virtual Joystick
  39549. */
  39550. getLeftJoystick(): VirtualJoystick;
  39551. /**
  39552. * Gets the right stick of the virtual joystick.
  39553. * @returns The virtual Joystick
  39554. */
  39555. getRightJoystick(): VirtualJoystick;
  39556. /**
  39557. * Update the current camera state depending on the inputs that have been used this frame.
  39558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39559. */
  39560. checkInputs(): void;
  39561. /**
  39562. * Attach the input controls to a specific dom element to get the input from.
  39563. * @param element Defines the element the controls should be listened from
  39564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39565. */
  39566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39567. /**
  39568. * Detach the current controls from the specified dom element.
  39569. * @param element Defines the element to stop listening the inputs from
  39570. */
  39571. detachControl(element: Nullable<HTMLElement>): void;
  39572. /**
  39573. * Gets the class name of the current intput.
  39574. * @returns the class name
  39575. */
  39576. getClassName(): string;
  39577. /**
  39578. * Get the friendly name associated with the input class.
  39579. * @returns the input friendly name
  39580. */
  39581. getSimpleName(): string;
  39582. }
  39583. }
  39584. declare module "babylonjs/Cameras/Inputs/index" {
  39585. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39586. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39587. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39588. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39589. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39590. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39591. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39592. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39593. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39594. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39595. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39596. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39597. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39598. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39599. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39600. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39601. }
  39602. declare module "babylonjs/Cameras/touchCamera" {
  39603. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39604. import { Scene } from "babylonjs/scene";
  39605. import { Vector3 } from "babylonjs/Maths/math.vector";
  39606. /**
  39607. * This represents a FPS type of camera controlled by touch.
  39608. * This is like a universal camera minus the Gamepad controls.
  39609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39610. */
  39611. export class TouchCamera extends FreeCamera {
  39612. /**
  39613. * Defines the touch sensibility for rotation.
  39614. * The higher the faster.
  39615. */
  39616. touchAngularSensibility: number;
  39617. /**
  39618. * Defines the touch sensibility for move.
  39619. * The higher the faster.
  39620. */
  39621. touchMoveSensibility: number;
  39622. /**
  39623. * Instantiates a new touch camera.
  39624. * This represents a FPS type of camera controlled by touch.
  39625. * This is like a universal camera minus the Gamepad controls.
  39626. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39627. * @param name Define the name of the camera in the scene
  39628. * @param position Define the start position of the camera in the scene
  39629. * @param scene Define the scene the camera belongs to
  39630. */
  39631. constructor(name: string, position: Vector3, scene: Scene);
  39632. /**
  39633. * Gets the current object class name.
  39634. * @return the class name
  39635. */
  39636. getClassName(): string;
  39637. /** @hidden */
  39638. _setupInputs(): void;
  39639. }
  39640. }
  39641. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39642. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39643. import { Scene } from "babylonjs/scene";
  39644. import { Vector3 } from "babylonjs/Maths/math.vector";
  39645. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39646. import { Axis } from "babylonjs/Maths/math.axis";
  39647. /**
  39648. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39649. * being tilted forward or back and left or right.
  39650. */
  39651. export class DeviceOrientationCamera extends FreeCamera {
  39652. private _initialQuaternion;
  39653. private _quaternionCache;
  39654. private _tmpDragQuaternion;
  39655. private _disablePointerInputWhenUsingDeviceOrientation;
  39656. /**
  39657. * Creates a new device orientation camera
  39658. * @param name The name of the camera
  39659. * @param position The start position camera
  39660. * @param scene The scene the camera belongs to
  39661. */
  39662. constructor(name: string, position: Vector3, scene: Scene);
  39663. /**
  39664. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39665. */
  39666. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39667. private _dragFactor;
  39668. /**
  39669. * Enabled turning on the y axis when the orientation sensor is active
  39670. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39671. */
  39672. enableHorizontalDragging(dragFactor?: number): void;
  39673. /**
  39674. * Gets the current instance class name ("DeviceOrientationCamera").
  39675. * This helps avoiding instanceof at run time.
  39676. * @returns the class name
  39677. */
  39678. getClassName(): string;
  39679. /**
  39680. * @hidden
  39681. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39682. */
  39683. _checkInputs(): void;
  39684. /**
  39685. * Reset the camera to its default orientation on the specified axis only.
  39686. * @param axis The axis to reset
  39687. */
  39688. resetToCurrentRotation(axis?: Axis): void;
  39689. }
  39690. }
  39691. declare module "babylonjs/Gamepads/xboxGamepad" {
  39692. import { Observable } from "babylonjs/Misc/observable";
  39693. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39694. /**
  39695. * Defines supported buttons for XBox360 compatible gamepads
  39696. */
  39697. export enum Xbox360Button {
  39698. /** A */
  39699. A = 0,
  39700. /** B */
  39701. B = 1,
  39702. /** X */
  39703. X = 2,
  39704. /** Y */
  39705. Y = 3,
  39706. /** Start */
  39707. Start = 4,
  39708. /** Back */
  39709. Back = 5,
  39710. /** Left button */
  39711. LB = 6,
  39712. /** Right button */
  39713. RB = 7,
  39714. /** Left stick */
  39715. LeftStick = 8,
  39716. /** Right stick */
  39717. RightStick = 9
  39718. }
  39719. /** Defines values for XBox360 DPad */
  39720. export enum Xbox360Dpad {
  39721. /** Up */
  39722. Up = 0,
  39723. /** Down */
  39724. Down = 1,
  39725. /** Left */
  39726. Left = 2,
  39727. /** Right */
  39728. Right = 3
  39729. }
  39730. /**
  39731. * Defines a XBox360 gamepad
  39732. */
  39733. export class Xbox360Pad extends Gamepad {
  39734. private _leftTrigger;
  39735. private _rightTrigger;
  39736. private _onlefttriggerchanged;
  39737. private _onrighttriggerchanged;
  39738. private _onbuttondown;
  39739. private _onbuttonup;
  39740. private _ondpaddown;
  39741. private _ondpadup;
  39742. /** Observable raised when a button is pressed */
  39743. onButtonDownObservable: Observable<Xbox360Button>;
  39744. /** Observable raised when a button is released */
  39745. onButtonUpObservable: Observable<Xbox360Button>;
  39746. /** Observable raised when a pad is pressed */
  39747. onPadDownObservable: Observable<Xbox360Dpad>;
  39748. /** Observable raised when a pad is released */
  39749. onPadUpObservable: Observable<Xbox360Dpad>;
  39750. private _buttonA;
  39751. private _buttonB;
  39752. private _buttonX;
  39753. private _buttonY;
  39754. private _buttonBack;
  39755. private _buttonStart;
  39756. private _buttonLB;
  39757. private _buttonRB;
  39758. private _buttonLeftStick;
  39759. private _buttonRightStick;
  39760. private _dPadUp;
  39761. private _dPadDown;
  39762. private _dPadLeft;
  39763. private _dPadRight;
  39764. private _isXboxOnePad;
  39765. /**
  39766. * Creates a new XBox360 gamepad object
  39767. * @param id defines the id of this gamepad
  39768. * @param index defines its index
  39769. * @param gamepad defines the internal HTML gamepad object
  39770. * @param xboxOne defines if it is a XBox One gamepad
  39771. */
  39772. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39773. /**
  39774. * Defines the callback to call when left trigger is pressed
  39775. * @param callback defines the callback to use
  39776. */
  39777. onlefttriggerchanged(callback: (value: number) => void): void;
  39778. /**
  39779. * Defines the callback to call when right trigger is pressed
  39780. * @param callback defines the callback to use
  39781. */
  39782. onrighttriggerchanged(callback: (value: number) => void): void;
  39783. /**
  39784. * Gets the left trigger value
  39785. */
  39786. /**
  39787. * Sets the left trigger value
  39788. */
  39789. leftTrigger: number;
  39790. /**
  39791. * Gets the right trigger value
  39792. */
  39793. /**
  39794. * Sets the right trigger value
  39795. */
  39796. rightTrigger: number;
  39797. /**
  39798. * Defines the callback to call when a button is pressed
  39799. * @param callback defines the callback to use
  39800. */
  39801. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39802. /**
  39803. * Defines the callback to call when a button is released
  39804. * @param callback defines the callback to use
  39805. */
  39806. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39807. /**
  39808. * Defines the callback to call when a pad is pressed
  39809. * @param callback defines the callback to use
  39810. */
  39811. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39812. /**
  39813. * Defines the callback to call when a pad is released
  39814. * @param callback defines the callback to use
  39815. */
  39816. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39817. private _setButtonValue;
  39818. private _setDPadValue;
  39819. /**
  39820. * Gets the value of the `A` button
  39821. */
  39822. /**
  39823. * Sets the value of the `A` button
  39824. */
  39825. buttonA: number;
  39826. /**
  39827. * Gets the value of the `B` button
  39828. */
  39829. /**
  39830. * Sets the value of the `B` button
  39831. */
  39832. buttonB: number;
  39833. /**
  39834. * Gets the value of the `X` button
  39835. */
  39836. /**
  39837. * Sets the value of the `X` button
  39838. */
  39839. buttonX: number;
  39840. /**
  39841. * Gets the value of the `Y` button
  39842. */
  39843. /**
  39844. * Sets the value of the `Y` button
  39845. */
  39846. buttonY: number;
  39847. /**
  39848. * Gets the value of the `Start` button
  39849. */
  39850. /**
  39851. * Sets the value of the `Start` button
  39852. */
  39853. buttonStart: number;
  39854. /**
  39855. * Gets the value of the `Back` button
  39856. */
  39857. /**
  39858. * Sets the value of the `Back` button
  39859. */
  39860. buttonBack: number;
  39861. /**
  39862. * Gets the value of the `Left` button
  39863. */
  39864. /**
  39865. * Sets the value of the `Left` button
  39866. */
  39867. buttonLB: number;
  39868. /**
  39869. * Gets the value of the `Right` button
  39870. */
  39871. /**
  39872. * Sets the value of the `Right` button
  39873. */
  39874. buttonRB: number;
  39875. /**
  39876. * Gets the value of the Left joystick
  39877. */
  39878. /**
  39879. * Sets the value of the Left joystick
  39880. */
  39881. buttonLeftStick: number;
  39882. /**
  39883. * Gets the value of the Right joystick
  39884. */
  39885. /**
  39886. * Sets the value of the Right joystick
  39887. */
  39888. buttonRightStick: number;
  39889. /**
  39890. * Gets the value of D-pad up
  39891. */
  39892. /**
  39893. * Sets the value of D-pad up
  39894. */
  39895. dPadUp: number;
  39896. /**
  39897. * Gets the value of D-pad down
  39898. */
  39899. /**
  39900. * Sets the value of D-pad down
  39901. */
  39902. dPadDown: number;
  39903. /**
  39904. * Gets the value of D-pad left
  39905. */
  39906. /**
  39907. * Sets the value of D-pad left
  39908. */
  39909. dPadLeft: number;
  39910. /**
  39911. * Gets the value of D-pad right
  39912. */
  39913. /**
  39914. * Sets the value of D-pad right
  39915. */
  39916. dPadRight: number;
  39917. /**
  39918. * Force the gamepad to synchronize with device values
  39919. */
  39920. update(): void;
  39921. /**
  39922. * Disposes the gamepad
  39923. */
  39924. dispose(): void;
  39925. }
  39926. }
  39927. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39928. import { Observable } from "babylonjs/Misc/observable";
  39929. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39930. /**
  39931. * Defines supported buttons for DualShock compatible gamepads
  39932. */
  39933. export enum DualShockButton {
  39934. /** Cross */
  39935. Cross = 0,
  39936. /** Circle */
  39937. Circle = 1,
  39938. /** Square */
  39939. Square = 2,
  39940. /** Triangle */
  39941. Triangle = 3,
  39942. /** Options */
  39943. Options = 4,
  39944. /** Share */
  39945. Share = 5,
  39946. /** L1 */
  39947. L1 = 6,
  39948. /** R1 */
  39949. R1 = 7,
  39950. /** Left stick */
  39951. LeftStick = 8,
  39952. /** Right stick */
  39953. RightStick = 9
  39954. }
  39955. /** Defines values for DualShock DPad */
  39956. export enum DualShockDpad {
  39957. /** Up */
  39958. Up = 0,
  39959. /** Down */
  39960. Down = 1,
  39961. /** Left */
  39962. Left = 2,
  39963. /** Right */
  39964. Right = 3
  39965. }
  39966. /**
  39967. * Defines a DualShock gamepad
  39968. */
  39969. export class DualShockPad extends Gamepad {
  39970. private _leftTrigger;
  39971. private _rightTrigger;
  39972. private _onlefttriggerchanged;
  39973. private _onrighttriggerchanged;
  39974. private _onbuttondown;
  39975. private _onbuttonup;
  39976. private _ondpaddown;
  39977. private _ondpadup;
  39978. /** Observable raised when a button is pressed */
  39979. onButtonDownObservable: Observable<DualShockButton>;
  39980. /** Observable raised when a button is released */
  39981. onButtonUpObservable: Observable<DualShockButton>;
  39982. /** Observable raised when a pad is pressed */
  39983. onPadDownObservable: Observable<DualShockDpad>;
  39984. /** Observable raised when a pad is released */
  39985. onPadUpObservable: Observable<DualShockDpad>;
  39986. private _buttonCross;
  39987. private _buttonCircle;
  39988. private _buttonSquare;
  39989. private _buttonTriangle;
  39990. private _buttonShare;
  39991. private _buttonOptions;
  39992. private _buttonL1;
  39993. private _buttonR1;
  39994. private _buttonLeftStick;
  39995. private _buttonRightStick;
  39996. private _dPadUp;
  39997. private _dPadDown;
  39998. private _dPadLeft;
  39999. private _dPadRight;
  40000. /**
  40001. * Creates a new DualShock gamepad object
  40002. * @param id defines the id of this gamepad
  40003. * @param index defines its index
  40004. * @param gamepad defines the internal HTML gamepad object
  40005. */
  40006. constructor(id: string, index: number, gamepad: any);
  40007. /**
  40008. * Defines the callback to call when left trigger is pressed
  40009. * @param callback defines the callback to use
  40010. */
  40011. onlefttriggerchanged(callback: (value: number) => void): void;
  40012. /**
  40013. * Defines the callback to call when right trigger is pressed
  40014. * @param callback defines the callback to use
  40015. */
  40016. onrighttriggerchanged(callback: (value: number) => void): void;
  40017. /**
  40018. * Gets the left trigger value
  40019. */
  40020. /**
  40021. * Sets the left trigger value
  40022. */
  40023. leftTrigger: number;
  40024. /**
  40025. * Gets the right trigger value
  40026. */
  40027. /**
  40028. * Sets the right trigger value
  40029. */
  40030. rightTrigger: number;
  40031. /**
  40032. * Defines the callback to call when a button is pressed
  40033. * @param callback defines the callback to use
  40034. */
  40035. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40036. /**
  40037. * Defines the callback to call when a button is released
  40038. * @param callback defines the callback to use
  40039. */
  40040. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40041. /**
  40042. * Defines the callback to call when a pad is pressed
  40043. * @param callback defines the callback to use
  40044. */
  40045. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40046. /**
  40047. * Defines the callback to call when a pad is released
  40048. * @param callback defines the callback to use
  40049. */
  40050. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40051. private _setButtonValue;
  40052. private _setDPadValue;
  40053. /**
  40054. * Gets the value of the `Cross` button
  40055. */
  40056. /**
  40057. * Sets the value of the `Cross` button
  40058. */
  40059. buttonCross: number;
  40060. /**
  40061. * Gets the value of the `Circle` button
  40062. */
  40063. /**
  40064. * Sets the value of the `Circle` button
  40065. */
  40066. buttonCircle: number;
  40067. /**
  40068. * Gets the value of the `Square` button
  40069. */
  40070. /**
  40071. * Sets the value of the `Square` button
  40072. */
  40073. buttonSquare: number;
  40074. /**
  40075. * Gets the value of the `Triangle` button
  40076. */
  40077. /**
  40078. * Sets the value of the `Triangle` button
  40079. */
  40080. buttonTriangle: number;
  40081. /**
  40082. * Gets the value of the `Options` button
  40083. */
  40084. /**
  40085. * Sets the value of the `Options` button
  40086. */
  40087. buttonOptions: number;
  40088. /**
  40089. * Gets the value of the `Share` button
  40090. */
  40091. /**
  40092. * Sets the value of the `Share` button
  40093. */
  40094. buttonShare: number;
  40095. /**
  40096. * Gets the value of the `L1` button
  40097. */
  40098. /**
  40099. * Sets the value of the `L1` button
  40100. */
  40101. buttonL1: number;
  40102. /**
  40103. * Gets the value of the `R1` button
  40104. */
  40105. /**
  40106. * Sets the value of the `R1` button
  40107. */
  40108. buttonR1: number;
  40109. /**
  40110. * Gets the value of the Left joystick
  40111. */
  40112. /**
  40113. * Sets the value of the Left joystick
  40114. */
  40115. buttonLeftStick: number;
  40116. /**
  40117. * Gets the value of the Right joystick
  40118. */
  40119. /**
  40120. * Sets the value of the Right joystick
  40121. */
  40122. buttonRightStick: number;
  40123. /**
  40124. * Gets the value of D-pad up
  40125. */
  40126. /**
  40127. * Sets the value of D-pad up
  40128. */
  40129. dPadUp: number;
  40130. /**
  40131. * Gets the value of D-pad down
  40132. */
  40133. /**
  40134. * Sets the value of D-pad down
  40135. */
  40136. dPadDown: number;
  40137. /**
  40138. * Gets the value of D-pad left
  40139. */
  40140. /**
  40141. * Sets the value of D-pad left
  40142. */
  40143. dPadLeft: number;
  40144. /**
  40145. * Gets the value of D-pad right
  40146. */
  40147. /**
  40148. * Sets the value of D-pad right
  40149. */
  40150. dPadRight: number;
  40151. /**
  40152. * Force the gamepad to synchronize with device values
  40153. */
  40154. update(): void;
  40155. /**
  40156. * Disposes the gamepad
  40157. */
  40158. dispose(): void;
  40159. }
  40160. }
  40161. declare module "babylonjs/Gamepads/gamepadManager" {
  40162. import { Observable } from "babylonjs/Misc/observable";
  40163. import { Nullable } from "babylonjs/types";
  40164. import { Scene } from "babylonjs/scene";
  40165. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40166. /**
  40167. * Manager for handling gamepads
  40168. */
  40169. export class GamepadManager {
  40170. private _scene?;
  40171. private _babylonGamepads;
  40172. private _oneGamepadConnected;
  40173. /** @hidden */
  40174. _isMonitoring: boolean;
  40175. private _gamepadEventSupported;
  40176. private _gamepadSupport;
  40177. /**
  40178. * observable to be triggered when the gamepad controller has been connected
  40179. */
  40180. onGamepadConnectedObservable: Observable<Gamepad>;
  40181. /**
  40182. * observable to be triggered when the gamepad controller has been disconnected
  40183. */
  40184. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40185. private _onGamepadConnectedEvent;
  40186. private _onGamepadDisconnectedEvent;
  40187. /**
  40188. * Initializes the gamepad manager
  40189. * @param _scene BabylonJS scene
  40190. */
  40191. constructor(_scene?: Scene | undefined);
  40192. /**
  40193. * The gamepads in the game pad manager
  40194. */
  40195. readonly gamepads: Gamepad[];
  40196. /**
  40197. * Get the gamepad controllers based on type
  40198. * @param type The type of gamepad controller
  40199. * @returns Nullable gamepad
  40200. */
  40201. getGamepadByType(type?: number): Nullable<Gamepad>;
  40202. /**
  40203. * Disposes the gamepad manager
  40204. */
  40205. dispose(): void;
  40206. private _addNewGamepad;
  40207. private _startMonitoringGamepads;
  40208. private _stopMonitoringGamepads;
  40209. /** @hidden */
  40210. _checkGamepadsStatus(): void;
  40211. private _updateGamepadObjects;
  40212. }
  40213. }
  40214. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40215. import { Nullable } from "babylonjs/types";
  40216. import { Scene } from "babylonjs/scene";
  40217. import { ISceneComponent } from "babylonjs/sceneComponent";
  40218. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40219. module "babylonjs/scene" {
  40220. interface Scene {
  40221. /** @hidden */
  40222. _gamepadManager: Nullable<GamepadManager>;
  40223. /**
  40224. * Gets the gamepad manager associated with the scene
  40225. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40226. */
  40227. gamepadManager: GamepadManager;
  40228. }
  40229. }
  40230. module "babylonjs/Cameras/freeCameraInputsManager" {
  40231. /**
  40232. * Interface representing a free camera inputs manager
  40233. */
  40234. interface FreeCameraInputsManager {
  40235. /**
  40236. * Adds gamepad input support to the FreeCameraInputsManager.
  40237. * @returns the FreeCameraInputsManager
  40238. */
  40239. addGamepad(): FreeCameraInputsManager;
  40240. }
  40241. }
  40242. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40243. /**
  40244. * Interface representing an arc rotate camera inputs manager
  40245. */
  40246. interface ArcRotateCameraInputsManager {
  40247. /**
  40248. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40249. * @returns the camera inputs manager
  40250. */
  40251. addGamepad(): ArcRotateCameraInputsManager;
  40252. }
  40253. }
  40254. /**
  40255. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40256. */
  40257. export class GamepadSystemSceneComponent implements ISceneComponent {
  40258. /**
  40259. * The component name helpfull to identify the component in the list of scene components.
  40260. */
  40261. readonly name: string;
  40262. /**
  40263. * The scene the component belongs to.
  40264. */
  40265. scene: Scene;
  40266. /**
  40267. * Creates a new instance of the component for the given scene
  40268. * @param scene Defines the scene to register the component in
  40269. */
  40270. constructor(scene: Scene);
  40271. /**
  40272. * Registers the component in a given scene
  40273. */
  40274. register(): void;
  40275. /**
  40276. * Rebuilds the elements related to this component in case of
  40277. * context lost for instance.
  40278. */
  40279. rebuild(): void;
  40280. /**
  40281. * Disposes the component and the associated ressources
  40282. */
  40283. dispose(): void;
  40284. private _beforeCameraUpdate;
  40285. }
  40286. }
  40287. declare module "babylonjs/Cameras/universalCamera" {
  40288. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40289. import { Scene } from "babylonjs/scene";
  40290. import { Vector3 } from "babylonjs/Maths/math.vector";
  40291. import "babylonjs/Gamepads/gamepadSceneComponent";
  40292. /**
  40293. * 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,
  40294. * which still works and will still be found in many Playgrounds.
  40295. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40296. */
  40297. export class UniversalCamera extends TouchCamera {
  40298. /**
  40299. * Defines the gamepad rotation sensiblity.
  40300. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40301. */
  40302. gamepadAngularSensibility: number;
  40303. /**
  40304. * Defines the gamepad move sensiblity.
  40305. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40306. */
  40307. gamepadMoveSensibility: number;
  40308. /**
  40309. * 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,
  40310. * which still works and will still be found in many Playgrounds.
  40311. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40312. * @param name Define the name of the camera in the scene
  40313. * @param position Define the start position of the camera in the scene
  40314. * @param scene Define the scene the camera belongs to
  40315. */
  40316. constructor(name: string, position: Vector3, scene: Scene);
  40317. /**
  40318. * Gets the current object class name.
  40319. * @return the class name
  40320. */
  40321. getClassName(): string;
  40322. }
  40323. }
  40324. declare module "babylonjs/Cameras/gamepadCamera" {
  40325. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40326. import { Scene } from "babylonjs/scene";
  40327. import { Vector3 } from "babylonjs/Maths/math.vector";
  40328. /**
  40329. * This represents a FPS type of camera. This is only here for back compat purpose.
  40330. * Please use the UniversalCamera instead as both are identical.
  40331. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40332. */
  40333. export class GamepadCamera extends UniversalCamera {
  40334. /**
  40335. * Instantiates a new Gamepad Camera
  40336. * This represents a FPS type of camera. This is only here for back compat purpose.
  40337. * Please use the UniversalCamera instead as both are identical.
  40338. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40339. * @param name Define the name of the camera in the scene
  40340. * @param position Define the start position of the camera in the scene
  40341. * @param scene Define the scene the camera belongs to
  40342. */
  40343. constructor(name: string, position: Vector3, scene: Scene);
  40344. /**
  40345. * Gets the current object class name.
  40346. * @return the class name
  40347. */
  40348. getClassName(): string;
  40349. }
  40350. }
  40351. declare module "babylonjs/Shaders/pass.fragment" {
  40352. /** @hidden */
  40353. export var passPixelShader: {
  40354. name: string;
  40355. shader: string;
  40356. };
  40357. }
  40358. declare module "babylonjs/Shaders/passCube.fragment" {
  40359. /** @hidden */
  40360. export var passCubePixelShader: {
  40361. name: string;
  40362. shader: string;
  40363. };
  40364. }
  40365. declare module "babylonjs/PostProcesses/passPostProcess" {
  40366. import { Nullable } from "babylonjs/types";
  40367. import { Camera } from "babylonjs/Cameras/camera";
  40368. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40369. import { Engine } from "babylonjs/Engines/engine";
  40370. import "babylonjs/Shaders/pass.fragment";
  40371. import "babylonjs/Shaders/passCube.fragment";
  40372. /**
  40373. * PassPostProcess which produces an output the same as it's input
  40374. */
  40375. export class PassPostProcess extends PostProcess {
  40376. /**
  40377. * Creates the PassPostProcess
  40378. * @param name The name of the effect.
  40379. * @param options The required width/height ratio to downsize to before computing the render pass.
  40380. * @param camera The camera to apply the render pass to.
  40381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40382. * @param engine The engine which the post process will be applied. (default: current engine)
  40383. * @param reusable If the post process can be reused on the same frame. (default: false)
  40384. * @param textureType The type of texture to be used when performing the post processing.
  40385. * @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)
  40386. */
  40387. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40388. }
  40389. /**
  40390. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40391. */
  40392. export class PassCubePostProcess extends PostProcess {
  40393. private _face;
  40394. /**
  40395. * Gets or sets the cube face to display.
  40396. * * 0 is +X
  40397. * * 1 is -X
  40398. * * 2 is +Y
  40399. * * 3 is -Y
  40400. * * 4 is +Z
  40401. * * 5 is -Z
  40402. */
  40403. face: number;
  40404. /**
  40405. * Creates the PassCubePostProcess
  40406. * @param name The name of the effect.
  40407. * @param options The required width/height ratio to downsize to before computing the render pass.
  40408. * @param camera The camera to apply the render pass to.
  40409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40410. * @param engine The engine which the post process will be applied. (default: current engine)
  40411. * @param reusable If the post process can be reused on the same frame. (default: false)
  40412. * @param textureType The type of texture to be used when performing the post processing.
  40413. * @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)
  40414. */
  40415. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40416. }
  40417. }
  40418. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40419. /** @hidden */
  40420. export var anaglyphPixelShader: {
  40421. name: string;
  40422. shader: string;
  40423. };
  40424. }
  40425. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40426. import { Engine } from "babylonjs/Engines/engine";
  40427. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40428. import { Camera } from "babylonjs/Cameras/camera";
  40429. import "babylonjs/Shaders/anaglyph.fragment";
  40430. /**
  40431. * Postprocess used to generate anaglyphic rendering
  40432. */
  40433. export class AnaglyphPostProcess extends PostProcess {
  40434. private _passedProcess;
  40435. /**
  40436. * Creates a new AnaglyphPostProcess
  40437. * @param name defines postprocess name
  40438. * @param options defines creation options or target ratio scale
  40439. * @param rigCameras defines cameras using this postprocess
  40440. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40441. * @param engine defines hosting engine
  40442. * @param reusable defines if the postprocess will be reused multiple times per frame
  40443. */
  40444. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40445. }
  40446. }
  40447. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40448. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40449. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40450. import { Scene } from "babylonjs/scene";
  40451. import { Vector3 } from "babylonjs/Maths/math.vector";
  40452. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40453. /**
  40454. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40455. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40456. */
  40457. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40458. /**
  40459. * Creates a new AnaglyphArcRotateCamera
  40460. * @param name defines camera name
  40461. * @param alpha defines alpha angle (in radians)
  40462. * @param beta defines beta angle (in radians)
  40463. * @param radius defines radius
  40464. * @param target defines camera target
  40465. * @param interaxialDistance defines distance between each color axis
  40466. * @param scene defines the hosting scene
  40467. */
  40468. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40469. /**
  40470. * Gets camera class name
  40471. * @returns AnaglyphArcRotateCamera
  40472. */
  40473. getClassName(): string;
  40474. }
  40475. }
  40476. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40477. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40478. import { Scene } from "babylonjs/scene";
  40479. import { Vector3 } from "babylonjs/Maths/math.vector";
  40480. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40481. /**
  40482. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40483. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40484. */
  40485. export class AnaglyphFreeCamera extends FreeCamera {
  40486. /**
  40487. * Creates a new AnaglyphFreeCamera
  40488. * @param name defines camera name
  40489. * @param position defines initial position
  40490. * @param interaxialDistance defines distance between each color axis
  40491. * @param scene defines the hosting scene
  40492. */
  40493. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40494. /**
  40495. * Gets camera class name
  40496. * @returns AnaglyphFreeCamera
  40497. */
  40498. getClassName(): string;
  40499. }
  40500. }
  40501. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40502. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40503. import { Scene } from "babylonjs/scene";
  40504. import { Vector3 } from "babylonjs/Maths/math.vector";
  40505. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40506. /**
  40507. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40508. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40509. */
  40510. export class AnaglyphGamepadCamera extends GamepadCamera {
  40511. /**
  40512. * Creates a new AnaglyphGamepadCamera
  40513. * @param name defines camera name
  40514. * @param position defines initial position
  40515. * @param interaxialDistance defines distance between each color axis
  40516. * @param scene defines the hosting scene
  40517. */
  40518. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40519. /**
  40520. * Gets camera class name
  40521. * @returns AnaglyphGamepadCamera
  40522. */
  40523. getClassName(): string;
  40524. }
  40525. }
  40526. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40527. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40528. import { Scene } from "babylonjs/scene";
  40529. import { Vector3 } from "babylonjs/Maths/math.vector";
  40530. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40531. /**
  40532. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40533. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40534. */
  40535. export class AnaglyphUniversalCamera extends UniversalCamera {
  40536. /**
  40537. * Creates a new AnaglyphUniversalCamera
  40538. * @param name defines camera name
  40539. * @param position defines initial position
  40540. * @param interaxialDistance defines distance between each color axis
  40541. * @param scene defines the hosting scene
  40542. */
  40543. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40544. /**
  40545. * Gets camera class name
  40546. * @returns AnaglyphUniversalCamera
  40547. */
  40548. getClassName(): string;
  40549. }
  40550. }
  40551. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40552. /** @hidden */
  40553. export var stereoscopicInterlacePixelShader: {
  40554. name: string;
  40555. shader: string;
  40556. };
  40557. }
  40558. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40559. import { Camera } from "babylonjs/Cameras/camera";
  40560. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40561. import { Engine } from "babylonjs/Engines/engine";
  40562. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40563. /**
  40564. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40565. */
  40566. export class StereoscopicInterlacePostProcess extends PostProcess {
  40567. private _stepSize;
  40568. private _passedProcess;
  40569. /**
  40570. * Initializes a StereoscopicInterlacePostProcess
  40571. * @param name The name of the effect.
  40572. * @param rigCameras The rig cameras to be appled to the post process
  40573. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40575. * @param engine The engine which the post process will be applied. (default: current engine)
  40576. * @param reusable If the post process can be reused on the same frame. (default: false)
  40577. */
  40578. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40579. }
  40580. }
  40581. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40582. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40583. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40584. import { Scene } from "babylonjs/scene";
  40585. import { Vector3 } from "babylonjs/Maths/math.vector";
  40586. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40587. /**
  40588. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40589. * @see http://doc.babylonjs.com/features/cameras
  40590. */
  40591. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40592. /**
  40593. * Creates a new StereoscopicArcRotateCamera
  40594. * @param name defines camera name
  40595. * @param alpha defines alpha angle (in radians)
  40596. * @param beta defines beta angle (in radians)
  40597. * @param radius defines radius
  40598. * @param target defines camera target
  40599. * @param interaxialDistance defines distance between each color axis
  40600. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40601. * @param scene defines the hosting scene
  40602. */
  40603. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40604. /**
  40605. * Gets camera class name
  40606. * @returns StereoscopicArcRotateCamera
  40607. */
  40608. getClassName(): string;
  40609. }
  40610. }
  40611. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40612. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40613. import { Scene } from "babylonjs/scene";
  40614. import { Vector3 } from "babylonjs/Maths/math.vector";
  40615. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40616. /**
  40617. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40618. * @see http://doc.babylonjs.com/features/cameras
  40619. */
  40620. export class StereoscopicFreeCamera extends FreeCamera {
  40621. /**
  40622. * Creates a new StereoscopicFreeCamera
  40623. * @param name defines camera name
  40624. * @param position defines initial position
  40625. * @param interaxialDistance defines distance between each color axis
  40626. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40627. * @param scene defines the hosting scene
  40628. */
  40629. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40630. /**
  40631. * Gets camera class name
  40632. * @returns StereoscopicFreeCamera
  40633. */
  40634. getClassName(): string;
  40635. }
  40636. }
  40637. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40638. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40639. import { Scene } from "babylonjs/scene";
  40640. import { Vector3 } from "babylonjs/Maths/math.vector";
  40641. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40642. /**
  40643. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40644. * @see http://doc.babylonjs.com/features/cameras
  40645. */
  40646. export class StereoscopicGamepadCamera extends GamepadCamera {
  40647. /**
  40648. * Creates a new StereoscopicGamepadCamera
  40649. * @param name defines camera name
  40650. * @param position defines initial position
  40651. * @param interaxialDistance defines distance between each color axis
  40652. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40653. * @param scene defines the hosting scene
  40654. */
  40655. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40656. /**
  40657. * Gets camera class name
  40658. * @returns StereoscopicGamepadCamera
  40659. */
  40660. getClassName(): string;
  40661. }
  40662. }
  40663. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40664. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40665. import { Scene } from "babylonjs/scene";
  40666. import { Vector3 } from "babylonjs/Maths/math.vector";
  40667. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40668. /**
  40669. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40670. * @see http://doc.babylonjs.com/features/cameras
  40671. */
  40672. export class StereoscopicUniversalCamera extends UniversalCamera {
  40673. /**
  40674. * Creates a new StereoscopicUniversalCamera
  40675. * @param name defines camera name
  40676. * @param position defines initial position
  40677. * @param interaxialDistance defines distance between each color axis
  40678. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40679. * @param scene defines the hosting scene
  40680. */
  40681. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40682. /**
  40683. * Gets camera class name
  40684. * @returns StereoscopicUniversalCamera
  40685. */
  40686. getClassName(): string;
  40687. }
  40688. }
  40689. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40690. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40691. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40692. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40693. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40694. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40695. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40696. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40697. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40698. }
  40699. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40700. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40701. import { Scene } from "babylonjs/scene";
  40702. import { Vector3 } from "babylonjs/Maths/math.vector";
  40703. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40704. /**
  40705. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40706. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40707. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40708. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40709. */
  40710. export class VirtualJoysticksCamera extends FreeCamera {
  40711. /**
  40712. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40713. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40714. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40715. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40716. * @param name Define the name of the camera in the scene
  40717. * @param position Define the start position of the camera in the scene
  40718. * @param scene Define the scene the camera belongs to
  40719. */
  40720. constructor(name: string, position: Vector3, scene: Scene);
  40721. /**
  40722. * Gets the current object class name.
  40723. * @return the class name
  40724. */
  40725. getClassName(): string;
  40726. }
  40727. }
  40728. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40729. import { Matrix } from "babylonjs/Maths/math.vector";
  40730. /**
  40731. * This represents all the required metrics to create a VR camera.
  40732. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40733. */
  40734. export class VRCameraMetrics {
  40735. /**
  40736. * Define the horizontal resolution off the screen.
  40737. */
  40738. hResolution: number;
  40739. /**
  40740. * Define the vertical resolution off the screen.
  40741. */
  40742. vResolution: number;
  40743. /**
  40744. * Define the horizontal screen size.
  40745. */
  40746. hScreenSize: number;
  40747. /**
  40748. * Define the vertical screen size.
  40749. */
  40750. vScreenSize: number;
  40751. /**
  40752. * Define the vertical screen center position.
  40753. */
  40754. vScreenCenter: number;
  40755. /**
  40756. * Define the distance of the eyes to the screen.
  40757. */
  40758. eyeToScreenDistance: number;
  40759. /**
  40760. * Define the distance between both lenses
  40761. */
  40762. lensSeparationDistance: number;
  40763. /**
  40764. * Define the distance between both viewer's eyes.
  40765. */
  40766. interpupillaryDistance: number;
  40767. /**
  40768. * Define the distortion factor of the VR postprocess.
  40769. * Please, touch with care.
  40770. */
  40771. distortionK: number[];
  40772. /**
  40773. * Define the chromatic aberration correction factors for the VR post process.
  40774. */
  40775. chromaAbCorrection: number[];
  40776. /**
  40777. * Define the scale factor of the post process.
  40778. * The smaller the better but the slower.
  40779. */
  40780. postProcessScaleFactor: number;
  40781. /**
  40782. * Define an offset for the lens center.
  40783. */
  40784. lensCenterOffset: number;
  40785. /**
  40786. * Define if the current vr camera should compensate the distortion of the lense or not.
  40787. */
  40788. compensateDistortion: boolean;
  40789. /**
  40790. * Defines if multiview should be enabled when rendering (Default: false)
  40791. */
  40792. multiviewEnabled: boolean;
  40793. /**
  40794. * Gets the rendering aspect ratio based on the provided resolutions.
  40795. */
  40796. readonly aspectRatio: number;
  40797. /**
  40798. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40799. */
  40800. readonly aspectRatioFov: number;
  40801. /**
  40802. * @hidden
  40803. */
  40804. readonly leftHMatrix: Matrix;
  40805. /**
  40806. * @hidden
  40807. */
  40808. readonly rightHMatrix: Matrix;
  40809. /**
  40810. * @hidden
  40811. */
  40812. readonly leftPreViewMatrix: Matrix;
  40813. /**
  40814. * @hidden
  40815. */
  40816. readonly rightPreViewMatrix: Matrix;
  40817. /**
  40818. * Get the default VRMetrics based on the most generic setup.
  40819. * @returns the default vr metrics
  40820. */
  40821. static GetDefault(): VRCameraMetrics;
  40822. }
  40823. }
  40824. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40825. /** @hidden */
  40826. export var vrDistortionCorrectionPixelShader: {
  40827. name: string;
  40828. shader: string;
  40829. };
  40830. }
  40831. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40832. import { Camera } from "babylonjs/Cameras/camera";
  40833. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40834. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40835. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40836. /**
  40837. * VRDistortionCorrectionPostProcess used for mobile VR
  40838. */
  40839. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40840. private _isRightEye;
  40841. private _distortionFactors;
  40842. private _postProcessScaleFactor;
  40843. private _lensCenterOffset;
  40844. private _scaleIn;
  40845. private _scaleFactor;
  40846. private _lensCenter;
  40847. /**
  40848. * Initializes the VRDistortionCorrectionPostProcess
  40849. * @param name The name of the effect.
  40850. * @param camera The camera to apply the render pass to.
  40851. * @param isRightEye If this is for the right eye distortion
  40852. * @param vrMetrics All the required metrics for the VR camera
  40853. */
  40854. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40855. }
  40856. }
  40857. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40858. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40859. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40860. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40861. import { Scene } from "babylonjs/scene";
  40862. import { Vector3 } from "babylonjs/Maths/math.vector";
  40863. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40864. import "babylonjs/Cameras/RigModes/vrRigMode";
  40865. /**
  40866. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40867. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40868. */
  40869. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40870. /**
  40871. * Creates a new VRDeviceOrientationArcRotateCamera
  40872. * @param name defines camera name
  40873. * @param alpha defines the camera rotation along the logitudinal axis
  40874. * @param beta defines the camera rotation along the latitudinal axis
  40875. * @param radius defines the camera distance from its target
  40876. * @param target defines the camera target
  40877. * @param scene defines the scene the camera belongs to
  40878. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40879. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40880. */
  40881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40882. /**
  40883. * Gets camera class name
  40884. * @returns VRDeviceOrientationArcRotateCamera
  40885. */
  40886. getClassName(): string;
  40887. }
  40888. }
  40889. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40890. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40891. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40892. import { Scene } from "babylonjs/scene";
  40893. import { Vector3 } from "babylonjs/Maths/math.vector";
  40894. import "babylonjs/Cameras/RigModes/vrRigMode";
  40895. /**
  40896. * Camera used to simulate VR rendering (based on FreeCamera)
  40897. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40898. */
  40899. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40900. /**
  40901. * Creates a new VRDeviceOrientationFreeCamera
  40902. * @param name defines camera name
  40903. * @param position defines the start position of the camera
  40904. * @param scene defines the scene the camera belongs to
  40905. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40906. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40907. */
  40908. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40909. /**
  40910. * Gets camera class name
  40911. * @returns VRDeviceOrientationFreeCamera
  40912. */
  40913. getClassName(): string;
  40914. }
  40915. }
  40916. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40917. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40918. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40919. import { Scene } from "babylonjs/scene";
  40920. import { Vector3 } from "babylonjs/Maths/math.vector";
  40921. import "babylonjs/Gamepads/gamepadSceneComponent";
  40922. /**
  40923. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40924. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40925. */
  40926. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40927. /**
  40928. * Creates a new VRDeviceOrientationGamepadCamera
  40929. * @param name defines camera name
  40930. * @param position defines the start position of the camera
  40931. * @param scene defines the scene the camera belongs to
  40932. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40933. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40934. */
  40935. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40936. /**
  40937. * Gets camera class name
  40938. * @returns VRDeviceOrientationGamepadCamera
  40939. */
  40940. getClassName(): string;
  40941. }
  40942. }
  40943. declare module "babylonjs/Materials/pushMaterial" {
  40944. import { Nullable } from "babylonjs/types";
  40945. import { Scene } from "babylonjs/scene";
  40946. import { Matrix } from "babylonjs/Maths/math.vector";
  40947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40948. import { Mesh } from "babylonjs/Meshes/mesh";
  40949. import { Material } from "babylonjs/Materials/material";
  40950. import { Effect } from "babylonjs/Materials/effect";
  40951. /**
  40952. * Base class of materials working in push mode in babylon JS
  40953. * @hidden
  40954. */
  40955. export class PushMaterial extends Material {
  40956. protected _activeEffect: Effect;
  40957. protected _normalMatrix: Matrix;
  40958. /**
  40959. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40960. * This means that the material can keep using a previous shader while a new one is being compiled.
  40961. * This is mostly used when shader parallel compilation is supported (true by default)
  40962. */
  40963. allowShaderHotSwapping: boolean;
  40964. constructor(name: string, scene: Scene);
  40965. getEffect(): Effect;
  40966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40967. /**
  40968. * Binds the given world matrix to the active effect
  40969. *
  40970. * @param world the matrix to bind
  40971. */
  40972. bindOnlyWorldMatrix(world: Matrix): void;
  40973. /**
  40974. * Binds the given normal matrix to the active effect
  40975. *
  40976. * @param normalMatrix the matrix to bind
  40977. */
  40978. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40979. bind(world: Matrix, mesh?: Mesh): void;
  40980. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40981. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40982. }
  40983. }
  40984. declare module "babylonjs/Materials/materialFlags" {
  40985. /**
  40986. * This groups all the flags used to control the materials channel.
  40987. */
  40988. export class MaterialFlags {
  40989. private static _DiffuseTextureEnabled;
  40990. /**
  40991. * Are diffuse textures enabled in the application.
  40992. */
  40993. static DiffuseTextureEnabled: boolean;
  40994. private static _AmbientTextureEnabled;
  40995. /**
  40996. * Are ambient textures enabled in the application.
  40997. */
  40998. static AmbientTextureEnabled: boolean;
  40999. private static _OpacityTextureEnabled;
  41000. /**
  41001. * Are opacity textures enabled in the application.
  41002. */
  41003. static OpacityTextureEnabled: boolean;
  41004. private static _ReflectionTextureEnabled;
  41005. /**
  41006. * Are reflection textures enabled in the application.
  41007. */
  41008. static ReflectionTextureEnabled: boolean;
  41009. private static _EmissiveTextureEnabled;
  41010. /**
  41011. * Are emissive textures enabled in the application.
  41012. */
  41013. static EmissiveTextureEnabled: boolean;
  41014. private static _SpecularTextureEnabled;
  41015. /**
  41016. * Are specular textures enabled in the application.
  41017. */
  41018. static SpecularTextureEnabled: boolean;
  41019. private static _BumpTextureEnabled;
  41020. /**
  41021. * Are bump textures enabled in the application.
  41022. */
  41023. static BumpTextureEnabled: boolean;
  41024. private static _LightmapTextureEnabled;
  41025. /**
  41026. * Are lightmap textures enabled in the application.
  41027. */
  41028. static LightmapTextureEnabled: boolean;
  41029. private static _RefractionTextureEnabled;
  41030. /**
  41031. * Are refraction textures enabled in the application.
  41032. */
  41033. static RefractionTextureEnabled: boolean;
  41034. private static _ColorGradingTextureEnabled;
  41035. /**
  41036. * Are color grading textures enabled in the application.
  41037. */
  41038. static ColorGradingTextureEnabled: boolean;
  41039. private static _FresnelEnabled;
  41040. /**
  41041. * Are fresnels enabled in the application.
  41042. */
  41043. static FresnelEnabled: boolean;
  41044. private static _ClearCoatTextureEnabled;
  41045. /**
  41046. * Are clear coat textures enabled in the application.
  41047. */
  41048. static ClearCoatTextureEnabled: boolean;
  41049. private static _ClearCoatBumpTextureEnabled;
  41050. /**
  41051. * Are clear coat bump textures enabled in the application.
  41052. */
  41053. static ClearCoatBumpTextureEnabled: boolean;
  41054. private static _ClearCoatTintTextureEnabled;
  41055. /**
  41056. * Are clear coat tint textures enabled in the application.
  41057. */
  41058. static ClearCoatTintTextureEnabled: boolean;
  41059. private static _SheenTextureEnabled;
  41060. /**
  41061. * Are sheen textures enabled in the application.
  41062. */
  41063. static SheenTextureEnabled: boolean;
  41064. private static _AnisotropicTextureEnabled;
  41065. /**
  41066. * Are anisotropic textures enabled in the application.
  41067. */
  41068. static AnisotropicTextureEnabled: boolean;
  41069. private static _ThicknessTextureEnabled;
  41070. /**
  41071. * Are thickness textures enabled in the application.
  41072. */
  41073. static ThicknessTextureEnabled: boolean;
  41074. }
  41075. }
  41076. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41077. /** @hidden */
  41078. export var defaultFragmentDeclaration: {
  41079. name: string;
  41080. shader: string;
  41081. };
  41082. }
  41083. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41084. /** @hidden */
  41085. export var defaultUboDeclaration: {
  41086. name: string;
  41087. shader: string;
  41088. };
  41089. }
  41090. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41091. /** @hidden */
  41092. export var lightFragmentDeclaration: {
  41093. name: string;
  41094. shader: string;
  41095. };
  41096. }
  41097. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41098. /** @hidden */
  41099. export var lightUboDeclaration: {
  41100. name: string;
  41101. shader: string;
  41102. };
  41103. }
  41104. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41105. /** @hidden */
  41106. export var lightsFragmentFunctions: {
  41107. name: string;
  41108. shader: string;
  41109. };
  41110. }
  41111. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41112. /** @hidden */
  41113. export var shadowsFragmentFunctions: {
  41114. name: string;
  41115. shader: string;
  41116. };
  41117. }
  41118. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41119. /** @hidden */
  41120. export var fresnelFunction: {
  41121. name: string;
  41122. shader: string;
  41123. };
  41124. }
  41125. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41126. /** @hidden */
  41127. export var reflectionFunction: {
  41128. name: string;
  41129. shader: string;
  41130. };
  41131. }
  41132. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41133. /** @hidden */
  41134. export var bumpFragmentFunctions: {
  41135. name: string;
  41136. shader: string;
  41137. };
  41138. }
  41139. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41140. /** @hidden */
  41141. export var logDepthDeclaration: {
  41142. name: string;
  41143. shader: string;
  41144. };
  41145. }
  41146. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41147. /** @hidden */
  41148. export var bumpFragment: {
  41149. name: string;
  41150. shader: string;
  41151. };
  41152. }
  41153. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41154. /** @hidden */
  41155. export var depthPrePass: {
  41156. name: string;
  41157. shader: string;
  41158. };
  41159. }
  41160. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41161. /** @hidden */
  41162. export var lightFragment: {
  41163. name: string;
  41164. shader: string;
  41165. };
  41166. }
  41167. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41168. /** @hidden */
  41169. export var logDepthFragment: {
  41170. name: string;
  41171. shader: string;
  41172. };
  41173. }
  41174. declare module "babylonjs/Shaders/default.fragment" {
  41175. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41176. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41177. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41178. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41179. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41180. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41181. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41182. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41183. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41184. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41185. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41186. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41187. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41188. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41189. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41190. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41191. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41192. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41193. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41194. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41195. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41196. /** @hidden */
  41197. export var defaultPixelShader: {
  41198. name: string;
  41199. shader: string;
  41200. };
  41201. }
  41202. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41203. /** @hidden */
  41204. export var defaultVertexDeclaration: {
  41205. name: string;
  41206. shader: string;
  41207. };
  41208. }
  41209. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41210. /** @hidden */
  41211. export var bumpVertexDeclaration: {
  41212. name: string;
  41213. shader: string;
  41214. };
  41215. }
  41216. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41217. /** @hidden */
  41218. export var bumpVertex: {
  41219. name: string;
  41220. shader: string;
  41221. };
  41222. }
  41223. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41224. /** @hidden */
  41225. export var fogVertex: {
  41226. name: string;
  41227. shader: string;
  41228. };
  41229. }
  41230. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41231. /** @hidden */
  41232. export var shadowsVertex: {
  41233. name: string;
  41234. shader: string;
  41235. };
  41236. }
  41237. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41238. /** @hidden */
  41239. export var pointCloudVertex: {
  41240. name: string;
  41241. shader: string;
  41242. };
  41243. }
  41244. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41245. /** @hidden */
  41246. export var logDepthVertex: {
  41247. name: string;
  41248. shader: string;
  41249. };
  41250. }
  41251. declare module "babylonjs/Shaders/default.vertex" {
  41252. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41253. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41254. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41255. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41256. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41257. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41258. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41259. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41260. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41261. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41262. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41263. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41264. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41266. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41267. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41268. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41269. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41270. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41271. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41272. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41273. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41274. /** @hidden */
  41275. export var defaultVertexShader: {
  41276. name: string;
  41277. shader: string;
  41278. };
  41279. }
  41280. declare module "babylonjs/Materials/standardMaterial" {
  41281. import { SmartArray } from "babylonjs/Misc/smartArray";
  41282. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41283. import { Nullable } from "babylonjs/types";
  41284. import { Scene } from "babylonjs/scene";
  41285. import { Matrix } from "babylonjs/Maths/math.vector";
  41286. import { Color3 } from "babylonjs/Maths/math.color";
  41287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41289. import { Mesh } from "babylonjs/Meshes/mesh";
  41290. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41291. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41292. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41293. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41294. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41295. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41296. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41297. import "babylonjs/Shaders/default.fragment";
  41298. import "babylonjs/Shaders/default.vertex";
  41299. /** @hidden */
  41300. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41301. MAINUV1: boolean;
  41302. MAINUV2: boolean;
  41303. DIFFUSE: boolean;
  41304. DIFFUSEDIRECTUV: number;
  41305. AMBIENT: boolean;
  41306. AMBIENTDIRECTUV: number;
  41307. OPACITY: boolean;
  41308. OPACITYDIRECTUV: number;
  41309. OPACITYRGB: boolean;
  41310. REFLECTION: boolean;
  41311. EMISSIVE: boolean;
  41312. EMISSIVEDIRECTUV: number;
  41313. SPECULAR: boolean;
  41314. SPECULARDIRECTUV: number;
  41315. BUMP: boolean;
  41316. BUMPDIRECTUV: number;
  41317. PARALLAX: boolean;
  41318. PARALLAXOCCLUSION: boolean;
  41319. SPECULAROVERALPHA: boolean;
  41320. CLIPPLANE: boolean;
  41321. CLIPPLANE2: boolean;
  41322. CLIPPLANE3: boolean;
  41323. CLIPPLANE4: boolean;
  41324. ALPHATEST: boolean;
  41325. DEPTHPREPASS: boolean;
  41326. ALPHAFROMDIFFUSE: boolean;
  41327. POINTSIZE: boolean;
  41328. FOG: boolean;
  41329. SPECULARTERM: boolean;
  41330. DIFFUSEFRESNEL: boolean;
  41331. OPACITYFRESNEL: boolean;
  41332. REFLECTIONFRESNEL: boolean;
  41333. REFRACTIONFRESNEL: boolean;
  41334. EMISSIVEFRESNEL: boolean;
  41335. FRESNEL: boolean;
  41336. NORMAL: boolean;
  41337. UV1: boolean;
  41338. UV2: boolean;
  41339. VERTEXCOLOR: boolean;
  41340. VERTEXALPHA: boolean;
  41341. NUM_BONE_INFLUENCERS: number;
  41342. BonesPerMesh: number;
  41343. BONETEXTURE: boolean;
  41344. INSTANCES: boolean;
  41345. GLOSSINESS: boolean;
  41346. ROUGHNESS: boolean;
  41347. EMISSIVEASILLUMINATION: boolean;
  41348. LINKEMISSIVEWITHDIFFUSE: boolean;
  41349. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41350. LIGHTMAP: boolean;
  41351. LIGHTMAPDIRECTUV: number;
  41352. OBJECTSPACE_NORMALMAP: boolean;
  41353. USELIGHTMAPASSHADOWMAP: boolean;
  41354. REFLECTIONMAP_3D: boolean;
  41355. REFLECTIONMAP_SPHERICAL: boolean;
  41356. REFLECTIONMAP_PLANAR: boolean;
  41357. REFLECTIONMAP_CUBIC: boolean;
  41358. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41359. REFLECTIONMAP_PROJECTION: boolean;
  41360. REFLECTIONMAP_SKYBOX: boolean;
  41361. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41362. REFLECTIONMAP_EXPLICIT: boolean;
  41363. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41364. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41365. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41366. INVERTCUBICMAP: boolean;
  41367. LOGARITHMICDEPTH: boolean;
  41368. REFRACTION: boolean;
  41369. REFRACTIONMAP_3D: boolean;
  41370. REFLECTIONOVERALPHA: boolean;
  41371. TWOSIDEDLIGHTING: boolean;
  41372. SHADOWFLOAT: boolean;
  41373. MORPHTARGETS: boolean;
  41374. MORPHTARGETS_NORMAL: boolean;
  41375. MORPHTARGETS_TANGENT: boolean;
  41376. MORPHTARGETS_UV: boolean;
  41377. NUM_MORPH_INFLUENCERS: number;
  41378. NONUNIFORMSCALING: boolean;
  41379. PREMULTIPLYALPHA: boolean;
  41380. IMAGEPROCESSING: boolean;
  41381. VIGNETTE: boolean;
  41382. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41383. VIGNETTEBLENDMODEOPAQUE: boolean;
  41384. TONEMAPPING: boolean;
  41385. TONEMAPPING_ACES: boolean;
  41386. CONTRAST: boolean;
  41387. COLORCURVES: boolean;
  41388. COLORGRADING: boolean;
  41389. COLORGRADING3D: boolean;
  41390. SAMPLER3DGREENDEPTH: boolean;
  41391. SAMPLER3DBGRMAP: boolean;
  41392. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41393. MULTIVIEW: boolean;
  41394. /**
  41395. * If the reflection texture on this material is in linear color space
  41396. * @hidden
  41397. */
  41398. IS_REFLECTION_LINEAR: boolean;
  41399. /**
  41400. * If the refraction texture on this material is in linear color space
  41401. * @hidden
  41402. */
  41403. IS_REFRACTION_LINEAR: boolean;
  41404. EXPOSURE: boolean;
  41405. constructor();
  41406. setReflectionMode(modeToEnable: string): void;
  41407. }
  41408. /**
  41409. * This is the default material used in Babylon. It is the best trade off between quality
  41410. * and performances.
  41411. * @see http://doc.babylonjs.com/babylon101/materials
  41412. */
  41413. export class StandardMaterial extends PushMaterial {
  41414. private _diffuseTexture;
  41415. /**
  41416. * The basic texture of the material as viewed under a light.
  41417. */
  41418. diffuseTexture: Nullable<BaseTexture>;
  41419. private _ambientTexture;
  41420. /**
  41421. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41422. */
  41423. ambientTexture: Nullable<BaseTexture>;
  41424. private _opacityTexture;
  41425. /**
  41426. * Define the transparency of the material from a texture.
  41427. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41428. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41429. */
  41430. opacityTexture: Nullable<BaseTexture>;
  41431. private _reflectionTexture;
  41432. /**
  41433. * Define the texture used to display the reflection.
  41434. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41435. */
  41436. reflectionTexture: Nullable<BaseTexture>;
  41437. private _emissiveTexture;
  41438. /**
  41439. * Define texture of the material as if self lit.
  41440. * This will be mixed in the final result even in the absence of light.
  41441. */
  41442. emissiveTexture: Nullable<BaseTexture>;
  41443. private _specularTexture;
  41444. /**
  41445. * Define how the color and intensity of the highlight given by the light in the material.
  41446. */
  41447. specularTexture: Nullable<BaseTexture>;
  41448. private _bumpTexture;
  41449. /**
  41450. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41451. * 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.
  41452. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41453. */
  41454. bumpTexture: Nullable<BaseTexture>;
  41455. private _lightmapTexture;
  41456. /**
  41457. * Complex lighting can be computationally expensive to compute at runtime.
  41458. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41459. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41460. */
  41461. lightmapTexture: Nullable<BaseTexture>;
  41462. private _refractionTexture;
  41463. /**
  41464. * Define the texture used to display the refraction.
  41465. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41466. */
  41467. refractionTexture: Nullable<BaseTexture>;
  41468. /**
  41469. * The color of the material lit by the environmental background lighting.
  41470. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41471. */
  41472. ambientColor: Color3;
  41473. /**
  41474. * The basic color of the material as viewed under a light.
  41475. */
  41476. diffuseColor: Color3;
  41477. /**
  41478. * Define how the color and intensity of the highlight given by the light in the material.
  41479. */
  41480. specularColor: Color3;
  41481. /**
  41482. * Define the color of the material as if self lit.
  41483. * This will be mixed in the final result even in the absence of light.
  41484. */
  41485. emissiveColor: Color3;
  41486. /**
  41487. * Defines how sharp are the highlights in the material.
  41488. * The bigger the value the sharper giving a more glossy feeling to the result.
  41489. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41490. */
  41491. specularPower: number;
  41492. private _useAlphaFromDiffuseTexture;
  41493. /**
  41494. * Does the transparency come from the diffuse texture alpha channel.
  41495. */
  41496. useAlphaFromDiffuseTexture: boolean;
  41497. private _useEmissiveAsIllumination;
  41498. /**
  41499. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41500. */
  41501. useEmissiveAsIllumination: boolean;
  41502. private _linkEmissiveWithDiffuse;
  41503. /**
  41504. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41505. * the emissive level when the final color is close to one.
  41506. */
  41507. linkEmissiveWithDiffuse: boolean;
  41508. private _useSpecularOverAlpha;
  41509. /**
  41510. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41511. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41512. */
  41513. useSpecularOverAlpha: boolean;
  41514. private _useReflectionOverAlpha;
  41515. /**
  41516. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41517. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41518. */
  41519. useReflectionOverAlpha: boolean;
  41520. private _disableLighting;
  41521. /**
  41522. * Does lights from the scene impacts this material.
  41523. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41524. */
  41525. disableLighting: boolean;
  41526. private _useObjectSpaceNormalMap;
  41527. /**
  41528. * Allows using an object space normal map (instead of tangent space).
  41529. */
  41530. useObjectSpaceNormalMap: boolean;
  41531. private _useParallax;
  41532. /**
  41533. * Is parallax enabled or not.
  41534. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41535. */
  41536. useParallax: boolean;
  41537. private _useParallaxOcclusion;
  41538. /**
  41539. * Is parallax occlusion enabled or not.
  41540. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41541. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41542. */
  41543. useParallaxOcclusion: boolean;
  41544. /**
  41545. * 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.
  41546. */
  41547. parallaxScaleBias: number;
  41548. private _roughness;
  41549. /**
  41550. * Helps to define how blurry the reflections should appears in the material.
  41551. */
  41552. roughness: number;
  41553. /**
  41554. * In case of refraction, define the value of the index of refraction.
  41555. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41556. */
  41557. indexOfRefraction: number;
  41558. /**
  41559. * Invert the refraction texture alongside the y axis.
  41560. * It can be useful with procedural textures or probe for instance.
  41561. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41562. */
  41563. invertRefractionY: boolean;
  41564. /**
  41565. * Defines the alpha limits in alpha test mode.
  41566. */
  41567. alphaCutOff: number;
  41568. private _useLightmapAsShadowmap;
  41569. /**
  41570. * In case of light mapping, define whether the map contains light or shadow informations.
  41571. */
  41572. useLightmapAsShadowmap: boolean;
  41573. private _diffuseFresnelParameters;
  41574. /**
  41575. * Define the diffuse fresnel parameters of the material.
  41576. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41577. */
  41578. diffuseFresnelParameters: FresnelParameters;
  41579. private _opacityFresnelParameters;
  41580. /**
  41581. * Define the opacity fresnel parameters of the material.
  41582. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41583. */
  41584. opacityFresnelParameters: FresnelParameters;
  41585. private _reflectionFresnelParameters;
  41586. /**
  41587. * Define the reflection fresnel parameters of the material.
  41588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41589. */
  41590. reflectionFresnelParameters: FresnelParameters;
  41591. private _refractionFresnelParameters;
  41592. /**
  41593. * Define the refraction fresnel parameters of the material.
  41594. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41595. */
  41596. refractionFresnelParameters: FresnelParameters;
  41597. private _emissiveFresnelParameters;
  41598. /**
  41599. * Define the emissive fresnel parameters of the material.
  41600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41601. */
  41602. emissiveFresnelParameters: FresnelParameters;
  41603. private _useReflectionFresnelFromSpecular;
  41604. /**
  41605. * If true automatically deducts the fresnels values from the material specularity.
  41606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41607. */
  41608. useReflectionFresnelFromSpecular: boolean;
  41609. private _useGlossinessFromSpecularMapAlpha;
  41610. /**
  41611. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41612. */
  41613. useGlossinessFromSpecularMapAlpha: boolean;
  41614. private _maxSimultaneousLights;
  41615. /**
  41616. * Defines the maximum number of lights that can be used in the material
  41617. */
  41618. maxSimultaneousLights: number;
  41619. private _invertNormalMapX;
  41620. /**
  41621. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41622. */
  41623. invertNormalMapX: boolean;
  41624. private _invertNormalMapY;
  41625. /**
  41626. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41627. */
  41628. invertNormalMapY: boolean;
  41629. private _twoSidedLighting;
  41630. /**
  41631. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41632. */
  41633. twoSidedLighting: boolean;
  41634. /**
  41635. * Default configuration related to image processing available in the standard Material.
  41636. */
  41637. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41638. /**
  41639. * Gets the image processing configuration used either in this material.
  41640. */
  41641. /**
  41642. * Sets the Default image processing configuration used either in the this material.
  41643. *
  41644. * If sets to null, the scene one is in use.
  41645. */
  41646. imageProcessingConfiguration: ImageProcessingConfiguration;
  41647. /**
  41648. * Keep track of the image processing observer to allow dispose and replace.
  41649. */
  41650. private _imageProcessingObserver;
  41651. /**
  41652. * Attaches a new image processing configuration to the Standard Material.
  41653. * @param configuration
  41654. */
  41655. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41656. /**
  41657. * Gets wether the color curves effect is enabled.
  41658. */
  41659. /**
  41660. * Sets wether the color curves effect is enabled.
  41661. */
  41662. cameraColorCurvesEnabled: boolean;
  41663. /**
  41664. * Gets wether the color grading effect is enabled.
  41665. */
  41666. /**
  41667. * Gets wether the color grading effect is enabled.
  41668. */
  41669. cameraColorGradingEnabled: boolean;
  41670. /**
  41671. * Gets wether tonemapping is enabled or not.
  41672. */
  41673. /**
  41674. * Sets wether tonemapping is enabled or not
  41675. */
  41676. cameraToneMappingEnabled: boolean;
  41677. /**
  41678. * The camera exposure used on this material.
  41679. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41680. * This corresponds to a photographic exposure.
  41681. */
  41682. /**
  41683. * The camera exposure used on this material.
  41684. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41685. * This corresponds to a photographic exposure.
  41686. */
  41687. cameraExposure: number;
  41688. /**
  41689. * Gets The camera contrast used on this material.
  41690. */
  41691. /**
  41692. * Sets The camera contrast used on this material.
  41693. */
  41694. cameraContrast: number;
  41695. /**
  41696. * Gets the Color Grading 2D Lookup Texture.
  41697. */
  41698. /**
  41699. * Sets the Color Grading 2D Lookup Texture.
  41700. */
  41701. cameraColorGradingTexture: Nullable<BaseTexture>;
  41702. /**
  41703. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41704. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41705. * 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;
  41706. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41707. */
  41708. /**
  41709. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41710. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41711. * 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;
  41712. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41713. */
  41714. cameraColorCurves: Nullable<ColorCurves>;
  41715. /**
  41716. * Custom callback helping to override the default shader used in the material.
  41717. */
  41718. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41719. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41720. protected _worldViewProjectionMatrix: Matrix;
  41721. protected _globalAmbientColor: Color3;
  41722. protected _useLogarithmicDepth: boolean;
  41723. protected _rebuildInParallel: boolean;
  41724. /**
  41725. * Instantiates a new standard material.
  41726. * This is the default material used in Babylon. It is the best trade off between quality
  41727. * and performances.
  41728. * @see http://doc.babylonjs.com/babylon101/materials
  41729. * @param name Define the name of the material in the scene
  41730. * @param scene Define the scene the material belong to
  41731. */
  41732. constructor(name: string, scene: Scene);
  41733. /**
  41734. * Gets a boolean indicating that current material needs to register RTT
  41735. */
  41736. readonly hasRenderTargetTextures: boolean;
  41737. /**
  41738. * Gets the current class name of the material e.g. "StandardMaterial"
  41739. * Mainly use in serialization.
  41740. * @returns the class name
  41741. */
  41742. getClassName(): string;
  41743. /**
  41744. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41745. * You can try switching to logarithmic depth.
  41746. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41747. */
  41748. useLogarithmicDepth: boolean;
  41749. /**
  41750. * Specifies if the material will require alpha blending
  41751. * @returns a boolean specifying if alpha blending is needed
  41752. */
  41753. needAlphaBlending(): boolean;
  41754. /**
  41755. * Specifies if this material should be rendered in alpha test mode
  41756. * @returns a boolean specifying if an alpha test is needed.
  41757. */
  41758. needAlphaTesting(): boolean;
  41759. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41760. /**
  41761. * Get the texture used for alpha test purpose.
  41762. * @returns the diffuse texture in case of the standard material.
  41763. */
  41764. getAlphaTestTexture(): Nullable<BaseTexture>;
  41765. /**
  41766. * Get if the submesh is ready to be used and all its information available.
  41767. * Child classes can use it to update shaders
  41768. * @param mesh defines the mesh to check
  41769. * @param subMesh defines which submesh to check
  41770. * @param useInstances specifies that instances should be used
  41771. * @returns a boolean indicating that the submesh is ready or not
  41772. */
  41773. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41774. /**
  41775. * Builds the material UBO layouts.
  41776. * Used internally during the effect preparation.
  41777. */
  41778. buildUniformLayout(): void;
  41779. /**
  41780. * Unbinds the material from the mesh
  41781. */
  41782. unbind(): void;
  41783. /**
  41784. * Binds the submesh to this material by preparing the effect and shader to draw
  41785. * @param world defines the world transformation matrix
  41786. * @param mesh defines the mesh containing the submesh
  41787. * @param subMesh defines the submesh to bind the material to
  41788. */
  41789. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41790. /**
  41791. * Get the list of animatables in the material.
  41792. * @returns the list of animatables object used in the material
  41793. */
  41794. getAnimatables(): IAnimatable[];
  41795. /**
  41796. * Gets the active textures from the material
  41797. * @returns an array of textures
  41798. */
  41799. getActiveTextures(): BaseTexture[];
  41800. /**
  41801. * Specifies if the material uses a texture
  41802. * @param texture defines the texture to check against the material
  41803. * @returns a boolean specifying if the material uses the texture
  41804. */
  41805. hasTexture(texture: BaseTexture): boolean;
  41806. /**
  41807. * Disposes the material
  41808. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41809. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41810. */
  41811. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41812. /**
  41813. * Makes a duplicate of the material, and gives it a new name
  41814. * @param name defines the new name for the duplicated material
  41815. * @returns the cloned material
  41816. */
  41817. clone(name: string): StandardMaterial;
  41818. /**
  41819. * Serializes this material in a JSON representation
  41820. * @returns the serialized material object
  41821. */
  41822. serialize(): any;
  41823. /**
  41824. * Creates a standard material from parsed material data
  41825. * @param source defines the JSON representation of the material
  41826. * @param scene defines the hosting scene
  41827. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41828. * @returns a new standard material
  41829. */
  41830. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41831. /**
  41832. * Are diffuse textures enabled in the application.
  41833. */
  41834. static DiffuseTextureEnabled: boolean;
  41835. /**
  41836. * Are ambient textures enabled in the application.
  41837. */
  41838. static AmbientTextureEnabled: boolean;
  41839. /**
  41840. * Are opacity textures enabled in the application.
  41841. */
  41842. static OpacityTextureEnabled: boolean;
  41843. /**
  41844. * Are reflection textures enabled in the application.
  41845. */
  41846. static ReflectionTextureEnabled: boolean;
  41847. /**
  41848. * Are emissive textures enabled in the application.
  41849. */
  41850. static EmissiveTextureEnabled: boolean;
  41851. /**
  41852. * Are specular textures enabled in the application.
  41853. */
  41854. static SpecularTextureEnabled: boolean;
  41855. /**
  41856. * Are bump textures enabled in the application.
  41857. */
  41858. static BumpTextureEnabled: boolean;
  41859. /**
  41860. * Are lightmap textures enabled in the application.
  41861. */
  41862. static LightmapTextureEnabled: boolean;
  41863. /**
  41864. * Are refraction textures enabled in the application.
  41865. */
  41866. static RefractionTextureEnabled: boolean;
  41867. /**
  41868. * Are color grading textures enabled in the application.
  41869. */
  41870. static ColorGradingTextureEnabled: boolean;
  41871. /**
  41872. * Are fresnels enabled in the application.
  41873. */
  41874. static FresnelEnabled: boolean;
  41875. }
  41876. }
  41877. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41878. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41879. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41880. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41881. /** @hidden */
  41882. export var imageProcessingPixelShader: {
  41883. name: string;
  41884. shader: string;
  41885. };
  41886. }
  41887. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41888. import { Nullable } from "babylonjs/types";
  41889. import { Color4 } from "babylonjs/Maths/math.color";
  41890. import { Camera } from "babylonjs/Cameras/camera";
  41891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41892. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41893. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41894. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41895. import { Engine } from "babylonjs/Engines/engine";
  41896. import "babylonjs/Shaders/imageProcessing.fragment";
  41897. import "babylonjs/Shaders/postprocess.vertex";
  41898. /**
  41899. * ImageProcessingPostProcess
  41900. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41901. */
  41902. export class ImageProcessingPostProcess extends PostProcess {
  41903. /**
  41904. * Default configuration related to image processing available in the PBR Material.
  41905. */
  41906. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41907. /**
  41908. * Gets the image processing configuration used either in this material.
  41909. */
  41910. /**
  41911. * Sets the Default image processing configuration used either in the this material.
  41912. *
  41913. * If sets to null, the scene one is in use.
  41914. */
  41915. imageProcessingConfiguration: ImageProcessingConfiguration;
  41916. /**
  41917. * Keep track of the image processing observer to allow dispose and replace.
  41918. */
  41919. private _imageProcessingObserver;
  41920. /**
  41921. * Attaches a new image processing configuration to the PBR Material.
  41922. * @param configuration
  41923. */
  41924. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41925. /**
  41926. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41927. */
  41928. /**
  41929. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41930. */
  41931. colorCurves: Nullable<ColorCurves>;
  41932. /**
  41933. * Gets wether the color curves effect is enabled.
  41934. */
  41935. /**
  41936. * Sets wether the color curves effect is enabled.
  41937. */
  41938. colorCurvesEnabled: boolean;
  41939. /**
  41940. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41941. */
  41942. /**
  41943. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41944. */
  41945. colorGradingTexture: Nullable<BaseTexture>;
  41946. /**
  41947. * Gets wether the color grading effect is enabled.
  41948. */
  41949. /**
  41950. * Gets wether the color grading effect is enabled.
  41951. */
  41952. colorGradingEnabled: boolean;
  41953. /**
  41954. * Gets exposure used in the effect.
  41955. */
  41956. /**
  41957. * Sets exposure used in the effect.
  41958. */
  41959. exposure: number;
  41960. /**
  41961. * Gets wether tonemapping is enabled or not.
  41962. */
  41963. /**
  41964. * Sets wether tonemapping is enabled or not
  41965. */
  41966. toneMappingEnabled: boolean;
  41967. /**
  41968. * Gets the type of tone mapping effect.
  41969. */
  41970. /**
  41971. * Sets the type of tone mapping effect.
  41972. */
  41973. toneMappingType: number;
  41974. /**
  41975. * Gets contrast used in the effect.
  41976. */
  41977. /**
  41978. * Sets contrast used in the effect.
  41979. */
  41980. contrast: number;
  41981. /**
  41982. * Gets Vignette stretch size.
  41983. */
  41984. /**
  41985. * Sets Vignette stretch size.
  41986. */
  41987. vignetteStretch: number;
  41988. /**
  41989. * Gets Vignette centre X Offset.
  41990. */
  41991. /**
  41992. * Sets Vignette centre X Offset.
  41993. */
  41994. vignetteCentreX: number;
  41995. /**
  41996. * Gets Vignette centre Y Offset.
  41997. */
  41998. /**
  41999. * Sets Vignette centre Y Offset.
  42000. */
  42001. vignetteCentreY: number;
  42002. /**
  42003. * Gets Vignette weight or intensity of the vignette effect.
  42004. */
  42005. /**
  42006. * Sets Vignette weight or intensity of the vignette effect.
  42007. */
  42008. vignetteWeight: number;
  42009. /**
  42010. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42011. * if vignetteEnabled is set to true.
  42012. */
  42013. /**
  42014. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42015. * if vignetteEnabled is set to true.
  42016. */
  42017. vignetteColor: Color4;
  42018. /**
  42019. * Gets Camera field of view used by the Vignette effect.
  42020. */
  42021. /**
  42022. * Sets Camera field of view used by the Vignette effect.
  42023. */
  42024. vignetteCameraFov: number;
  42025. /**
  42026. * Gets the vignette blend mode allowing different kind of effect.
  42027. */
  42028. /**
  42029. * Sets the vignette blend mode allowing different kind of effect.
  42030. */
  42031. vignetteBlendMode: number;
  42032. /**
  42033. * Gets wether the vignette effect is enabled.
  42034. */
  42035. /**
  42036. * Sets wether the vignette effect is enabled.
  42037. */
  42038. vignetteEnabled: boolean;
  42039. private _fromLinearSpace;
  42040. /**
  42041. * Gets wether the input of the processing is in Gamma or Linear Space.
  42042. */
  42043. /**
  42044. * Sets wether the input of the processing is in Gamma or Linear Space.
  42045. */
  42046. fromLinearSpace: boolean;
  42047. /**
  42048. * Defines cache preventing GC.
  42049. */
  42050. private _defines;
  42051. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42052. /**
  42053. * "ImageProcessingPostProcess"
  42054. * @returns "ImageProcessingPostProcess"
  42055. */
  42056. getClassName(): string;
  42057. protected _updateParameters(): void;
  42058. dispose(camera?: Camera): void;
  42059. }
  42060. }
  42061. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42062. import { Scene } from "babylonjs/scene";
  42063. import { Color3 } from "babylonjs/Maths/math.color";
  42064. import { Mesh } from "babylonjs/Meshes/mesh";
  42065. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42066. import { Nullable } from "babylonjs/types";
  42067. /**
  42068. * Class containing static functions to help procedurally build meshes
  42069. */
  42070. export class GroundBuilder {
  42071. /**
  42072. * Creates a ground mesh
  42073. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42074. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42076. * @param name defines the name of the mesh
  42077. * @param options defines the options used to create the mesh
  42078. * @param scene defines the hosting scene
  42079. * @returns the ground mesh
  42080. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42081. */
  42082. static CreateGround(name: string, options: {
  42083. width?: number;
  42084. height?: number;
  42085. subdivisions?: number;
  42086. subdivisionsX?: number;
  42087. subdivisionsY?: number;
  42088. updatable?: boolean;
  42089. }, scene: any): Mesh;
  42090. /**
  42091. * Creates a tiled ground mesh
  42092. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42093. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42094. * * 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
  42095. * * 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
  42096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42097. * @param name defines the name of the mesh
  42098. * @param options defines the options used to create the mesh
  42099. * @param scene defines the hosting scene
  42100. * @returns the tiled ground mesh
  42101. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42102. */
  42103. static CreateTiledGround(name: string, options: {
  42104. xmin: number;
  42105. zmin: number;
  42106. xmax: number;
  42107. zmax: number;
  42108. subdivisions?: {
  42109. w: number;
  42110. h: number;
  42111. };
  42112. precision?: {
  42113. w: number;
  42114. h: number;
  42115. };
  42116. updatable?: boolean;
  42117. }, scene?: Nullable<Scene>): Mesh;
  42118. /**
  42119. * Creates a ground mesh from a height map
  42120. * * The parameter `url` sets the URL of the height map image resource.
  42121. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42122. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42123. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42124. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42125. * * 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.
  42126. * * 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).
  42127. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42129. * @param name defines the name of the mesh
  42130. * @param url defines the url to the height map
  42131. * @param options defines the options used to create the mesh
  42132. * @param scene defines the hosting scene
  42133. * @returns the ground mesh
  42134. * @see https://doc.babylonjs.com/babylon101/height_map
  42135. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42136. */
  42137. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42138. width?: number;
  42139. height?: number;
  42140. subdivisions?: number;
  42141. minHeight?: number;
  42142. maxHeight?: number;
  42143. colorFilter?: Color3;
  42144. alphaFilter?: number;
  42145. updatable?: boolean;
  42146. onReady?: (mesh: GroundMesh) => void;
  42147. }, scene?: Nullable<Scene>): GroundMesh;
  42148. }
  42149. }
  42150. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42151. import { Vector4 } from "babylonjs/Maths/math.vector";
  42152. import { Mesh } from "babylonjs/Meshes/mesh";
  42153. /**
  42154. * Class containing static functions to help procedurally build meshes
  42155. */
  42156. export class TorusBuilder {
  42157. /**
  42158. * Creates a torus mesh
  42159. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42160. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42161. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42165. * @param name defines the name of the mesh
  42166. * @param options defines the options used to create the mesh
  42167. * @param scene defines the hosting scene
  42168. * @returns the torus mesh
  42169. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42170. */
  42171. static CreateTorus(name: string, options: {
  42172. diameter?: number;
  42173. thickness?: number;
  42174. tessellation?: number;
  42175. updatable?: boolean;
  42176. sideOrientation?: number;
  42177. frontUVs?: Vector4;
  42178. backUVs?: Vector4;
  42179. }, scene: any): Mesh;
  42180. }
  42181. }
  42182. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42183. import { Vector4 } from "babylonjs/Maths/math.vector";
  42184. import { Color4 } from "babylonjs/Maths/math.color";
  42185. import { Mesh } from "babylonjs/Meshes/mesh";
  42186. /**
  42187. * Class containing static functions to help procedurally build meshes
  42188. */
  42189. export class CylinderBuilder {
  42190. /**
  42191. * Creates a cylinder or a cone mesh
  42192. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42193. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42194. * * 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.
  42195. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42196. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42197. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42198. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42199. * * 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).
  42200. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42201. * * 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).
  42202. * * 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
  42203. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42204. * * 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
  42205. * * 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.
  42206. * * If `enclose` is false, a ring surface is one element.
  42207. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42208. * * 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
  42209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42212. * @param name defines the name of the mesh
  42213. * @param options defines the options used to create the mesh
  42214. * @param scene defines the hosting scene
  42215. * @returns the cylinder mesh
  42216. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42217. */
  42218. static CreateCylinder(name: string, options: {
  42219. height?: number;
  42220. diameterTop?: number;
  42221. diameterBottom?: number;
  42222. diameter?: number;
  42223. tessellation?: number;
  42224. subdivisions?: number;
  42225. arc?: number;
  42226. faceColors?: Color4[];
  42227. faceUV?: Vector4[];
  42228. updatable?: boolean;
  42229. hasRings?: boolean;
  42230. enclose?: boolean;
  42231. cap?: number;
  42232. sideOrientation?: number;
  42233. frontUVs?: Vector4;
  42234. backUVs?: Vector4;
  42235. }, scene: any): Mesh;
  42236. }
  42237. }
  42238. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42239. import { Observable } from "babylonjs/Misc/observable";
  42240. import { Nullable } from "babylonjs/types";
  42241. import { Camera } from "babylonjs/Cameras/camera";
  42242. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42243. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42244. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42245. import { Scene } from "babylonjs/scene";
  42246. import { Vector3 } from "babylonjs/Maths/math.vector";
  42247. import { Color3 } from "babylonjs/Maths/math.color";
  42248. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42250. import { Mesh } from "babylonjs/Meshes/mesh";
  42251. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42252. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42253. import "babylonjs/Meshes/Builders/groundBuilder";
  42254. import "babylonjs/Meshes/Builders/torusBuilder";
  42255. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42256. import "babylonjs/Gamepads/gamepadSceneComponent";
  42257. import "babylonjs/Animations/animatable";
  42258. /**
  42259. * Options to modify the vr teleportation behavior.
  42260. */
  42261. export interface VRTeleportationOptions {
  42262. /**
  42263. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42264. */
  42265. floorMeshName?: string;
  42266. /**
  42267. * A list of meshes to be used as the teleportation floor. (default: empty)
  42268. */
  42269. floorMeshes?: Mesh[];
  42270. }
  42271. /**
  42272. * Options to modify the vr experience helper's behavior.
  42273. */
  42274. export interface VRExperienceHelperOptions extends WebVROptions {
  42275. /**
  42276. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42277. */
  42278. createDeviceOrientationCamera?: boolean;
  42279. /**
  42280. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42281. */
  42282. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42283. /**
  42284. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42285. */
  42286. laserToggle?: boolean;
  42287. /**
  42288. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42289. */
  42290. floorMeshes?: Mesh[];
  42291. /**
  42292. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42293. */
  42294. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42295. }
  42296. /**
  42297. * Event containing information after VR has been entered
  42298. */
  42299. export class OnAfterEnteringVRObservableEvent {
  42300. /**
  42301. * If entering vr was successful
  42302. */
  42303. success: boolean;
  42304. }
  42305. /**
  42306. * Helps to quickly add VR support to an existing scene.
  42307. * See http://doc.babylonjs.com/how_to/webvr_helper
  42308. */
  42309. export class VRExperienceHelper {
  42310. /** Options to modify the vr experience helper's behavior. */
  42311. webVROptions: VRExperienceHelperOptions;
  42312. private _scene;
  42313. private _position;
  42314. private _btnVR;
  42315. private _btnVRDisplayed;
  42316. private _webVRsupported;
  42317. private _webVRready;
  42318. private _webVRrequesting;
  42319. private _webVRpresenting;
  42320. private _hasEnteredVR;
  42321. private _fullscreenVRpresenting;
  42322. private _canvas;
  42323. private _webVRCamera;
  42324. private _vrDeviceOrientationCamera;
  42325. private _deviceOrientationCamera;
  42326. private _existingCamera;
  42327. private _onKeyDown;
  42328. private _onVrDisplayPresentChange;
  42329. private _onVRDisplayChanged;
  42330. private _onVRRequestPresentStart;
  42331. private _onVRRequestPresentComplete;
  42332. /**
  42333. * 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)
  42334. */
  42335. enableGazeEvenWhenNoPointerLock: boolean;
  42336. /**
  42337. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42338. */
  42339. exitVROnDoubleTap: boolean;
  42340. /**
  42341. * Observable raised right before entering VR.
  42342. */
  42343. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42344. /**
  42345. * Observable raised when entering VR has completed.
  42346. */
  42347. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42348. /**
  42349. * Observable raised when exiting VR.
  42350. */
  42351. onExitingVRObservable: Observable<VRExperienceHelper>;
  42352. /**
  42353. * Observable raised when controller mesh is loaded.
  42354. */
  42355. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42356. /** Return this.onEnteringVRObservable
  42357. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42358. */
  42359. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42360. /** Return this.onExitingVRObservable
  42361. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42362. */
  42363. readonly onExitingVR: Observable<VRExperienceHelper>;
  42364. /** Return this.onControllerMeshLoadedObservable
  42365. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42366. */
  42367. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42368. private _rayLength;
  42369. private _useCustomVRButton;
  42370. private _teleportationRequested;
  42371. private _teleportActive;
  42372. private _floorMeshName;
  42373. private _floorMeshesCollection;
  42374. private _rotationAllowed;
  42375. private _teleportBackwardsVector;
  42376. private _teleportationTarget;
  42377. private _isDefaultTeleportationTarget;
  42378. private _postProcessMove;
  42379. private _teleportationFillColor;
  42380. private _teleportationBorderColor;
  42381. private _rotationAngle;
  42382. private _haloCenter;
  42383. private _cameraGazer;
  42384. private _padSensibilityUp;
  42385. private _padSensibilityDown;
  42386. private _leftController;
  42387. private _rightController;
  42388. /**
  42389. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42390. */
  42391. onNewMeshSelected: Observable<AbstractMesh>;
  42392. /**
  42393. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42394. * This observable will provide the mesh and the controller used to select the mesh
  42395. */
  42396. onMeshSelectedWithController: Observable<{
  42397. mesh: AbstractMesh;
  42398. controller: WebVRController;
  42399. }>;
  42400. /**
  42401. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42402. */
  42403. onNewMeshPicked: Observable<PickingInfo>;
  42404. private _circleEase;
  42405. /**
  42406. * Observable raised before camera teleportation
  42407. */
  42408. onBeforeCameraTeleport: Observable<Vector3>;
  42409. /**
  42410. * Observable raised after camera teleportation
  42411. */
  42412. onAfterCameraTeleport: Observable<Vector3>;
  42413. /**
  42414. * Observable raised when current selected mesh gets unselected
  42415. */
  42416. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42417. private _raySelectionPredicate;
  42418. /**
  42419. * To be optionaly changed by user to define custom ray selection
  42420. */
  42421. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42422. /**
  42423. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42424. */
  42425. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42426. /**
  42427. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42428. */
  42429. teleportationEnabled: boolean;
  42430. private _defaultHeight;
  42431. private _teleportationInitialized;
  42432. private _interactionsEnabled;
  42433. private _interactionsRequested;
  42434. private _displayGaze;
  42435. private _displayLaserPointer;
  42436. /**
  42437. * The mesh used to display where the user is going to teleport.
  42438. */
  42439. /**
  42440. * Sets the mesh to be used to display where the user is going to teleport.
  42441. */
  42442. teleportationTarget: Mesh;
  42443. /**
  42444. * 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
  42445. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42446. * See http://doc.babylonjs.com/resources/baking_transformations
  42447. */
  42448. gazeTrackerMesh: Mesh;
  42449. /**
  42450. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42451. */
  42452. updateGazeTrackerScale: boolean;
  42453. /**
  42454. * If the gaze trackers color should be updated when selecting meshes
  42455. */
  42456. updateGazeTrackerColor: boolean;
  42457. /**
  42458. * If the controller laser color should be updated when selecting meshes
  42459. */
  42460. updateControllerLaserColor: boolean;
  42461. /**
  42462. * The gaze tracking mesh corresponding to the left controller
  42463. */
  42464. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42465. /**
  42466. * The gaze tracking mesh corresponding to the right controller
  42467. */
  42468. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42469. /**
  42470. * If the ray of the gaze should be displayed.
  42471. */
  42472. /**
  42473. * Sets if the ray of the gaze should be displayed.
  42474. */
  42475. displayGaze: boolean;
  42476. /**
  42477. * If the ray of the LaserPointer should be displayed.
  42478. */
  42479. /**
  42480. * Sets if the ray of the LaserPointer should be displayed.
  42481. */
  42482. displayLaserPointer: boolean;
  42483. /**
  42484. * The deviceOrientationCamera used as the camera when not in VR.
  42485. */
  42486. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42487. /**
  42488. * Based on the current WebVR support, returns the current VR camera used.
  42489. */
  42490. readonly currentVRCamera: Nullable<Camera>;
  42491. /**
  42492. * The webVRCamera which is used when in VR.
  42493. */
  42494. readonly webVRCamera: WebVRFreeCamera;
  42495. /**
  42496. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42497. */
  42498. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42499. /**
  42500. * The html button that is used to trigger entering into VR.
  42501. */
  42502. readonly vrButton: Nullable<HTMLButtonElement>;
  42503. private readonly _teleportationRequestInitiated;
  42504. /**
  42505. * Defines wether or not Pointer lock should be requested when switching to
  42506. * full screen.
  42507. */
  42508. requestPointerLockOnFullScreen: boolean;
  42509. /**
  42510. * Instantiates a VRExperienceHelper.
  42511. * Helps to quickly add VR support to an existing scene.
  42512. * @param scene The scene the VRExperienceHelper belongs to.
  42513. * @param webVROptions Options to modify the vr experience helper's behavior.
  42514. */
  42515. constructor(scene: Scene,
  42516. /** Options to modify the vr experience helper's behavior. */
  42517. webVROptions?: VRExperienceHelperOptions);
  42518. private _onDefaultMeshLoaded;
  42519. private _onResize;
  42520. private _onFullscreenChange;
  42521. /**
  42522. * Gets a value indicating if we are currently in VR mode.
  42523. */
  42524. readonly isInVRMode: boolean;
  42525. private onVrDisplayPresentChange;
  42526. private onVRDisplayChanged;
  42527. private moveButtonToBottomRight;
  42528. private displayVRButton;
  42529. private updateButtonVisibility;
  42530. private _cachedAngularSensibility;
  42531. /**
  42532. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42533. * Otherwise, will use the fullscreen API.
  42534. */
  42535. enterVR(): void;
  42536. /**
  42537. * Attempt to exit VR, or fullscreen.
  42538. */
  42539. exitVR(): void;
  42540. /**
  42541. * The position of the vr experience helper.
  42542. */
  42543. /**
  42544. * Sets the position of the vr experience helper.
  42545. */
  42546. position: Vector3;
  42547. /**
  42548. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42549. */
  42550. enableInteractions(): void;
  42551. private readonly _noControllerIsActive;
  42552. private beforeRender;
  42553. private _isTeleportationFloor;
  42554. /**
  42555. * Adds a floor mesh to be used for teleportation.
  42556. * @param floorMesh the mesh to be used for teleportation.
  42557. */
  42558. addFloorMesh(floorMesh: Mesh): void;
  42559. /**
  42560. * Removes a floor mesh from being used for teleportation.
  42561. * @param floorMesh the mesh to be removed.
  42562. */
  42563. removeFloorMesh(floorMesh: Mesh): void;
  42564. /**
  42565. * Enables interactions and teleportation using the VR controllers and gaze.
  42566. * @param vrTeleportationOptions options to modify teleportation behavior.
  42567. */
  42568. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42569. private _onNewGamepadConnected;
  42570. private _tryEnableInteractionOnController;
  42571. private _onNewGamepadDisconnected;
  42572. private _enableInteractionOnController;
  42573. private _checkTeleportWithRay;
  42574. private _checkRotate;
  42575. private _checkTeleportBackwards;
  42576. private _enableTeleportationOnController;
  42577. private _createTeleportationCircles;
  42578. private _displayTeleportationTarget;
  42579. private _hideTeleportationTarget;
  42580. private _rotateCamera;
  42581. private _moveTeleportationSelectorTo;
  42582. private _workingVector;
  42583. private _workingQuaternion;
  42584. private _workingMatrix;
  42585. /**
  42586. * Teleports the users feet to the desired location
  42587. * @param location The location where the user's feet should be placed
  42588. */
  42589. teleportCamera(location: Vector3): void;
  42590. private _convertNormalToDirectionOfRay;
  42591. private _castRayAndSelectObject;
  42592. private _notifySelectedMeshUnselected;
  42593. /**
  42594. * Sets the color of the laser ray from the vr controllers.
  42595. * @param color new color for the ray.
  42596. */
  42597. changeLaserColor(color: Color3): void;
  42598. /**
  42599. * Sets the color of the ray from the vr headsets gaze.
  42600. * @param color new color for the ray.
  42601. */
  42602. changeGazeColor(color: Color3): void;
  42603. /**
  42604. * Exits VR and disposes of the vr experience helper
  42605. */
  42606. dispose(): void;
  42607. /**
  42608. * Gets the name of the VRExperienceHelper class
  42609. * @returns "VRExperienceHelper"
  42610. */
  42611. getClassName(): string;
  42612. }
  42613. }
  42614. declare module "babylonjs/Cameras/VR/index" {
  42615. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42616. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42617. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42618. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42619. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42620. export * from "babylonjs/Cameras/VR/webVRCamera";
  42621. }
  42622. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42623. import { Observable } from "babylonjs/Misc/observable";
  42624. import { Nullable } from "babylonjs/types";
  42625. import { IDisposable, Scene } from "babylonjs/scene";
  42626. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42627. /**
  42628. * Manages an XRSession to work with Babylon's engine
  42629. * @see https://doc.babylonjs.com/how_to/webxr
  42630. */
  42631. export class WebXRSessionManager implements IDisposable {
  42632. private scene;
  42633. /**
  42634. * Fires every time a new xrFrame arrives which can be used to update the camera
  42635. */
  42636. onXRFrameObservable: Observable<any>;
  42637. /**
  42638. * Fires when the xr session is ended either by the device or manually done
  42639. */
  42640. onXRSessionEnded: Observable<any>;
  42641. /**
  42642. * Underlying xr session
  42643. */
  42644. session: XRSession;
  42645. /**
  42646. * Type of reference space used when creating the session
  42647. */
  42648. referenceSpace: XRReferenceSpace;
  42649. /** @hidden */
  42650. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42651. /**
  42652. * Current XR frame
  42653. */
  42654. currentFrame: Nullable<XRFrame>;
  42655. private _xrNavigator;
  42656. private baseLayer;
  42657. /**
  42658. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42659. * @param scene The scene which the session should be created for
  42660. */
  42661. constructor(scene: Scene);
  42662. /**
  42663. * Initializes the manager
  42664. * After initialization enterXR can be called to start an XR session
  42665. * @returns Promise which resolves after it is initialized
  42666. */
  42667. initializeAsync(): Promise<void>;
  42668. /**
  42669. * Initializes an xr session
  42670. * @param xrSessionMode mode to initialize
  42671. * @returns a promise which will resolve once the session has been initialized
  42672. */
  42673. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42674. /**
  42675. * Sets the reference space on the xr session
  42676. * @param referenceSpace space to set
  42677. * @returns a promise that will resolve once the reference space has been set
  42678. */
  42679. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42680. /**
  42681. * Updates the render state of the session
  42682. * @param state state to set
  42683. * @returns a promise that resolves once the render state has been updated
  42684. */
  42685. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42686. /**
  42687. * Starts rendering to the xr layer
  42688. * @returns a promise that will resolve once rendering has started
  42689. */
  42690. startRenderingToXRAsync(): Promise<void>;
  42691. /**
  42692. * Stops the xrSession and restores the renderloop
  42693. * @returns Promise which resolves after it exits XR
  42694. */
  42695. exitXRAsync(): Promise<unknown>;
  42696. /**
  42697. * Checks if a session would be supported for the creation options specified
  42698. * @param sessionMode session mode to check if supported eg. immersive-vr
  42699. * @returns true if supported
  42700. */
  42701. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42702. /**
  42703. * @hidden
  42704. * Converts the render layer of xrSession to a render target
  42705. * @param session session to create render target for
  42706. * @param scene scene the new render target should be created for
  42707. */
  42708. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42709. /**
  42710. * Disposes of the session manager
  42711. */
  42712. dispose(): void;
  42713. }
  42714. }
  42715. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42716. import { Scene } from "babylonjs/scene";
  42717. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42718. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42719. /**
  42720. * WebXR Camera which holds the views for the xrSession
  42721. * @see https://doc.babylonjs.com/how_to/webxr
  42722. */
  42723. export class WebXRCamera extends FreeCamera {
  42724. private static _TmpMatrix;
  42725. /**
  42726. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42727. * @param name the name of the camera
  42728. * @param scene the scene to add the camera to
  42729. */
  42730. constructor(name: string, scene: Scene);
  42731. private _updateNumberOfRigCameras;
  42732. /** @hidden */
  42733. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42734. /**
  42735. * Updates the cameras position from the current pose information of the XR session
  42736. * @param xrSessionManager the session containing pose information
  42737. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42738. */
  42739. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42740. }
  42741. }
  42742. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42743. import { Nullable } from "babylonjs/types";
  42744. import { IDisposable } from "babylonjs/scene";
  42745. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42746. /**
  42747. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42748. */
  42749. export class WebXRManagedOutputCanvas implements IDisposable {
  42750. private helper;
  42751. private _canvas;
  42752. /**
  42753. * xrpresent context of the canvas which can be used to display/mirror xr content
  42754. */
  42755. canvasContext: WebGLRenderingContext;
  42756. /**
  42757. * xr layer for the canvas
  42758. */
  42759. xrLayer: Nullable<XRWebGLLayer>;
  42760. /**
  42761. * Initializes the xr layer for the session
  42762. * @param xrSession xr session
  42763. * @returns a promise that will resolve once the XR Layer has been created
  42764. */
  42765. initializeXRLayerAsync(xrSession: any): any;
  42766. /**
  42767. * Initializes the canvas to be added/removed upon entering/exiting xr
  42768. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42769. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42770. */
  42771. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42772. /**
  42773. * Disposes of the object
  42774. */
  42775. dispose(): void;
  42776. private _setManagedOutputCanvas;
  42777. private _addCanvas;
  42778. private _removeCanvas;
  42779. }
  42780. }
  42781. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42782. import { Observable } from "babylonjs/Misc/observable";
  42783. import { IDisposable, Scene } from "babylonjs/scene";
  42784. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42786. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42787. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42788. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42789. /**
  42790. * States of the webXR experience
  42791. */
  42792. export enum WebXRState {
  42793. /**
  42794. * Transitioning to being in XR mode
  42795. */
  42796. ENTERING_XR = 0,
  42797. /**
  42798. * Transitioning to non XR mode
  42799. */
  42800. EXITING_XR = 1,
  42801. /**
  42802. * In XR mode and presenting
  42803. */
  42804. IN_XR = 2,
  42805. /**
  42806. * Not entered XR mode
  42807. */
  42808. NOT_IN_XR = 3
  42809. }
  42810. /**
  42811. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42812. * @see https://doc.babylonjs.com/how_to/webxr
  42813. */
  42814. export class WebXRExperienceHelper implements IDisposable {
  42815. private scene;
  42816. /**
  42817. * 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
  42818. */
  42819. container: AbstractMesh;
  42820. /**
  42821. * Camera used to render xr content
  42822. */
  42823. camera: WebXRCamera;
  42824. /**
  42825. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42826. */
  42827. state: WebXRState;
  42828. private _setState;
  42829. private static _TmpVector;
  42830. /**
  42831. * Fires when the state of the experience helper has changed
  42832. */
  42833. onStateChangedObservable: Observable<WebXRState>;
  42834. /** Session manager used to keep track of xr session */
  42835. sessionManager: WebXRSessionManager;
  42836. private _nonVRCamera;
  42837. private _originalSceneAutoClear;
  42838. private _supported;
  42839. /**
  42840. * Creates the experience helper
  42841. * @param scene the scene to attach the experience helper to
  42842. * @returns a promise for the experience helper
  42843. */
  42844. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42845. /**
  42846. * Creates a WebXRExperienceHelper
  42847. * @param scene The scene the helper should be created in
  42848. */
  42849. private constructor();
  42850. /**
  42851. * Exits XR mode and returns the scene to its original state
  42852. * @returns promise that resolves after xr mode has exited
  42853. */
  42854. exitXRAsync(): Promise<unknown>;
  42855. /**
  42856. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42857. * @param sessionCreationOptions options for the XR session
  42858. * @param referenceSpaceType frame of reference of the XR session
  42859. * @param outputCanvas the output canvas that will be used to enter XR mode
  42860. * @returns promise that resolves after xr mode has entered
  42861. */
  42862. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42863. /**
  42864. * Updates the global position of the camera by moving the camera's container
  42865. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42866. * @param position The desired global position of the camera
  42867. */
  42868. setPositionOfCameraUsingContainer(position: Vector3): void;
  42869. /**
  42870. * Rotates the xr camera by rotating the camera's container around the camera's position
  42871. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42872. * @param rotation the desired quaternion rotation to apply to the camera
  42873. */
  42874. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42875. /**
  42876. * Disposes of the experience helper
  42877. */
  42878. dispose(): void;
  42879. }
  42880. }
  42881. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42882. import { Nullable } from "babylonjs/types";
  42883. import { Observable } from "babylonjs/Misc/observable";
  42884. import { IDisposable, Scene } from "babylonjs/scene";
  42885. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42886. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42887. /**
  42888. * Button which can be used to enter a different mode of XR
  42889. */
  42890. export class WebXREnterExitUIButton {
  42891. /** button element */
  42892. element: HTMLElement;
  42893. /** XR initialization options for the button */
  42894. sessionMode: XRSessionMode;
  42895. /** Reference space type */
  42896. referenceSpaceType: XRReferenceSpaceType;
  42897. /**
  42898. * Creates a WebXREnterExitUIButton
  42899. * @param element button element
  42900. * @param sessionMode XR initialization session mode
  42901. * @param referenceSpaceType the type of reference space to be used
  42902. */
  42903. constructor(
  42904. /** button element */
  42905. element: HTMLElement,
  42906. /** XR initialization options for the button */
  42907. sessionMode: XRSessionMode,
  42908. /** Reference space type */
  42909. referenceSpaceType: XRReferenceSpaceType);
  42910. /**
  42911. * Overwritable function which can be used to update the button's visuals when the state changes
  42912. * @param activeButton the current active button in the UI
  42913. */
  42914. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42915. }
  42916. /**
  42917. * Options to create the webXR UI
  42918. */
  42919. export class WebXREnterExitUIOptions {
  42920. /**
  42921. * Context to enter xr with
  42922. */
  42923. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42924. /**
  42925. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42926. */
  42927. customButtons?: Array<WebXREnterExitUIButton>;
  42928. }
  42929. /**
  42930. * UI to allow the user to enter/exit XR mode
  42931. */
  42932. export class WebXREnterExitUI implements IDisposable {
  42933. private scene;
  42934. private _overlay;
  42935. private _buttons;
  42936. private _activeButton;
  42937. /**
  42938. * Fired every time the active button is changed.
  42939. *
  42940. * When xr is entered via a button that launches xr that button will be the callback parameter
  42941. *
  42942. * When exiting xr the callback parameter will be null)
  42943. */
  42944. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42945. /**
  42946. * Creates UI to allow the user to enter/exit XR mode
  42947. * @param scene the scene to add the ui to
  42948. * @param helper the xr experience helper to enter/exit xr with
  42949. * @param options options to configure the UI
  42950. * @returns the created ui
  42951. */
  42952. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42953. private constructor();
  42954. private _updateButtons;
  42955. /**
  42956. * Disposes of the object
  42957. */
  42958. dispose(): void;
  42959. }
  42960. }
  42961. declare module "babylonjs/Cameras/XR/webXRController" {
  42962. import { Nullable } from "babylonjs/types";
  42963. import { Observable } from "babylonjs/Misc/observable";
  42964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42965. import { Ray } from "babylonjs/Culling/ray";
  42966. import { Scene } from "babylonjs/scene";
  42967. /**
  42968. * Represents an XR input
  42969. */
  42970. export class WebXRController {
  42971. private scene;
  42972. /** The underlying input source for the controller */
  42973. inputSource: XRInputSource;
  42974. private parentContainer;
  42975. /**
  42976. * 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
  42977. */
  42978. grip?: AbstractMesh;
  42979. /**
  42980. * Pointer which can be used to select objects or attach a visible laser to
  42981. */
  42982. pointer: AbstractMesh;
  42983. /**
  42984. * Event that fires when the controller is removed/disposed
  42985. */
  42986. onDisposeObservable: Observable<{}>;
  42987. private _tmpMatrix;
  42988. private _tmpQuaternion;
  42989. private _tmpVector;
  42990. /**
  42991. * Creates the controller
  42992. * @see https://doc.babylonjs.com/how_to/webxr
  42993. * @param scene the scene which the controller should be associated to
  42994. * @param inputSource the underlying input source for the controller
  42995. * @param parentContainer parent that the controller meshes should be children of
  42996. */
  42997. constructor(scene: Scene,
  42998. /** The underlying input source for the controller */
  42999. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43000. /**
  43001. * Updates the controller pose based on the given XRFrame
  43002. * @param xrFrame xr frame to update the pose with
  43003. * @param referenceSpace reference space to use
  43004. */
  43005. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43006. /**
  43007. * Gets a world space ray coming from the controller
  43008. * @param result the resulting ray
  43009. */
  43010. getWorldPointerRayToRef(result: Ray): void;
  43011. /**
  43012. * Disposes of the object
  43013. */
  43014. dispose(): void;
  43015. }
  43016. }
  43017. declare module "babylonjs/Cameras/XR/webXRInput" {
  43018. import { Observable } from "babylonjs/Misc/observable";
  43019. import { IDisposable } from "babylonjs/scene";
  43020. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43021. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43022. /**
  43023. * XR input used to track XR inputs such as controllers/rays
  43024. */
  43025. export class WebXRInput implements IDisposable {
  43026. /**
  43027. * Base experience the input listens to
  43028. */
  43029. baseExperience: WebXRExperienceHelper;
  43030. /**
  43031. * XR controllers being tracked
  43032. */
  43033. controllers: Array<WebXRController>;
  43034. private _frameObserver;
  43035. private _stateObserver;
  43036. /**
  43037. * Event when a controller has been connected/added
  43038. */
  43039. onControllerAddedObservable: Observable<WebXRController>;
  43040. /**
  43041. * Event when a controller has been removed/disconnected
  43042. */
  43043. onControllerRemovedObservable: Observable<WebXRController>;
  43044. /**
  43045. * Initializes the WebXRInput
  43046. * @param baseExperience experience helper which the input should be created for
  43047. */
  43048. constructor(
  43049. /**
  43050. * Base experience the input listens to
  43051. */
  43052. baseExperience: WebXRExperienceHelper);
  43053. private _onInputSourcesChange;
  43054. private _addAndRemoveControllers;
  43055. /**
  43056. * Disposes of the object
  43057. */
  43058. dispose(): void;
  43059. }
  43060. }
  43061. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43063. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43064. /**
  43065. * Enables teleportation
  43066. */
  43067. export class WebXRControllerTeleportation {
  43068. private _teleportationFillColor;
  43069. private _teleportationBorderColor;
  43070. private _tmpRay;
  43071. private _tmpVector;
  43072. /**
  43073. * Creates a WebXRControllerTeleportation
  43074. * @param input input manager to add teleportation to
  43075. * @param floorMeshes floormeshes which can be teleported to
  43076. */
  43077. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43078. }
  43079. }
  43080. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43081. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43082. /**
  43083. * Handles pointer input automatically for the pointer of XR controllers
  43084. */
  43085. export class WebXRControllerPointerSelection {
  43086. private static _idCounter;
  43087. private _tmpRay;
  43088. /**
  43089. * Creates a WebXRControllerPointerSelection
  43090. * @param input input manager to setup pointer selection
  43091. */
  43092. constructor(input: WebXRInput);
  43093. private _convertNormalToDirectionOfRay;
  43094. private _updatePointerDistance;
  43095. }
  43096. }
  43097. declare module "babylonjs/Loading/sceneLoader" {
  43098. import { Observable } from "babylonjs/Misc/observable";
  43099. import { Nullable } from "babylonjs/types";
  43100. import { Scene } from "babylonjs/scene";
  43101. import { Engine } from "babylonjs/Engines/engine";
  43102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43103. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43104. import { AssetContainer } from "babylonjs/assetContainer";
  43105. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43106. import { Skeleton } from "babylonjs/Bones/skeleton";
  43107. /**
  43108. * Class used to represent data loading progression
  43109. */
  43110. export class SceneLoaderProgressEvent {
  43111. /** defines if data length to load can be evaluated */
  43112. readonly lengthComputable: boolean;
  43113. /** defines the loaded data length */
  43114. readonly loaded: number;
  43115. /** defines the data length to load */
  43116. readonly total: number;
  43117. /**
  43118. * Create a new progress event
  43119. * @param lengthComputable defines if data length to load can be evaluated
  43120. * @param loaded defines the loaded data length
  43121. * @param total defines the data length to load
  43122. */
  43123. constructor(
  43124. /** defines if data length to load can be evaluated */
  43125. lengthComputable: boolean,
  43126. /** defines the loaded data length */
  43127. loaded: number,
  43128. /** defines the data length to load */
  43129. total: number);
  43130. /**
  43131. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43132. * @param event defines the source event
  43133. * @returns a new SceneLoaderProgressEvent
  43134. */
  43135. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43136. }
  43137. /**
  43138. * Interface used by SceneLoader plugins to define supported file extensions
  43139. */
  43140. export interface ISceneLoaderPluginExtensions {
  43141. /**
  43142. * Defines the list of supported extensions
  43143. */
  43144. [extension: string]: {
  43145. isBinary: boolean;
  43146. };
  43147. }
  43148. /**
  43149. * Interface used by SceneLoader plugin factory
  43150. */
  43151. export interface ISceneLoaderPluginFactory {
  43152. /**
  43153. * Defines the name of the factory
  43154. */
  43155. name: string;
  43156. /**
  43157. * Function called to create a new plugin
  43158. * @return the new plugin
  43159. */
  43160. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43161. /**
  43162. * Boolean indicating if the plugin can direct load specific data
  43163. */
  43164. canDirectLoad?: (data: string) => boolean;
  43165. }
  43166. /**
  43167. * Interface used to define a SceneLoader plugin
  43168. */
  43169. export interface ISceneLoaderPlugin {
  43170. /**
  43171. * The friendly name of this plugin.
  43172. */
  43173. name: string;
  43174. /**
  43175. * The file extensions supported by this plugin.
  43176. */
  43177. extensions: string | ISceneLoaderPluginExtensions;
  43178. /**
  43179. * Import meshes into a scene.
  43180. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43181. * @param scene The scene to import into
  43182. * @param data The data to import
  43183. * @param rootUrl The root url for scene and resources
  43184. * @param meshes The meshes array to import into
  43185. * @param particleSystems The particle systems array to import into
  43186. * @param skeletons The skeletons array to import into
  43187. * @param onError The callback when import fails
  43188. * @returns True if successful or false otherwise
  43189. */
  43190. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43191. /**
  43192. * Load into a scene.
  43193. * @param scene The scene to load into
  43194. * @param data The data to import
  43195. * @param rootUrl The root url for scene and resources
  43196. * @param onError The callback when import fails
  43197. * @returns true if successful or false otherwise
  43198. */
  43199. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43200. /**
  43201. * The callback that returns true if the data can be directly loaded.
  43202. */
  43203. canDirectLoad?: (data: string) => boolean;
  43204. /**
  43205. * The callback that allows custom handling of the root url based on the response url.
  43206. */
  43207. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43208. /**
  43209. * Load into an asset container.
  43210. * @param scene The scene to load into
  43211. * @param data The data to import
  43212. * @param rootUrl The root url for scene and resources
  43213. * @param onError The callback when import fails
  43214. * @returns The loaded asset container
  43215. */
  43216. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43217. }
  43218. /**
  43219. * Interface used to define an async SceneLoader plugin
  43220. */
  43221. export interface ISceneLoaderPluginAsync {
  43222. /**
  43223. * The friendly name of this plugin.
  43224. */
  43225. name: string;
  43226. /**
  43227. * The file extensions supported by this plugin.
  43228. */
  43229. extensions: string | ISceneLoaderPluginExtensions;
  43230. /**
  43231. * Import meshes into a scene.
  43232. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43233. * @param scene The scene to import into
  43234. * @param data The data to import
  43235. * @param rootUrl The root url for scene and resources
  43236. * @param onProgress The callback when the load progresses
  43237. * @param fileName Defines the name of the file to load
  43238. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43239. */
  43240. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43241. meshes: AbstractMesh[];
  43242. particleSystems: IParticleSystem[];
  43243. skeletons: Skeleton[];
  43244. animationGroups: AnimationGroup[];
  43245. }>;
  43246. /**
  43247. * Load into a scene.
  43248. * @param scene The scene to load into
  43249. * @param data The data to import
  43250. * @param rootUrl The root url for scene and resources
  43251. * @param onProgress The callback when the load progresses
  43252. * @param fileName Defines the name of the file to load
  43253. * @returns Nothing
  43254. */
  43255. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43256. /**
  43257. * The callback that returns true if the data can be directly loaded.
  43258. */
  43259. canDirectLoad?: (data: string) => boolean;
  43260. /**
  43261. * The callback that allows custom handling of the root url based on the response url.
  43262. */
  43263. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43264. /**
  43265. * Load into an asset container.
  43266. * @param scene The scene to load into
  43267. * @param data The data to import
  43268. * @param rootUrl The root url for scene and resources
  43269. * @param onProgress The callback when the load progresses
  43270. * @param fileName Defines the name of the file to load
  43271. * @returns The loaded asset container
  43272. */
  43273. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43274. }
  43275. /**
  43276. * Class used to load scene from various file formats using registered plugins
  43277. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43278. */
  43279. export class SceneLoader {
  43280. /**
  43281. * No logging while loading
  43282. */
  43283. static readonly NO_LOGGING: number;
  43284. /**
  43285. * Minimal logging while loading
  43286. */
  43287. static readonly MINIMAL_LOGGING: number;
  43288. /**
  43289. * Summary logging while loading
  43290. */
  43291. static readonly SUMMARY_LOGGING: number;
  43292. /**
  43293. * Detailled logging while loading
  43294. */
  43295. static readonly DETAILED_LOGGING: number;
  43296. /**
  43297. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43298. */
  43299. static ForceFullSceneLoadingForIncremental: boolean;
  43300. /**
  43301. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43302. */
  43303. static ShowLoadingScreen: boolean;
  43304. /**
  43305. * Defines the current logging level (while loading the scene)
  43306. * @ignorenaming
  43307. */
  43308. static loggingLevel: number;
  43309. /**
  43310. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43311. */
  43312. static CleanBoneMatrixWeights: boolean;
  43313. /**
  43314. * Event raised when a plugin is used to load a scene
  43315. */
  43316. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43317. private static _registeredPlugins;
  43318. private static _getDefaultPlugin;
  43319. private static _getPluginForExtension;
  43320. private static _getPluginForDirectLoad;
  43321. private static _getPluginForFilename;
  43322. private static _getDirectLoad;
  43323. private static _loadData;
  43324. private static _getFileInfo;
  43325. /**
  43326. * Gets a plugin that can load the given extension
  43327. * @param extension defines the extension to load
  43328. * @returns a plugin or null if none works
  43329. */
  43330. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43331. /**
  43332. * Gets a boolean indicating that the given extension can be loaded
  43333. * @param extension defines the extension to load
  43334. * @returns true if the extension is supported
  43335. */
  43336. static IsPluginForExtensionAvailable(extension: string): boolean;
  43337. /**
  43338. * Adds a new plugin to the list of registered plugins
  43339. * @param plugin defines the plugin to add
  43340. */
  43341. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43342. /**
  43343. * Import meshes into a scene
  43344. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43345. * @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)
  43346. * @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)
  43347. * @param scene the instance of BABYLON.Scene to append to
  43348. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43349. * @param onProgress a callback with a progress event for each file being loaded
  43350. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43351. * @param pluginExtension the extension used to determine the plugin
  43352. * @returns The loaded plugin
  43353. */
  43354. 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>;
  43355. /**
  43356. * Import meshes into a scene
  43357. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43358. * @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)
  43359. * @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)
  43360. * @param scene the instance of BABYLON.Scene to append to
  43361. * @param onProgress a callback with a progress event for each file being loaded
  43362. * @param pluginExtension the extension used to determine the plugin
  43363. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43364. */
  43365. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43366. meshes: AbstractMesh[];
  43367. particleSystems: IParticleSystem[];
  43368. skeletons: Skeleton[];
  43369. animationGroups: AnimationGroup[];
  43370. }>;
  43371. /**
  43372. * Load a scene
  43373. * @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)
  43374. * @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)
  43375. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43376. * @param onSuccess a callback with the scene when import succeeds
  43377. * @param onProgress a callback with a progress event for each file being loaded
  43378. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43379. * @param pluginExtension the extension used to determine the plugin
  43380. * @returns The loaded plugin
  43381. */
  43382. 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>;
  43383. /**
  43384. * Load a scene
  43385. * @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)
  43386. * @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)
  43387. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43388. * @param onProgress a callback with a progress event for each file being loaded
  43389. * @param pluginExtension the extension used to determine the plugin
  43390. * @returns The loaded scene
  43391. */
  43392. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43393. /**
  43394. * Append a scene
  43395. * @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)
  43396. * @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)
  43397. * @param scene is the instance of BABYLON.Scene to append to
  43398. * @param onSuccess a callback with the scene when import succeeds
  43399. * @param onProgress a callback with a progress event for each file being loaded
  43400. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43401. * @param pluginExtension the extension used to determine the plugin
  43402. * @returns The loaded plugin
  43403. */
  43404. 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>;
  43405. /**
  43406. * Append a scene
  43407. * @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)
  43408. * @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)
  43409. * @param scene is the instance of BABYLON.Scene to append to
  43410. * @param onProgress a callback with a progress event for each file being loaded
  43411. * @param pluginExtension the extension used to determine the plugin
  43412. * @returns The given scene
  43413. */
  43414. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43415. /**
  43416. * Load a scene into an asset container
  43417. * @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)
  43418. * @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)
  43419. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43420. * @param onSuccess a callback with the scene when import succeeds
  43421. * @param onProgress a callback with a progress event for each file being loaded
  43422. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43423. * @param pluginExtension the extension used to determine the plugin
  43424. * @returns The loaded plugin
  43425. */
  43426. 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>;
  43427. /**
  43428. * Load a scene into an asset container
  43429. * @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)
  43430. * @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)
  43431. * @param scene is the instance of Scene to append to
  43432. * @param onProgress a callback with a progress event for each file being loaded
  43433. * @param pluginExtension the extension used to determine the plugin
  43434. * @returns The loaded asset container
  43435. */
  43436. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43437. }
  43438. }
  43439. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43440. import { Scene } from "babylonjs/scene";
  43441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43442. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43443. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43444. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43445. /**
  43446. * Generic Controller
  43447. */
  43448. export class GenericController extends WebVRController {
  43449. /**
  43450. * Base Url for the controller model.
  43451. */
  43452. static readonly MODEL_BASE_URL: string;
  43453. /**
  43454. * File name for the controller model.
  43455. */
  43456. static readonly MODEL_FILENAME: string;
  43457. /**
  43458. * Creates a new GenericController from a gamepad
  43459. * @param vrGamepad the gamepad that the controller should be created from
  43460. */
  43461. constructor(vrGamepad: any);
  43462. /**
  43463. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43464. * @param scene scene in which to add meshes
  43465. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43466. */
  43467. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43468. /**
  43469. * Called once for each button that changed state since the last frame
  43470. * @param buttonIdx Which button index changed
  43471. * @param state New state of the button
  43472. * @param changes Which properties on the state changed since last frame
  43473. */
  43474. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43475. }
  43476. }
  43477. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43478. import { Observable } from "babylonjs/Misc/observable";
  43479. import { Scene } from "babylonjs/scene";
  43480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43481. import { Ray } from "babylonjs/Culling/ray";
  43482. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43483. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43484. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43485. /**
  43486. * Defines the WindowsMotionController object that the state of the windows motion controller
  43487. */
  43488. export class WindowsMotionController extends WebVRController {
  43489. /**
  43490. * The base url used to load the left and right controller models
  43491. */
  43492. static MODEL_BASE_URL: string;
  43493. /**
  43494. * The name of the left controller model file
  43495. */
  43496. static MODEL_LEFT_FILENAME: string;
  43497. /**
  43498. * The name of the right controller model file
  43499. */
  43500. static MODEL_RIGHT_FILENAME: string;
  43501. /**
  43502. * The controller name prefix for this controller type
  43503. */
  43504. static readonly GAMEPAD_ID_PREFIX: string;
  43505. /**
  43506. * The controller id pattern for this controller type
  43507. */
  43508. private static readonly GAMEPAD_ID_PATTERN;
  43509. private _loadedMeshInfo;
  43510. private readonly _mapping;
  43511. /**
  43512. * Fired when the trackpad on this controller is clicked
  43513. */
  43514. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43515. /**
  43516. * Fired when the trackpad on this controller is modified
  43517. */
  43518. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43519. /**
  43520. * The current x and y values of this controller's trackpad
  43521. */
  43522. trackpad: StickValues;
  43523. /**
  43524. * Creates a new WindowsMotionController from a gamepad
  43525. * @param vrGamepad the gamepad that the controller should be created from
  43526. */
  43527. constructor(vrGamepad: any);
  43528. /**
  43529. * Fired when the trigger on this controller is modified
  43530. */
  43531. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43532. /**
  43533. * Fired when the menu button on this controller is modified
  43534. */
  43535. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43536. /**
  43537. * Fired when the grip button on this controller is modified
  43538. */
  43539. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43540. /**
  43541. * Fired when the thumbstick button on this controller is modified
  43542. */
  43543. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43544. /**
  43545. * Fired when the touchpad button on this controller is modified
  43546. */
  43547. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43548. /**
  43549. * Fired when the touchpad values on this controller are modified
  43550. */
  43551. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43552. private _updateTrackpad;
  43553. /**
  43554. * Called once per frame by the engine.
  43555. */
  43556. update(): void;
  43557. /**
  43558. * Called once for each button that changed state since the last frame
  43559. * @param buttonIdx Which button index changed
  43560. * @param state New state of the button
  43561. * @param changes Which properties on the state changed since last frame
  43562. */
  43563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43564. /**
  43565. * Moves the buttons on the controller mesh based on their current state
  43566. * @param buttonName the name of the button to move
  43567. * @param buttonValue the value of the button which determines the buttons new position
  43568. */
  43569. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43570. /**
  43571. * Moves the axis on the controller mesh based on its current state
  43572. * @param axis the index of the axis
  43573. * @param axisValue the value of the axis which determines the meshes new position
  43574. * @hidden
  43575. */
  43576. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43577. /**
  43578. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43579. * @param scene scene in which to add meshes
  43580. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43581. */
  43582. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43583. /**
  43584. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43585. * can be transformed by button presses and axes values, based on this._mapping.
  43586. *
  43587. * @param scene scene in which the meshes exist
  43588. * @param meshes list of meshes that make up the controller model to process
  43589. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43590. */
  43591. private processModel;
  43592. private createMeshInfo;
  43593. /**
  43594. * Gets the ray of the controller in the direction the controller is pointing
  43595. * @param length the length the resulting ray should be
  43596. * @returns a ray in the direction the controller is pointing
  43597. */
  43598. getForwardRay(length?: number): Ray;
  43599. /**
  43600. * Disposes of the controller
  43601. */
  43602. dispose(): void;
  43603. }
  43604. }
  43605. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43606. import { Observable } from "babylonjs/Misc/observable";
  43607. import { Scene } from "babylonjs/scene";
  43608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43609. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43610. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43611. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43612. /**
  43613. * Oculus Touch Controller
  43614. */
  43615. export class OculusTouchController extends WebVRController {
  43616. /**
  43617. * Base Url for the controller model.
  43618. */
  43619. static MODEL_BASE_URL: string;
  43620. /**
  43621. * File name for the left controller model.
  43622. */
  43623. static MODEL_LEFT_FILENAME: string;
  43624. /**
  43625. * File name for the right controller model.
  43626. */
  43627. static MODEL_RIGHT_FILENAME: string;
  43628. /**
  43629. * Base Url for the Quest controller model.
  43630. */
  43631. static QUEST_MODEL_BASE_URL: string;
  43632. /**
  43633. * @hidden
  43634. * If the controllers are running on a device that needs the updated Quest controller models
  43635. */
  43636. static _IsQuest: boolean;
  43637. /**
  43638. * Fired when the secondary trigger on this controller is modified
  43639. */
  43640. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43641. /**
  43642. * Fired when the thumb rest on this controller is modified
  43643. */
  43644. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43645. /**
  43646. * Creates a new OculusTouchController from a gamepad
  43647. * @param vrGamepad the gamepad that the controller should be created from
  43648. */
  43649. constructor(vrGamepad: any);
  43650. /**
  43651. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43652. * @param scene scene in which to add meshes
  43653. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43654. */
  43655. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43656. /**
  43657. * Fired when the A button on this controller is modified
  43658. */
  43659. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43660. /**
  43661. * Fired when the B button on this controller is modified
  43662. */
  43663. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43664. /**
  43665. * Fired when the X button on this controller is modified
  43666. */
  43667. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43668. /**
  43669. * Fired when the Y button on this controller is modified
  43670. */
  43671. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43672. /**
  43673. * Called once for each button that changed state since the last frame
  43674. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43675. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43676. * 2) secondary trigger (same)
  43677. * 3) A (right) X (left), touch, pressed = value
  43678. * 4) B / Y
  43679. * 5) thumb rest
  43680. * @param buttonIdx Which button index changed
  43681. * @param state New state of the button
  43682. * @param changes Which properties on the state changed since last frame
  43683. */
  43684. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43685. }
  43686. }
  43687. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43688. import { Scene } from "babylonjs/scene";
  43689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43690. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43691. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43692. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43693. import { Observable } from "babylonjs/Misc/observable";
  43694. /**
  43695. * Vive Controller
  43696. */
  43697. export class ViveController extends WebVRController {
  43698. /**
  43699. * Base Url for the controller model.
  43700. */
  43701. static MODEL_BASE_URL: string;
  43702. /**
  43703. * File name for the controller model.
  43704. */
  43705. static MODEL_FILENAME: string;
  43706. /**
  43707. * Creates a new ViveController from a gamepad
  43708. * @param vrGamepad the gamepad that the controller should be created from
  43709. */
  43710. constructor(vrGamepad: any);
  43711. /**
  43712. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43713. * @param scene scene in which to add meshes
  43714. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43715. */
  43716. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43717. /**
  43718. * Fired when the left button on this controller is modified
  43719. */
  43720. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43721. /**
  43722. * Fired when the right button on this controller is modified
  43723. */
  43724. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43725. /**
  43726. * Fired when the menu button on this controller is modified
  43727. */
  43728. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43729. /**
  43730. * Called once for each button that changed state since the last frame
  43731. * Vive mapping:
  43732. * 0: touchpad
  43733. * 1: trigger
  43734. * 2: left AND right buttons
  43735. * 3: menu button
  43736. * @param buttonIdx Which button index changed
  43737. * @param state New state of the button
  43738. * @param changes Which properties on the state changed since last frame
  43739. */
  43740. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43741. }
  43742. }
  43743. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43744. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43745. /**
  43746. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43747. */
  43748. export class WebXRControllerModelLoader {
  43749. /**
  43750. * Creates the WebXRControllerModelLoader
  43751. * @param input xr input that creates the controllers
  43752. */
  43753. constructor(input: WebXRInput);
  43754. }
  43755. }
  43756. declare module "babylonjs/Cameras/XR/index" {
  43757. export * from "babylonjs/Cameras/XR/webXRCamera";
  43758. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43759. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43760. export * from "babylonjs/Cameras/XR/webXRInput";
  43761. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43762. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43763. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43764. export * from "babylonjs/Cameras/XR/webXRController";
  43765. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43766. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43767. }
  43768. declare module "babylonjs/Cameras/RigModes/index" {
  43769. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43770. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43771. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43772. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43773. }
  43774. declare module "babylonjs/Cameras/index" {
  43775. export * from "babylonjs/Cameras/Inputs/index";
  43776. export * from "babylonjs/Cameras/cameraInputsManager";
  43777. export * from "babylonjs/Cameras/camera";
  43778. export * from "babylonjs/Cameras/targetCamera";
  43779. export * from "babylonjs/Cameras/freeCamera";
  43780. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43781. export * from "babylonjs/Cameras/touchCamera";
  43782. export * from "babylonjs/Cameras/arcRotateCamera";
  43783. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43784. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43785. export * from "babylonjs/Cameras/flyCamera";
  43786. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43787. export * from "babylonjs/Cameras/followCamera";
  43788. export * from "babylonjs/Cameras/followCameraInputsManager";
  43789. export * from "babylonjs/Cameras/gamepadCamera";
  43790. export * from "babylonjs/Cameras/Stereoscopic/index";
  43791. export * from "babylonjs/Cameras/universalCamera";
  43792. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43793. export * from "babylonjs/Cameras/VR/index";
  43794. export * from "babylonjs/Cameras/XR/index";
  43795. export * from "babylonjs/Cameras/RigModes/index";
  43796. }
  43797. declare module "babylonjs/Collisions/index" {
  43798. export * from "babylonjs/Collisions/collider";
  43799. export * from "babylonjs/Collisions/collisionCoordinator";
  43800. export * from "babylonjs/Collisions/pickingInfo";
  43801. export * from "babylonjs/Collisions/intersectionInfo";
  43802. export * from "babylonjs/Collisions/meshCollisionData";
  43803. }
  43804. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43805. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43806. import { Vector3 } from "babylonjs/Maths/math.vector";
  43807. import { Ray } from "babylonjs/Culling/ray";
  43808. import { Plane } from "babylonjs/Maths/math.plane";
  43809. /**
  43810. * Contains an array of blocks representing the octree
  43811. */
  43812. export interface IOctreeContainer<T> {
  43813. /**
  43814. * Blocks within the octree
  43815. */
  43816. blocks: Array<OctreeBlock<T>>;
  43817. }
  43818. /**
  43819. * Class used to store a cell in an octree
  43820. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43821. */
  43822. export class OctreeBlock<T> {
  43823. /**
  43824. * Gets the content of the current block
  43825. */
  43826. entries: T[];
  43827. /**
  43828. * Gets the list of block children
  43829. */
  43830. blocks: Array<OctreeBlock<T>>;
  43831. private _depth;
  43832. private _maxDepth;
  43833. private _capacity;
  43834. private _minPoint;
  43835. private _maxPoint;
  43836. private _boundingVectors;
  43837. private _creationFunc;
  43838. /**
  43839. * Creates a new block
  43840. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43841. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43842. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43843. * @param depth defines the current depth of this block in the octree
  43844. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43845. * @param creationFunc defines a callback to call when an element is added to the block
  43846. */
  43847. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43848. /**
  43849. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43850. */
  43851. readonly capacity: number;
  43852. /**
  43853. * Gets the minimum vector (in world space) of the block's bounding box
  43854. */
  43855. readonly minPoint: Vector3;
  43856. /**
  43857. * Gets the maximum vector (in world space) of the block's bounding box
  43858. */
  43859. readonly maxPoint: Vector3;
  43860. /**
  43861. * Add a new element to this block
  43862. * @param entry defines the element to add
  43863. */
  43864. addEntry(entry: T): void;
  43865. /**
  43866. * Remove an element from this block
  43867. * @param entry defines the element to remove
  43868. */
  43869. removeEntry(entry: T): void;
  43870. /**
  43871. * Add an array of elements to this block
  43872. * @param entries defines the array of elements to add
  43873. */
  43874. addEntries(entries: T[]): void;
  43875. /**
  43876. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43877. * @param frustumPlanes defines the frustum planes to test
  43878. * @param selection defines the array to store current content if selection is positive
  43879. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43880. */
  43881. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43882. /**
  43883. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43884. * @param sphereCenter defines the bounding sphere center
  43885. * @param sphereRadius defines the bounding sphere radius
  43886. * @param selection defines the array to store current content if selection is positive
  43887. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43888. */
  43889. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43890. /**
  43891. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43892. * @param ray defines the ray to test with
  43893. * @param selection defines the array to store current content if selection is positive
  43894. */
  43895. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43896. /**
  43897. * Subdivide the content into child blocks (this block will then be empty)
  43898. */
  43899. createInnerBlocks(): void;
  43900. /**
  43901. * @hidden
  43902. */
  43903. 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;
  43904. }
  43905. }
  43906. declare module "babylonjs/Culling/Octrees/octree" {
  43907. import { SmartArray } from "babylonjs/Misc/smartArray";
  43908. import { Vector3 } from "babylonjs/Maths/math.vector";
  43909. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43911. import { Ray } from "babylonjs/Culling/ray";
  43912. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43913. import { Plane } from "babylonjs/Maths/math.plane";
  43914. /**
  43915. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43916. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43917. */
  43918. export class Octree<T> {
  43919. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  43920. maxDepth: number;
  43921. /**
  43922. * Blocks within the octree containing objects
  43923. */
  43924. blocks: Array<OctreeBlock<T>>;
  43925. /**
  43926. * Content stored in the octree
  43927. */
  43928. dynamicContent: T[];
  43929. private _maxBlockCapacity;
  43930. private _selectionContent;
  43931. private _creationFunc;
  43932. /**
  43933. * Creates a octree
  43934. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43935. * @param creationFunc function to be used to instatiate the octree
  43936. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43937. * @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.)
  43938. */
  43939. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43940. /** 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.) */
  43941. maxDepth?: number);
  43942. /**
  43943. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43944. * @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);
  43945. * @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);
  43946. * @param entries meshes to be added to the octree blocks
  43947. */
  43948. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43949. /**
  43950. * Adds a mesh to the octree
  43951. * @param entry Mesh to add to the octree
  43952. */
  43953. addMesh(entry: T): void;
  43954. /**
  43955. * Remove an element from the octree
  43956. * @param entry defines the element to remove
  43957. */
  43958. removeMesh(entry: T): void;
  43959. /**
  43960. * Selects an array of meshes within the frustum
  43961. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43962. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43963. * @returns array of meshes within the frustum
  43964. */
  43965. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43966. /**
  43967. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43968. * @param sphereCenter defines the bounding sphere center
  43969. * @param sphereRadius defines the bounding sphere radius
  43970. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43971. * @returns an array of objects that intersect the sphere
  43972. */
  43973. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43974. /**
  43975. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43976. * @param ray defines the ray to test with
  43977. * @returns array of intersected objects
  43978. */
  43979. intersectsRay(ray: Ray): SmartArray<T>;
  43980. /**
  43981. * Adds a mesh into the octree block if it intersects the block
  43982. */
  43983. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43984. /**
  43985. * Adds a submesh into the octree block if it intersects the block
  43986. */
  43987. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43988. }
  43989. }
  43990. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43991. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43992. import { Scene } from "babylonjs/scene";
  43993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43995. import { Ray } from "babylonjs/Culling/ray";
  43996. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43997. import { Collider } from "babylonjs/Collisions/collider";
  43998. module "babylonjs/scene" {
  43999. interface Scene {
  44000. /**
  44001. * @hidden
  44002. * Backing Filed
  44003. */
  44004. _selectionOctree: Octree<AbstractMesh>;
  44005. /**
  44006. * Gets the octree used to boost mesh selection (picking)
  44007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44008. */
  44009. selectionOctree: Octree<AbstractMesh>;
  44010. /**
  44011. * Creates or updates the octree used to boost selection (picking)
  44012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44013. * @param maxCapacity defines the maximum capacity per leaf
  44014. * @param maxDepth defines the maximum depth of the octree
  44015. * @returns an octree of AbstractMesh
  44016. */
  44017. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44018. }
  44019. }
  44020. module "babylonjs/Meshes/abstractMesh" {
  44021. interface AbstractMesh {
  44022. /**
  44023. * @hidden
  44024. * Backing Field
  44025. */
  44026. _submeshesOctree: Octree<SubMesh>;
  44027. /**
  44028. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44029. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44030. * @param maxCapacity defines the maximum size of each block (64 by default)
  44031. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44032. * @returns the new octree
  44033. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44034. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44035. */
  44036. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44037. }
  44038. }
  44039. /**
  44040. * Defines the octree scene component responsible to manage any octrees
  44041. * in a given scene.
  44042. */
  44043. export class OctreeSceneComponent {
  44044. /**
  44045. * The component name help to identify the component in the list of scene components.
  44046. */
  44047. readonly name: string;
  44048. /**
  44049. * The scene the component belongs to.
  44050. */
  44051. scene: Scene;
  44052. /**
  44053. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44054. */
  44055. readonly checksIsEnabled: boolean;
  44056. /**
  44057. * Creates a new instance of the component for the given scene
  44058. * @param scene Defines the scene to register the component in
  44059. */
  44060. constructor(scene: Scene);
  44061. /**
  44062. * Registers the component in a given scene
  44063. */
  44064. register(): void;
  44065. /**
  44066. * Return the list of active meshes
  44067. * @returns the list of active meshes
  44068. */
  44069. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44070. /**
  44071. * Return the list of active sub meshes
  44072. * @param mesh The mesh to get the candidates sub meshes from
  44073. * @returns the list of active sub meshes
  44074. */
  44075. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44076. private _tempRay;
  44077. /**
  44078. * Return the list of sub meshes intersecting with a given local ray
  44079. * @param mesh defines the mesh to find the submesh for
  44080. * @param localRay defines the ray in local space
  44081. * @returns the list of intersecting sub meshes
  44082. */
  44083. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44084. /**
  44085. * Return the list of sub meshes colliding with a collider
  44086. * @param mesh defines the mesh to find the submesh for
  44087. * @param collider defines the collider to evaluate the collision against
  44088. * @returns the list of colliding sub meshes
  44089. */
  44090. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44091. /**
  44092. * Rebuilds the elements related to this component in case of
  44093. * context lost for instance.
  44094. */
  44095. rebuild(): void;
  44096. /**
  44097. * Disposes the component and the associated ressources.
  44098. */
  44099. dispose(): void;
  44100. }
  44101. }
  44102. declare module "babylonjs/Culling/Octrees/index" {
  44103. export * from "babylonjs/Culling/Octrees/octree";
  44104. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44105. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44106. }
  44107. declare module "babylonjs/Culling/index" {
  44108. export * from "babylonjs/Culling/boundingBox";
  44109. export * from "babylonjs/Culling/boundingInfo";
  44110. export * from "babylonjs/Culling/boundingSphere";
  44111. export * from "babylonjs/Culling/Octrees/index";
  44112. export * from "babylonjs/Culling/ray";
  44113. }
  44114. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44115. import { IDisposable, Scene } from "babylonjs/scene";
  44116. import { Nullable } from "babylonjs/types";
  44117. import { Observable } from "babylonjs/Misc/observable";
  44118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44119. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44120. import { Camera } from "babylonjs/Cameras/camera";
  44121. /**
  44122. * Renders a layer on top of an existing scene
  44123. */
  44124. export class UtilityLayerRenderer implements IDisposable {
  44125. /** the original scene that will be rendered on top of */
  44126. originalScene: Scene;
  44127. private _pointerCaptures;
  44128. private _lastPointerEvents;
  44129. private static _DefaultUtilityLayer;
  44130. private static _DefaultKeepDepthUtilityLayer;
  44131. private _sharedGizmoLight;
  44132. private _renderCamera;
  44133. /**
  44134. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44135. * @returns the camera that is used when rendering the utility layer
  44136. */
  44137. getRenderCamera(): Nullable<Camera>;
  44138. /**
  44139. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44140. * @param cam the camera that should be used when rendering the utility layer
  44141. */
  44142. setRenderCamera(cam: Nullable<Camera>): void;
  44143. /**
  44144. * @hidden
  44145. * Light which used by gizmos to get light shading
  44146. */
  44147. _getSharedGizmoLight(): HemisphericLight;
  44148. /**
  44149. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44150. */
  44151. pickUtilitySceneFirst: boolean;
  44152. /**
  44153. * 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)
  44154. */
  44155. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44156. /**
  44157. * 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)
  44158. */
  44159. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44160. /**
  44161. * The scene that is rendered on top of the original scene
  44162. */
  44163. utilityLayerScene: Scene;
  44164. /**
  44165. * If the utility layer should automatically be rendered on top of existing scene
  44166. */
  44167. shouldRender: boolean;
  44168. /**
  44169. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44170. */
  44171. onlyCheckPointerDownEvents: boolean;
  44172. /**
  44173. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44174. */
  44175. processAllEvents: boolean;
  44176. /**
  44177. * Observable raised when the pointer move from the utility layer scene to the main scene
  44178. */
  44179. onPointerOutObservable: Observable<number>;
  44180. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44181. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44182. private _afterRenderObserver;
  44183. private _sceneDisposeObserver;
  44184. private _originalPointerObserver;
  44185. /**
  44186. * Instantiates a UtilityLayerRenderer
  44187. * @param originalScene the original scene that will be rendered on top of
  44188. * @param handleEvents boolean indicating if the utility layer should handle events
  44189. */
  44190. constructor(
  44191. /** the original scene that will be rendered on top of */
  44192. originalScene: Scene, handleEvents?: boolean);
  44193. private _notifyObservers;
  44194. /**
  44195. * Renders the utility layers scene on top of the original scene
  44196. */
  44197. render(): void;
  44198. /**
  44199. * Disposes of the renderer
  44200. */
  44201. dispose(): void;
  44202. private _updateCamera;
  44203. }
  44204. }
  44205. declare module "babylonjs/Gizmos/gizmo" {
  44206. import { Nullable } from "babylonjs/types";
  44207. import { IDisposable } from "babylonjs/scene";
  44208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44209. import { Mesh } from "babylonjs/Meshes/mesh";
  44210. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44211. /**
  44212. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44213. */
  44214. export class Gizmo implements IDisposable {
  44215. /** The utility layer the gizmo will be added to */
  44216. gizmoLayer: UtilityLayerRenderer;
  44217. /**
  44218. * The root mesh of the gizmo
  44219. */
  44220. _rootMesh: Mesh;
  44221. private _attachedMesh;
  44222. /**
  44223. * Ratio for the scale of the gizmo (Default: 1)
  44224. */
  44225. scaleRatio: number;
  44226. /**
  44227. * If a custom mesh has been set (Default: false)
  44228. */
  44229. protected _customMeshSet: boolean;
  44230. /**
  44231. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44232. * * When set, interactions will be enabled
  44233. */
  44234. attachedMesh: Nullable<AbstractMesh>;
  44235. /**
  44236. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44237. * @param mesh The mesh to replace the default mesh of the gizmo
  44238. */
  44239. setCustomMesh(mesh: Mesh): void;
  44240. /**
  44241. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44242. */
  44243. updateGizmoRotationToMatchAttachedMesh: boolean;
  44244. /**
  44245. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44246. */
  44247. updateGizmoPositionToMatchAttachedMesh: boolean;
  44248. /**
  44249. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44250. */
  44251. updateScale: boolean;
  44252. protected _interactionsEnabled: boolean;
  44253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44254. private _beforeRenderObserver;
  44255. private _tempVector;
  44256. /**
  44257. * Creates a gizmo
  44258. * @param gizmoLayer The utility layer the gizmo will be added to
  44259. */
  44260. constructor(
  44261. /** The utility layer the gizmo will be added to */
  44262. gizmoLayer?: UtilityLayerRenderer);
  44263. /**
  44264. * Updates the gizmo to match the attached mesh's position/rotation
  44265. */
  44266. protected _update(): void;
  44267. /**
  44268. * Disposes of the gizmo
  44269. */
  44270. dispose(): void;
  44271. }
  44272. }
  44273. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44274. import { Observable } from "babylonjs/Misc/observable";
  44275. import { Nullable } from "babylonjs/types";
  44276. import { Vector3 } from "babylonjs/Maths/math.vector";
  44277. import { Color3 } from "babylonjs/Maths/math.color";
  44278. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44280. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44281. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44282. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44283. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44284. import { Scene } from "babylonjs/scene";
  44285. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44286. /**
  44287. * Single plane drag gizmo
  44288. */
  44289. export class PlaneDragGizmo extends Gizmo {
  44290. /**
  44291. * Drag behavior responsible for the gizmos dragging interactions
  44292. */
  44293. dragBehavior: PointerDragBehavior;
  44294. private _pointerObserver;
  44295. /**
  44296. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44297. */
  44298. snapDistance: number;
  44299. /**
  44300. * Event that fires each time the gizmo snaps to a new location.
  44301. * * snapDistance is the the change in distance
  44302. */
  44303. onSnapObservable: Observable<{
  44304. snapDistance: number;
  44305. }>;
  44306. private _plane;
  44307. private _coloredMaterial;
  44308. private _hoverMaterial;
  44309. private _isEnabled;
  44310. private _parent;
  44311. /** @hidden */
  44312. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44313. /** @hidden */
  44314. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44315. /**
  44316. * Creates a PlaneDragGizmo
  44317. * @param gizmoLayer The utility layer the gizmo will be added to
  44318. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44319. * @param color The color of the gizmo
  44320. */
  44321. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44322. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44323. /**
  44324. * If the gizmo is enabled
  44325. */
  44326. isEnabled: boolean;
  44327. /**
  44328. * Disposes of the gizmo
  44329. */
  44330. dispose(): void;
  44331. }
  44332. }
  44333. declare module "babylonjs/Gizmos/positionGizmo" {
  44334. import { Observable } from "babylonjs/Misc/observable";
  44335. import { Nullable } from "babylonjs/types";
  44336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44337. import { Mesh } from "babylonjs/Meshes/mesh";
  44338. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44339. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44340. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44341. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44342. /**
  44343. * Gizmo that enables dragging a mesh along 3 axis
  44344. */
  44345. export class PositionGizmo extends Gizmo {
  44346. /**
  44347. * Internal gizmo used for interactions on the x axis
  44348. */
  44349. xGizmo: AxisDragGizmo;
  44350. /**
  44351. * Internal gizmo used for interactions on the y axis
  44352. */
  44353. yGizmo: AxisDragGizmo;
  44354. /**
  44355. * Internal gizmo used for interactions on the z axis
  44356. */
  44357. zGizmo: AxisDragGizmo;
  44358. /**
  44359. * Internal gizmo used for interactions on the yz plane
  44360. */
  44361. xPlaneGizmo: PlaneDragGizmo;
  44362. /**
  44363. * Internal gizmo used for interactions on the xz plane
  44364. */
  44365. yPlaneGizmo: PlaneDragGizmo;
  44366. /**
  44367. * Internal gizmo used for interactions on the xy plane
  44368. */
  44369. zPlaneGizmo: PlaneDragGizmo;
  44370. /**
  44371. * private variables
  44372. */
  44373. private _meshAttached;
  44374. private _updateGizmoRotationToMatchAttachedMesh;
  44375. private _snapDistance;
  44376. private _scaleRatio;
  44377. /** Fires an event when any of it's sub gizmos are dragged */
  44378. onDragStartObservable: Observable<unknown>;
  44379. /** Fires an event when any of it's sub gizmos are released from dragging */
  44380. onDragEndObservable: Observable<unknown>;
  44381. /**
  44382. * If set to true, planar drag is enabled
  44383. */
  44384. private _planarGizmoEnabled;
  44385. attachedMesh: Nullable<AbstractMesh>;
  44386. /**
  44387. * Creates a PositionGizmo
  44388. * @param gizmoLayer The utility layer the gizmo will be added to
  44389. */
  44390. constructor(gizmoLayer?: UtilityLayerRenderer);
  44391. /**
  44392. * If the planar drag gizmo is enabled
  44393. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44394. */
  44395. planarGizmoEnabled: boolean;
  44396. updateGizmoRotationToMatchAttachedMesh: boolean;
  44397. /**
  44398. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44399. */
  44400. snapDistance: number;
  44401. /**
  44402. * Ratio for the scale of the gizmo (Default: 1)
  44403. */
  44404. scaleRatio: number;
  44405. /**
  44406. * Disposes of the gizmo
  44407. */
  44408. dispose(): void;
  44409. /**
  44410. * CustomMeshes are not supported by this gizmo
  44411. * @param mesh The mesh to replace the default mesh of the gizmo
  44412. */
  44413. setCustomMesh(mesh: Mesh): void;
  44414. }
  44415. }
  44416. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44417. import { Observable } from "babylonjs/Misc/observable";
  44418. import { Nullable } from "babylonjs/types";
  44419. import { Vector3 } from "babylonjs/Maths/math.vector";
  44420. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44422. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44423. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44424. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44425. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44426. import { Scene } from "babylonjs/scene";
  44427. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44428. import { Color3 } from "babylonjs/Maths/math.color";
  44429. /**
  44430. * Single axis drag gizmo
  44431. */
  44432. export class AxisDragGizmo extends Gizmo {
  44433. /**
  44434. * Drag behavior responsible for the gizmos dragging interactions
  44435. */
  44436. dragBehavior: PointerDragBehavior;
  44437. private _pointerObserver;
  44438. /**
  44439. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44440. */
  44441. snapDistance: number;
  44442. /**
  44443. * Event that fires each time the gizmo snaps to a new location.
  44444. * * snapDistance is the the change in distance
  44445. */
  44446. onSnapObservable: Observable<{
  44447. snapDistance: number;
  44448. }>;
  44449. private _isEnabled;
  44450. private _parent;
  44451. private _arrow;
  44452. private _coloredMaterial;
  44453. private _hoverMaterial;
  44454. /** @hidden */
  44455. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44456. /** @hidden */
  44457. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44458. /**
  44459. * Creates an AxisDragGizmo
  44460. * @param gizmoLayer The utility layer the gizmo will be added to
  44461. * @param dragAxis The axis which the gizmo will be able to drag on
  44462. * @param color The color of the gizmo
  44463. */
  44464. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44465. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44466. /**
  44467. * If the gizmo is enabled
  44468. */
  44469. isEnabled: boolean;
  44470. /**
  44471. * Disposes of the gizmo
  44472. */
  44473. dispose(): void;
  44474. }
  44475. }
  44476. declare module "babylonjs/Debug/axesViewer" {
  44477. import { Vector3 } from "babylonjs/Maths/math.vector";
  44478. import { Nullable } from "babylonjs/types";
  44479. import { Scene } from "babylonjs/scene";
  44480. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44481. /**
  44482. * The Axes viewer will show 3 axes in a specific point in space
  44483. */
  44484. export class AxesViewer {
  44485. private _xAxis;
  44486. private _yAxis;
  44487. private _zAxis;
  44488. private _scaleLinesFactor;
  44489. private _instanced;
  44490. /**
  44491. * Gets the hosting scene
  44492. */
  44493. scene: Scene;
  44494. /**
  44495. * Gets or sets a number used to scale line length
  44496. */
  44497. scaleLines: number;
  44498. /** Gets the node hierarchy used to render x-axis */
  44499. readonly xAxis: TransformNode;
  44500. /** Gets the node hierarchy used to render y-axis */
  44501. readonly yAxis: TransformNode;
  44502. /** Gets the node hierarchy used to render z-axis */
  44503. readonly zAxis: TransformNode;
  44504. /**
  44505. * Creates a new AxesViewer
  44506. * @param scene defines the hosting scene
  44507. * @param scaleLines defines a number used to scale line length (1 by default)
  44508. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44509. * @param xAxis defines the node hierarchy used to render the x-axis
  44510. * @param yAxis defines the node hierarchy used to render the y-axis
  44511. * @param zAxis defines the node hierarchy used to render the z-axis
  44512. */
  44513. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44514. /**
  44515. * Force the viewer to update
  44516. * @param position defines the position of the viewer
  44517. * @param xaxis defines the x axis of the viewer
  44518. * @param yaxis defines the y axis of the viewer
  44519. * @param zaxis defines the z axis of the viewer
  44520. */
  44521. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44522. /**
  44523. * Creates an instance of this axes viewer.
  44524. * @returns a new axes viewer with instanced meshes
  44525. */
  44526. createInstance(): AxesViewer;
  44527. /** Releases resources */
  44528. dispose(): void;
  44529. private static _SetRenderingGroupId;
  44530. }
  44531. }
  44532. declare module "babylonjs/Debug/boneAxesViewer" {
  44533. import { Nullable } from "babylonjs/types";
  44534. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44535. import { Vector3 } from "babylonjs/Maths/math.vector";
  44536. import { Mesh } from "babylonjs/Meshes/mesh";
  44537. import { Bone } from "babylonjs/Bones/bone";
  44538. import { Scene } from "babylonjs/scene";
  44539. /**
  44540. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44541. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44542. */
  44543. export class BoneAxesViewer extends AxesViewer {
  44544. /**
  44545. * Gets or sets the target mesh where to display the axes viewer
  44546. */
  44547. mesh: Nullable<Mesh>;
  44548. /**
  44549. * Gets or sets the target bone where to display the axes viewer
  44550. */
  44551. bone: Nullable<Bone>;
  44552. /** Gets current position */
  44553. pos: Vector3;
  44554. /** Gets direction of X axis */
  44555. xaxis: Vector3;
  44556. /** Gets direction of Y axis */
  44557. yaxis: Vector3;
  44558. /** Gets direction of Z axis */
  44559. zaxis: Vector3;
  44560. /**
  44561. * Creates a new BoneAxesViewer
  44562. * @param scene defines the hosting scene
  44563. * @param bone defines the target bone
  44564. * @param mesh defines the target mesh
  44565. * @param scaleLines defines a scaling factor for line length (1 by default)
  44566. */
  44567. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44568. /**
  44569. * Force the viewer to update
  44570. */
  44571. update(): void;
  44572. /** Releases resources */
  44573. dispose(): void;
  44574. }
  44575. }
  44576. declare module "babylonjs/Debug/debugLayer" {
  44577. import { Scene } from "babylonjs/scene";
  44578. /**
  44579. * Interface used to define scene explorer extensibility option
  44580. */
  44581. export interface IExplorerExtensibilityOption {
  44582. /**
  44583. * Define the option label
  44584. */
  44585. label: string;
  44586. /**
  44587. * Defines the action to execute on click
  44588. */
  44589. action: (entity: any) => void;
  44590. }
  44591. /**
  44592. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44593. */
  44594. export interface IExplorerExtensibilityGroup {
  44595. /**
  44596. * Defines a predicate to test if a given type mut be extended
  44597. */
  44598. predicate: (entity: any) => boolean;
  44599. /**
  44600. * Gets the list of options added to a type
  44601. */
  44602. entries: IExplorerExtensibilityOption[];
  44603. }
  44604. /**
  44605. * Interface used to define the options to use to create the Inspector
  44606. */
  44607. export interface IInspectorOptions {
  44608. /**
  44609. * Display in overlay mode (default: false)
  44610. */
  44611. overlay?: boolean;
  44612. /**
  44613. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44614. */
  44615. globalRoot?: HTMLElement;
  44616. /**
  44617. * Display the Scene explorer
  44618. */
  44619. showExplorer?: boolean;
  44620. /**
  44621. * Display the property inspector
  44622. */
  44623. showInspector?: boolean;
  44624. /**
  44625. * Display in embed mode (both panes on the right)
  44626. */
  44627. embedMode?: boolean;
  44628. /**
  44629. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44630. */
  44631. handleResize?: boolean;
  44632. /**
  44633. * Allow the panes to popup (default: true)
  44634. */
  44635. enablePopup?: boolean;
  44636. /**
  44637. * Allow the panes to be closed by users (default: true)
  44638. */
  44639. enableClose?: boolean;
  44640. /**
  44641. * Optional list of extensibility entries
  44642. */
  44643. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44644. /**
  44645. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44646. */
  44647. inspectorURL?: string;
  44648. }
  44649. module "babylonjs/scene" {
  44650. interface Scene {
  44651. /**
  44652. * @hidden
  44653. * Backing field
  44654. */
  44655. _debugLayer: DebugLayer;
  44656. /**
  44657. * Gets the debug layer (aka Inspector) associated with the scene
  44658. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44659. */
  44660. debugLayer: DebugLayer;
  44661. }
  44662. }
  44663. /**
  44664. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44665. * what is happening in your scene
  44666. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44667. */
  44668. export class DebugLayer {
  44669. /**
  44670. * Define the url to get the inspector script from.
  44671. * By default it uses the babylonjs CDN.
  44672. * @ignoreNaming
  44673. */
  44674. static InspectorURL: string;
  44675. private _scene;
  44676. private BJSINSPECTOR;
  44677. private _onPropertyChangedObservable?;
  44678. /**
  44679. * Observable triggered when a property is changed through the inspector.
  44680. */
  44681. readonly onPropertyChangedObservable: any;
  44682. /**
  44683. * Instantiates a new debug layer.
  44684. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44685. * what is happening in your scene
  44686. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44687. * @param scene Defines the scene to inspect
  44688. */
  44689. constructor(scene: Scene);
  44690. /** Creates the inspector window. */
  44691. private _createInspector;
  44692. /**
  44693. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44694. * @param entity defines the entity to select
  44695. * @param lineContainerTitle defines the specific block to highlight
  44696. */
  44697. select(entity: any, lineContainerTitle?: string): void;
  44698. /** Get the inspector from bundle or global */
  44699. private _getGlobalInspector;
  44700. /**
  44701. * Get if the inspector is visible or not.
  44702. * @returns true if visible otherwise, false
  44703. */
  44704. isVisible(): boolean;
  44705. /**
  44706. * Hide the inspector and close its window.
  44707. */
  44708. hide(): void;
  44709. /**
  44710. * Launch the debugLayer.
  44711. * @param config Define the configuration of the inspector
  44712. * @return a promise fulfilled when the debug layer is visible
  44713. */
  44714. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44715. }
  44716. }
  44717. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44718. import { Nullable } from "babylonjs/types";
  44719. import { Scene } from "babylonjs/scene";
  44720. import { Vector4 } from "babylonjs/Maths/math.vector";
  44721. import { Color4 } from "babylonjs/Maths/math.color";
  44722. import { Mesh } from "babylonjs/Meshes/mesh";
  44723. /**
  44724. * Class containing static functions to help procedurally build meshes
  44725. */
  44726. export class BoxBuilder {
  44727. /**
  44728. * Creates a box mesh
  44729. * * The parameter `size` sets the size (float) of each box side (default 1)
  44730. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44731. * * 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)
  44732. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44736. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44737. * @param name defines the name of the mesh
  44738. * @param options defines the options used to create the mesh
  44739. * @param scene defines the hosting scene
  44740. * @returns the box mesh
  44741. */
  44742. static CreateBox(name: string, options: {
  44743. size?: number;
  44744. width?: number;
  44745. height?: number;
  44746. depth?: number;
  44747. faceUV?: Vector4[];
  44748. faceColors?: Color4[];
  44749. sideOrientation?: number;
  44750. frontUVs?: Vector4;
  44751. backUVs?: Vector4;
  44752. wrap?: boolean;
  44753. topBaseAt?: number;
  44754. bottomBaseAt?: number;
  44755. updatable?: boolean;
  44756. }, scene?: Nullable<Scene>): Mesh;
  44757. }
  44758. }
  44759. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44760. import { Vector4 } from "babylonjs/Maths/math.vector";
  44761. import { Mesh } from "babylonjs/Meshes/mesh";
  44762. import { Scene } from "babylonjs/scene";
  44763. import { Nullable } from "babylonjs/types";
  44764. /**
  44765. * Class containing static functions to help procedurally build meshes
  44766. */
  44767. export class SphereBuilder {
  44768. /**
  44769. * Creates a sphere mesh
  44770. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44771. * * 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`)
  44772. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44773. * * 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
  44774. * * 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)
  44775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44778. * @param name defines the name of the mesh
  44779. * @param options defines the options used to create the mesh
  44780. * @param scene defines the hosting scene
  44781. * @returns the sphere mesh
  44782. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44783. */
  44784. static CreateSphere(name: string, options: {
  44785. segments?: number;
  44786. diameter?: number;
  44787. diameterX?: number;
  44788. diameterY?: number;
  44789. diameterZ?: number;
  44790. arc?: number;
  44791. slice?: number;
  44792. sideOrientation?: number;
  44793. frontUVs?: Vector4;
  44794. backUVs?: Vector4;
  44795. updatable?: boolean;
  44796. }, scene?: Nullable<Scene>): Mesh;
  44797. }
  44798. }
  44799. declare module "babylonjs/Debug/physicsViewer" {
  44800. import { Nullable } from "babylonjs/types";
  44801. import { Scene } from "babylonjs/scene";
  44802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44803. import { Mesh } from "babylonjs/Meshes/mesh";
  44804. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44805. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44806. /**
  44807. * Used to show the physics impostor around the specific mesh
  44808. */
  44809. export class PhysicsViewer {
  44810. /** @hidden */
  44811. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44812. /** @hidden */
  44813. protected _meshes: Array<Nullable<AbstractMesh>>;
  44814. /** @hidden */
  44815. protected _scene: Nullable<Scene>;
  44816. /** @hidden */
  44817. protected _numMeshes: number;
  44818. /** @hidden */
  44819. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44820. private _renderFunction;
  44821. private _utilityLayer;
  44822. private _debugBoxMesh;
  44823. private _debugSphereMesh;
  44824. private _debugCylinderMesh;
  44825. private _debugMaterial;
  44826. private _debugMeshMeshes;
  44827. /**
  44828. * Creates a new PhysicsViewer
  44829. * @param scene defines the hosting scene
  44830. */
  44831. constructor(scene: Scene);
  44832. /** @hidden */
  44833. protected _updateDebugMeshes(): void;
  44834. /**
  44835. * Renders a specified physic impostor
  44836. * @param impostor defines the impostor to render
  44837. * @param targetMesh defines the mesh represented by the impostor
  44838. * @returns the new debug mesh used to render the impostor
  44839. */
  44840. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44841. /**
  44842. * Hides a specified physic impostor
  44843. * @param impostor defines the impostor to hide
  44844. */
  44845. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44846. private _getDebugMaterial;
  44847. private _getDebugBoxMesh;
  44848. private _getDebugSphereMesh;
  44849. private _getDebugCylinderMesh;
  44850. private _getDebugMeshMesh;
  44851. private _getDebugMesh;
  44852. /** Releases all resources */
  44853. dispose(): void;
  44854. }
  44855. }
  44856. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44857. import { Vector3 } from "babylonjs/Maths/math.vector";
  44858. import { Color4 } from "babylonjs/Maths/math.color";
  44859. import { Nullable } from "babylonjs/types";
  44860. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44861. import { Scene } from "babylonjs/scene";
  44862. /**
  44863. * Class containing static functions to help procedurally build meshes
  44864. */
  44865. export class LinesBuilder {
  44866. /**
  44867. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44868. * * 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
  44869. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44870. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44871. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44872. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44873. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44874. * * 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
  44875. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44878. * @param name defines the name of the new line system
  44879. * @param options defines the options used to create the line system
  44880. * @param scene defines the hosting scene
  44881. * @returns a new line system mesh
  44882. */
  44883. static CreateLineSystem(name: string, options: {
  44884. lines: Vector3[][];
  44885. updatable?: boolean;
  44886. instance?: Nullable<LinesMesh>;
  44887. colors?: Nullable<Color4[][]>;
  44888. useVertexAlpha?: boolean;
  44889. }, scene: Nullable<Scene>): LinesMesh;
  44890. /**
  44891. * Creates a line mesh
  44892. * 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
  44893. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44894. * * The parameter `points` is an array successive Vector3
  44895. * * 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
  44896. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44897. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44898. * * When updating an instance, remember that only point positions can change, not the number of points
  44899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44901. * @param name defines the name of the new line system
  44902. * @param options defines the options used to create the line system
  44903. * @param scene defines the hosting scene
  44904. * @returns a new line mesh
  44905. */
  44906. static CreateLines(name: string, options: {
  44907. points: Vector3[];
  44908. updatable?: boolean;
  44909. instance?: Nullable<LinesMesh>;
  44910. colors?: Color4[];
  44911. useVertexAlpha?: boolean;
  44912. }, scene?: Nullable<Scene>): LinesMesh;
  44913. /**
  44914. * Creates a dashed line mesh
  44915. * * 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
  44916. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44917. * * The parameter `points` is an array successive Vector3
  44918. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44919. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44920. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44921. * * 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
  44922. * * When updating an instance, remember that only point positions can change, not the number of points
  44923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44924. * @param name defines the name of the mesh
  44925. * @param options defines the options used to create the mesh
  44926. * @param scene defines the hosting scene
  44927. * @returns the dashed line mesh
  44928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44929. */
  44930. static CreateDashedLines(name: string, options: {
  44931. points: Vector3[];
  44932. dashSize?: number;
  44933. gapSize?: number;
  44934. dashNb?: number;
  44935. updatable?: boolean;
  44936. instance?: LinesMesh;
  44937. }, scene?: Nullable<Scene>): LinesMesh;
  44938. }
  44939. }
  44940. declare module "babylonjs/Debug/rayHelper" {
  44941. import { Nullable } from "babylonjs/types";
  44942. import { Ray } from "babylonjs/Culling/ray";
  44943. import { Vector3 } from "babylonjs/Maths/math.vector";
  44944. import { Color3 } from "babylonjs/Maths/math.color";
  44945. import { Scene } from "babylonjs/scene";
  44946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44947. import "babylonjs/Meshes/Builders/linesBuilder";
  44948. /**
  44949. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44950. * in order to better appreciate the issue one might have.
  44951. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44952. */
  44953. export class RayHelper {
  44954. /**
  44955. * Defines the ray we are currently tryin to visualize.
  44956. */
  44957. ray: Nullable<Ray>;
  44958. private _renderPoints;
  44959. private _renderLine;
  44960. private _renderFunction;
  44961. private _scene;
  44962. private _updateToMeshFunction;
  44963. private _attachedToMesh;
  44964. private _meshSpaceDirection;
  44965. private _meshSpaceOrigin;
  44966. /**
  44967. * Helper function to create a colored helper in a scene in one line.
  44968. * @param ray Defines the ray we are currently tryin to visualize
  44969. * @param scene Defines the scene the ray is used in
  44970. * @param color Defines the color we want to see the ray in
  44971. * @returns The newly created ray helper.
  44972. */
  44973. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44974. /**
  44975. * Instantiate a new ray helper.
  44976. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44977. * in order to better appreciate the issue one might have.
  44978. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44979. * @param ray Defines the ray we are currently tryin to visualize
  44980. */
  44981. constructor(ray: Ray);
  44982. /**
  44983. * Shows the ray we are willing to debug.
  44984. * @param scene Defines the scene the ray needs to be rendered in
  44985. * @param color Defines the color the ray needs to be rendered in
  44986. */
  44987. show(scene: Scene, color?: Color3): void;
  44988. /**
  44989. * Hides the ray we are debugging.
  44990. */
  44991. hide(): void;
  44992. private _render;
  44993. /**
  44994. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44995. * @param mesh Defines the mesh we want the helper attached to
  44996. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44997. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44998. * @param length Defines the length of the ray
  44999. */
  45000. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45001. /**
  45002. * Detach the ray helper from the mesh it has previously been attached to.
  45003. */
  45004. detachFromMesh(): void;
  45005. private _updateToMesh;
  45006. /**
  45007. * Dispose the helper and release its associated resources.
  45008. */
  45009. dispose(): void;
  45010. }
  45011. }
  45012. declare module "babylonjs/Debug/skeletonViewer" {
  45013. import { Color3 } from "babylonjs/Maths/math.color";
  45014. import { Scene } from "babylonjs/scene";
  45015. import { Nullable } from "babylonjs/types";
  45016. import { Skeleton } from "babylonjs/Bones/skeleton";
  45017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45018. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45019. /**
  45020. * Class used to render a debug view of a given skeleton
  45021. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45022. */
  45023. export class SkeletonViewer {
  45024. /** defines the skeleton to render */
  45025. skeleton: Skeleton;
  45026. /** defines the mesh attached to the skeleton */
  45027. mesh: AbstractMesh;
  45028. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45029. autoUpdateBonesMatrices: boolean;
  45030. /** defines the rendering group id to use with the viewer */
  45031. renderingGroupId: number;
  45032. /** Gets or sets the color used to render the skeleton */
  45033. color: Color3;
  45034. private _scene;
  45035. private _debugLines;
  45036. private _debugMesh;
  45037. private _isEnabled;
  45038. private _renderFunction;
  45039. private _utilityLayer;
  45040. /**
  45041. * Returns the mesh used to render the bones
  45042. */
  45043. readonly debugMesh: Nullable<LinesMesh>;
  45044. /**
  45045. * Creates a new SkeletonViewer
  45046. * @param skeleton defines the skeleton to render
  45047. * @param mesh defines the mesh attached to the skeleton
  45048. * @param scene defines the hosting scene
  45049. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45050. * @param renderingGroupId defines the rendering group id to use with the viewer
  45051. */
  45052. constructor(
  45053. /** defines the skeleton to render */
  45054. skeleton: Skeleton,
  45055. /** defines the mesh attached to the skeleton */
  45056. mesh: AbstractMesh, scene: Scene,
  45057. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45058. autoUpdateBonesMatrices?: boolean,
  45059. /** defines the rendering group id to use with the viewer */
  45060. renderingGroupId?: number);
  45061. /** Gets or sets a boolean indicating if the viewer is enabled */
  45062. isEnabled: boolean;
  45063. private _getBonePosition;
  45064. private _getLinesForBonesWithLength;
  45065. private _getLinesForBonesNoLength;
  45066. /** Update the viewer to sync with current skeleton state */
  45067. update(): void;
  45068. /** Release associated resources */
  45069. dispose(): void;
  45070. }
  45071. }
  45072. declare module "babylonjs/Debug/index" {
  45073. export * from "babylonjs/Debug/axesViewer";
  45074. export * from "babylonjs/Debug/boneAxesViewer";
  45075. export * from "babylonjs/Debug/debugLayer";
  45076. export * from "babylonjs/Debug/physicsViewer";
  45077. export * from "babylonjs/Debug/rayHelper";
  45078. export * from "babylonjs/Debug/skeletonViewer";
  45079. }
  45080. declare module "babylonjs/Engines/nullEngine" {
  45081. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45082. import { Scene } from "babylonjs/scene";
  45083. import { Engine } from "babylonjs/Engines/engine";
  45084. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45085. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45086. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45087. import { Effect } from "babylonjs/Materials/effect";
  45088. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45089. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45090. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45091. /**
  45092. * Options to create the null engine
  45093. */
  45094. export class NullEngineOptions {
  45095. /**
  45096. * Render width (Default: 512)
  45097. */
  45098. renderWidth: number;
  45099. /**
  45100. * Render height (Default: 256)
  45101. */
  45102. renderHeight: number;
  45103. /**
  45104. * Texture size (Default: 512)
  45105. */
  45106. textureSize: number;
  45107. /**
  45108. * If delta time between frames should be constant
  45109. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45110. */
  45111. deterministicLockstep: boolean;
  45112. /**
  45113. * Maximum about of steps between frames (Default: 4)
  45114. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45115. */
  45116. lockstepMaxSteps: number;
  45117. }
  45118. /**
  45119. * The null engine class provides support for headless version of babylon.js.
  45120. * This can be used in server side scenario or for testing purposes
  45121. */
  45122. export class NullEngine extends Engine {
  45123. private _options;
  45124. /**
  45125. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45126. */
  45127. isDeterministicLockStep(): boolean;
  45128. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45129. getLockstepMaxSteps(): number;
  45130. /**
  45131. * Sets hardware scaling, used to save performance if needed
  45132. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45133. */
  45134. getHardwareScalingLevel(): number;
  45135. constructor(options?: NullEngineOptions);
  45136. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45137. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45138. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45139. getRenderWidth(useScreen?: boolean): number;
  45140. getRenderHeight(useScreen?: boolean): number;
  45141. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45142. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45143. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45144. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45145. bindSamplers(effect: Effect): void;
  45146. enableEffect(effect: Effect): void;
  45147. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45148. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45149. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45150. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45151. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45152. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45153. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45154. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45155. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45156. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45157. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45158. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45159. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45160. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45161. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45162. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45163. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45164. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45165. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45166. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45167. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45168. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45169. bindBuffers(vertexBuffers: {
  45170. [key: string]: VertexBuffer;
  45171. }, indexBuffer: DataBuffer, effect: Effect): void;
  45172. wipeCaches(bruteForce?: boolean): void;
  45173. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45174. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45175. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45176. /** @hidden */
  45177. _createTexture(): WebGLTexture;
  45178. /** @hidden */
  45179. _releaseTexture(texture: InternalTexture): void;
  45180. 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;
  45181. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45182. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45183. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45184. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45185. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45186. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45187. areAllEffectsReady(): boolean;
  45188. /**
  45189. * @hidden
  45190. * Get the current error code of the webGL context
  45191. * @returns the error code
  45192. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45193. */
  45194. getError(): number;
  45195. /** @hidden */
  45196. _getUnpackAlignement(): number;
  45197. /** @hidden */
  45198. _unpackFlipY(value: boolean): void;
  45199. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45200. /**
  45201. * Updates a dynamic vertex buffer.
  45202. * @param vertexBuffer the vertex buffer to update
  45203. * @param data the data used to update the vertex buffer
  45204. * @param byteOffset the byte offset of the data (optional)
  45205. * @param byteLength the byte length of the data (optional)
  45206. */
  45207. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45208. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45209. /** @hidden */
  45210. _bindTexture(channel: number, texture: InternalTexture): void;
  45211. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45212. releaseEffects(): void;
  45213. displayLoadingUI(): void;
  45214. hideLoadingUI(): void;
  45215. /** @hidden */
  45216. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45217. /** @hidden */
  45218. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45219. /** @hidden */
  45220. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45221. /** @hidden */
  45222. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45223. }
  45224. }
  45225. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45226. import { Nullable, int } from "babylonjs/types";
  45227. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45228. /** @hidden */
  45229. export class _OcclusionDataStorage {
  45230. /** @hidden */
  45231. occlusionInternalRetryCounter: number;
  45232. /** @hidden */
  45233. isOcclusionQueryInProgress: boolean;
  45234. /** @hidden */
  45235. isOccluded: boolean;
  45236. /** @hidden */
  45237. occlusionRetryCount: number;
  45238. /** @hidden */
  45239. occlusionType: number;
  45240. /** @hidden */
  45241. occlusionQueryAlgorithmType: number;
  45242. }
  45243. module "babylonjs/Engines/engine" {
  45244. interface Engine {
  45245. /**
  45246. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45247. * @return the new query
  45248. */
  45249. createQuery(): WebGLQuery;
  45250. /**
  45251. * Delete and release a webGL query
  45252. * @param query defines the query to delete
  45253. * @return the current engine
  45254. */
  45255. deleteQuery(query: WebGLQuery): Engine;
  45256. /**
  45257. * Check if a given query has resolved and got its value
  45258. * @param query defines the query to check
  45259. * @returns true if the query got its value
  45260. */
  45261. isQueryResultAvailable(query: WebGLQuery): boolean;
  45262. /**
  45263. * Gets the value of a given query
  45264. * @param query defines the query to check
  45265. * @returns the value of the query
  45266. */
  45267. getQueryResult(query: WebGLQuery): number;
  45268. /**
  45269. * Initiates an occlusion query
  45270. * @param algorithmType defines the algorithm to use
  45271. * @param query defines the query to use
  45272. * @returns the current engine
  45273. * @see http://doc.babylonjs.com/features/occlusionquery
  45274. */
  45275. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45276. /**
  45277. * Ends an occlusion query
  45278. * @see http://doc.babylonjs.com/features/occlusionquery
  45279. * @param algorithmType defines the algorithm to use
  45280. * @returns the current engine
  45281. */
  45282. endOcclusionQuery(algorithmType: number): Engine;
  45283. /**
  45284. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45285. * Please note that only one query can be issued at a time
  45286. * @returns a time token used to track the time span
  45287. */
  45288. startTimeQuery(): Nullable<_TimeToken>;
  45289. /**
  45290. * Ends a time query
  45291. * @param token defines the token used to measure the time span
  45292. * @returns the time spent (in ns)
  45293. */
  45294. endTimeQuery(token: _TimeToken): int;
  45295. /** @hidden */
  45296. _currentNonTimestampToken: Nullable<_TimeToken>;
  45297. /** @hidden */
  45298. _createTimeQuery(): WebGLQuery;
  45299. /** @hidden */
  45300. _deleteTimeQuery(query: WebGLQuery): void;
  45301. /** @hidden */
  45302. _getGlAlgorithmType(algorithmType: number): number;
  45303. /** @hidden */
  45304. _getTimeQueryResult(query: WebGLQuery): any;
  45305. /** @hidden */
  45306. _getTimeQueryAvailability(query: WebGLQuery): any;
  45307. }
  45308. }
  45309. module "babylonjs/Meshes/abstractMesh" {
  45310. interface AbstractMesh {
  45311. /**
  45312. * Backing filed
  45313. * @hidden
  45314. */
  45315. __occlusionDataStorage: _OcclusionDataStorage;
  45316. /**
  45317. * Access property
  45318. * @hidden
  45319. */
  45320. _occlusionDataStorage: _OcclusionDataStorage;
  45321. /**
  45322. * 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.
  45323. * The default value is -1 which means don't break the query and wait till the result
  45324. * @see http://doc.babylonjs.com/features/occlusionquery
  45325. */
  45326. occlusionRetryCount: number;
  45327. /**
  45328. * 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:
  45329. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45330. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45331. * * 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.
  45332. * @see http://doc.babylonjs.com/features/occlusionquery
  45333. */
  45334. occlusionType: number;
  45335. /**
  45336. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45337. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45338. * * 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.
  45339. * @see http://doc.babylonjs.com/features/occlusionquery
  45340. */
  45341. occlusionQueryAlgorithmType: number;
  45342. /**
  45343. * 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
  45344. * @see http://doc.babylonjs.com/features/occlusionquery
  45345. */
  45346. isOccluded: boolean;
  45347. /**
  45348. * Flag to check the progress status of the query
  45349. * @see http://doc.babylonjs.com/features/occlusionquery
  45350. */
  45351. isOcclusionQueryInProgress: boolean;
  45352. }
  45353. }
  45354. }
  45355. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45356. import { Nullable } from "babylonjs/types";
  45357. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45358. /** @hidden */
  45359. export var _forceTransformFeedbackToBundle: boolean;
  45360. module "babylonjs/Engines/engine" {
  45361. interface Engine {
  45362. /**
  45363. * Creates a webGL transform feedback object
  45364. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45365. * @returns the webGL transform feedback object
  45366. */
  45367. createTransformFeedback(): WebGLTransformFeedback;
  45368. /**
  45369. * Delete a webGL transform feedback object
  45370. * @param value defines the webGL transform feedback object to delete
  45371. */
  45372. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45373. /**
  45374. * Bind a webGL transform feedback object to the webgl context
  45375. * @param value defines the webGL transform feedback object to bind
  45376. */
  45377. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45378. /**
  45379. * Begins a transform feedback operation
  45380. * @param usePoints defines if points or triangles must be used
  45381. */
  45382. beginTransformFeedback(usePoints: boolean): void;
  45383. /**
  45384. * Ends a transform feedback operation
  45385. */
  45386. endTransformFeedback(): void;
  45387. /**
  45388. * Specify the varyings to use with transform feedback
  45389. * @param program defines the associated webGL program
  45390. * @param value defines the list of strings representing the varying names
  45391. */
  45392. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45393. /**
  45394. * Bind a webGL buffer for a transform feedback operation
  45395. * @param value defines the webGL buffer to bind
  45396. */
  45397. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45398. }
  45399. }
  45400. }
  45401. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45402. import { Scene } from "babylonjs/scene";
  45403. import { Engine } from "babylonjs/Engines/engine";
  45404. import { Texture } from "babylonjs/Materials/Textures/texture";
  45405. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45406. import "babylonjs/Engines/Extensions/engine.multiRender";
  45407. /**
  45408. * Creation options of the multi render target texture.
  45409. */
  45410. export interface IMultiRenderTargetOptions {
  45411. /**
  45412. * Define if the texture needs to create mip maps after render.
  45413. */
  45414. generateMipMaps?: boolean;
  45415. /**
  45416. * Define the types of all the draw buffers we want to create
  45417. */
  45418. types?: number[];
  45419. /**
  45420. * Define the sampling modes of all the draw buffers we want to create
  45421. */
  45422. samplingModes?: number[];
  45423. /**
  45424. * Define if a depth buffer is required
  45425. */
  45426. generateDepthBuffer?: boolean;
  45427. /**
  45428. * Define if a stencil buffer is required
  45429. */
  45430. generateStencilBuffer?: boolean;
  45431. /**
  45432. * Define if a depth texture is required instead of a depth buffer
  45433. */
  45434. generateDepthTexture?: boolean;
  45435. /**
  45436. * Define the number of desired draw buffers
  45437. */
  45438. textureCount?: number;
  45439. /**
  45440. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45441. */
  45442. doNotChangeAspectRatio?: boolean;
  45443. /**
  45444. * Define the default type of the buffers we are creating
  45445. */
  45446. defaultType?: number;
  45447. }
  45448. /**
  45449. * A multi render target, like a render target provides the ability to render to a texture.
  45450. * Unlike the render target, it can render to several draw buffers in one draw.
  45451. * This is specially interesting in deferred rendering or for any effects requiring more than
  45452. * just one color from a single pass.
  45453. */
  45454. export class MultiRenderTarget extends RenderTargetTexture {
  45455. private _internalTextures;
  45456. private _textures;
  45457. private _multiRenderTargetOptions;
  45458. /**
  45459. * Get if draw buffers are currently supported by the used hardware and browser.
  45460. */
  45461. readonly isSupported: boolean;
  45462. /**
  45463. * Get the list of textures generated by the multi render target.
  45464. */
  45465. readonly textures: Texture[];
  45466. /**
  45467. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45468. */
  45469. readonly depthTexture: Texture;
  45470. /**
  45471. * Set the wrapping mode on U of all the textures we are rendering to.
  45472. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45473. */
  45474. wrapU: number;
  45475. /**
  45476. * Set the wrapping mode on V of all the textures we are rendering to.
  45477. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45478. */
  45479. wrapV: number;
  45480. /**
  45481. * Instantiate a new multi render target texture.
  45482. * A multi render target, like a render target provides the ability to render to a texture.
  45483. * Unlike the render target, it can render to several draw buffers in one draw.
  45484. * This is specially interesting in deferred rendering or for any effects requiring more than
  45485. * just one color from a single pass.
  45486. * @param name Define the name of the texture
  45487. * @param size Define the size of the buffers to render to
  45488. * @param count Define the number of target we are rendering into
  45489. * @param scene Define the scene the texture belongs to
  45490. * @param options Define the options used to create the multi render target
  45491. */
  45492. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45493. /** @hidden */
  45494. _rebuild(): void;
  45495. private _createInternalTextures;
  45496. private _createTextures;
  45497. /**
  45498. * Define the number of samples used if MSAA is enabled.
  45499. */
  45500. samples: number;
  45501. /**
  45502. * Resize all the textures in the multi render target.
  45503. * Be carrefull as it will recreate all the data in the new texture.
  45504. * @param size Define the new size
  45505. */
  45506. resize(size: any): void;
  45507. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45508. /**
  45509. * Dispose the render targets and their associated resources
  45510. */
  45511. dispose(): void;
  45512. /**
  45513. * Release all the underlying texture used as draw buffers.
  45514. */
  45515. releaseInternalTextures(): void;
  45516. }
  45517. }
  45518. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45520. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45521. import { Nullable } from "babylonjs/types";
  45522. module "babylonjs/Engines/engine" {
  45523. interface Engine {
  45524. /**
  45525. * Unbind a list of render target textures from the webGL context
  45526. * This is used only when drawBuffer extension or webGL2 are active
  45527. * @param textures defines the render target textures to unbind
  45528. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45529. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45530. */
  45531. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45532. /**
  45533. * Create a multi render target texture
  45534. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45535. * @param size defines the size of the texture
  45536. * @param options defines the creation options
  45537. * @returns the cube texture as an InternalTexture
  45538. */
  45539. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45540. /**
  45541. * Update the sample count for a given multiple render target texture
  45542. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45543. * @param textures defines the textures to update
  45544. * @param samples defines the sample count to set
  45545. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45546. */
  45547. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45548. }
  45549. }
  45550. }
  45551. declare module "babylonjs/Engines/Extensions/index" {
  45552. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45553. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45554. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45555. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45556. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45557. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45558. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45559. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45560. }
  45561. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45562. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45563. /** @hidden */
  45564. export var rgbdEncodePixelShader: {
  45565. name: string;
  45566. shader: string;
  45567. };
  45568. }
  45569. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45570. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45571. /** @hidden */
  45572. export var rgbdDecodePixelShader: {
  45573. name: string;
  45574. shader: string;
  45575. };
  45576. }
  45577. declare module "babylonjs/Misc/environmentTextureTools" {
  45578. import { Nullable } from "babylonjs/types";
  45579. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45580. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45581. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45582. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45583. import "babylonjs/Shaders/rgbdEncode.fragment";
  45584. import "babylonjs/Shaders/rgbdDecode.fragment";
  45585. /**
  45586. * Raw texture data and descriptor sufficient for WebGL texture upload
  45587. */
  45588. export interface EnvironmentTextureInfo {
  45589. /**
  45590. * Version of the environment map
  45591. */
  45592. version: number;
  45593. /**
  45594. * Width of image
  45595. */
  45596. width: number;
  45597. /**
  45598. * Irradiance information stored in the file.
  45599. */
  45600. irradiance: any;
  45601. /**
  45602. * Specular information stored in the file.
  45603. */
  45604. specular: any;
  45605. }
  45606. /**
  45607. * Defines One Image in the file. It requires only the position in the file
  45608. * as well as the length.
  45609. */
  45610. interface BufferImageData {
  45611. /**
  45612. * Length of the image data.
  45613. */
  45614. length: number;
  45615. /**
  45616. * Position of the data from the null terminator delimiting the end of the JSON.
  45617. */
  45618. position: number;
  45619. }
  45620. /**
  45621. * Defines the specular data enclosed in the file.
  45622. * This corresponds to the version 1 of the data.
  45623. */
  45624. export interface EnvironmentTextureSpecularInfoV1 {
  45625. /**
  45626. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45627. */
  45628. specularDataPosition?: number;
  45629. /**
  45630. * This contains all the images data needed to reconstruct the cubemap.
  45631. */
  45632. mipmaps: Array<BufferImageData>;
  45633. /**
  45634. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45635. */
  45636. lodGenerationScale: number;
  45637. }
  45638. /**
  45639. * Sets of helpers addressing the serialization and deserialization of environment texture
  45640. * stored in a BabylonJS env file.
  45641. * Those files are usually stored as .env files.
  45642. */
  45643. export class EnvironmentTextureTools {
  45644. /**
  45645. * Magic number identifying the env file.
  45646. */
  45647. private static _MagicBytes;
  45648. /**
  45649. * Gets the environment info from an env file.
  45650. * @param data The array buffer containing the .env bytes.
  45651. * @returns the environment file info (the json header) if successfully parsed.
  45652. */
  45653. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45654. /**
  45655. * Creates an environment texture from a loaded cube texture.
  45656. * @param texture defines the cube texture to convert in env file
  45657. * @return a promise containing the environment data if succesfull.
  45658. */
  45659. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45660. /**
  45661. * Creates a JSON representation of the spherical data.
  45662. * @param texture defines the texture containing the polynomials
  45663. * @return the JSON representation of the spherical info
  45664. */
  45665. private static _CreateEnvTextureIrradiance;
  45666. /**
  45667. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45668. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45669. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45670. * @return the views described by info providing access to the underlying buffer
  45671. */
  45672. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45673. /**
  45674. * Uploads the texture info contained in the env file to the GPU.
  45675. * @param texture defines the internal texture to upload to
  45676. * @param arrayBuffer defines the buffer cotaining the data to load
  45677. * @param info defines the texture info retrieved through the GetEnvInfo method
  45678. * @returns a promise
  45679. */
  45680. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45681. /**
  45682. * Uploads the levels of image data to the GPU.
  45683. * @param texture defines the internal texture to upload to
  45684. * @param imageData defines the array buffer views of image data [mipmap][face]
  45685. * @returns a promise
  45686. */
  45687. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45688. /**
  45689. * Uploads spherical polynomials information to the texture.
  45690. * @param texture defines the texture we are trying to upload the information to
  45691. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45692. */
  45693. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45694. /** @hidden */
  45695. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45696. }
  45697. }
  45698. declare module "babylonjs/Maths/math.vertexFormat" {
  45699. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45700. /**
  45701. * Contains position and normal vectors for a vertex
  45702. */
  45703. export class PositionNormalVertex {
  45704. /** the position of the vertex (defaut: 0,0,0) */
  45705. position: Vector3;
  45706. /** the normal of the vertex (defaut: 0,1,0) */
  45707. normal: Vector3;
  45708. /**
  45709. * Creates a PositionNormalVertex
  45710. * @param position the position of the vertex (defaut: 0,0,0)
  45711. * @param normal the normal of the vertex (defaut: 0,1,0)
  45712. */
  45713. constructor(
  45714. /** the position of the vertex (defaut: 0,0,0) */
  45715. position?: Vector3,
  45716. /** the normal of the vertex (defaut: 0,1,0) */
  45717. normal?: Vector3);
  45718. /**
  45719. * Clones the PositionNormalVertex
  45720. * @returns the cloned PositionNormalVertex
  45721. */
  45722. clone(): PositionNormalVertex;
  45723. }
  45724. /**
  45725. * Contains position, normal and uv vectors for a vertex
  45726. */
  45727. export class PositionNormalTextureVertex {
  45728. /** the position of the vertex (defaut: 0,0,0) */
  45729. position: Vector3;
  45730. /** the normal of the vertex (defaut: 0,1,0) */
  45731. normal: Vector3;
  45732. /** the uv of the vertex (default: 0,0) */
  45733. uv: Vector2;
  45734. /**
  45735. * Creates a PositionNormalTextureVertex
  45736. * @param position the position of the vertex (defaut: 0,0,0)
  45737. * @param normal the normal of the vertex (defaut: 0,1,0)
  45738. * @param uv the uv of the vertex (default: 0,0)
  45739. */
  45740. constructor(
  45741. /** the position of the vertex (defaut: 0,0,0) */
  45742. position?: Vector3,
  45743. /** the normal of the vertex (defaut: 0,1,0) */
  45744. normal?: Vector3,
  45745. /** the uv of the vertex (default: 0,0) */
  45746. uv?: Vector2);
  45747. /**
  45748. * Clones the PositionNormalTextureVertex
  45749. * @returns the cloned PositionNormalTextureVertex
  45750. */
  45751. clone(): PositionNormalTextureVertex;
  45752. }
  45753. }
  45754. declare module "babylonjs/Maths/math" {
  45755. export * from "babylonjs/Maths/math.axis";
  45756. export * from "babylonjs/Maths/math.color";
  45757. export * from "babylonjs/Maths/math.constants";
  45758. export * from "babylonjs/Maths/math.frustum";
  45759. export * from "babylonjs/Maths/math.path";
  45760. export * from "babylonjs/Maths/math.plane";
  45761. export * from "babylonjs/Maths/math.size";
  45762. export * from "babylonjs/Maths/math.vector";
  45763. export * from "babylonjs/Maths/math.vertexFormat";
  45764. export * from "babylonjs/Maths/math.viewport";
  45765. }
  45766. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45767. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45768. /** @hidden */
  45769. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45770. private _genericAttributeLocation;
  45771. private _varyingLocationCount;
  45772. private _varyingLocationMap;
  45773. private _replacements;
  45774. private _textureCount;
  45775. private _uniforms;
  45776. lineProcessor(line: string): string;
  45777. attributeProcessor(attribute: string): string;
  45778. varyingProcessor(varying: string, isFragment: boolean): string;
  45779. uniformProcessor(uniform: string): string;
  45780. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45781. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45782. }
  45783. }
  45784. declare module "babylonjs/Engines/nativeEngine" {
  45785. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45786. import { Engine } from "babylonjs/Engines/engine";
  45787. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45788. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45790. import { Effect } from "babylonjs/Materials/effect";
  45791. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45792. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45793. import { Scene } from "babylonjs/scene";
  45794. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45795. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45796. /**
  45797. * Container for accessors for natively-stored mesh data buffers.
  45798. */
  45799. class NativeDataBuffer extends DataBuffer {
  45800. /**
  45801. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45802. */
  45803. nativeIndexBuffer?: any;
  45804. /**
  45805. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45806. */
  45807. nativeVertexBuffer?: any;
  45808. }
  45809. /** @hidden */
  45810. export class NativeEngine extends Engine {
  45811. private readonly _native;
  45812. getHardwareScalingLevel(): number;
  45813. constructor();
  45814. /**
  45815. * Can be used to override the current requestAnimationFrame requester.
  45816. * @hidden
  45817. */
  45818. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45819. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45820. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45821. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45822. recordVertexArrayObject(vertexBuffers: {
  45823. [key: string]: VertexBuffer;
  45824. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45825. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45826. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45827. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45828. /**
  45829. * Draw a list of indexed primitives
  45830. * @param fillMode defines the primitive to use
  45831. * @param indexStart defines the starting index
  45832. * @param indexCount defines the number of index to draw
  45833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45834. */
  45835. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45836. /**
  45837. * Draw a list of unindexed primitives
  45838. * @param fillMode defines the primitive to use
  45839. * @param verticesStart defines the index of first vertex to draw
  45840. * @param verticesCount defines the count of vertices to draw
  45841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45842. */
  45843. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45844. createPipelineContext(): IPipelineContext;
  45845. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45846. /** @hidden */
  45847. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45848. /** @hidden */
  45849. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45850. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45851. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45852. protected _setProgram(program: WebGLProgram): void;
  45853. _releaseEffect(effect: Effect): void;
  45854. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45855. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45856. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45857. bindSamplers(effect: Effect): void;
  45858. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45859. getRenderWidth(useScreen?: boolean): number;
  45860. getRenderHeight(useScreen?: boolean): number;
  45861. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45862. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45863. /**
  45864. * Set the z offset to apply to current rendering
  45865. * @param value defines the offset to apply
  45866. */
  45867. setZOffset(value: number): void;
  45868. /**
  45869. * Gets the current value of the zOffset
  45870. * @returns the current zOffset state
  45871. */
  45872. getZOffset(): number;
  45873. /**
  45874. * Enable or disable depth buffering
  45875. * @param enable defines the state to set
  45876. */
  45877. setDepthBuffer(enable: boolean): void;
  45878. /**
  45879. * Gets a boolean indicating if depth writing is enabled
  45880. * @returns the current depth writing state
  45881. */
  45882. getDepthWrite(): boolean;
  45883. /**
  45884. * Enable or disable depth writing
  45885. * @param enable defines the state to set
  45886. */
  45887. setDepthWrite(enable: boolean): void;
  45888. /**
  45889. * Enable or disable color writing
  45890. * @param enable defines the state to set
  45891. */
  45892. setColorWrite(enable: boolean): void;
  45893. /**
  45894. * Gets a boolean indicating if color writing is enabled
  45895. * @returns the current color writing state
  45896. */
  45897. getColorWrite(): boolean;
  45898. /**
  45899. * Sets alpha constants used by some alpha blending modes
  45900. * @param r defines the red component
  45901. * @param g defines the green component
  45902. * @param b defines the blue component
  45903. * @param a defines the alpha component
  45904. */
  45905. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45906. /**
  45907. * Sets the current alpha mode
  45908. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  45909. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45910. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45911. */
  45912. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45913. /**
  45914. * Gets the current alpha mode
  45915. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45916. * @returns the current alpha mode
  45917. */
  45918. getAlphaMode(): number;
  45919. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45920. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45921. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45922. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45923. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45924. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45925. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45926. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45927. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45928. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45929. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45930. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45931. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45932. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45933. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45934. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45935. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45936. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45937. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45938. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45939. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45940. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45941. wipeCaches(bruteForce?: boolean): void;
  45942. _createTexture(): WebGLTexture;
  45943. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45944. /**
  45945. * Usually called from BABYLON.Texture.ts.
  45946. * Passed information to create a WebGLTexture
  45947. * @param urlArg defines a value which contains one of the following:
  45948. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45949. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45950. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45951. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45952. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45953. * @param scene needed for loading to the correct scene
  45954. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45955. * @param onLoad optional callback to be called upon successful completion
  45956. * @param onError optional callback to be called upon failure
  45957. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45958. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45959. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45960. * @param forcedExtension defines the extension to use to pick the right loader
  45961. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45962. */
  45963. 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;
  45964. /**
  45965. * Creates a cube texture
  45966. * @param rootUrl defines the url where the files to load is located
  45967. * @param scene defines the current scene
  45968. * @param files defines the list of files to load (1 per face)
  45969. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45970. * @param onLoad defines an optional callback raised when the texture is loaded
  45971. * @param onError defines an optional callback raised if there is an issue to load the texture
  45972. * @param format defines the format of the data
  45973. * @param forcedExtension defines the extension to use to pick the right loader
  45974. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45975. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45976. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45977. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45978. * @returns the cube texture as an InternalTexture
  45979. */
  45980. 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;
  45981. private _getSamplingFilter;
  45982. private static _GetNativeTextureFormat;
  45983. createRenderTargetTexture(size: number | {
  45984. width: number;
  45985. height: number;
  45986. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45987. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45988. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45989. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45990. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45991. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45992. /**
  45993. * Updates a dynamic vertex buffer.
  45994. * @param vertexBuffer the vertex buffer to update
  45995. * @param data the data used to update the vertex buffer
  45996. * @param byteOffset the byte offset of the data (optional)
  45997. * @param byteLength the byte length of the data (optional)
  45998. */
  45999. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46000. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46001. private _updateAnisotropicLevel;
  46002. private _getAddressMode;
  46003. /** @hidden */
  46004. _bindTexture(channel: number, texture: InternalTexture): void;
  46005. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46006. releaseEffects(): void;
  46007. /** @hidden */
  46008. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46009. /** @hidden */
  46010. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46011. /** @hidden */
  46012. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46013. /** @hidden */
  46014. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46015. }
  46016. }
  46017. declare module "babylonjs/Engines/index" {
  46018. export * from "babylonjs/Engines/constants";
  46019. export * from "babylonjs/Engines/engine";
  46020. export * from "babylonjs/Engines/engineStore";
  46021. export * from "babylonjs/Engines/nullEngine";
  46022. export * from "babylonjs/Engines/Extensions/index";
  46023. export * from "babylonjs/Engines/IPipelineContext";
  46024. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46025. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46026. export * from "babylonjs/Engines/nativeEngine";
  46027. }
  46028. declare module "babylonjs/Events/clipboardEvents" {
  46029. /**
  46030. * Gather the list of clipboard event types as constants.
  46031. */
  46032. export class ClipboardEventTypes {
  46033. /**
  46034. * The clipboard event is fired when a copy command is active (pressed).
  46035. */
  46036. static readonly COPY: number;
  46037. /**
  46038. * The clipboard event is fired when a cut command is active (pressed).
  46039. */
  46040. static readonly CUT: number;
  46041. /**
  46042. * The clipboard event is fired when a paste command is active (pressed).
  46043. */
  46044. static readonly PASTE: number;
  46045. }
  46046. /**
  46047. * This class is used to store clipboard related info for the onClipboardObservable event.
  46048. */
  46049. export class ClipboardInfo {
  46050. /**
  46051. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46052. */
  46053. type: number;
  46054. /**
  46055. * Defines the related dom event
  46056. */
  46057. event: ClipboardEvent;
  46058. /**
  46059. *Creates an instance of ClipboardInfo.
  46060. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46061. * @param event Defines the related dom event
  46062. */
  46063. constructor(
  46064. /**
  46065. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46066. */
  46067. type: number,
  46068. /**
  46069. * Defines the related dom event
  46070. */
  46071. event: ClipboardEvent);
  46072. /**
  46073. * Get the clipboard event's type from the keycode.
  46074. * @param keyCode Defines the keyCode for the current keyboard event.
  46075. * @return {number}
  46076. */
  46077. static GetTypeFromCharacter(keyCode: number): number;
  46078. }
  46079. }
  46080. declare module "babylonjs/Events/index" {
  46081. export * from "babylonjs/Events/keyboardEvents";
  46082. export * from "babylonjs/Events/pointerEvents";
  46083. export * from "babylonjs/Events/clipboardEvents";
  46084. }
  46085. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46086. import { Scene } from "babylonjs/scene";
  46087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46088. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46089. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46090. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46091. /**
  46092. * Google Daydream controller
  46093. */
  46094. export class DaydreamController extends WebVRController {
  46095. /**
  46096. * Base Url for the controller model.
  46097. */
  46098. static MODEL_BASE_URL: string;
  46099. /**
  46100. * File name for the controller model.
  46101. */
  46102. static MODEL_FILENAME: string;
  46103. /**
  46104. * Gamepad Id prefix used to identify Daydream Controller.
  46105. */
  46106. static readonly GAMEPAD_ID_PREFIX: string;
  46107. /**
  46108. * Creates a new DaydreamController from a gamepad
  46109. * @param vrGamepad the gamepad that the controller should be created from
  46110. */
  46111. constructor(vrGamepad: any);
  46112. /**
  46113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46114. * @param scene scene in which to add meshes
  46115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46116. */
  46117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46118. /**
  46119. * Called once for each button that changed state since the last frame
  46120. * @param buttonIdx Which button index changed
  46121. * @param state New state of the button
  46122. * @param changes Which properties on the state changed since last frame
  46123. */
  46124. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46125. }
  46126. }
  46127. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46128. import { Scene } from "babylonjs/scene";
  46129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46130. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46131. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46132. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46133. /**
  46134. * Gear VR Controller
  46135. */
  46136. export class GearVRController extends WebVRController {
  46137. /**
  46138. * Base Url for the controller model.
  46139. */
  46140. static MODEL_BASE_URL: string;
  46141. /**
  46142. * File name for the controller model.
  46143. */
  46144. static MODEL_FILENAME: string;
  46145. /**
  46146. * Gamepad Id prefix used to identify this controller.
  46147. */
  46148. static readonly GAMEPAD_ID_PREFIX: string;
  46149. private readonly _buttonIndexToObservableNameMap;
  46150. /**
  46151. * Creates a new GearVRController from a gamepad
  46152. * @param vrGamepad the gamepad that the controller should be created from
  46153. */
  46154. constructor(vrGamepad: any);
  46155. /**
  46156. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46157. * @param scene scene in which to add meshes
  46158. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46159. */
  46160. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46161. /**
  46162. * Called once for each button that changed state since the last frame
  46163. * @param buttonIdx Which button index changed
  46164. * @param state New state of the button
  46165. * @param changes Which properties on the state changed since last frame
  46166. */
  46167. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46168. }
  46169. }
  46170. declare module "babylonjs/Gamepads/Controllers/index" {
  46171. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46172. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46173. export * from "babylonjs/Gamepads/Controllers/genericController";
  46174. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46175. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46176. export * from "babylonjs/Gamepads/Controllers/viveController";
  46177. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46178. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46179. }
  46180. declare module "babylonjs/Gamepads/index" {
  46181. export * from "babylonjs/Gamepads/Controllers/index";
  46182. export * from "babylonjs/Gamepads/gamepad";
  46183. export * from "babylonjs/Gamepads/gamepadManager";
  46184. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46185. export * from "babylonjs/Gamepads/xboxGamepad";
  46186. export * from "babylonjs/Gamepads/dualShockGamepad";
  46187. }
  46188. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46189. import { Scene } from "babylonjs/scene";
  46190. import { Vector4 } from "babylonjs/Maths/math.vector";
  46191. import { Color4 } from "babylonjs/Maths/math.color";
  46192. import { Mesh } from "babylonjs/Meshes/mesh";
  46193. import { Nullable } from "babylonjs/types";
  46194. /**
  46195. * Class containing static functions to help procedurally build meshes
  46196. */
  46197. export class PolyhedronBuilder {
  46198. /**
  46199. * Creates a polyhedron mesh
  46200. * * 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
  46201. * * The parameter `size` (positive float, default 1) sets the polygon size
  46202. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46203. * * 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`
  46204. * * 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
  46205. * * 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)`)
  46206. * * 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
  46207. * * 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
  46208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46211. * @param name defines the name of the mesh
  46212. * @param options defines the options used to create the mesh
  46213. * @param scene defines the hosting scene
  46214. * @returns the polyhedron mesh
  46215. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46216. */
  46217. static CreatePolyhedron(name: string, options: {
  46218. type?: number;
  46219. size?: number;
  46220. sizeX?: number;
  46221. sizeY?: number;
  46222. sizeZ?: number;
  46223. custom?: any;
  46224. faceUV?: Vector4[];
  46225. faceColors?: Color4[];
  46226. flat?: boolean;
  46227. updatable?: boolean;
  46228. sideOrientation?: number;
  46229. frontUVs?: Vector4;
  46230. backUVs?: Vector4;
  46231. }, scene?: Nullable<Scene>): Mesh;
  46232. }
  46233. }
  46234. declare module "babylonjs/Gizmos/scaleGizmo" {
  46235. import { Observable } from "babylonjs/Misc/observable";
  46236. import { Nullable } from "babylonjs/types";
  46237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46238. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46239. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46240. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46241. /**
  46242. * Gizmo that enables scaling a mesh along 3 axis
  46243. */
  46244. export class ScaleGizmo extends Gizmo {
  46245. /**
  46246. * Internal gizmo used for interactions on the x axis
  46247. */
  46248. xGizmo: AxisScaleGizmo;
  46249. /**
  46250. * Internal gizmo used for interactions on the y axis
  46251. */
  46252. yGizmo: AxisScaleGizmo;
  46253. /**
  46254. * Internal gizmo used for interactions on the z axis
  46255. */
  46256. zGizmo: AxisScaleGizmo;
  46257. /**
  46258. * Internal gizmo used to scale all axis equally
  46259. */
  46260. uniformScaleGizmo: AxisScaleGizmo;
  46261. private _meshAttached;
  46262. private _updateGizmoRotationToMatchAttachedMesh;
  46263. private _snapDistance;
  46264. private _scaleRatio;
  46265. private _uniformScalingMesh;
  46266. private _octahedron;
  46267. /** Fires an event when any of it's sub gizmos are dragged */
  46268. onDragStartObservable: Observable<unknown>;
  46269. /** Fires an event when any of it's sub gizmos are released from dragging */
  46270. onDragEndObservable: Observable<unknown>;
  46271. attachedMesh: Nullable<AbstractMesh>;
  46272. /**
  46273. * Creates a ScaleGizmo
  46274. * @param gizmoLayer The utility layer the gizmo will be added to
  46275. */
  46276. constructor(gizmoLayer?: UtilityLayerRenderer);
  46277. updateGizmoRotationToMatchAttachedMesh: boolean;
  46278. /**
  46279. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46280. */
  46281. snapDistance: number;
  46282. /**
  46283. * Ratio for the scale of the gizmo (Default: 1)
  46284. */
  46285. scaleRatio: number;
  46286. /**
  46287. * Disposes of the gizmo
  46288. */
  46289. dispose(): void;
  46290. }
  46291. }
  46292. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46293. import { Observable } from "babylonjs/Misc/observable";
  46294. import { Nullable } from "babylonjs/types";
  46295. import { Vector3 } from "babylonjs/Maths/math.vector";
  46296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46297. import { Mesh } from "babylonjs/Meshes/mesh";
  46298. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46299. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46300. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46301. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46302. import { Color3 } from "babylonjs/Maths/math.color";
  46303. /**
  46304. * Single axis scale gizmo
  46305. */
  46306. export class AxisScaleGizmo extends Gizmo {
  46307. /**
  46308. * Drag behavior responsible for the gizmos dragging interactions
  46309. */
  46310. dragBehavior: PointerDragBehavior;
  46311. private _pointerObserver;
  46312. /**
  46313. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46314. */
  46315. snapDistance: number;
  46316. /**
  46317. * Event that fires each time the gizmo snaps to a new location.
  46318. * * snapDistance is the the change in distance
  46319. */
  46320. onSnapObservable: Observable<{
  46321. snapDistance: number;
  46322. }>;
  46323. /**
  46324. * If the scaling operation should be done on all axis (default: false)
  46325. */
  46326. uniformScaling: boolean;
  46327. private _isEnabled;
  46328. private _parent;
  46329. private _arrow;
  46330. private _coloredMaterial;
  46331. private _hoverMaterial;
  46332. /**
  46333. * Creates an AxisScaleGizmo
  46334. * @param gizmoLayer The utility layer the gizmo will be added to
  46335. * @param dragAxis The axis which the gizmo will be able to scale on
  46336. * @param color The color of the gizmo
  46337. */
  46338. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46339. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46340. /**
  46341. * If the gizmo is enabled
  46342. */
  46343. isEnabled: boolean;
  46344. /**
  46345. * Disposes of the gizmo
  46346. */
  46347. dispose(): void;
  46348. /**
  46349. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46350. * @param mesh The mesh to replace the default mesh of the gizmo
  46351. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46352. */
  46353. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46354. }
  46355. }
  46356. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46357. import { Observable } from "babylonjs/Misc/observable";
  46358. import { Nullable } from "babylonjs/types";
  46359. import { Vector3 } from "babylonjs/Maths/math.vector";
  46360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46361. import { Mesh } from "babylonjs/Meshes/mesh";
  46362. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46363. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46364. import { Color3 } from "babylonjs/Maths/math.color";
  46365. import "babylonjs/Meshes/Builders/boxBuilder";
  46366. /**
  46367. * Bounding box gizmo
  46368. */
  46369. export class BoundingBoxGizmo extends Gizmo {
  46370. private _lineBoundingBox;
  46371. private _rotateSpheresParent;
  46372. private _scaleBoxesParent;
  46373. private _boundingDimensions;
  46374. private _renderObserver;
  46375. private _pointerObserver;
  46376. private _scaleDragSpeed;
  46377. private _tmpQuaternion;
  46378. private _tmpVector;
  46379. private _tmpRotationMatrix;
  46380. /**
  46381. * 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)
  46382. */
  46383. ignoreChildren: boolean;
  46384. /**
  46385. * 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)
  46386. */
  46387. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46388. /**
  46389. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46390. */
  46391. rotationSphereSize: number;
  46392. /**
  46393. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46394. */
  46395. scaleBoxSize: number;
  46396. /**
  46397. * 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)
  46398. */
  46399. fixedDragMeshScreenSize: boolean;
  46400. /**
  46401. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46402. */
  46403. fixedDragMeshScreenSizeDistanceFactor: number;
  46404. /**
  46405. * Fired when a rotation sphere or scale box is dragged
  46406. */
  46407. onDragStartObservable: Observable<{}>;
  46408. /**
  46409. * Fired when a scale box is dragged
  46410. */
  46411. onScaleBoxDragObservable: Observable<{}>;
  46412. /**
  46413. * Fired when a scale box drag is ended
  46414. */
  46415. onScaleBoxDragEndObservable: Observable<{}>;
  46416. /**
  46417. * Fired when a rotation sphere is dragged
  46418. */
  46419. onRotationSphereDragObservable: Observable<{}>;
  46420. /**
  46421. * Fired when a rotation sphere drag is ended
  46422. */
  46423. onRotationSphereDragEndObservable: Observable<{}>;
  46424. /**
  46425. * 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)
  46426. */
  46427. scalePivot: Nullable<Vector3>;
  46428. /**
  46429. * Mesh used as a pivot to rotate the attached mesh
  46430. */
  46431. private _anchorMesh;
  46432. private _existingMeshScale;
  46433. private _dragMesh;
  46434. private pointerDragBehavior;
  46435. private coloredMaterial;
  46436. private hoverColoredMaterial;
  46437. /**
  46438. * Sets the color of the bounding box gizmo
  46439. * @param color the color to set
  46440. */
  46441. setColor(color: Color3): void;
  46442. /**
  46443. * Creates an BoundingBoxGizmo
  46444. * @param gizmoLayer The utility layer the gizmo will be added to
  46445. * @param color The color of the gizmo
  46446. */
  46447. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46448. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46449. private _selectNode;
  46450. /**
  46451. * Updates the bounding box information for the Gizmo
  46452. */
  46453. updateBoundingBox(): void;
  46454. private _updateRotationSpheres;
  46455. private _updateScaleBoxes;
  46456. /**
  46457. * Enables rotation on the specified axis and disables rotation on the others
  46458. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46459. */
  46460. setEnabledRotationAxis(axis: string): void;
  46461. /**
  46462. * Enables/disables scaling
  46463. * @param enable if scaling should be enabled
  46464. */
  46465. setEnabledScaling(enable: boolean): void;
  46466. private _updateDummy;
  46467. /**
  46468. * Enables a pointer drag behavior on the bounding box of the gizmo
  46469. */
  46470. enableDragBehavior(): void;
  46471. /**
  46472. * Disposes of the gizmo
  46473. */
  46474. dispose(): void;
  46475. /**
  46476. * 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)
  46477. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46478. * @returns the bounding box mesh with the passed in mesh as a child
  46479. */
  46480. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46481. /**
  46482. * CustomMeshes are not supported by this gizmo
  46483. * @param mesh The mesh to replace the default mesh of the gizmo
  46484. */
  46485. setCustomMesh(mesh: Mesh): void;
  46486. }
  46487. }
  46488. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46489. import { Observable } from "babylonjs/Misc/observable";
  46490. import { Nullable } from "babylonjs/types";
  46491. import { Vector3 } from "babylonjs/Maths/math.vector";
  46492. import { Color3 } from "babylonjs/Maths/math.color";
  46493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46494. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46495. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46496. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46497. import "babylonjs/Meshes/Builders/linesBuilder";
  46498. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46499. /**
  46500. * Single plane rotation gizmo
  46501. */
  46502. export class PlaneRotationGizmo extends Gizmo {
  46503. /**
  46504. * Drag behavior responsible for the gizmos dragging interactions
  46505. */
  46506. dragBehavior: PointerDragBehavior;
  46507. private _pointerObserver;
  46508. /**
  46509. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46510. */
  46511. snapDistance: number;
  46512. /**
  46513. * Event that fires each time the gizmo snaps to a new location.
  46514. * * snapDistance is the the change in distance
  46515. */
  46516. onSnapObservable: Observable<{
  46517. snapDistance: number;
  46518. }>;
  46519. private _isEnabled;
  46520. private _parent;
  46521. /**
  46522. * Creates a PlaneRotationGizmo
  46523. * @param gizmoLayer The utility layer the gizmo will be added to
  46524. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46525. * @param color The color of the gizmo
  46526. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46527. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46528. */
  46529. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46530. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46531. /**
  46532. * If the gizmo is enabled
  46533. */
  46534. isEnabled: boolean;
  46535. /**
  46536. * Disposes of the gizmo
  46537. */
  46538. dispose(): void;
  46539. }
  46540. }
  46541. declare module "babylonjs/Gizmos/rotationGizmo" {
  46542. import { Observable } from "babylonjs/Misc/observable";
  46543. import { Nullable } from "babylonjs/types";
  46544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46545. import { Mesh } from "babylonjs/Meshes/mesh";
  46546. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46547. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46548. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46549. /**
  46550. * Gizmo that enables rotating a mesh along 3 axis
  46551. */
  46552. export class RotationGizmo extends Gizmo {
  46553. /**
  46554. * Internal gizmo used for interactions on the x axis
  46555. */
  46556. xGizmo: PlaneRotationGizmo;
  46557. /**
  46558. * Internal gizmo used for interactions on the y axis
  46559. */
  46560. yGizmo: PlaneRotationGizmo;
  46561. /**
  46562. * Internal gizmo used for interactions on the z axis
  46563. */
  46564. zGizmo: PlaneRotationGizmo;
  46565. /** Fires an event when any of it's sub gizmos are dragged */
  46566. onDragStartObservable: Observable<unknown>;
  46567. /** Fires an event when any of it's sub gizmos are released from dragging */
  46568. onDragEndObservable: Observable<unknown>;
  46569. private _meshAttached;
  46570. attachedMesh: Nullable<AbstractMesh>;
  46571. /**
  46572. * Creates a RotationGizmo
  46573. * @param gizmoLayer The utility layer the gizmo will be added to
  46574. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46575. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46576. */
  46577. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46578. updateGizmoRotationToMatchAttachedMesh: boolean;
  46579. /**
  46580. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46581. */
  46582. snapDistance: number;
  46583. /**
  46584. * Ratio for the scale of the gizmo (Default: 1)
  46585. */
  46586. scaleRatio: number;
  46587. /**
  46588. * Disposes of the gizmo
  46589. */
  46590. dispose(): void;
  46591. /**
  46592. * CustomMeshes are not supported by this gizmo
  46593. * @param mesh The mesh to replace the default mesh of the gizmo
  46594. */
  46595. setCustomMesh(mesh: Mesh): void;
  46596. }
  46597. }
  46598. declare module "babylonjs/Gizmos/gizmoManager" {
  46599. import { Observable } from "babylonjs/Misc/observable";
  46600. import { Nullable } from "babylonjs/types";
  46601. import { Scene, IDisposable } from "babylonjs/scene";
  46602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46603. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46604. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46605. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46606. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46607. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46608. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46609. /**
  46610. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46611. */
  46612. export class GizmoManager implements IDisposable {
  46613. private scene;
  46614. /**
  46615. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46616. */
  46617. gizmos: {
  46618. positionGizmo: Nullable<PositionGizmo>;
  46619. rotationGizmo: Nullable<RotationGizmo>;
  46620. scaleGizmo: Nullable<ScaleGizmo>;
  46621. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46622. };
  46623. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46624. clearGizmoOnEmptyPointerEvent: boolean;
  46625. /** Fires an event when the manager is attached to a mesh */
  46626. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46627. private _gizmosEnabled;
  46628. private _pointerObserver;
  46629. private _attachedMesh;
  46630. private _boundingBoxColor;
  46631. private _defaultUtilityLayer;
  46632. private _defaultKeepDepthUtilityLayer;
  46633. /**
  46634. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46635. */
  46636. boundingBoxDragBehavior: SixDofDragBehavior;
  46637. /**
  46638. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46639. */
  46640. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46641. /**
  46642. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46643. */
  46644. usePointerToAttachGizmos: boolean;
  46645. /**
  46646. * Utility layer that the bounding box gizmo belongs to
  46647. */
  46648. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46649. /**
  46650. * Utility layer that all gizmos besides bounding box belong to
  46651. */
  46652. readonly utilityLayer: UtilityLayerRenderer;
  46653. /**
  46654. * Instatiates a gizmo manager
  46655. * @param scene the scene to overlay the gizmos on top of
  46656. */
  46657. constructor(scene: Scene);
  46658. /**
  46659. * Attaches a set of gizmos to the specified mesh
  46660. * @param mesh The mesh the gizmo's should be attached to
  46661. */
  46662. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46663. /**
  46664. * If the position gizmo is enabled
  46665. */
  46666. positionGizmoEnabled: boolean;
  46667. /**
  46668. * If the rotation gizmo is enabled
  46669. */
  46670. rotationGizmoEnabled: boolean;
  46671. /**
  46672. * If the scale gizmo is enabled
  46673. */
  46674. scaleGizmoEnabled: boolean;
  46675. /**
  46676. * If the boundingBox gizmo is enabled
  46677. */
  46678. boundingBoxGizmoEnabled: boolean;
  46679. /**
  46680. * Disposes of the gizmo manager
  46681. */
  46682. dispose(): void;
  46683. }
  46684. }
  46685. declare module "babylonjs/Lights/directionalLight" {
  46686. import { Camera } from "babylonjs/Cameras/camera";
  46687. import { Scene } from "babylonjs/scene";
  46688. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46690. import { Light } from "babylonjs/Lights/light";
  46691. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46692. import { Effect } from "babylonjs/Materials/effect";
  46693. /**
  46694. * A directional light is defined by a direction (what a surprise!).
  46695. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46696. * 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.
  46697. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46698. */
  46699. export class DirectionalLight extends ShadowLight {
  46700. private _shadowFrustumSize;
  46701. /**
  46702. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46703. */
  46704. /**
  46705. * Specifies a fix frustum size for the shadow generation.
  46706. */
  46707. shadowFrustumSize: number;
  46708. private _shadowOrthoScale;
  46709. /**
  46710. * Gets the shadow projection scale against the optimal computed one.
  46711. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46712. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46713. */
  46714. /**
  46715. * Sets the shadow projection scale against the optimal computed one.
  46716. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46717. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46718. */
  46719. shadowOrthoScale: number;
  46720. /**
  46721. * Automatically compute the projection matrix to best fit (including all the casters)
  46722. * on each frame.
  46723. */
  46724. autoUpdateExtends: boolean;
  46725. private _orthoLeft;
  46726. private _orthoRight;
  46727. private _orthoTop;
  46728. private _orthoBottom;
  46729. /**
  46730. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46731. * The directional light is emitted from everywhere in the given direction.
  46732. * It can cast shadows.
  46733. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46734. * @param name The friendly name of the light
  46735. * @param direction The direction of the light
  46736. * @param scene The scene the light belongs to
  46737. */
  46738. constructor(name: string, direction: Vector3, scene: Scene);
  46739. /**
  46740. * Returns the string "DirectionalLight".
  46741. * @return The class name
  46742. */
  46743. getClassName(): string;
  46744. /**
  46745. * Returns the integer 1.
  46746. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46747. */
  46748. getTypeID(): number;
  46749. /**
  46750. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46751. * Returns the DirectionalLight Shadow projection matrix.
  46752. */
  46753. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46754. /**
  46755. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46756. * Returns the DirectionalLight Shadow projection matrix.
  46757. */
  46758. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46759. /**
  46760. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46761. * Returns the DirectionalLight Shadow projection matrix.
  46762. */
  46763. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46764. protected _buildUniformLayout(): void;
  46765. /**
  46766. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46767. * @param effect The effect to update
  46768. * @param lightIndex The index of the light in the effect to update
  46769. * @returns The directional light
  46770. */
  46771. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46772. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46773. /**
  46774. * Gets the minZ used for shadow according to both the scene and the light.
  46775. *
  46776. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46777. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46778. * @param activeCamera The camera we are returning the min for
  46779. * @returns the depth min z
  46780. */
  46781. getDepthMinZ(activeCamera: Camera): number;
  46782. /**
  46783. * Gets the maxZ used for shadow according to both the scene and the light.
  46784. *
  46785. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46786. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46787. * @param activeCamera The camera we are returning the max for
  46788. * @returns the depth max z
  46789. */
  46790. getDepthMaxZ(activeCamera: Camera): number;
  46791. /**
  46792. * Prepares the list of defines specific to the light type.
  46793. * @param defines the list of defines
  46794. * @param lightIndex defines the index of the light for the effect
  46795. */
  46796. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46797. }
  46798. }
  46799. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46800. import { Mesh } from "babylonjs/Meshes/mesh";
  46801. /**
  46802. * Class containing static functions to help procedurally build meshes
  46803. */
  46804. export class HemisphereBuilder {
  46805. /**
  46806. * Creates a hemisphere mesh
  46807. * @param name defines the name of the mesh
  46808. * @param options defines the options used to create the mesh
  46809. * @param scene defines the hosting scene
  46810. * @returns the hemisphere mesh
  46811. */
  46812. static CreateHemisphere(name: string, options: {
  46813. segments?: number;
  46814. diameter?: number;
  46815. sideOrientation?: number;
  46816. }, scene: any): Mesh;
  46817. }
  46818. }
  46819. declare module "babylonjs/Lights/spotLight" {
  46820. import { Nullable } from "babylonjs/types";
  46821. import { Scene } from "babylonjs/scene";
  46822. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46824. import { Effect } from "babylonjs/Materials/effect";
  46825. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46826. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46827. /**
  46828. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46829. * These values define a cone of light starting from the position, emitting toward the direction.
  46830. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46831. * and the exponent defines the speed of the decay of the light with distance (reach).
  46832. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46833. */
  46834. export class SpotLight extends ShadowLight {
  46835. private _angle;
  46836. private _innerAngle;
  46837. private _cosHalfAngle;
  46838. private _lightAngleScale;
  46839. private _lightAngleOffset;
  46840. /**
  46841. * Gets the cone angle of the spot light in Radians.
  46842. */
  46843. /**
  46844. * Sets the cone angle of the spot light in Radians.
  46845. */
  46846. angle: number;
  46847. /**
  46848. * Only used in gltf falloff mode, this defines the angle where
  46849. * the directional falloff will start before cutting at angle which could be seen
  46850. * as outer angle.
  46851. */
  46852. /**
  46853. * Only used in gltf falloff mode, this defines the angle where
  46854. * the directional falloff will start before cutting at angle which could be seen
  46855. * as outer angle.
  46856. */
  46857. innerAngle: number;
  46858. private _shadowAngleScale;
  46859. /**
  46860. * Allows scaling the angle of the light for shadow generation only.
  46861. */
  46862. /**
  46863. * Allows scaling the angle of the light for shadow generation only.
  46864. */
  46865. shadowAngleScale: number;
  46866. /**
  46867. * The light decay speed with the distance from the emission spot.
  46868. */
  46869. exponent: number;
  46870. private _projectionTextureMatrix;
  46871. /**
  46872. * Allows reading the projecton texture
  46873. */
  46874. readonly projectionTextureMatrix: Matrix;
  46875. protected _projectionTextureLightNear: number;
  46876. /**
  46877. * Gets the near clip of the Spotlight for texture projection.
  46878. */
  46879. /**
  46880. * Sets the near clip of the Spotlight for texture projection.
  46881. */
  46882. projectionTextureLightNear: number;
  46883. protected _projectionTextureLightFar: number;
  46884. /**
  46885. * Gets the far clip of the Spotlight for texture projection.
  46886. */
  46887. /**
  46888. * Sets the far clip of the Spotlight for texture projection.
  46889. */
  46890. projectionTextureLightFar: number;
  46891. protected _projectionTextureUpDirection: Vector3;
  46892. /**
  46893. * Gets the Up vector of the Spotlight for texture projection.
  46894. */
  46895. /**
  46896. * Sets the Up vector of the Spotlight for texture projection.
  46897. */
  46898. projectionTextureUpDirection: Vector3;
  46899. private _projectionTexture;
  46900. /**
  46901. * Gets the projection texture of the light.
  46902. */
  46903. /**
  46904. * Sets the projection texture of the light.
  46905. */
  46906. projectionTexture: Nullable<BaseTexture>;
  46907. private _projectionTextureViewLightDirty;
  46908. private _projectionTextureProjectionLightDirty;
  46909. private _projectionTextureDirty;
  46910. private _projectionTextureViewTargetVector;
  46911. private _projectionTextureViewLightMatrix;
  46912. private _projectionTextureProjectionLightMatrix;
  46913. private _projectionTextureScalingMatrix;
  46914. /**
  46915. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46916. * It can cast shadows.
  46917. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46918. * @param name The light friendly name
  46919. * @param position The position of the spot light in the scene
  46920. * @param direction The direction of the light in the scene
  46921. * @param angle The cone angle of the light in Radians
  46922. * @param exponent The light decay speed with the distance from the emission spot
  46923. * @param scene The scene the lights belongs to
  46924. */
  46925. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46926. /**
  46927. * Returns the string "SpotLight".
  46928. * @returns the class name
  46929. */
  46930. getClassName(): string;
  46931. /**
  46932. * Returns the integer 2.
  46933. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46934. */
  46935. getTypeID(): number;
  46936. /**
  46937. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46938. */
  46939. protected _setDirection(value: Vector3): void;
  46940. /**
  46941. * Overrides the position setter to recompute the projection texture view light Matrix.
  46942. */
  46943. protected _setPosition(value: Vector3): void;
  46944. /**
  46945. * 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.
  46946. * Returns the SpotLight.
  46947. */
  46948. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46949. protected _computeProjectionTextureViewLightMatrix(): void;
  46950. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46951. /**
  46952. * Main function for light texture projection matrix computing.
  46953. */
  46954. protected _computeProjectionTextureMatrix(): void;
  46955. protected _buildUniformLayout(): void;
  46956. private _computeAngleValues;
  46957. /**
  46958. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46959. * @param effect The effect to update
  46960. * @param lightIndex The index of the light in the effect to update
  46961. * @returns The spot light
  46962. */
  46963. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46964. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46965. /**
  46966. * Disposes the light and the associated resources.
  46967. */
  46968. dispose(): void;
  46969. /**
  46970. * Prepares the list of defines specific to the light type.
  46971. * @param defines the list of defines
  46972. * @param lightIndex defines the index of the light for the effect
  46973. */
  46974. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46975. }
  46976. }
  46977. declare module "babylonjs/Gizmos/lightGizmo" {
  46978. import { Nullable } from "babylonjs/types";
  46979. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46980. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46981. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46982. import { Light } from "babylonjs/Lights/light";
  46983. /**
  46984. * Gizmo that enables viewing a light
  46985. */
  46986. export class LightGizmo extends Gizmo {
  46987. private _lightMesh;
  46988. private _material;
  46989. private cachedPosition;
  46990. private cachedForward;
  46991. /**
  46992. * Creates a LightGizmo
  46993. * @param gizmoLayer The utility layer the gizmo will be added to
  46994. */
  46995. constructor(gizmoLayer?: UtilityLayerRenderer);
  46996. private _light;
  46997. /**
  46998. * The light that the gizmo is attached to
  46999. */
  47000. light: Nullable<Light>;
  47001. /**
  47002. * Gets the material used to render the light gizmo
  47003. */
  47004. readonly material: StandardMaterial;
  47005. /**
  47006. * @hidden
  47007. * Updates the gizmo to match the attached mesh's position/rotation
  47008. */
  47009. protected _update(): void;
  47010. private static _Scale;
  47011. /**
  47012. * Creates the lines for a light mesh
  47013. */
  47014. private static _createLightLines;
  47015. /**
  47016. * Disposes of the light gizmo
  47017. */
  47018. dispose(): void;
  47019. private static _CreateHemisphericLightMesh;
  47020. private static _CreatePointLightMesh;
  47021. private static _CreateSpotLightMesh;
  47022. private static _CreateDirectionalLightMesh;
  47023. }
  47024. }
  47025. declare module "babylonjs/Gizmos/index" {
  47026. export * from "babylonjs/Gizmos/axisDragGizmo";
  47027. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47028. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47029. export * from "babylonjs/Gizmos/gizmo";
  47030. export * from "babylonjs/Gizmos/gizmoManager";
  47031. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47032. export * from "babylonjs/Gizmos/positionGizmo";
  47033. export * from "babylonjs/Gizmos/rotationGizmo";
  47034. export * from "babylonjs/Gizmos/scaleGizmo";
  47035. export * from "babylonjs/Gizmos/lightGizmo";
  47036. export * from "babylonjs/Gizmos/planeDragGizmo";
  47037. }
  47038. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47039. /** @hidden */
  47040. export var backgroundFragmentDeclaration: {
  47041. name: string;
  47042. shader: string;
  47043. };
  47044. }
  47045. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47046. /** @hidden */
  47047. export var backgroundUboDeclaration: {
  47048. name: string;
  47049. shader: string;
  47050. };
  47051. }
  47052. declare module "babylonjs/Shaders/background.fragment" {
  47053. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47054. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47055. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47056. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47057. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47058. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47059. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47060. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47061. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47062. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47063. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47064. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47065. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47066. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47067. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47068. /** @hidden */
  47069. export var backgroundPixelShader: {
  47070. name: string;
  47071. shader: string;
  47072. };
  47073. }
  47074. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47075. /** @hidden */
  47076. export var backgroundVertexDeclaration: {
  47077. name: string;
  47078. shader: string;
  47079. };
  47080. }
  47081. declare module "babylonjs/Shaders/background.vertex" {
  47082. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47083. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47084. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47085. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47086. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47087. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47088. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47089. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47090. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47091. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47092. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47093. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47094. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47095. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47096. /** @hidden */
  47097. export var backgroundVertexShader: {
  47098. name: string;
  47099. shader: string;
  47100. };
  47101. }
  47102. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47103. import { Nullable, int, float } from "babylonjs/types";
  47104. import { Scene } from "babylonjs/scene";
  47105. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47106. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47108. import { Mesh } from "babylonjs/Meshes/mesh";
  47109. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47110. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47111. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47113. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47114. import { Color3 } from "babylonjs/Maths/math.color";
  47115. import "babylonjs/Shaders/background.fragment";
  47116. import "babylonjs/Shaders/background.vertex";
  47117. /**
  47118. * Background material used to create an efficient environement around your scene.
  47119. */
  47120. export class BackgroundMaterial extends PushMaterial {
  47121. /**
  47122. * Standard reflectance value at parallel view angle.
  47123. */
  47124. static StandardReflectance0: number;
  47125. /**
  47126. * Standard reflectance value at grazing angle.
  47127. */
  47128. static StandardReflectance90: number;
  47129. protected _primaryColor: Color3;
  47130. /**
  47131. * Key light Color (multiply against the environement texture)
  47132. */
  47133. primaryColor: Color3;
  47134. protected __perceptualColor: Nullable<Color3>;
  47135. /**
  47136. * Experimental Internal Use Only.
  47137. *
  47138. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47139. * This acts as a helper to set the primary color to a more "human friendly" value.
  47140. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47141. * output color as close as possible from the chosen value.
  47142. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47143. * part of lighting setup.)
  47144. */
  47145. _perceptualColor: Nullable<Color3>;
  47146. protected _primaryColorShadowLevel: float;
  47147. /**
  47148. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47149. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47150. */
  47151. primaryColorShadowLevel: float;
  47152. protected _primaryColorHighlightLevel: float;
  47153. /**
  47154. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47155. * The primary color is used at the level chosen to define what the white area would look.
  47156. */
  47157. primaryColorHighlightLevel: float;
  47158. protected _reflectionTexture: Nullable<BaseTexture>;
  47159. /**
  47160. * Reflection Texture used in the material.
  47161. * Should be author in a specific way for the best result (refer to the documentation).
  47162. */
  47163. reflectionTexture: Nullable<BaseTexture>;
  47164. protected _reflectionBlur: float;
  47165. /**
  47166. * Reflection Texture level of blur.
  47167. *
  47168. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47169. * texture twice.
  47170. */
  47171. reflectionBlur: float;
  47172. protected _diffuseTexture: Nullable<BaseTexture>;
  47173. /**
  47174. * Diffuse Texture used in the material.
  47175. * Should be author in a specific way for the best result (refer to the documentation).
  47176. */
  47177. diffuseTexture: Nullable<BaseTexture>;
  47178. protected _shadowLights: Nullable<IShadowLight[]>;
  47179. /**
  47180. * Specify the list of lights casting shadow on the material.
  47181. * All scene shadow lights will be included if null.
  47182. */
  47183. shadowLights: Nullable<IShadowLight[]>;
  47184. protected _shadowLevel: float;
  47185. /**
  47186. * Helps adjusting the shadow to a softer level if required.
  47187. * 0 means black shadows and 1 means no shadows.
  47188. */
  47189. shadowLevel: float;
  47190. protected _sceneCenter: Vector3;
  47191. /**
  47192. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47193. * It is usually zero but might be interesting to modify according to your setup.
  47194. */
  47195. sceneCenter: Vector3;
  47196. protected _opacityFresnel: boolean;
  47197. /**
  47198. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47199. * This helps ensuring a nice transition when the camera goes under the ground.
  47200. */
  47201. opacityFresnel: boolean;
  47202. protected _reflectionFresnel: boolean;
  47203. /**
  47204. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47205. * This helps adding a mirror texture on the ground.
  47206. */
  47207. reflectionFresnel: boolean;
  47208. protected _reflectionFalloffDistance: number;
  47209. /**
  47210. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47211. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47212. */
  47213. reflectionFalloffDistance: number;
  47214. protected _reflectionAmount: number;
  47215. /**
  47216. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47217. */
  47218. reflectionAmount: number;
  47219. protected _reflectionReflectance0: number;
  47220. /**
  47221. * This specifies the weight of the reflection at grazing angle.
  47222. */
  47223. reflectionReflectance0: number;
  47224. protected _reflectionReflectance90: number;
  47225. /**
  47226. * This specifies the weight of the reflection at a perpendicular point of view.
  47227. */
  47228. reflectionReflectance90: number;
  47229. /**
  47230. * Sets the reflection reflectance fresnel values according to the default standard
  47231. * empirically know to work well :-)
  47232. */
  47233. reflectionStandardFresnelWeight: number;
  47234. protected _useRGBColor: boolean;
  47235. /**
  47236. * Helps to directly use the maps channels instead of their level.
  47237. */
  47238. useRGBColor: boolean;
  47239. protected _enableNoise: boolean;
  47240. /**
  47241. * This helps reducing the banding effect that could occur on the background.
  47242. */
  47243. enableNoise: boolean;
  47244. /**
  47245. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47246. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47247. * Recommended to be keep at 1.0 except for special cases.
  47248. */
  47249. fovMultiplier: number;
  47250. private _fovMultiplier;
  47251. /**
  47252. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47253. */
  47254. useEquirectangularFOV: boolean;
  47255. private _maxSimultaneousLights;
  47256. /**
  47257. * Number of Simultaneous lights allowed on the material.
  47258. */
  47259. maxSimultaneousLights: int;
  47260. /**
  47261. * Default configuration related to image processing available in the Background Material.
  47262. */
  47263. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47264. /**
  47265. * Keep track of the image processing observer to allow dispose and replace.
  47266. */
  47267. private _imageProcessingObserver;
  47268. /**
  47269. * Attaches a new image processing configuration to the PBR Material.
  47270. * @param configuration (if null the scene configuration will be use)
  47271. */
  47272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47273. /**
  47274. * Gets the image processing configuration used either in this material.
  47275. */
  47276. /**
  47277. * Sets the Default image processing configuration used either in the this material.
  47278. *
  47279. * If sets to null, the scene one is in use.
  47280. */
  47281. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47282. /**
  47283. * Gets wether the color curves effect is enabled.
  47284. */
  47285. /**
  47286. * Sets wether the color curves effect is enabled.
  47287. */
  47288. cameraColorCurvesEnabled: boolean;
  47289. /**
  47290. * Gets wether the color grading effect is enabled.
  47291. */
  47292. /**
  47293. * Gets wether the color grading effect is enabled.
  47294. */
  47295. cameraColorGradingEnabled: boolean;
  47296. /**
  47297. * Gets wether tonemapping is enabled or not.
  47298. */
  47299. /**
  47300. * Sets wether tonemapping is enabled or not
  47301. */
  47302. cameraToneMappingEnabled: boolean;
  47303. /**
  47304. * The camera exposure used on this material.
  47305. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47306. * This corresponds to a photographic exposure.
  47307. */
  47308. /**
  47309. * The camera exposure used on this material.
  47310. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47311. * This corresponds to a photographic exposure.
  47312. */
  47313. cameraExposure: float;
  47314. /**
  47315. * Gets The camera contrast used on this material.
  47316. */
  47317. /**
  47318. * Sets The camera contrast used on this material.
  47319. */
  47320. cameraContrast: float;
  47321. /**
  47322. * Gets the Color Grading 2D Lookup Texture.
  47323. */
  47324. /**
  47325. * Sets the Color Grading 2D Lookup Texture.
  47326. */
  47327. cameraColorGradingTexture: Nullable<BaseTexture>;
  47328. /**
  47329. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47330. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47331. * 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;
  47332. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47333. */
  47334. /**
  47335. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47336. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47337. * 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;
  47338. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47339. */
  47340. cameraColorCurves: Nullable<ColorCurves>;
  47341. /**
  47342. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47343. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47344. */
  47345. switchToBGR: boolean;
  47346. private _renderTargets;
  47347. private _reflectionControls;
  47348. private _white;
  47349. private _primaryShadowColor;
  47350. private _primaryHighlightColor;
  47351. /**
  47352. * Instantiates a Background Material in the given scene
  47353. * @param name The friendly name of the material
  47354. * @param scene The scene to add the material to
  47355. */
  47356. constructor(name: string, scene: Scene);
  47357. /**
  47358. * Gets a boolean indicating that current material needs to register RTT
  47359. */
  47360. readonly hasRenderTargetTextures: boolean;
  47361. /**
  47362. * The entire material has been created in order to prevent overdraw.
  47363. * @returns false
  47364. */
  47365. needAlphaTesting(): boolean;
  47366. /**
  47367. * The entire material has been created in order to prevent overdraw.
  47368. * @returns true if blending is enable
  47369. */
  47370. needAlphaBlending(): boolean;
  47371. /**
  47372. * Checks wether the material is ready to be rendered for a given mesh.
  47373. * @param mesh The mesh to render
  47374. * @param subMesh The submesh to check against
  47375. * @param useInstances Specify wether or not the material is used with instances
  47376. * @returns true if all the dependencies are ready (Textures, Effects...)
  47377. */
  47378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47379. /**
  47380. * Compute the primary color according to the chosen perceptual color.
  47381. */
  47382. private _computePrimaryColorFromPerceptualColor;
  47383. /**
  47384. * Compute the highlights and shadow colors according to their chosen levels.
  47385. */
  47386. private _computePrimaryColors;
  47387. /**
  47388. * Build the uniform buffer used in the material.
  47389. */
  47390. buildUniformLayout(): void;
  47391. /**
  47392. * Unbind the material.
  47393. */
  47394. unbind(): void;
  47395. /**
  47396. * Bind only the world matrix to the material.
  47397. * @param world The world matrix to bind.
  47398. */
  47399. bindOnlyWorldMatrix(world: Matrix): void;
  47400. /**
  47401. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47402. * @param world The world matrix to bind.
  47403. * @param subMesh The submesh to bind for.
  47404. */
  47405. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47406. /**
  47407. * Checks to see if a texture is used in the material.
  47408. * @param texture - Base texture to use.
  47409. * @returns - Boolean specifying if a texture is used in the material.
  47410. */
  47411. hasTexture(texture: BaseTexture): boolean;
  47412. /**
  47413. * Dispose the material.
  47414. * @param forceDisposeEffect Force disposal of the associated effect.
  47415. * @param forceDisposeTextures Force disposal of the associated textures.
  47416. */
  47417. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47418. /**
  47419. * Clones the material.
  47420. * @param name The cloned name.
  47421. * @returns The cloned material.
  47422. */
  47423. clone(name: string): BackgroundMaterial;
  47424. /**
  47425. * Serializes the current material to its JSON representation.
  47426. * @returns The JSON representation.
  47427. */
  47428. serialize(): any;
  47429. /**
  47430. * Gets the class name of the material
  47431. * @returns "BackgroundMaterial"
  47432. */
  47433. getClassName(): string;
  47434. /**
  47435. * Parse a JSON input to create back a background material.
  47436. * @param source The JSON data to parse
  47437. * @param scene The scene to create the parsed material in
  47438. * @param rootUrl The root url of the assets the material depends upon
  47439. * @returns the instantiated BackgroundMaterial.
  47440. */
  47441. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47442. }
  47443. }
  47444. declare module "babylonjs/Helpers/environmentHelper" {
  47445. import { Observable } from "babylonjs/Misc/observable";
  47446. import { Nullable } from "babylonjs/types";
  47447. import { Scene } from "babylonjs/scene";
  47448. import { Vector3 } from "babylonjs/Maths/math.vector";
  47449. import { Color3 } from "babylonjs/Maths/math.color";
  47450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47451. import { Mesh } from "babylonjs/Meshes/mesh";
  47452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47453. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47454. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47455. import "babylonjs/Meshes/Builders/planeBuilder";
  47456. import "babylonjs/Meshes/Builders/boxBuilder";
  47457. /**
  47458. * Represents the different options available during the creation of
  47459. * a Environment helper.
  47460. *
  47461. * This can control the default ground, skybox and image processing setup of your scene.
  47462. */
  47463. export interface IEnvironmentHelperOptions {
  47464. /**
  47465. * Specifies wether or not to create a ground.
  47466. * True by default.
  47467. */
  47468. createGround: boolean;
  47469. /**
  47470. * Specifies the ground size.
  47471. * 15 by default.
  47472. */
  47473. groundSize: number;
  47474. /**
  47475. * The texture used on the ground for the main color.
  47476. * Comes from the BabylonJS CDN by default.
  47477. *
  47478. * Remarks: Can be either a texture or a url.
  47479. */
  47480. groundTexture: string | BaseTexture;
  47481. /**
  47482. * The color mixed in the ground texture by default.
  47483. * BabylonJS clearColor by default.
  47484. */
  47485. groundColor: Color3;
  47486. /**
  47487. * Specifies the ground opacity.
  47488. * 1 by default.
  47489. */
  47490. groundOpacity: number;
  47491. /**
  47492. * Enables the ground to receive shadows.
  47493. * True by default.
  47494. */
  47495. enableGroundShadow: boolean;
  47496. /**
  47497. * Helps preventing the shadow to be fully black on the ground.
  47498. * 0.5 by default.
  47499. */
  47500. groundShadowLevel: number;
  47501. /**
  47502. * Creates a mirror texture attach to the ground.
  47503. * false by default.
  47504. */
  47505. enableGroundMirror: boolean;
  47506. /**
  47507. * Specifies the ground mirror size ratio.
  47508. * 0.3 by default as the default kernel is 64.
  47509. */
  47510. groundMirrorSizeRatio: number;
  47511. /**
  47512. * Specifies the ground mirror blur kernel size.
  47513. * 64 by default.
  47514. */
  47515. groundMirrorBlurKernel: number;
  47516. /**
  47517. * Specifies the ground mirror visibility amount.
  47518. * 1 by default
  47519. */
  47520. groundMirrorAmount: number;
  47521. /**
  47522. * Specifies the ground mirror reflectance weight.
  47523. * This uses the standard weight of the background material to setup the fresnel effect
  47524. * of the mirror.
  47525. * 1 by default.
  47526. */
  47527. groundMirrorFresnelWeight: number;
  47528. /**
  47529. * Specifies the ground mirror Falloff distance.
  47530. * This can helps reducing the size of the reflection.
  47531. * 0 by Default.
  47532. */
  47533. groundMirrorFallOffDistance: number;
  47534. /**
  47535. * Specifies the ground mirror texture type.
  47536. * Unsigned Int by Default.
  47537. */
  47538. groundMirrorTextureType: number;
  47539. /**
  47540. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47541. * the shown objects.
  47542. */
  47543. groundYBias: number;
  47544. /**
  47545. * Specifies wether or not to create a skybox.
  47546. * True by default.
  47547. */
  47548. createSkybox: boolean;
  47549. /**
  47550. * Specifies the skybox size.
  47551. * 20 by default.
  47552. */
  47553. skyboxSize: number;
  47554. /**
  47555. * The texture used on the skybox for the main color.
  47556. * Comes from the BabylonJS CDN by default.
  47557. *
  47558. * Remarks: Can be either a texture or a url.
  47559. */
  47560. skyboxTexture: string | BaseTexture;
  47561. /**
  47562. * The color mixed in the skybox texture by default.
  47563. * BabylonJS clearColor by default.
  47564. */
  47565. skyboxColor: Color3;
  47566. /**
  47567. * The background rotation around the Y axis of the scene.
  47568. * This helps aligning the key lights of your scene with the background.
  47569. * 0 by default.
  47570. */
  47571. backgroundYRotation: number;
  47572. /**
  47573. * Compute automatically the size of the elements to best fit with the scene.
  47574. */
  47575. sizeAuto: boolean;
  47576. /**
  47577. * Default position of the rootMesh if autoSize is not true.
  47578. */
  47579. rootPosition: Vector3;
  47580. /**
  47581. * Sets up the image processing in the scene.
  47582. * true by default.
  47583. */
  47584. setupImageProcessing: boolean;
  47585. /**
  47586. * The texture used as your environment texture in the scene.
  47587. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47588. *
  47589. * Remarks: Can be either a texture or a url.
  47590. */
  47591. environmentTexture: string | BaseTexture;
  47592. /**
  47593. * The value of the exposure to apply to the scene.
  47594. * 0.6 by default if setupImageProcessing is true.
  47595. */
  47596. cameraExposure: number;
  47597. /**
  47598. * The value of the contrast to apply to the scene.
  47599. * 1.6 by default if setupImageProcessing is true.
  47600. */
  47601. cameraContrast: number;
  47602. /**
  47603. * Specifies wether or not tonemapping should be enabled in the scene.
  47604. * true by default if setupImageProcessing is true.
  47605. */
  47606. toneMappingEnabled: boolean;
  47607. }
  47608. /**
  47609. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47610. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47611. * It also helps with the default setup of your imageProcessing configuration.
  47612. */
  47613. export class EnvironmentHelper {
  47614. /**
  47615. * Default ground texture URL.
  47616. */
  47617. private static _groundTextureCDNUrl;
  47618. /**
  47619. * Default skybox texture URL.
  47620. */
  47621. private static _skyboxTextureCDNUrl;
  47622. /**
  47623. * Default environment texture URL.
  47624. */
  47625. private static _environmentTextureCDNUrl;
  47626. /**
  47627. * Creates the default options for the helper.
  47628. */
  47629. private static _getDefaultOptions;
  47630. private _rootMesh;
  47631. /**
  47632. * Gets the root mesh created by the helper.
  47633. */
  47634. readonly rootMesh: Mesh;
  47635. private _skybox;
  47636. /**
  47637. * Gets the skybox created by the helper.
  47638. */
  47639. readonly skybox: Nullable<Mesh>;
  47640. private _skyboxTexture;
  47641. /**
  47642. * Gets the skybox texture created by the helper.
  47643. */
  47644. readonly skyboxTexture: Nullable<BaseTexture>;
  47645. private _skyboxMaterial;
  47646. /**
  47647. * Gets the skybox material created by the helper.
  47648. */
  47649. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47650. private _ground;
  47651. /**
  47652. * Gets the ground mesh created by the helper.
  47653. */
  47654. readonly ground: Nullable<Mesh>;
  47655. private _groundTexture;
  47656. /**
  47657. * Gets the ground texture created by the helper.
  47658. */
  47659. readonly groundTexture: Nullable<BaseTexture>;
  47660. private _groundMirror;
  47661. /**
  47662. * Gets the ground mirror created by the helper.
  47663. */
  47664. readonly groundMirror: Nullable<MirrorTexture>;
  47665. /**
  47666. * Gets the ground mirror render list to helps pushing the meshes
  47667. * you wish in the ground reflection.
  47668. */
  47669. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47670. private _groundMaterial;
  47671. /**
  47672. * Gets the ground material created by the helper.
  47673. */
  47674. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47675. /**
  47676. * Stores the creation options.
  47677. */
  47678. private readonly _scene;
  47679. private _options;
  47680. /**
  47681. * This observable will be notified with any error during the creation of the environment,
  47682. * mainly texture creation errors.
  47683. */
  47684. onErrorObservable: Observable<{
  47685. message?: string;
  47686. exception?: any;
  47687. }>;
  47688. /**
  47689. * constructor
  47690. * @param options Defines the options we want to customize the helper
  47691. * @param scene The scene to add the material to
  47692. */
  47693. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47694. /**
  47695. * Updates the background according to the new options
  47696. * @param options
  47697. */
  47698. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47699. /**
  47700. * Sets the primary color of all the available elements.
  47701. * @param color the main color to affect to the ground and the background
  47702. */
  47703. setMainColor(color: Color3): void;
  47704. /**
  47705. * Setup the image processing according to the specified options.
  47706. */
  47707. private _setupImageProcessing;
  47708. /**
  47709. * Setup the environment texture according to the specified options.
  47710. */
  47711. private _setupEnvironmentTexture;
  47712. /**
  47713. * Setup the background according to the specified options.
  47714. */
  47715. private _setupBackground;
  47716. /**
  47717. * Get the scene sizes according to the setup.
  47718. */
  47719. private _getSceneSize;
  47720. /**
  47721. * Setup the ground according to the specified options.
  47722. */
  47723. private _setupGround;
  47724. /**
  47725. * Setup the ground material according to the specified options.
  47726. */
  47727. private _setupGroundMaterial;
  47728. /**
  47729. * Setup the ground diffuse texture according to the specified options.
  47730. */
  47731. private _setupGroundDiffuseTexture;
  47732. /**
  47733. * Setup the ground mirror texture according to the specified options.
  47734. */
  47735. private _setupGroundMirrorTexture;
  47736. /**
  47737. * Setup the ground to receive the mirror texture.
  47738. */
  47739. private _setupMirrorInGroundMaterial;
  47740. /**
  47741. * Setup the skybox according to the specified options.
  47742. */
  47743. private _setupSkybox;
  47744. /**
  47745. * Setup the skybox material according to the specified options.
  47746. */
  47747. private _setupSkyboxMaterial;
  47748. /**
  47749. * Setup the skybox reflection texture according to the specified options.
  47750. */
  47751. private _setupSkyboxReflectionTexture;
  47752. private _errorHandler;
  47753. /**
  47754. * Dispose all the elements created by the Helper.
  47755. */
  47756. dispose(): void;
  47757. }
  47758. }
  47759. declare module "babylonjs/Helpers/photoDome" {
  47760. import { Observable } from "babylonjs/Misc/observable";
  47761. import { Nullable } from "babylonjs/types";
  47762. import { Scene } from "babylonjs/scene";
  47763. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47764. import { Mesh } from "babylonjs/Meshes/mesh";
  47765. import { Texture } from "babylonjs/Materials/Textures/texture";
  47766. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47767. import "babylonjs/Meshes/Builders/sphereBuilder";
  47768. /**
  47769. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47770. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47771. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47772. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47773. */
  47774. export class PhotoDome extends TransformNode {
  47775. /**
  47776. * Define the image as a Monoscopic panoramic 360 image.
  47777. */
  47778. static readonly MODE_MONOSCOPIC: number;
  47779. /**
  47780. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47781. */
  47782. static readonly MODE_TOPBOTTOM: number;
  47783. /**
  47784. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47785. */
  47786. static readonly MODE_SIDEBYSIDE: number;
  47787. private _useDirectMapping;
  47788. /**
  47789. * The texture being displayed on the sphere
  47790. */
  47791. protected _photoTexture: Texture;
  47792. /**
  47793. * Gets or sets the texture being displayed on the sphere
  47794. */
  47795. photoTexture: Texture;
  47796. /**
  47797. * Observable raised when an error occured while loading the 360 image
  47798. */
  47799. onLoadErrorObservable: Observable<string>;
  47800. /**
  47801. * The skybox material
  47802. */
  47803. protected _material: BackgroundMaterial;
  47804. /**
  47805. * The surface used for the skybox
  47806. */
  47807. protected _mesh: Mesh;
  47808. /**
  47809. * Gets the mesh used for the skybox.
  47810. */
  47811. readonly mesh: Mesh;
  47812. /**
  47813. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47814. * Also see the options.resolution property.
  47815. */
  47816. fovMultiplier: number;
  47817. private _imageMode;
  47818. /**
  47819. * Gets or set the current video mode for the video. It can be:
  47820. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47821. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47822. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47823. */
  47824. imageMode: number;
  47825. /**
  47826. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47827. * @param name Element's name, child elements will append suffixes for their own names.
  47828. * @param urlsOfPhoto defines the url of the photo to display
  47829. * @param options defines an object containing optional or exposed sub element properties
  47830. * @param onError defines a callback called when an error occured while loading the texture
  47831. */
  47832. constructor(name: string, urlOfPhoto: string, options: {
  47833. resolution?: number;
  47834. size?: number;
  47835. useDirectMapping?: boolean;
  47836. faceForward?: boolean;
  47837. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47838. private _onBeforeCameraRenderObserver;
  47839. private _changeImageMode;
  47840. /**
  47841. * Releases resources associated with this node.
  47842. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47843. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47844. */
  47845. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47846. }
  47847. }
  47848. declare module "babylonjs/Misc/rgbdTextureTools" {
  47849. import "babylonjs/Shaders/rgbdDecode.fragment";
  47850. import { Texture } from "babylonjs/Materials/Textures/texture";
  47851. /**
  47852. * Class used to host RGBD texture specific utilities
  47853. */
  47854. export class RGBDTextureTools {
  47855. /**
  47856. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47857. * @param texture the texture to expand.
  47858. */
  47859. static ExpandRGBDTexture(texture: Texture): void;
  47860. }
  47861. }
  47862. declare module "babylonjs/Misc/brdfTextureTools" {
  47863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47864. import { Scene } from "babylonjs/scene";
  47865. /**
  47866. * Class used to host texture specific utilities
  47867. */
  47868. export class BRDFTextureTools {
  47869. /**
  47870. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47871. * @param scene defines the hosting scene
  47872. * @returns the environment BRDF texture
  47873. */
  47874. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47875. private static _environmentBRDFBase64Texture;
  47876. }
  47877. }
  47878. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47879. import { Nullable } from "babylonjs/types";
  47880. import { Color3 } from "babylonjs/Maths/math.color";
  47881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47882. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47883. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47884. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47885. import { Engine } from "babylonjs/Engines/engine";
  47886. import { Scene } from "babylonjs/scene";
  47887. /**
  47888. * @hidden
  47889. */
  47890. export interface IMaterialClearCoatDefines {
  47891. CLEARCOAT: boolean;
  47892. CLEARCOAT_DEFAULTIOR: boolean;
  47893. CLEARCOAT_TEXTURE: boolean;
  47894. CLEARCOAT_TEXTUREDIRECTUV: number;
  47895. CLEARCOAT_BUMP: boolean;
  47896. CLEARCOAT_BUMPDIRECTUV: number;
  47897. CLEARCOAT_TINT: boolean;
  47898. CLEARCOAT_TINT_TEXTURE: boolean;
  47899. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47900. /** @hidden */
  47901. _areTexturesDirty: boolean;
  47902. }
  47903. /**
  47904. * Define the code related to the clear coat parameters of the pbr material.
  47905. */
  47906. export class PBRClearCoatConfiguration {
  47907. /**
  47908. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47909. * The default fits with a polyurethane material.
  47910. */
  47911. private static readonly _DefaultIndexOfRefraction;
  47912. private _isEnabled;
  47913. /**
  47914. * Defines if the clear coat is enabled in the material.
  47915. */
  47916. isEnabled: boolean;
  47917. /**
  47918. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47919. */
  47920. intensity: number;
  47921. /**
  47922. * Defines the clear coat layer roughness.
  47923. */
  47924. roughness: number;
  47925. private _indexOfRefraction;
  47926. /**
  47927. * Defines the index of refraction of the clear coat.
  47928. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47929. * The default fits with a polyurethane material.
  47930. * Changing the default value is more performance intensive.
  47931. */
  47932. indexOfRefraction: number;
  47933. private _texture;
  47934. /**
  47935. * Stores the clear coat values in a texture.
  47936. */
  47937. texture: Nullable<BaseTexture>;
  47938. private _bumpTexture;
  47939. /**
  47940. * Define the clear coat specific bump texture.
  47941. */
  47942. bumpTexture: Nullable<BaseTexture>;
  47943. private _isTintEnabled;
  47944. /**
  47945. * Defines if the clear coat tint is enabled in the material.
  47946. */
  47947. isTintEnabled: boolean;
  47948. /**
  47949. * Defines the clear coat tint of the material.
  47950. * This is only use if tint is enabled
  47951. */
  47952. tintColor: Color3;
  47953. /**
  47954. * Defines the distance at which the tint color should be found in the
  47955. * clear coat media.
  47956. * This is only use if tint is enabled
  47957. */
  47958. tintColorAtDistance: number;
  47959. /**
  47960. * Defines the clear coat layer thickness.
  47961. * This is only use if tint is enabled
  47962. */
  47963. tintThickness: number;
  47964. private _tintTexture;
  47965. /**
  47966. * Stores the clear tint values in a texture.
  47967. * rgb is tint
  47968. * a is a thickness factor
  47969. */
  47970. tintTexture: Nullable<BaseTexture>;
  47971. /** @hidden */
  47972. private _internalMarkAllSubMeshesAsTexturesDirty;
  47973. /** @hidden */
  47974. _markAllSubMeshesAsTexturesDirty(): void;
  47975. /**
  47976. * Instantiate a new istance of clear coat configuration.
  47977. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47978. */
  47979. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47980. /**
  47981. * Gets wehter the submesh is ready to be used or not.
  47982. * @param defines the list of "defines" to update.
  47983. * @param scene defines the scene the material belongs to.
  47984. * @param engine defines the engine the material belongs to.
  47985. * @param disableBumpMap defines wether the material disables bump or not.
  47986. * @returns - boolean indicating that the submesh is ready or not.
  47987. */
  47988. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47989. /**
  47990. * Checks to see if a texture is used in the material.
  47991. * @param defines the list of "defines" to update.
  47992. * @param scene defines the scene to the material belongs to.
  47993. */
  47994. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47995. /**
  47996. * Binds the material data.
  47997. * @param uniformBuffer defines the Uniform buffer to fill in.
  47998. * @param scene defines the scene the material belongs to.
  47999. * @param engine defines the engine the material belongs to.
  48000. * @param disableBumpMap defines wether the material disables bump or not.
  48001. * @param isFrozen defines wether the material is frozen or not.
  48002. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48003. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48004. */
  48005. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48006. /**
  48007. * Checks to see if a texture is used in the material.
  48008. * @param texture - Base texture to use.
  48009. * @returns - Boolean specifying if a texture is used in the material.
  48010. */
  48011. hasTexture(texture: BaseTexture): boolean;
  48012. /**
  48013. * Returns an array of the actively used textures.
  48014. * @param activeTextures Array of BaseTextures
  48015. */
  48016. getActiveTextures(activeTextures: BaseTexture[]): void;
  48017. /**
  48018. * Returns the animatable textures.
  48019. * @param animatables Array of animatable textures.
  48020. */
  48021. getAnimatables(animatables: IAnimatable[]): void;
  48022. /**
  48023. * Disposes the resources of the material.
  48024. * @param forceDisposeTextures - Forces the disposal of all textures.
  48025. */
  48026. dispose(forceDisposeTextures?: boolean): void;
  48027. /**
  48028. * Get the current class name of the texture useful for serialization or dynamic coding.
  48029. * @returns "PBRClearCoatConfiguration"
  48030. */
  48031. getClassName(): string;
  48032. /**
  48033. * Add fallbacks to the effect fallbacks list.
  48034. * @param defines defines the Base texture to use.
  48035. * @param fallbacks defines the current fallback list.
  48036. * @param currentRank defines the current fallback rank.
  48037. * @returns the new fallback rank.
  48038. */
  48039. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48040. /**
  48041. * Add the required uniforms to the current list.
  48042. * @param uniforms defines the current uniform list.
  48043. */
  48044. static AddUniforms(uniforms: string[]): void;
  48045. /**
  48046. * Add the required samplers to the current list.
  48047. * @param samplers defines the current sampler list.
  48048. */
  48049. static AddSamplers(samplers: string[]): void;
  48050. /**
  48051. * Add the required uniforms to the current buffer.
  48052. * @param uniformBuffer defines the current uniform buffer.
  48053. */
  48054. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48055. /**
  48056. * Makes a duplicate of the current configuration into another one.
  48057. * @param clearCoatConfiguration define the config where to copy the info
  48058. */
  48059. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48060. /**
  48061. * Serializes this clear coat configuration.
  48062. * @returns - An object with the serialized config.
  48063. */
  48064. serialize(): any;
  48065. /**
  48066. * Parses a anisotropy Configuration from a serialized object.
  48067. * @param source - Serialized object.
  48068. * @param scene Defines the scene we are parsing for
  48069. * @param rootUrl Defines the rootUrl to load from
  48070. */
  48071. parse(source: any, scene: Scene, rootUrl: string): void;
  48072. }
  48073. }
  48074. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48075. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48076. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48078. import { Vector2 } from "babylonjs/Maths/math.vector";
  48079. import { Scene } from "babylonjs/scene";
  48080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48081. import { Nullable } from "babylonjs/types";
  48082. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48083. /**
  48084. * @hidden
  48085. */
  48086. export interface IMaterialAnisotropicDefines {
  48087. ANISOTROPIC: boolean;
  48088. ANISOTROPIC_TEXTURE: boolean;
  48089. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48090. MAINUV1: boolean;
  48091. _areTexturesDirty: boolean;
  48092. _needUVs: boolean;
  48093. }
  48094. /**
  48095. * Define the code related to the anisotropic parameters of the pbr material.
  48096. */
  48097. export class PBRAnisotropicConfiguration {
  48098. private _isEnabled;
  48099. /**
  48100. * Defines if the anisotropy is enabled in the material.
  48101. */
  48102. isEnabled: boolean;
  48103. /**
  48104. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48105. */
  48106. intensity: number;
  48107. /**
  48108. * Defines if the effect is along the tangents, bitangents or in between.
  48109. * By default, the effect is "strectching" the highlights along the tangents.
  48110. */
  48111. direction: Vector2;
  48112. private _texture;
  48113. /**
  48114. * Stores the anisotropy values in a texture.
  48115. * rg is direction (like normal from -1 to 1)
  48116. * b is a intensity
  48117. */
  48118. texture: Nullable<BaseTexture>;
  48119. /** @hidden */
  48120. private _internalMarkAllSubMeshesAsTexturesDirty;
  48121. /** @hidden */
  48122. _markAllSubMeshesAsTexturesDirty(): void;
  48123. /**
  48124. * Instantiate a new istance of anisotropy configuration.
  48125. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48126. */
  48127. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48128. /**
  48129. * Specifies that the submesh is ready to be used.
  48130. * @param defines the list of "defines" to update.
  48131. * @param scene defines the scene the material belongs to.
  48132. * @returns - boolean indicating that the submesh is ready or not.
  48133. */
  48134. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48135. /**
  48136. * Checks to see if a texture is used in the material.
  48137. * @param defines the list of "defines" to update.
  48138. * @param mesh the mesh we are preparing the defines for.
  48139. * @param scene defines the scene the material belongs to.
  48140. */
  48141. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48142. /**
  48143. * Binds the material data.
  48144. * @param uniformBuffer defines the Uniform buffer to fill in.
  48145. * @param scene defines the scene the material belongs to.
  48146. * @param isFrozen defines wether the material is frozen or not.
  48147. */
  48148. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48149. /**
  48150. * Checks to see if a texture is used in the material.
  48151. * @param texture - Base texture to use.
  48152. * @returns - Boolean specifying if a texture is used in the material.
  48153. */
  48154. hasTexture(texture: BaseTexture): boolean;
  48155. /**
  48156. * Returns an array of the actively used textures.
  48157. * @param activeTextures Array of BaseTextures
  48158. */
  48159. getActiveTextures(activeTextures: BaseTexture[]): void;
  48160. /**
  48161. * Returns the animatable textures.
  48162. * @param animatables Array of animatable textures.
  48163. */
  48164. getAnimatables(animatables: IAnimatable[]): void;
  48165. /**
  48166. * Disposes the resources of the material.
  48167. * @param forceDisposeTextures - Forces the disposal of all textures.
  48168. */
  48169. dispose(forceDisposeTextures?: boolean): void;
  48170. /**
  48171. * Get the current class name of the texture useful for serialization or dynamic coding.
  48172. * @returns "PBRAnisotropicConfiguration"
  48173. */
  48174. getClassName(): string;
  48175. /**
  48176. * Add fallbacks to the effect fallbacks list.
  48177. * @param defines defines the Base texture to use.
  48178. * @param fallbacks defines the current fallback list.
  48179. * @param currentRank defines the current fallback rank.
  48180. * @returns the new fallback rank.
  48181. */
  48182. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48183. /**
  48184. * Add the required uniforms to the current list.
  48185. * @param uniforms defines the current uniform list.
  48186. */
  48187. static AddUniforms(uniforms: string[]): void;
  48188. /**
  48189. * Add the required uniforms to the current buffer.
  48190. * @param uniformBuffer defines the current uniform buffer.
  48191. */
  48192. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48193. /**
  48194. * Add the required samplers to the current list.
  48195. * @param samplers defines the current sampler list.
  48196. */
  48197. static AddSamplers(samplers: string[]): void;
  48198. /**
  48199. * Makes a duplicate of the current configuration into another one.
  48200. * @param anisotropicConfiguration define the config where to copy the info
  48201. */
  48202. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48203. /**
  48204. * Serializes this anisotropy configuration.
  48205. * @returns - An object with the serialized config.
  48206. */
  48207. serialize(): any;
  48208. /**
  48209. * Parses a anisotropy Configuration from a serialized object.
  48210. * @param source - Serialized object.
  48211. * @param scene Defines the scene we are parsing for
  48212. * @param rootUrl Defines the rootUrl to load from
  48213. */
  48214. parse(source: any, scene: Scene, rootUrl: string): void;
  48215. }
  48216. }
  48217. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48218. import { Scene } from "babylonjs/scene";
  48219. /**
  48220. * @hidden
  48221. */
  48222. export interface IMaterialBRDFDefines {
  48223. BRDF_V_HEIGHT_CORRELATED: boolean;
  48224. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48225. SPHERICAL_HARMONICS: boolean;
  48226. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48227. /** @hidden */
  48228. _areMiscDirty: boolean;
  48229. }
  48230. /**
  48231. * Define the code related to the BRDF parameters of the pbr material.
  48232. */
  48233. export class PBRBRDFConfiguration {
  48234. /**
  48235. * Default value used for the energy conservation.
  48236. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48237. */
  48238. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48239. /**
  48240. * Default value used for the Smith Visibility Height Correlated mode.
  48241. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48242. */
  48243. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48244. /**
  48245. * Default value used for the IBL diffuse part.
  48246. * This can help switching back to the polynomials mode globally which is a tiny bit
  48247. * less GPU intensive at the drawback of a lower quality.
  48248. */
  48249. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48250. /**
  48251. * Default value used for activating energy conservation for the specular workflow.
  48252. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48253. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48254. */
  48255. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48256. private _useEnergyConservation;
  48257. /**
  48258. * Defines if the material uses energy conservation.
  48259. */
  48260. useEnergyConservation: boolean;
  48261. private _useSmithVisibilityHeightCorrelated;
  48262. /**
  48263. * LEGACY Mode set to false
  48264. * Defines if the material uses height smith correlated visibility term.
  48265. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48266. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48267. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48268. * Not relying on height correlated will also disable energy conservation.
  48269. */
  48270. useSmithVisibilityHeightCorrelated: boolean;
  48271. private _useSphericalHarmonics;
  48272. /**
  48273. * LEGACY Mode set to false
  48274. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48275. * diffuse part of the IBL.
  48276. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48277. * to the ground truth.
  48278. */
  48279. useSphericalHarmonics: boolean;
  48280. private _useSpecularGlossinessInputEnergyConservation;
  48281. /**
  48282. * Defines if the material uses energy conservation, when the specular workflow is active.
  48283. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48284. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48285. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48286. */
  48287. useSpecularGlossinessInputEnergyConservation: boolean;
  48288. /** @hidden */
  48289. private _internalMarkAllSubMeshesAsMiscDirty;
  48290. /** @hidden */
  48291. _markAllSubMeshesAsMiscDirty(): void;
  48292. /**
  48293. * Instantiate a new istance of clear coat configuration.
  48294. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48295. */
  48296. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48297. /**
  48298. * Checks to see if a texture is used in the material.
  48299. * @param defines the list of "defines" to update.
  48300. */
  48301. prepareDefines(defines: IMaterialBRDFDefines): void;
  48302. /**
  48303. * Get the current class name of the texture useful for serialization or dynamic coding.
  48304. * @returns "PBRClearCoatConfiguration"
  48305. */
  48306. getClassName(): string;
  48307. /**
  48308. * Makes a duplicate of the current configuration into another one.
  48309. * @param brdfConfiguration define the config where to copy the info
  48310. */
  48311. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48312. /**
  48313. * Serializes this BRDF configuration.
  48314. * @returns - An object with the serialized config.
  48315. */
  48316. serialize(): any;
  48317. /**
  48318. * Parses a anisotropy Configuration from a serialized object.
  48319. * @param source - Serialized object.
  48320. * @param scene Defines the scene we are parsing for
  48321. * @param rootUrl Defines the rootUrl to load from
  48322. */
  48323. parse(source: any, scene: Scene, rootUrl: string): void;
  48324. }
  48325. }
  48326. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48327. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48328. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48329. import { Color3 } from "babylonjs/Maths/math.color";
  48330. import { Scene } from "babylonjs/scene";
  48331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48332. import { Nullable } from "babylonjs/types";
  48333. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48334. /**
  48335. * @hidden
  48336. */
  48337. export interface IMaterialSheenDefines {
  48338. SHEEN: boolean;
  48339. SHEEN_TEXTURE: boolean;
  48340. SHEEN_TEXTUREDIRECTUV: number;
  48341. SHEEN_LINKWITHALBEDO: boolean;
  48342. /** @hidden */
  48343. _areTexturesDirty: boolean;
  48344. }
  48345. /**
  48346. * Define the code related to the Sheen parameters of the pbr material.
  48347. */
  48348. export class PBRSheenConfiguration {
  48349. private _isEnabled;
  48350. /**
  48351. * Defines if the material uses sheen.
  48352. */
  48353. isEnabled: boolean;
  48354. private _linkSheenWithAlbedo;
  48355. /**
  48356. * Defines if the sheen is linked to the sheen color.
  48357. */
  48358. linkSheenWithAlbedo: boolean;
  48359. /**
  48360. * Defines the sheen intensity.
  48361. */
  48362. intensity: number;
  48363. /**
  48364. * Defines the sheen color.
  48365. */
  48366. color: Color3;
  48367. private _texture;
  48368. /**
  48369. * Stores the sheen tint values in a texture.
  48370. * rgb is tint
  48371. * a is a intensity
  48372. */
  48373. texture: Nullable<BaseTexture>;
  48374. /** @hidden */
  48375. private _internalMarkAllSubMeshesAsTexturesDirty;
  48376. /** @hidden */
  48377. _markAllSubMeshesAsTexturesDirty(): void;
  48378. /**
  48379. * Instantiate a new istance of clear coat configuration.
  48380. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48381. */
  48382. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48383. /**
  48384. * Specifies that the submesh is ready to be used.
  48385. * @param defines the list of "defines" to update.
  48386. * @param scene defines the scene the material belongs to.
  48387. * @returns - boolean indicating that the submesh is ready or not.
  48388. */
  48389. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48390. /**
  48391. * Checks to see if a texture is used in the material.
  48392. * @param defines the list of "defines" to update.
  48393. * @param scene defines the scene the material belongs to.
  48394. */
  48395. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48396. /**
  48397. * Binds the material data.
  48398. * @param uniformBuffer defines the Uniform buffer to fill in.
  48399. * @param scene defines the scene the material belongs to.
  48400. * @param isFrozen defines wether the material is frozen or not.
  48401. */
  48402. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48403. /**
  48404. * Checks to see if a texture is used in the material.
  48405. * @param texture - Base texture to use.
  48406. * @returns - Boolean specifying if a texture is used in the material.
  48407. */
  48408. hasTexture(texture: BaseTexture): boolean;
  48409. /**
  48410. * Returns an array of the actively used textures.
  48411. * @param activeTextures Array of BaseTextures
  48412. */
  48413. getActiveTextures(activeTextures: BaseTexture[]): void;
  48414. /**
  48415. * Returns the animatable textures.
  48416. * @param animatables Array of animatable textures.
  48417. */
  48418. getAnimatables(animatables: IAnimatable[]): void;
  48419. /**
  48420. * Disposes the resources of the material.
  48421. * @param forceDisposeTextures - Forces the disposal of all textures.
  48422. */
  48423. dispose(forceDisposeTextures?: boolean): void;
  48424. /**
  48425. * Get the current class name of the texture useful for serialization or dynamic coding.
  48426. * @returns "PBRSheenConfiguration"
  48427. */
  48428. getClassName(): string;
  48429. /**
  48430. * Add fallbacks to the effect fallbacks list.
  48431. * @param defines defines the Base texture to use.
  48432. * @param fallbacks defines the current fallback list.
  48433. * @param currentRank defines the current fallback rank.
  48434. * @returns the new fallback rank.
  48435. */
  48436. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48437. /**
  48438. * Add the required uniforms to the current list.
  48439. * @param uniforms defines the current uniform list.
  48440. */
  48441. static AddUniforms(uniforms: string[]): void;
  48442. /**
  48443. * Add the required uniforms to the current buffer.
  48444. * @param uniformBuffer defines the current uniform buffer.
  48445. */
  48446. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48447. /**
  48448. * Add the required samplers to the current list.
  48449. * @param samplers defines the current sampler list.
  48450. */
  48451. static AddSamplers(samplers: string[]): void;
  48452. /**
  48453. * Makes a duplicate of the current configuration into another one.
  48454. * @param sheenConfiguration define the config where to copy the info
  48455. */
  48456. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48457. /**
  48458. * Serializes this BRDF configuration.
  48459. * @returns - An object with the serialized config.
  48460. */
  48461. serialize(): any;
  48462. /**
  48463. * Parses a anisotropy Configuration from a serialized object.
  48464. * @param source - Serialized object.
  48465. * @param scene Defines the scene we are parsing for
  48466. * @param rootUrl Defines the rootUrl to load from
  48467. */
  48468. parse(source: any, scene: Scene, rootUrl: string): void;
  48469. }
  48470. }
  48471. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48472. import { Nullable } from "babylonjs/types";
  48473. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48474. import { Color3 } from "babylonjs/Maths/math.color";
  48475. import { SmartArray } from "babylonjs/Misc/smartArray";
  48476. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48477. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48478. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48479. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48480. import { Engine } from "babylonjs/Engines/engine";
  48481. import { Scene } from "babylonjs/scene";
  48482. /**
  48483. * @hidden
  48484. */
  48485. export interface IMaterialSubSurfaceDefines {
  48486. SUBSURFACE: boolean;
  48487. SS_REFRACTION: boolean;
  48488. SS_TRANSLUCENCY: boolean;
  48489. SS_SCATERRING: boolean;
  48490. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48491. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48492. SS_REFRACTIONMAP_3D: boolean;
  48493. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48494. SS_LODINREFRACTIONALPHA: boolean;
  48495. SS_GAMMAREFRACTION: boolean;
  48496. SS_RGBDREFRACTION: boolean;
  48497. SS_LINEARSPECULARREFRACTION: boolean;
  48498. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48499. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48500. /** @hidden */
  48501. _areTexturesDirty: boolean;
  48502. }
  48503. /**
  48504. * Define the code related to the sub surface parameters of the pbr material.
  48505. */
  48506. export class PBRSubSurfaceConfiguration {
  48507. private _isRefractionEnabled;
  48508. /**
  48509. * Defines if the refraction is enabled in the material.
  48510. */
  48511. isRefractionEnabled: boolean;
  48512. private _isTranslucencyEnabled;
  48513. /**
  48514. * Defines if the translucency is enabled in the material.
  48515. */
  48516. isTranslucencyEnabled: boolean;
  48517. private _isScatteringEnabled;
  48518. /**
  48519. * Defines the refraction intensity of the material.
  48520. * The refraction when enabled replaces the Diffuse part of the material.
  48521. * The intensity helps transitionning between diffuse and refraction.
  48522. */
  48523. refractionIntensity: number;
  48524. /**
  48525. * Defines the translucency intensity of the material.
  48526. * When translucency has been enabled, this defines how much of the "translucency"
  48527. * is addded to the diffuse part of the material.
  48528. */
  48529. translucencyIntensity: number;
  48530. /**
  48531. * Defines the scattering intensity of the material.
  48532. * When scattering has been enabled, this defines how much of the "scattered light"
  48533. * is addded to the diffuse part of the material.
  48534. */
  48535. scatteringIntensity: number;
  48536. private _thicknessTexture;
  48537. /**
  48538. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48539. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48540. * 0 would mean minimumThickness
  48541. * 1 would mean maximumThickness
  48542. * The other channels might be use as a mask to vary the different effects intensity.
  48543. */
  48544. thicknessTexture: Nullable<BaseTexture>;
  48545. private _refractionTexture;
  48546. /**
  48547. * Defines the texture to use for refraction.
  48548. */
  48549. refractionTexture: Nullable<BaseTexture>;
  48550. private _indexOfRefraction;
  48551. /**
  48552. * Defines the index of refraction used in the material.
  48553. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48554. */
  48555. indexOfRefraction: number;
  48556. private _invertRefractionY;
  48557. /**
  48558. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48559. */
  48560. invertRefractionY: boolean;
  48561. private _linkRefractionWithTransparency;
  48562. /**
  48563. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48564. * Materials half opaque for instance using refraction could benefit from this control.
  48565. */
  48566. linkRefractionWithTransparency: boolean;
  48567. /**
  48568. * Defines the minimum thickness stored in the thickness map.
  48569. * If no thickness map is defined, this value will be used to simulate thickness.
  48570. */
  48571. minimumThickness: number;
  48572. /**
  48573. * Defines the maximum thickness stored in the thickness map.
  48574. */
  48575. maximumThickness: number;
  48576. /**
  48577. * Defines the volume tint of the material.
  48578. * This is used for both translucency and scattering.
  48579. */
  48580. tintColor: Color3;
  48581. /**
  48582. * Defines the distance at which the tint color should be found in the media.
  48583. * This is used for refraction only.
  48584. */
  48585. tintColorAtDistance: number;
  48586. /**
  48587. * Defines how far each channel transmit through the media.
  48588. * It is defined as a color to simplify it selection.
  48589. */
  48590. diffusionDistance: Color3;
  48591. private _useMaskFromThicknessTexture;
  48592. /**
  48593. * Stores the intensity of the different subsurface effects in the thickness texture.
  48594. * * the green channel is the translucency intensity.
  48595. * * the blue channel is the scattering intensity.
  48596. * * the alpha channel is the refraction intensity.
  48597. */
  48598. useMaskFromThicknessTexture: boolean;
  48599. /** @hidden */
  48600. private _internalMarkAllSubMeshesAsTexturesDirty;
  48601. /** @hidden */
  48602. _markAllSubMeshesAsTexturesDirty(): void;
  48603. /**
  48604. * Instantiate a new istance of sub surface configuration.
  48605. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48606. */
  48607. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48608. /**
  48609. * Gets wehter the submesh is ready to be used or not.
  48610. * @param defines the list of "defines" to update.
  48611. * @param scene defines the scene the material belongs to.
  48612. * @returns - boolean indicating that the submesh is ready or not.
  48613. */
  48614. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48615. /**
  48616. * Checks to see if a texture is used in the material.
  48617. * @param defines the list of "defines" to update.
  48618. * @param scene defines the scene to the material belongs to.
  48619. */
  48620. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48621. /**
  48622. * Binds the material data.
  48623. * @param uniformBuffer defines the Uniform buffer to fill in.
  48624. * @param scene defines the scene the material belongs to.
  48625. * @param engine defines the engine the material belongs to.
  48626. * @param isFrozen defines wether the material is frozen or not.
  48627. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48628. */
  48629. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48630. /**
  48631. * Unbinds the material from the mesh.
  48632. * @param activeEffect defines the effect that should be unbound from.
  48633. * @returns true if unbound, otherwise false
  48634. */
  48635. unbind(activeEffect: Effect): boolean;
  48636. /**
  48637. * Returns the texture used for refraction or null if none is used.
  48638. * @param scene defines the scene the material belongs to.
  48639. * @returns - Refraction texture if present. If no refraction texture and refraction
  48640. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48641. */
  48642. private _getRefractionTexture;
  48643. /**
  48644. * Returns true if alpha blending should be disabled.
  48645. */
  48646. readonly disableAlphaBlending: boolean;
  48647. /**
  48648. * Fills the list of render target textures.
  48649. * @param renderTargets the list of render targets to update
  48650. */
  48651. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48652. /**
  48653. * Checks to see if a texture is used in the material.
  48654. * @param texture - Base texture to use.
  48655. * @returns - Boolean specifying if a texture is used in the material.
  48656. */
  48657. hasTexture(texture: BaseTexture): boolean;
  48658. /**
  48659. * Gets a boolean indicating that current material needs to register RTT
  48660. * @returns true if this uses a render target otherwise false.
  48661. */
  48662. hasRenderTargetTextures(): boolean;
  48663. /**
  48664. * Returns an array of the actively used textures.
  48665. * @param activeTextures Array of BaseTextures
  48666. */
  48667. getActiveTextures(activeTextures: BaseTexture[]): void;
  48668. /**
  48669. * Returns the animatable textures.
  48670. * @param animatables Array of animatable textures.
  48671. */
  48672. getAnimatables(animatables: IAnimatable[]): void;
  48673. /**
  48674. * Disposes the resources of the material.
  48675. * @param forceDisposeTextures - Forces the disposal of all textures.
  48676. */
  48677. dispose(forceDisposeTextures?: boolean): void;
  48678. /**
  48679. * Get the current class name of the texture useful for serialization or dynamic coding.
  48680. * @returns "PBRSubSurfaceConfiguration"
  48681. */
  48682. getClassName(): string;
  48683. /**
  48684. * Add fallbacks to the effect fallbacks list.
  48685. * @param defines defines the Base texture to use.
  48686. * @param fallbacks defines the current fallback list.
  48687. * @param currentRank defines the current fallback rank.
  48688. * @returns the new fallback rank.
  48689. */
  48690. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48691. /**
  48692. * Add the required uniforms to the current list.
  48693. * @param uniforms defines the current uniform list.
  48694. */
  48695. static AddUniforms(uniforms: string[]): void;
  48696. /**
  48697. * Add the required samplers to the current list.
  48698. * @param samplers defines the current sampler list.
  48699. */
  48700. static AddSamplers(samplers: string[]): void;
  48701. /**
  48702. * Add the required uniforms to the current buffer.
  48703. * @param uniformBuffer defines the current uniform buffer.
  48704. */
  48705. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48706. /**
  48707. * Makes a duplicate of the current configuration into another one.
  48708. * @param configuration define the config where to copy the info
  48709. */
  48710. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48711. /**
  48712. * Serializes this Sub Surface configuration.
  48713. * @returns - An object with the serialized config.
  48714. */
  48715. serialize(): any;
  48716. /**
  48717. * Parses a anisotropy Configuration from a serialized object.
  48718. * @param source - Serialized object.
  48719. * @param scene Defines the scene we are parsing for
  48720. * @param rootUrl Defines the rootUrl to load from
  48721. */
  48722. parse(source: any, scene: Scene, rootUrl: string): void;
  48723. }
  48724. }
  48725. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48726. /** @hidden */
  48727. export var pbrFragmentDeclaration: {
  48728. name: string;
  48729. shader: string;
  48730. };
  48731. }
  48732. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48733. /** @hidden */
  48734. export var pbrUboDeclaration: {
  48735. name: string;
  48736. shader: string;
  48737. };
  48738. }
  48739. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48740. /** @hidden */
  48741. export var pbrFragmentExtraDeclaration: {
  48742. name: string;
  48743. shader: string;
  48744. };
  48745. }
  48746. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48747. /** @hidden */
  48748. export var pbrFragmentSamplersDeclaration: {
  48749. name: string;
  48750. shader: string;
  48751. };
  48752. }
  48753. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48754. /** @hidden */
  48755. export var pbrHelperFunctions: {
  48756. name: string;
  48757. shader: string;
  48758. };
  48759. }
  48760. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48761. /** @hidden */
  48762. export var harmonicsFunctions: {
  48763. name: string;
  48764. shader: string;
  48765. };
  48766. }
  48767. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48768. /** @hidden */
  48769. export var pbrDirectLightingSetupFunctions: {
  48770. name: string;
  48771. shader: string;
  48772. };
  48773. }
  48774. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48775. /** @hidden */
  48776. export var pbrDirectLightingFalloffFunctions: {
  48777. name: string;
  48778. shader: string;
  48779. };
  48780. }
  48781. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48782. /** @hidden */
  48783. export var pbrBRDFFunctions: {
  48784. name: string;
  48785. shader: string;
  48786. };
  48787. }
  48788. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48789. /** @hidden */
  48790. export var pbrDirectLightingFunctions: {
  48791. name: string;
  48792. shader: string;
  48793. };
  48794. }
  48795. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48796. /** @hidden */
  48797. export var pbrIBLFunctions: {
  48798. name: string;
  48799. shader: string;
  48800. };
  48801. }
  48802. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48803. /** @hidden */
  48804. export var pbrDebug: {
  48805. name: string;
  48806. shader: string;
  48807. };
  48808. }
  48809. declare module "babylonjs/Shaders/pbr.fragment" {
  48810. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48811. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48812. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48813. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48814. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48815. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48816. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48817. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48818. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48819. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48820. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48821. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48822. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48823. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48824. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48825. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48826. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48827. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48828. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48829. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48830. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48831. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48832. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48833. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48834. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48835. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48836. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48837. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48838. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48839. /** @hidden */
  48840. export var pbrPixelShader: {
  48841. name: string;
  48842. shader: string;
  48843. };
  48844. }
  48845. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48846. /** @hidden */
  48847. export var pbrVertexDeclaration: {
  48848. name: string;
  48849. shader: string;
  48850. };
  48851. }
  48852. declare module "babylonjs/Shaders/pbr.vertex" {
  48853. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48854. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48855. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48856. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48857. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48858. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48859. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48860. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48861. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48862. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48863. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48864. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48866. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48867. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48868. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48869. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48870. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48871. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48872. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48873. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48874. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48875. /** @hidden */
  48876. export var pbrVertexShader: {
  48877. name: string;
  48878. shader: string;
  48879. };
  48880. }
  48881. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48882. import { Nullable } from "babylonjs/types";
  48883. import { Scene } from "babylonjs/scene";
  48884. import { Matrix } from "babylonjs/Maths/math.vector";
  48885. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48887. import { Mesh } from "babylonjs/Meshes/mesh";
  48888. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48889. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48890. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48891. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48892. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48893. import { Color3 } from "babylonjs/Maths/math.color";
  48894. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48895. import { Material } from "babylonjs/Materials/material";
  48896. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48897. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48900. import "babylonjs/Shaders/pbr.fragment";
  48901. import "babylonjs/Shaders/pbr.vertex";
  48902. /**
  48903. * Manages the defines for the PBR Material.
  48904. * @hidden
  48905. */
  48906. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48907. PBR: boolean;
  48908. MAINUV1: boolean;
  48909. MAINUV2: boolean;
  48910. UV1: boolean;
  48911. UV2: boolean;
  48912. ALBEDO: boolean;
  48913. ALBEDODIRECTUV: number;
  48914. VERTEXCOLOR: boolean;
  48915. AMBIENT: boolean;
  48916. AMBIENTDIRECTUV: number;
  48917. AMBIENTINGRAYSCALE: boolean;
  48918. OPACITY: boolean;
  48919. VERTEXALPHA: boolean;
  48920. OPACITYDIRECTUV: number;
  48921. OPACITYRGB: boolean;
  48922. ALPHATEST: boolean;
  48923. DEPTHPREPASS: boolean;
  48924. ALPHABLEND: boolean;
  48925. ALPHAFROMALBEDO: boolean;
  48926. ALPHATESTVALUE: string;
  48927. SPECULAROVERALPHA: boolean;
  48928. RADIANCEOVERALPHA: boolean;
  48929. ALPHAFRESNEL: boolean;
  48930. LINEARALPHAFRESNEL: boolean;
  48931. PREMULTIPLYALPHA: boolean;
  48932. EMISSIVE: boolean;
  48933. EMISSIVEDIRECTUV: number;
  48934. REFLECTIVITY: boolean;
  48935. REFLECTIVITYDIRECTUV: number;
  48936. SPECULARTERM: boolean;
  48937. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48938. MICROSURFACEAUTOMATIC: boolean;
  48939. LODBASEDMICROSFURACE: boolean;
  48940. MICROSURFACEMAP: boolean;
  48941. MICROSURFACEMAPDIRECTUV: number;
  48942. METALLICWORKFLOW: boolean;
  48943. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48944. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48945. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48946. AOSTOREINMETALMAPRED: boolean;
  48947. ENVIRONMENTBRDF: boolean;
  48948. ENVIRONMENTBRDF_RGBD: boolean;
  48949. NORMAL: boolean;
  48950. TANGENT: boolean;
  48951. BUMP: boolean;
  48952. BUMPDIRECTUV: number;
  48953. OBJECTSPACE_NORMALMAP: boolean;
  48954. PARALLAX: boolean;
  48955. PARALLAXOCCLUSION: boolean;
  48956. NORMALXYSCALE: boolean;
  48957. LIGHTMAP: boolean;
  48958. LIGHTMAPDIRECTUV: number;
  48959. USELIGHTMAPASSHADOWMAP: boolean;
  48960. GAMMALIGHTMAP: boolean;
  48961. RGBDLIGHTMAP: boolean;
  48962. REFLECTION: boolean;
  48963. REFLECTIONMAP_3D: boolean;
  48964. REFLECTIONMAP_SPHERICAL: boolean;
  48965. REFLECTIONMAP_PLANAR: boolean;
  48966. REFLECTIONMAP_CUBIC: boolean;
  48967. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48968. REFLECTIONMAP_PROJECTION: boolean;
  48969. REFLECTIONMAP_SKYBOX: boolean;
  48970. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48971. REFLECTIONMAP_EXPLICIT: boolean;
  48972. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48973. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48974. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48975. INVERTCUBICMAP: boolean;
  48976. USESPHERICALFROMREFLECTIONMAP: boolean;
  48977. USEIRRADIANCEMAP: boolean;
  48978. SPHERICAL_HARMONICS: boolean;
  48979. USESPHERICALINVERTEX: boolean;
  48980. REFLECTIONMAP_OPPOSITEZ: boolean;
  48981. LODINREFLECTIONALPHA: boolean;
  48982. GAMMAREFLECTION: boolean;
  48983. RGBDREFLECTION: boolean;
  48984. LINEARSPECULARREFLECTION: boolean;
  48985. RADIANCEOCCLUSION: boolean;
  48986. HORIZONOCCLUSION: boolean;
  48987. INSTANCES: boolean;
  48988. NUM_BONE_INFLUENCERS: number;
  48989. BonesPerMesh: number;
  48990. BONETEXTURE: boolean;
  48991. NONUNIFORMSCALING: boolean;
  48992. MORPHTARGETS: boolean;
  48993. MORPHTARGETS_NORMAL: boolean;
  48994. MORPHTARGETS_TANGENT: boolean;
  48995. MORPHTARGETS_UV: boolean;
  48996. NUM_MORPH_INFLUENCERS: number;
  48997. IMAGEPROCESSING: boolean;
  48998. VIGNETTE: boolean;
  48999. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49000. VIGNETTEBLENDMODEOPAQUE: boolean;
  49001. TONEMAPPING: boolean;
  49002. TONEMAPPING_ACES: boolean;
  49003. CONTRAST: boolean;
  49004. COLORCURVES: boolean;
  49005. COLORGRADING: boolean;
  49006. COLORGRADING3D: boolean;
  49007. SAMPLER3DGREENDEPTH: boolean;
  49008. SAMPLER3DBGRMAP: boolean;
  49009. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49010. EXPOSURE: boolean;
  49011. MULTIVIEW: boolean;
  49012. USEPHYSICALLIGHTFALLOFF: boolean;
  49013. USEGLTFLIGHTFALLOFF: boolean;
  49014. TWOSIDEDLIGHTING: boolean;
  49015. SHADOWFLOAT: boolean;
  49016. CLIPPLANE: boolean;
  49017. CLIPPLANE2: boolean;
  49018. CLIPPLANE3: boolean;
  49019. CLIPPLANE4: boolean;
  49020. POINTSIZE: boolean;
  49021. FOG: boolean;
  49022. LOGARITHMICDEPTH: boolean;
  49023. FORCENORMALFORWARD: boolean;
  49024. SPECULARAA: boolean;
  49025. CLEARCOAT: boolean;
  49026. CLEARCOAT_DEFAULTIOR: boolean;
  49027. CLEARCOAT_TEXTURE: boolean;
  49028. CLEARCOAT_TEXTUREDIRECTUV: number;
  49029. CLEARCOAT_BUMP: boolean;
  49030. CLEARCOAT_BUMPDIRECTUV: number;
  49031. CLEARCOAT_TINT: boolean;
  49032. CLEARCOAT_TINT_TEXTURE: boolean;
  49033. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49034. ANISOTROPIC: boolean;
  49035. ANISOTROPIC_TEXTURE: boolean;
  49036. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49037. BRDF_V_HEIGHT_CORRELATED: boolean;
  49038. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49039. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49040. SHEEN: boolean;
  49041. SHEEN_TEXTURE: boolean;
  49042. SHEEN_TEXTUREDIRECTUV: number;
  49043. SHEEN_LINKWITHALBEDO: boolean;
  49044. SUBSURFACE: boolean;
  49045. SS_REFRACTION: boolean;
  49046. SS_TRANSLUCENCY: boolean;
  49047. SS_SCATERRING: boolean;
  49048. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49049. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49050. SS_REFRACTIONMAP_3D: boolean;
  49051. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49052. SS_LODINREFRACTIONALPHA: boolean;
  49053. SS_GAMMAREFRACTION: boolean;
  49054. SS_RGBDREFRACTION: boolean;
  49055. SS_LINEARSPECULARREFRACTION: boolean;
  49056. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49057. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49058. UNLIT: boolean;
  49059. DEBUGMODE: number;
  49060. /**
  49061. * Initializes the PBR Material defines.
  49062. */
  49063. constructor();
  49064. /**
  49065. * Resets the PBR Material defines.
  49066. */
  49067. reset(): void;
  49068. }
  49069. /**
  49070. * The Physically based material base class of BJS.
  49071. *
  49072. * This offers the main features of a standard PBR material.
  49073. * For more information, please refer to the documentation :
  49074. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49075. */
  49076. export abstract class PBRBaseMaterial extends PushMaterial {
  49077. /**
  49078. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49079. */
  49080. static readonly PBRMATERIAL_OPAQUE: number;
  49081. /**
  49082. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49083. */
  49084. static readonly PBRMATERIAL_ALPHATEST: number;
  49085. /**
  49086. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49087. */
  49088. static readonly PBRMATERIAL_ALPHABLEND: number;
  49089. /**
  49090. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49091. * They are also discarded below the alpha cutoff threshold to improve performances.
  49092. */
  49093. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49094. /**
  49095. * Defines the default value of how much AO map is occluding the analytical lights
  49096. * (point spot...).
  49097. */
  49098. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49099. /**
  49100. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49101. */
  49102. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49103. /**
  49104. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49105. * to enhance interoperability with other engines.
  49106. */
  49107. static readonly LIGHTFALLOFF_GLTF: number;
  49108. /**
  49109. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49110. * to enhance interoperability with other materials.
  49111. */
  49112. static readonly LIGHTFALLOFF_STANDARD: number;
  49113. /**
  49114. * Intensity of the direct lights e.g. the four lights available in your scene.
  49115. * This impacts both the direct diffuse and specular highlights.
  49116. */
  49117. protected _directIntensity: number;
  49118. /**
  49119. * Intensity of the emissive part of the material.
  49120. * This helps controlling the emissive effect without modifying the emissive color.
  49121. */
  49122. protected _emissiveIntensity: number;
  49123. /**
  49124. * Intensity of the environment e.g. how much the environment will light the object
  49125. * either through harmonics for rough material or through the refelction for shiny ones.
  49126. */
  49127. protected _environmentIntensity: number;
  49128. /**
  49129. * This is a special control allowing the reduction of the specular highlights coming from the
  49130. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49131. */
  49132. protected _specularIntensity: number;
  49133. /**
  49134. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49135. */
  49136. private _lightingInfos;
  49137. /**
  49138. * Debug Control allowing disabling the bump map on this material.
  49139. */
  49140. protected _disableBumpMap: boolean;
  49141. /**
  49142. * AKA Diffuse Texture in standard nomenclature.
  49143. */
  49144. protected _albedoTexture: Nullable<BaseTexture>;
  49145. /**
  49146. * AKA Occlusion Texture in other nomenclature.
  49147. */
  49148. protected _ambientTexture: Nullable<BaseTexture>;
  49149. /**
  49150. * AKA Occlusion Texture Intensity in other nomenclature.
  49151. */
  49152. protected _ambientTextureStrength: number;
  49153. /**
  49154. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49155. * 1 means it completely occludes it
  49156. * 0 mean it has no impact
  49157. */
  49158. protected _ambientTextureImpactOnAnalyticalLights: number;
  49159. /**
  49160. * Stores the alpha values in a texture.
  49161. */
  49162. protected _opacityTexture: Nullable<BaseTexture>;
  49163. /**
  49164. * Stores the reflection values in a texture.
  49165. */
  49166. protected _reflectionTexture: Nullable<BaseTexture>;
  49167. /**
  49168. * Stores the emissive values in a texture.
  49169. */
  49170. protected _emissiveTexture: Nullable<BaseTexture>;
  49171. /**
  49172. * AKA Specular texture in other nomenclature.
  49173. */
  49174. protected _reflectivityTexture: Nullable<BaseTexture>;
  49175. /**
  49176. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49177. */
  49178. protected _metallicTexture: Nullable<BaseTexture>;
  49179. /**
  49180. * Specifies the metallic scalar of the metallic/roughness workflow.
  49181. * Can also be used to scale the metalness values of the metallic texture.
  49182. */
  49183. protected _metallic: Nullable<number>;
  49184. /**
  49185. * Specifies the roughness scalar of the metallic/roughness workflow.
  49186. * Can also be used to scale the roughness values of the metallic texture.
  49187. */
  49188. protected _roughness: Nullable<number>;
  49189. /**
  49190. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49191. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49192. */
  49193. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49194. /**
  49195. * Stores surface normal data used to displace a mesh in a texture.
  49196. */
  49197. protected _bumpTexture: Nullable<BaseTexture>;
  49198. /**
  49199. * Stores the pre-calculated light information of a mesh in a texture.
  49200. */
  49201. protected _lightmapTexture: Nullable<BaseTexture>;
  49202. /**
  49203. * The color of a material in ambient lighting.
  49204. */
  49205. protected _ambientColor: Color3;
  49206. /**
  49207. * AKA Diffuse Color in other nomenclature.
  49208. */
  49209. protected _albedoColor: Color3;
  49210. /**
  49211. * AKA Specular Color in other nomenclature.
  49212. */
  49213. protected _reflectivityColor: Color3;
  49214. /**
  49215. * The color applied when light is reflected from a material.
  49216. */
  49217. protected _reflectionColor: Color3;
  49218. /**
  49219. * The color applied when light is emitted from a material.
  49220. */
  49221. protected _emissiveColor: Color3;
  49222. /**
  49223. * AKA Glossiness in other nomenclature.
  49224. */
  49225. protected _microSurface: number;
  49226. /**
  49227. * Specifies that the material will use the light map as a show map.
  49228. */
  49229. protected _useLightmapAsShadowmap: boolean;
  49230. /**
  49231. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49232. * makes the reflect vector face the model (under horizon).
  49233. */
  49234. protected _useHorizonOcclusion: boolean;
  49235. /**
  49236. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49237. * too much the area relying on ambient texture to define their ambient occlusion.
  49238. */
  49239. protected _useRadianceOcclusion: boolean;
  49240. /**
  49241. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49242. */
  49243. protected _useAlphaFromAlbedoTexture: boolean;
  49244. /**
  49245. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49246. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49247. */
  49248. protected _useSpecularOverAlpha: boolean;
  49249. /**
  49250. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49251. */
  49252. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49253. /**
  49254. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49255. */
  49256. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49257. /**
  49258. * Specifies if the metallic texture contains the roughness information in its green channel.
  49259. */
  49260. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49261. /**
  49262. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49263. */
  49264. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49265. /**
  49266. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49267. */
  49268. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49269. /**
  49270. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49271. */
  49272. protected _useAmbientInGrayScale: boolean;
  49273. /**
  49274. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49275. * The material will try to infer what glossiness each pixel should be.
  49276. */
  49277. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49278. /**
  49279. * Defines the falloff type used in this material.
  49280. * It by default is Physical.
  49281. */
  49282. protected _lightFalloff: number;
  49283. /**
  49284. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49285. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49286. */
  49287. protected _useRadianceOverAlpha: boolean;
  49288. /**
  49289. * Allows using an object space normal map (instead of tangent space).
  49290. */
  49291. protected _useObjectSpaceNormalMap: boolean;
  49292. /**
  49293. * Allows using the bump map in parallax mode.
  49294. */
  49295. protected _useParallax: boolean;
  49296. /**
  49297. * Allows using the bump map in parallax occlusion mode.
  49298. */
  49299. protected _useParallaxOcclusion: boolean;
  49300. /**
  49301. * Controls the scale bias of the parallax mode.
  49302. */
  49303. protected _parallaxScaleBias: number;
  49304. /**
  49305. * If sets to true, disables all the lights affecting the material.
  49306. */
  49307. protected _disableLighting: boolean;
  49308. /**
  49309. * Number of Simultaneous lights allowed on the material.
  49310. */
  49311. protected _maxSimultaneousLights: number;
  49312. /**
  49313. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49314. */
  49315. protected _invertNormalMapX: boolean;
  49316. /**
  49317. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49318. */
  49319. protected _invertNormalMapY: boolean;
  49320. /**
  49321. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49322. */
  49323. protected _twoSidedLighting: boolean;
  49324. /**
  49325. * Defines the alpha limits in alpha test mode.
  49326. */
  49327. protected _alphaCutOff: number;
  49328. /**
  49329. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49330. */
  49331. protected _forceAlphaTest: boolean;
  49332. /**
  49333. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49334. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49335. */
  49336. protected _useAlphaFresnel: boolean;
  49337. /**
  49338. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49339. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49340. */
  49341. protected _useLinearAlphaFresnel: boolean;
  49342. /**
  49343. * The transparency mode of the material.
  49344. */
  49345. protected _transparencyMode: Nullable<number>;
  49346. /**
  49347. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49348. * from cos thetav and roughness:
  49349. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49350. */
  49351. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49352. /**
  49353. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49354. */
  49355. protected _forceIrradianceInFragment: boolean;
  49356. /**
  49357. * Force normal to face away from face.
  49358. */
  49359. protected _forceNormalForward: boolean;
  49360. /**
  49361. * Enables specular anti aliasing in the PBR shader.
  49362. * It will both interacts on the Geometry for analytical and IBL lighting.
  49363. * It also prefilter the roughness map based on the bump values.
  49364. */
  49365. protected _enableSpecularAntiAliasing: boolean;
  49366. /**
  49367. * Default configuration related to image processing available in the PBR Material.
  49368. */
  49369. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49370. /**
  49371. * Keep track of the image processing observer to allow dispose and replace.
  49372. */
  49373. private _imageProcessingObserver;
  49374. /**
  49375. * Attaches a new image processing configuration to the PBR Material.
  49376. * @param configuration
  49377. */
  49378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49379. /**
  49380. * Stores the available render targets.
  49381. */
  49382. private _renderTargets;
  49383. /**
  49384. * Sets the global ambient color for the material used in lighting calculations.
  49385. */
  49386. private _globalAmbientColor;
  49387. /**
  49388. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49389. */
  49390. private _useLogarithmicDepth;
  49391. /**
  49392. * If set to true, no lighting calculations will be applied.
  49393. */
  49394. private _unlit;
  49395. private _debugMode;
  49396. /**
  49397. * @hidden
  49398. * This is reserved for the inspector.
  49399. * Defines the material debug mode.
  49400. * It helps seeing only some components of the material while troubleshooting.
  49401. */
  49402. debugMode: number;
  49403. /**
  49404. * @hidden
  49405. * This is reserved for the inspector.
  49406. * Specify from where on screen the debug mode should start.
  49407. * The value goes from -1 (full screen) to 1 (not visible)
  49408. * It helps with side by side comparison against the final render
  49409. * This defaults to -1
  49410. */
  49411. private debugLimit;
  49412. /**
  49413. * @hidden
  49414. * This is reserved for the inspector.
  49415. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49416. * You can use the factor to better multiply the final value.
  49417. */
  49418. private debugFactor;
  49419. /**
  49420. * Defines the clear coat layer parameters for the material.
  49421. */
  49422. readonly clearCoat: PBRClearCoatConfiguration;
  49423. /**
  49424. * Defines the anisotropic parameters for the material.
  49425. */
  49426. readonly anisotropy: PBRAnisotropicConfiguration;
  49427. /**
  49428. * Defines the BRDF parameters for the material.
  49429. */
  49430. readonly brdf: PBRBRDFConfiguration;
  49431. /**
  49432. * Defines the Sheen parameters for the material.
  49433. */
  49434. readonly sheen: PBRSheenConfiguration;
  49435. /**
  49436. * Defines the SubSurface parameters for the material.
  49437. */
  49438. readonly subSurface: PBRSubSurfaceConfiguration;
  49439. /**
  49440. * Custom callback helping to override the default shader used in the material.
  49441. */
  49442. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49443. protected _rebuildInParallel: boolean;
  49444. /**
  49445. * Instantiates a new PBRMaterial instance.
  49446. *
  49447. * @param name The material name
  49448. * @param scene The scene the material will be use in.
  49449. */
  49450. constructor(name: string, scene: Scene);
  49451. /**
  49452. * Gets a boolean indicating that current material needs to register RTT
  49453. */
  49454. readonly hasRenderTargetTextures: boolean;
  49455. /**
  49456. * Gets the name of the material class.
  49457. */
  49458. getClassName(): string;
  49459. /**
  49460. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49461. */
  49462. /**
  49463. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49464. */
  49465. useLogarithmicDepth: boolean;
  49466. /**
  49467. * Gets the current transparency mode.
  49468. */
  49469. /**
  49470. * Sets the transparency mode of the material.
  49471. *
  49472. * | Value | Type | Description |
  49473. * | ----- | ----------------------------------- | ----------- |
  49474. * | 0 | OPAQUE | |
  49475. * | 1 | ALPHATEST | |
  49476. * | 2 | ALPHABLEND | |
  49477. * | 3 | ALPHATESTANDBLEND | |
  49478. *
  49479. */
  49480. transparencyMode: Nullable<number>;
  49481. /**
  49482. * Returns true if alpha blending should be disabled.
  49483. */
  49484. private readonly _disableAlphaBlending;
  49485. /**
  49486. * Specifies whether or not this material should be rendered in alpha blend mode.
  49487. */
  49488. needAlphaBlending(): boolean;
  49489. /**
  49490. * Specifies if the mesh will require alpha blending.
  49491. * @param mesh - BJS mesh.
  49492. */
  49493. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49494. /**
  49495. * Specifies whether or not this material should be rendered in alpha test mode.
  49496. */
  49497. needAlphaTesting(): boolean;
  49498. /**
  49499. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49500. */
  49501. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49502. /**
  49503. * Gets the texture used for the alpha test.
  49504. */
  49505. getAlphaTestTexture(): Nullable<BaseTexture>;
  49506. /**
  49507. * Specifies that the submesh is ready to be used.
  49508. * @param mesh - BJS mesh.
  49509. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49510. * @param useInstances - Specifies that instances should be used.
  49511. * @returns - boolean indicating that the submesh is ready or not.
  49512. */
  49513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49514. /**
  49515. * Specifies if the material uses metallic roughness workflow.
  49516. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49517. */
  49518. isMetallicWorkflow(): boolean;
  49519. private _prepareEffect;
  49520. private _prepareDefines;
  49521. /**
  49522. * Force shader compilation
  49523. */
  49524. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49525. clipPlane: boolean;
  49526. }>): void;
  49527. /**
  49528. * Initializes the uniform buffer layout for the shader.
  49529. */
  49530. buildUniformLayout(): void;
  49531. /**
  49532. * Unbinds the material from the mesh
  49533. */
  49534. unbind(): void;
  49535. /**
  49536. * Binds the submesh data.
  49537. * @param world - The world matrix.
  49538. * @param mesh - The BJS mesh.
  49539. * @param subMesh - A submesh of the BJS mesh.
  49540. */
  49541. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49542. /**
  49543. * Returns the animatable textures.
  49544. * @returns - Array of animatable textures.
  49545. */
  49546. getAnimatables(): IAnimatable[];
  49547. /**
  49548. * Returns the texture used for reflections.
  49549. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49550. */
  49551. private _getReflectionTexture;
  49552. /**
  49553. * Returns an array of the actively used textures.
  49554. * @returns - Array of BaseTextures
  49555. */
  49556. getActiveTextures(): BaseTexture[];
  49557. /**
  49558. * Checks to see if a texture is used in the material.
  49559. * @param texture - Base texture to use.
  49560. * @returns - Boolean specifying if a texture is used in the material.
  49561. */
  49562. hasTexture(texture: BaseTexture): boolean;
  49563. /**
  49564. * Disposes the resources of the material.
  49565. * @param forceDisposeEffect - Forces the disposal of effects.
  49566. * @param forceDisposeTextures - Forces the disposal of all textures.
  49567. */
  49568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49569. }
  49570. }
  49571. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49572. import { Nullable } from "babylonjs/types";
  49573. import { Scene } from "babylonjs/scene";
  49574. import { Color3 } from "babylonjs/Maths/math.color";
  49575. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49576. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49578. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49579. /**
  49580. * The Physically based material of BJS.
  49581. *
  49582. * This offers the main features of a standard PBR material.
  49583. * For more information, please refer to the documentation :
  49584. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49585. */
  49586. export class PBRMaterial extends PBRBaseMaterial {
  49587. /**
  49588. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49589. */
  49590. static readonly PBRMATERIAL_OPAQUE: number;
  49591. /**
  49592. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49593. */
  49594. static readonly PBRMATERIAL_ALPHATEST: number;
  49595. /**
  49596. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49597. */
  49598. static readonly PBRMATERIAL_ALPHABLEND: number;
  49599. /**
  49600. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49601. * They are also discarded below the alpha cutoff threshold to improve performances.
  49602. */
  49603. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49604. /**
  49605. * Defines the default value of how much AO map is occluding the analytical lights
  49606. * (point spot...).
  49607. */
  49608. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49609. /**
  49610. * Intensity of the direct lights e.g. the four lights available in your scene.
  49611. * This impacts both the direct diffuse and specular highlights.
  49612. */
  49613. directIntensity: number;
  49614. /**
  49615. * Intensity of the emissive part of the material.
  49616. * This helps controlling the emissive effect without modifying the emissive color.
  49617. */
  49618. emissiveIntensity: number;
  49619. /**
  49620. * Intensity of the environment e.g. how much the environment will light the object
  49621. * either through harmonics for rough material or through the refelction for shiny ones.
  49622. */
  49623. environmentIntensity: number;
  49624. /**
  49625. * This is a special control allowing the reduction of the specular highlights coming from the
  49626. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49627. */
  49628. specularIntensity: number;
  49629. /**
  49630. * Debug Control allowing disabling the bump map on this material.
  49631. */
  49632. disableBumpMap: boolean;
  49633. /**
  49634. * AKA Diffuse Texture in standard nomenclature.
  49635. */
  49636. albedoTexture: BaseTexture;
  49637. /**
  49638. * AKA Occlusion Texture in other nomenclature.
  49639. */
  49640. ambientTexture: BaseTexture;
  49641. /**
  49642. * AKA Occlusion Texture Intensity in other nomenclature.
  49643. */
  49644. ambientTextureStrength: number;
  49645. /**
  49646. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49647. * 1 means it completely occludes it
  49648. * 0 mean it has no impact
  49649. */
  49650. ambientTextureImpactOnAnalyticalLights: number;
  49651. /**
  49652. * Stores the alpha values in a texture.
  49653. */
  49654. opacityTexture: BaseTexture;
  49655. /**
  49656. * Stores the reflection values in a texture.
  49657. */
  49658. reflectionTexture: Nullable<BaseTexture>;
  49659. /**
  49660. * Stores the emissive values in a texture.
  49661. */
  49662. emissiveTexture: BaseTexture;
  49663. /**
  49664. * AKA Specular texture in other nomenclature.
  49665. */
  49666. reflectivityTexture: BaseTexture;
  49667. /**
  49668. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49669. */
  49670. metallicTexture: BaseTexture;
  49671. /**
  49672. * Specifies the metallic scalar of the metallic/roughness workflow.
  49673. * Can also be used to scale the metalness values of the metallic texture.
  49674. */
  49675. metallic: Nullable<number>;
  49676. /**
  49677. * Specifies the roughness scalar of the metallic/roughness workflow.
  49678. * Can also be used to scale the roughness values of the metallic texture.
  49679. */
  49680. roughness: Nullable<number>;
  49681. /**
  49682. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49683. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49684. */
  49685. microSurfaceTexture: BaseTexture;
  49686. /**
  49687. * Stores surface normal data used to displace a mesh in a texture.
  49688. */
  49689. bumpTexture: BaseTexture;
  49690. /**
  49691. * Stores the pre-calculated light information of a mesh in a texture.
  49692. */
  49693. lightmapTexture: BaseTexture;
  49694. /**
  49695. * Stores the refracted light information in a texture.
  49696. */
  49697. refractionTexture: Nullable<BaseTexture>;
  49698. /**
  49699. * The color of a material in ambient lighting.
  49700. */
  49701. ambientColor: Color3;
  49702. /**
  49703. * AKA Diffuse Color in other nomenclature.
  49704. */
  49705. albedoColor: Color3;
  49706. /**
  49707. * AKA Specular Color in other nomenclature.
  49708. */
  49709. reflectivityColor: Color3;
  49710. /**
  49711. * The color reflected from the material.
  49712. */
  49713. reflectionColor: Color3;
  49714. /**
  49715. * The color emitted from the material.
  49716. */
  49717. emissiveColor: Color3;
  49718. /**
  49719. * AKA Glossiness in other nomenclature.
  49720. */
  49721. microSurface: number;
  49722. /**
  49723. * source material index of refraction (IOR)' / 'destination material IOR.
  49724. */
  49725. indexOfRefraction: number;
  49726. /**
  49727. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49728. */
  49729. invertRefractionY: boolean;
  49730. /**
  49731. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49732. * Materials half opaque for instance using refraction could benefit from this control.
  49733. */
  49734. linkRefractionWithTransparency: boolean;
  49735. /**
  49736. * If true, the light map contains occlusion information instead of lighting info.
  49737. */
  49738. useLightmapAsShadowmap: boolean;
  49739. /**
  49740. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49741. */
  49742. useAlphaFromAlbedoTexture: boolean;
  49743. /**
  49744. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49745. */
  49746. forceAlphaTest: boolean;
  49747. /**
  49748. * Defines the alpha limits in alpha test mode.
  49749. */
  49750. alphaCutOff: number;
  49751. /**
  49752. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49753. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49754. */
  49755. useSpecularOverAlpha: boolean;
  49756. /**
  49757. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49758. */
  49759. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49760. /**
  49761. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49762. */
  49763. useRoughnessFromMetallicTextureAlpha: boolean;
  49764. /**
  49765. * Specifies if the metallic texture contains the roughness information in its green channel.
  49766. */
  49767. useRoughnessFromMetallicTextureGreen: boolean;
  49768. /**
  49769. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49770. */
  49771. useMetallnessFromMetallicTextureBlue: boolean;
  49772. /**
  49773. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49774. */
  49775. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49776. /**
  49777. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49778. */
  49779. useAmbientInGrayScale: boolean;
  49780. /**
  49781. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49782. * The material will try to infer what glossiness each pixel should be.
  49783. */
  49784. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49785. /**
  49786. * BJS is using an harcoded light falloff based on a manually sets up range.
  49787. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49788. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49789. */
  49790. /**
  49791. * BJS is using an harcoded light falloff based on a manually sets up range.
  49792. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49793. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49794. */
  49795. usePhysicalLightFalloff: boolean;
  49796. /**
  49797. * In order to support the falloff compatibility with gltf, a special mode has been added
  49798. * to reproduce the gltf light falloff.
  49799. */
  49800. /**
  49801. * In order to support the falloff compatibility with gltf, a special mode has been added
  49802. * to reproduce the gltf light falloff.
  49803. */
  49804. useGLTFLightFalloff: boolean;
  49805. /**
  49806. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49807. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49808. */
  49809. useRadianceOverAlpha: boolean;
  49810. /**
  49811. * Allows using an object space normal map (instead of tangent space).
  49812. */
  49813. useObjectSpaceNormalMap: boolean;
  49814. /**
  49815. * Allows using the bump map in parallax mode.
  49816. */
  49817. useParallax: boolean;
  49818. /**
  49819. * Allows using the bump map in parallax occlusion mode.
  49820. */
  49821. useParallaxOcclusion: boolean;
  49822. /**
  49823. * Controls the scale bias of the parallax mode.
  49824. */
  49825. parallaxScaleBias: number;
  49826. /**
  49827. * If sets to true, disables all the lights affecting the material.
  49828. */
  49829. disableLighting: boolean;
  49830. /**
  49831. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49832. */
  49833. forceIrradianceInFragment: boolean;
  49834. /**
  49835. * Number of Simultaneous lights allowed on the material.
  49836. */
  49837. maxSimultaneousLights: number;
  49838. /**
  49839. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49840. */
  49841. invertNormalMapX: boolean;
  49842. /**
  49843. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49844. */
  49845. invertNormalMapY: boolean;
  49846. /**
  49847. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49848. */
  49849. twoSidedLighting: boolean;
  49850. /**
  49851. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49852. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49853. */
  49854. useAlphaFresnel: boolean;
  49855. /**
  49856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49857. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49858. */
  49859. useLinearAlphaFresnel: boolean;
  49860. /**
  49861. * Let user defines the brdf lookup texture used for IBL.
  49862. * A default 8bit version is embedded but you could point at :
  49863. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49864. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49865. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49866. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49867. */
  49868. environmentBRDFTexture: Nullable<BaseTexture>;
  49869. /**
  49870. * Force normal to face away from face.
  49871. */
  49872. forceNormalForward: boolean;
  49873. /**
  49874. * Enables specular anti aliasing in the PBR shader.
  49875. * It will both interacts on the Geometry for analytical and IBL lighting.
  49876. * It also prefilter the roughness map based on the bump values.
  49877. */
  49878. enableSpecularAntiAliasing: boolean;
  49879. /**
  49880. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49881. * makes the reflect vector face the model (under horizon).
  49882. */
  49883. useHorizonOcclusion: boolean;
  49884. /**
  49885. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49886. * too much the area relying on ambient texture to define their ambient occlusion.
  49887. */
  49888. useRadianceOcclusion: boolean;
  49889. /**
  49890. * If set to true, no lighting calculations will be applied.
  49891. */
  49892. unlit: boolean;
  49893. /**
  49894. * Gets the image processing configuration used either in this material.
  49895. */
  49896. /**
  49897. * Sets the Default image processing configuration used either in the this material.
  49898. *
  49899. * If sets to null, the scene one is in use.
  49900. */
  49901. imageProcessingConfiguration: ImageProcessingConfiguration;
  49902. /**
  49903. * Gets wether the color curves effect is enabled.
  49904. */
  49905. /**
  49906. * Sets wether the color curves effect is enabled.
  49907. */
  49908. cameraColorCurvesEnabled: boolean;
  49909. /**
  49910. * Gets wether the color grading effect is enabled.
  49911. */
  49912. /**
  49913. * Gets wether the color grading effect is enabled.
  49914. */
  49915. cameraColorGradingEnabled: boolean;
  49916. /**
  49917. * Gets wether tonemapping is enabled or not.
  49918. */
  49919. /**
  49920. * Sets wether tonemapping is enabled or not
  49921. */
  49922. cameraToneMappingEnabled: boolean;
  49923. /**
  49924. * The camera exposure used on this material.
  49925. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49926. * This corresponds to a photographic exposure.
  49927. */
  49928. /**
  49929. * The camera exposure used on this material.
  49930. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49931. * This corresponds to a photographic exposure.
  49932. */
  49933. cameraExposure: number;
  49934. /**
  49935. * Gets The camera contrast used on this material.
  49936. */
  49937. /**
  49938. * Sets The camera contrast used on this material.
  49939. */
  49940. cameraContrast: number;
  49941. /**
  49942. * Gets the Color Grading 2D Lookup Texture.
  49943. */
  49944. /**
  49945. * Sets the Color Grading 2D Lookup Texture.
  49946. */
  49947. cameraColorGradingTexture: Nullable<BaseTexture>;
  49948. /**
  49949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49951. * 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;
  49952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49953. */
  49954. /**
  49955. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49956. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49957. * 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;
  49958. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49959. */
  49960. cameraColorCurves: Nullable<ColorCurves>;
  49961. /**
  49962. * Instantiates a new PBRMaterial instance.
  49963. *
  49964. * @param name The material name
  49965. * @param scene The scene the material will be use in.
  49966. */
  49967. constructor(name: string, scene: Scene);
  49968. /**
  49969. * Returns the name of this material class.
  49970. */
  49971. getClassName(): string;
  49972. /**
  49973. * Makes a duplicate of the current material.
  49974. * @param name - name to use for the new material.
  49975. */
  49976. clone(name: string): PBRMaterial;
  49977. /**
  49978. * Serializes this PBR Material.
  49979. * @returns - An object with the serialized material.
  49980. */
  49981. serialize(): any;
  49982. /**
  49983. * Parses a PBR Material from a serialized object.
  49984. * @param source - Serialized object.
  49985. * @param scene - BJS scene instance.
  49986. * @param rootUrl - url for the scene object
  49987. * @returns - PBRMaterial
  49988. */
  49989. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49990. }
  49991. }
  49992. declare module "babylonjs/Misc/dds" {
  49993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49994. import { Engine } from "babylonjs/Engines/engine";
  49995. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49996. import { Nullable } from "babylonjs/types";
  49997. import { Scene } from "babylonjs/scene";
  49998. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49999. /**
  50000. * Direct draw surface info
  50001. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50002. */
  50003. export interface DDSInfo {
  50004. /**
  50005. * Width of the texture
  50006. */
  50007. width: number;
  50008. /**
  50009. * Width of the texture
  50010. */
  50011. height: number;
  50012. /**
  50013. * Number of Mipmaps for the texture
  50014. * @see https://en.wikipedia.org/wiki/Mipmap
  50015. */
  50016. mipmapCount: number;
  50017. /**
  50018. * If the textures format is a known fourCC format
  50019. * @see https://www.fourcc.org/
  50020. */
  50021. isFourCC: boolean;
  50022. /**
  50023. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50024. */
  50025. isRGB: boolean;
  50026. /**
  50027. * If the texture is a lumincance format
  50028. */
  50029. isLuminance: boolean;
  50030. /**
  50031. * If this is a cube texture
  50032. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50033. */
  50034. isCube: boolean;
  50035. /**
  50036. * If the texture is a compressed format eg. FOURCC_DXT1
  50037. */
  50038. isCompressed: boolean;
  50039. /**
  50040. * The dxgiFormat of the texture
  50041. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50042. */
  50043. dxgiFormat: number;
  50044. /**
  50045. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50046. */
  50047. textureType: number;
  50048. /**
  50049. * Sphericle polynomial created for the dds texture
  50050. */
  50051. sphericalPolynomial?: SphericalPolynomial;
  50052. }
  50053. /**
  50054. * Class used to provide DDS decompression tools
  50055. */
  50056. export class DDSTools {
  50057. /**
  50058. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50059. */
  50060. static StoreLODInAlphaChannel: boolean;
  50061. /**
  50062. * Gets DDS information from an array buffer
  50063. * @param arrayBuffer defines the array buffer to read data from
  50064. * @returns the DDS information
  50065. */
  50066. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50067. private static _FloatView;
  50068. private static _Int32View;
  50069. private static _ToHalfFloat;
  50070. private static _FromHalfFloat;
  50071. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50072. private static _GetHalfFloatRGBAArrayBuffer;
  50073. private static _GetFloatRGBAArrayBuffer;
  50074. private static _GetFloatAsUIntRGBAArrayBuffer;
  50075. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50076. private static _GetRGBAArrayBuffer;
  50077. private static _ExtractLongWordOrder;
  50078. private static _GetRGBArrayBuffer;
  50079. private static _GetLuminanceArrayBuffer;
  50080. /**
  50081. * Uploads DDS Levels to a Babylon Texture
  50082. * @hidden
  50083. */
  50084. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50085. }
  50086. module "babylonjs/Engines/engine" {
  50087. interface Engine {
  50088. /**
  50089. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50090. * @param rootUrl defines the url where the file to load is located
  50091. * @param scene defines the current scene
  50092. * @param lodScale defines scale to apply to the mip map selection
  50093. * @param lodOffset defines offset to apply to the mip map selection
  50094. * @param onLoad defines an optional callback raised when the texture is loaded
  50095. * @param onError defines an optional callback raised if there is an issue to load the texture
  50096. * @param format defines the format of the data
  50097. * @param forcedExtension defines the extension to use to pick the right loader
  50098. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50099. * @returns the cube texture as an InternalTexture
  50100. */
  50101. 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;
  50102. }
  50103. }
  50104. }
  50105. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50106. import { Nullable } from "babylonjs/types";
  50107. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50108. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50109. /**
  50110. * Implementation of the DDS Texture Loader.
  50111. * @hidden
  50112. */
  50113. export class _DDSTextureLoader implements IInternalTextureLoader {
  50114. /**
  50115. * Defines wether the loader supports cascade loading the different faces.
  50116. */
  50117. readonly supportCascades: boolean;
  50118. /**
  50119. * This returns if the loader support the current file information.
  50120. * @param extension defines the file extension of the file being loaded
  50121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50122. * @param fallback defines the fallback internal texture if any
  50123. * @param isBase64 defines whether the texture is encoded as a base64
  50124. * @param isBuffer defines whether the texture data are stored as a buffer
  50125. * @returns true if the loader can load the specified file
  50126. */
  50127. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50128. /**
  50129. * Transform the url before loading if required.
  50130. * @param rootUrl the url of the texture
  50131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50132. * @returns the transformed texture
  50133. */
  50134. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50135. /**
  50136. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50137. * @param rootUrl the url of the texture
  50138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50139. * @returns the fallback texture
  50140. */
  50141. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50142. /**
  50143. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50144. * @param data contains the texture data
  50145. * @param texture defines the BabylonJS internal texture
  50146. * @param createPolynomials will be true if polynomials have been requested
  50147. * @param onLoad defines the callback to trigger once the texture is ready
  50148. * @param onError defines the callback to trigger in case of error
  50149. */
  50150. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50151. /**
  50152. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50153. * @param data contains the texture data
  50154. * @param texture defines the BabylonJS internal texture
  50155. * @param callback defines the method to call once ready to upload
  50156. */
  50157. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50158. }
  50159. }
  50160. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50161. import { Nullable } from "babylonjs/types";
  50162. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50163. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50164. /**
  50165. * Implementation of the ENV Texture Loader.
  50166. * @hidden
  50167. */
  50168. export class _ENVTextureLoader implements IInternalTextureLoader {
  50169. /**
  50170. * Defines wether the loader supports cascade loading the different faces.
  50171. */
  50172. readonly supportCascades: boolean;
  50173. /**
  50174. * This returns if the loader support the current file information.
  50175. * @param extension defines the file extension of the file being loaded
  50176. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50177. * @param fallback defines the fallback internal texture if any
  50178. * @param isBase64 defines whether the texture is encoded as a base64
  50179. * @param isBuffer defines whether the texture data are stored as a buffer
  50180. * @returns true if the loader can load the specified file
  50181. */
  50182. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50183. /**
  50184. * Transform the url before loading if required.
  50185. * @param rootUrl the url of the texture
  50186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50187. * @returns the transformed texture
  50188. */
  50189. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50190. /**
  50191. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50192. * @param rootUrl the url of the texture
  50193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50194. * @returns the fallback texture
  50195. */
  50196. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50197. /**
  50198. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50199. * @param data contains the texture data
  50200. * @param texture defines the BabylonJS internal texture
  50201. * @param createPolynomials will be true if polynomials have been requested
  50202. * @param onLoad defines the callback to trigger once the texture is ready
  50203. * @param onError defines the callback to trigger in case of error
  50204. */
  50205. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50206. /**
  50207. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50208. * @param data contains the texture data
  50209. * @param texture defines the BabylonJS internal texture
  50210. * @param callback defines the method to call once ready to upload
  50211. */
  50212. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50213. }
  50214. }
  50215. declare module "babylonjs/Misc/khronosTextureContainer" {
  50216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50217. /**
  50218. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50219. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50220. */
  50221. export class KhronosTextureContainer {
  50222. /** contents of the KTX container file */
  50223. arrayBuffer: any;
  50224. private static HEADER_LEN;
  50225. private static COMPRESSED_2D;
  50226. private static COMPRESSED_3D;
  50227. private static TEX_2D;
  50228. private static TEX_3D;
  50229. /**
  50230. * Gets the openGL type
  50231. */
  50232. glType: number;
  50233. /**
  50234. * Gets the openGL type size
  50235. */
  50236. glTypeSize: number;
  50237. /**
  50238. * Gets the openGL format
  50239. */
  50240. glFormat: number;
  50241. /**
  50242. * Gets the openGL internal format
  50243. */
  50244. glInternalFormat: number;
  50245. /**
  50246. * Gets the base internal format
  50247. */
  50248. glBaseInternalFormat: number;
  50249. /**
  50250. * Gets image width in pixel
  50251. */
  50252. pixelWidth: number;
  50253. /**
  50254. * Gets image height in pixel
  50255. */
  50256. pixelHeight: number;
  50257. /**
  50258. * Gets image depth in pixels
  50259. */
  50260. pixelDepth: number;
  50261. /**
  50262. * Gets the number of array elements
  50263. */
  50264. numberOfArrayElements: number;
  50265. /**
  50266. * Gets the number of faces
  50267. */
  50268. numberOfFaces: number;
  50269. /**
  50270. * Gets the number of mipmap levels
  50271. */
  50272. numberOfMipmapLevels: number;
  50273. /**
  50274. * Gets the bytes of key value data
  50275. */
  50276. bytesOfKeyValueData: number;
  50277. /**
  50278. * Gets the load type
  50279. */
  50280. loadType: number;
  50281. /**
  50282. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50283. */
  50284. isInvalid: boolean;
  50285. /**
  50286. * Creates a new KhronosTextureContainer
  50287. * @param arrayBuffer contents of the KTX container file
  50288. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50289. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50290. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50291. */
  50292. constructor(
  50293. /** contents of the KTX container file */
  50294. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50295. /**
  50296. * Uploads KTX content to a Babylon Texture.
  50297. * It is assumed that the texture has already been created & is currently bound
  50298. * @hidden
  50299. */
  50300. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50301. private _upload2DCompressedLevels;
  50302. }
  50303. }
  50304. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50305. import { Nullable } from "babylonjs/types";
  50306. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50307. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50308. /**
  50309. * Implementation of the KTX Texture Loader.
  50310. * @hidden
  50311. */
  50312. export class _KTXTextureLoader implements IInternalTextureLoader {
  50313. /**
  50314. * Defines wether the loader supports cascade loading the different faces.
  50315. */
  50316. readonly supportCascades: boolean;
  50317. /**
  50318. * This returns if the loader support the current file information.
  50319. * @param extension defines the file extension of the file being loaded
  50320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50321. * @param fallback defines the fallback internal texture if any
  50322. * @param isBase64 defines whether the texture is encoded as a base64
  50323. * @param isBuffer defines whether the texture data are stored as a buffer
  50324. * @returns true if the loader can load the specified file
  50325. */
  50326. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50327. /**
  50328. * Transform the url before loading if required.
  50329. * @param rootUrl the url of the texture
  50330. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50331. * @returns the transformed texture
  50332. */
  50333. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50334. /**
  50335. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50336. * @param rootUrl the url of the texture
  50337. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50338. * @returns the fallback texture
  50339. */
  50340. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50341. /**
  50342. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50343. * @param data contains the texture data
  50344. * @param texture defines the BabylonJS internal texture
  50345. * @param createPolynomials will be true if polynomials have been requested
  50346. * @param onLoad defines the callback to trigger once the texture is ready
  50347. * @param onError defines the callback to trigger in case of error
  50348. */
  50349. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50350. /**
  50351. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50352. * @param data contains the texture data
  50353. * @param texture defines the BabylonJS internal texture
  50354. * @param callback defines the method to call once ready to upload
  50355. */
  50356. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50357. }
  50358. }
  50359. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50360. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50361. import { Scene } from "babylonjs/scene";
  50362. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50363. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50364. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50365. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50366. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50367. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50369. /**
  50370. * Options for the default xr helper
  50371. */
  50372. export class WebXRDefaultExperienceOptions {
  50373. /**
  50374. * Floor meshes that should be used for teleporting
  50375. */
  50376. floorMeshes: Array<AbstractMesh>;
  50377. }
  50378. /**
  50379. * Default experience which provides a similar setup to the previous webVRExperience
  50380. */
  50381. export class WebXRDefaultExperience {
  50382. /**
  50383. * Base experience
  50384. */
  50385. baseExperience: WebXRExperienceHelper;
  50386. /**
  50387. * Input experience extension
  50388. */
  50389. input: WebXRInput;
  50390. /**
  50391. * Loads the controller models
  50392. */
  50393. controllerModelLoader: WebXRControllerModelLoader;
  50394. /**
  50395. * Enables laser pointer and selection
  50396. */
  50397. pointerSelection: WebXRControllerPointerSelection;
  50398. /**
  50399. * Enables teleportation
  50400. */
  50401. teleportation: WebXRControllerTeleportation;
  50402. /**
  50403. * Enables ui for enetering/exiting xr
  50404. */
  50405. enterExitUI: WebXREnterExitUI;
  50406. /**
  50407. * Default output canvas xr should render to
  50408. */
  50409. outputCanvas: WebXRManagedOutputCanvas;
  50410. /**
  50411. * Creates the default xr experience
  50412. * @param scene scene
  50413. * @param options options for basic configuration
  50414. * @returns resulting WebXRDefaultExperience
  50415. */
  50416. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50417. private constructor();
  50418. /**
  50419. * DIsposes of the experience helper
  50420. */
  50421. dispose(): void;
  50422. }
  50423. }
  50424. declare module "babylonjs/Helpers/sceneHelpers" {
  50425. import { Nullable } from "babylonjs/types";
  50426. import { Mesh } from "babylonjs/Meshes/mesh";
  50427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50428. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50429. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50430. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50431. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50432. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50433. import "babylonjs/Meshes/Builders/boxBuilder";
  50434. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50435. /** @hidden */
  50436. export var _forceSceneHelpersToBundle: boolean;
  50437. module "babylonjs/scene" {
  50438. interface Scene {
  50439. /**
  50440. * Creates a default light for the scene.
  50441. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50442. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50443. */
  50444. createDefaultLight(replace?: boolean): void;
  50445. /**
  50446. * Creates a default camera for the scene.
  50447. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50448. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50449. * @param replace has default false, when true replaces the active camera in the scene
  50450. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50451. */
  50452. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50453. /**
  50454. * Creates a default camera and a default light.
  50455. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50456. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50457. * @param replace has the default false, when true replaces the active camera/light in the scene
  50458. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50459. */
  50460. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50461. /**
  50462. * Creates a new sky box
  50463. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50464. * @param environmentTexture defines the texture to use as environment texture
  50465. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50466. * @param scale defines the overall scale of the skybox
  50467. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50468. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50469. * @returns a new mesh holding the sky box
  50470. */
  50471. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50472. /**
  50473. * Creates a new environment
  50474. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50475. * @param options defines the options you can use to configure the environment
  50476. * @returns the new EnvironmentHelper
  50477. */
  50478. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50479. /**
  50480. * Creates a new VREXperienceHelper
  50481. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50482. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50483. * @returns a new VREXperienceHelper
  50484. */
  50485. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50486. /**
  50487. * Creates a new WebXRDefaultExperience
  50488. * @see http://doc.babylonjs.com/how_to/webxr
  50489. * @param options experience options
  50490. * @returns a promise for a new WebXRDefaultExperience
  50491. */
  50492. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50493. }
  50494. }
  50495. }
  50496. declare module "babylonjs/Helpers/videoDome" {
  50497. import { Scene } from "babylonjs/scene";
  50498. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50499. import { Mesh } from "babylonjs/Meshes/mesh";
  50500. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50501. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50502. import "babylonjs/Meshes/Builders/sphereBuilder";
  50503. /**
  50504. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50505. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50506. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50507. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50508. */
  50509. export class VideoDome extends TransformNode {
  50510. /**
  50511. * Define the video source as a Monoscopic panoramic 360 video.
  50512. */
  50513. static readonly MODE_MONOSCOPIC: number;
  50514. /**
  50515. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50516. */
  50517. static readonly MODE_TOPBOTTOM: number;
  50518. /**
  50519. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50520. */
  50521. static readonly MODE_SIDEBYSIDE: number;
  50522. private _halfDome;
  50523. private _useDirectMapping;
  50524. /**
  50525. * The video texture being displayed on the sphere
  50526. */
  50527. protected _videoTexture: VideoTexture;
  50528. /**
  50529. * Gets the video texture being displayed on the sphere
  50530. */
  50531. readonly videoTexture: VideoTexture;
  50532. /**
  50533. * The skybox material
  50534. */
  50535. protected _material: BackgroundMaterial;
  50536. /**
  50537. * The surface used for the skybox
  50538. */
  50539. protected _mesh: Mesh;
  50540. /**
  50541. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50542. */
  50543. private _halfDomeMask;
  50544. /**
  50545. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50546. * Also see the options.resolution property.
  50547. */
  50548. fovMultiplier: number;
  50549. private _videoMode;
  50550. /**
  50551. * Gets or set the current video mode for the video. It can be:
  50552. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50553. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50554. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50555. */
  50556. videoMode: number;
  50557. /**
  50558. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50559. *
  50560. */
  50561. /**
  50562. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50563. */
  50564. halfDome: boolean;
  50565. /**
  50566. * Oberserver used in Stereoscopic VR Mode.
  50567. */
  50568. private _onBeforeCameraRenderObserver;
  50569. /**
  50570. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50571. * @param name Element's name, child elements will append suffixes for their own names.
  50572. * @param urlsOrVideo defines the url(s) or the video element to use
  50573. * @param options An object containing optional or exposed sub element properties
  50574. */
  50575. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50576. resolution?: number;
  50577. clickToPlay?: boolean;
  50578. autoPlay?: boolean;
  50579. loop?: boolean;
  50580. size?: number;
  50581. poster?: string;
  50582. faceForward?: boolean;
  50583. useDirectMapping?: boolean;
  50584. halfDomeMode?: boolean;
  50585. }, scene: Scene);
  50586. private _changeVideoMode;
  50587. /**
  50588. * Releases resources associated with this node.
  50589. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50590. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50591. */
  50592. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50593. }
  50594. }
  50595. declare module "babylonjs/Helpers/index" {
  50596. export * from "babylonjs/Helpers/environmentHelper";
  50597. export * from "babylonjs/Helpers/photoDome";
  50598. export * from "babylonjs/Helpers/sceneHelpers";
  50599. export * from "babylonjs/Helpers/videoDome";
  50600. }
  50601. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50602. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50603. import { IDisposable } from "babylonjs/scene";
  50604. import { Engine } from "babylonjs/Engines/engine";
  50605. /**
  50606. * This class can be used to get instrumentation data from a Babylon engine
  50607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50608. */
  50609. export class EngineInstrumentation implements IDisposable {
  50610. /**
  50611. * Define the instrumented engine.
  50612. */
  50613. engine: Engine;
  50614. private _captureGPUFrameTime;
  50615. private _gpuFrameTimeToken;
  50616. private _gpuFrameTime;
  50617. private _captureShaderCompilationTime;
  50618. private _shaderCompilationTime;
  50619. private _onBeginFrameObserver;
  50620. private _onEndFrameObserver;
  50621. private _onBeforeShaderCompilationObserver;
  50622. private _onAfterShaderCompilationObserver;
  50623. /**
  50624. * Gets the perf counter used for GPU frame time
  50625. */
  50626. readonly gpuFrameTimeCounter: PerfCounter;
  50627. /**
  50628. * Gets the GPU frame time capture status
  50629. */
  50630. /**
  50631. * Enable or disable the GPU frame time capture
  50632. */
  50633. captureGPUFrameTime: boolean;
  50634. /**
  50635. * Gets the perf counter used for shader compilation time
  50636. */
  50637. readonly shaderCompilationTimeCounter: PerfCounter;
  50638. /**
  50639. * Gets the shader compilation time capture status
  50640. */
  50641. /**
  50642. * Enable or disable the shader compilation time capture
  50643. */
  50644. captureShaderCompilationTime: boolean;
  50645. /**
  50646. * Instantiates a new engine instrumentation.
  50647. * This class can be used to get instrumentation data from a Babylon engine
  50648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50649. * @param engine Defines the engine to instrument
  50650. */
  50651. constructor(
  50652. /**
  50653. * Define the instrumented engine.
  50654. */
  50655. engine: Engine);
  50656. /**
  50657. * Dispose and release associated resources.
  50658. */
  50659. dispose(): void;
  50660. }
  50661. }
  50662. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50663. import { Scene, IDisposable } from "babylonjs/scene";
  50664. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50665. /**
  50666. * This class can be used to get instrumentation data from a Babylon engine
  50667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50668. */
  50669. export class SceneInstrumentation implements IDisposable {
  50670. /**
  50671. * Defines the scene to instrument
  50672. */
  50673. scene: Scene;
  50674. private _captureActiveMeshesEvaluationTime;
  50675. private _activeMeshesEvaluationTime;
  50676. private _captureRenderTargetsRenderTime;
  50677. private _renderTargetsRenderTime;
  50678. private _captureFrameTime;
  50679. private _frameTime;
  50680. private _captureRenderTime;
  50681. private _renderTime;
  50682. private _captureInterFrameTime;
  50683. private _interFrameTime;
  50684. private _captureParticlesRenderTime;
  50685. private _particlesRenderTime;
  50686. private _captureSpritesRenderTime;
  50687. private _spritesRenderTime;
  50688. private _capturePhysicsTime;
  50689. private _physicsTime;
  50690. private _captureAnimationsTime;
  50691. private _animationsTime;
  50692. private _captureCameraRenderTime;
  50693. private _cameraRenderTime;
  50694. private _onBeforeActiveMeshesEvaluationObserver;
  50695. private _onAfterActiveMeshesEvaluationObserver;
  50696. private _onBeforeRenderTargetsRenderObserver;
  50697. private _onAfterRenderTargetsRenderObserver;
  50698. private _onAfterRenderObserver;
  50699. private _onBeforeDrawPhaseObserver;
  50700. private _onAfterDrawPhaseObserver;
  50701. private _onBeforeAnimationsObserver;
  50702. private _onBeforeParticlesRenderingObserver;
  50703. private _onAfterParticlesRenderingObserver;
  50704. private _onBeforeSpritesRenderingObserver;
  50705. private _onAfterSpritesRenderingObserver;
  50706. private _onBeforePhysicsObserver;
  50707. private _onAfterPhysicsObserver;
  50708. private _onAfterAnimationsObserver;
  50709. private _onBeforeCameraRenderObserver;
  50710. private _onAfterCameraRenderObserver;
  50711. /**
  50712. * Gets the perf counter used for active meshes evaluation time
  50713. */
  50714. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50715. /**
  50716. * Gets the active meshes evaluation time capture status
  50717. */
  50718. /**
  50719. * Enable or disable the active meshes evaluation time capture
  50720. */
  50721. captureActiveMeshesEvaluationTime: boolean;
  50722. /**
  50723. * Gets the perf counter used for render targets render time
  50724. */
  50725. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50726. /**
  50727. * Gets the render targets render time capture status
  50728. */
  50729. /**
  50730. * Enable or disable the render targets render time capture
  50731. */
  50732. captureRenderTargetsRenderTime: boolean;
  50733. /**
  50734. * Gets the perf counter used for particles render time
  50735. */
  50736. readonly particlesRenderTimeCounter: PerfCounter;
  50737. /**
  50738. * Gets the particles render time capture status
  50739. */
  50740. /**
  50741. * Enable or disable the particles render time capture
  50742. */
  50743. captureParticlesRenderTime: boolean;
  50744. /**
  50745. * Gets the perf counter used for sprites render time
  50746. */
  50747. readonly spritesRenderTimeCounter: PerfCounter;
  50748. /**
  50749. * Gets the sprites render time capture status
  50750. */
  50751. /**
  50752. * Enable or disable the sprites render time capture
  50753. */
  50754. captureSpritesRenderTime: boolean;
  50755. /**
  50756. * Gets the perf counter used for physics time
  50757. */
  50758. readonly physicsTimeCounter: PerfCounter;
  50759. /**
  50760. * Gets the physics time capture status
  50761. */
  50762. /**
  50763. * Enable or disable the physics time capture
  50764. */
  50765. capturePhysicsTime: boolean;
  50766. /**
  50767. * Gets the perf counter used for animations time
  50768. */
  50769. readonly animationsTimeCounter: PerfCounter;
  50770. /**
  50771. * Gets the animations time capture status
  50772. */
  50773. /**
  50774. * Enable or disable the animations time capture
  50775. */
  50776. captureAnimationsTime: boolean;
  50777. /**
  50778. * Gets the perf counter used for frame time capture
  50779. */
  50780. readonly frameTimeCounter: PerfCounter;
  50781. /**
  50782. * Gets the frame time capture status
  50783. */
  50784. /**
  50785. * Enable or disable the frame time capture
  50786. */
  50787. captureFrameTime: boolean;
  50788. /**
  50789. * Gets the perf counter used for inter-frames time capture
  50790. */
  50791. readonly interFrameTimeCounter: PerfCounter;
  50792. /**
  50793. * Gets the inter-frames time capture status
  50794. */
  50795. /**
  50796. * Enable or disable the inter-frames time capture
  50797. */
  50798. captureInterFrameTime: boolean;
  50799. /**
  50800. * Gets the perf counter used for render time capture
  50801. */
  50802. readonly renderTimeCounter: PerfCounter;
  50803. /**
  50804. * Gets the render time capture status
  50805. */
  50806. /**
  50807. * Enable or disable the render time capture
  50808. */
  50809. captureRenderTime: boolean;
  50810. /**
  50811. * Gets the perf counter used for camera render time capture
  50812. */
  50813. readonly cameraRenderTimeCounter: PerfCounter;
  50814. /**
  50815. * Gets the camera render time capture status
  50816. */
  50817. /**
  50818. * Enable or disable the camera render time capture
  50819. */
  50820. captureCameraRenderTime: boolean;
  50821. /**
  50822. * Gets the perf counter used for draw calls
  50823. */
  50824. readonly drawCallsCounter: PerfCounter;
  50825. /**
  50826. * Instantiates a new scene instrumentation.
  50827. * This class can be used to get instrumentation data from a Babylon engine
  50828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50829. * @param scene Defines the scene to instrument
  50830. */
  50831. constructor(
  50832. /**
  50833. * Defines the scene to instrument
  50834. */
  50835. scene: Scene);
  50836. /**
  50837. * Dispose and release associated resources.
  50838. */
  50839. dispose(): void;
  50840. }
  50841. }
  50842. declare module "babylonjs/Instrumentation/index" {
  50843. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50844. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50845. export * from "babylonjs/Instrumentation/timeToken";
  50846. }
  50847. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50848. /** @hidden */
  50849. export var glowMapGenerationPixelShader: {
  50850. name: string;
  50851. shader: string;
  50852. };
  50853. }
  50854. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50858. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50860. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50861. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50862. /** @hidden */
  50863. export var glowMapGenerationVertexShader: {
  50864. name: string;
  50865. shader: string;
  50866. };
  50867. }
  50868. declare module "babylonjs/Layers/effectLayer" {
  50869. import { Observable } from "babylonjs/Misc/observable";
  50870. import { Nullable } from "babylonjs/types";
  50871. import { Camera } from "babylonjs/Cameras/camera";
  50872. import { Scene } from "babylonjs/scene";
  50873. import { ISize } from "babylonjs/Maths/math.size";
  50874. import { Color4 } from "babylonjs/Maths/math.color";
  50875. import { Engine } from "babylonjs/Engines/engine";
  50876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50878. import { Mesh } from "babylonjs/Meshes/mesh";
  50879. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50881. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50882. import { Effect } from "babylonjs/Materials/effect";
  50883. import { Material } from "babylonjs/Materials/material";
  50884. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50885. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50886. /**
  50887. * Effect layer options. This helps customizing the behaviour
  50888. * of the effect layer.
  50889. */
  50890. export interface IEffectLayerOptions {
  50891. /**
  50892. * Multiplication factor apply to the canvas size to compute the render target size
  50893. * used to generated the objects (the smaller the faster).
  50894. */
  50895. mainTextureRatio: number;
  50896. /**
  50897. * Enforces a fixed size texture to ensure effect stability across devices.
  50898. */
  50899. mainTextureFixedSize?: number;
  50900. /**
  50901. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50902. */
  50903. alphaBlendingMode: number;
  50904. /**
  50905. * The camera attached to the layer.
  50906. */
  50907. camera: Nullable<Camera>;
  50908. /**
  50909. * The rendering group to draw the layer in.
  50910. */
  50911. renderingGroupId: number;
  50912. }
  50913. /**
  50914. * The effect layer Helps adding post process effect blended with the main pass.
  50915. *
  50916. * This can be for instance use to generate glow or higlight effects on the scene.
  50917. *
  50918. * The effect layer class can not be used directly and is intented to inherited from to be
  50919. * customized per effects.
  50920. */
  50921. export abstract class EffectLayer {
  50922. private _vertexBuffers;
  50923. private _indexBuffer;
  50924. private _cachedDefines;
  50925. private _effectLayerMapGenerationEffect;
  50926. private _effectLayerOptions;
  50927. private _mergeEffect;
  50928. protected _scene: Scene;
  50929. protected _engine: Engine;
  50930. protected _maxSize: number;
  50931. protected _mainTextureDesiredSize: ISize;
  50932. protected _mainTexture: RenderTargetTexture;
  50933. protected _shouldRender: boolean;
  50934. protected _postProcesses: PostProcess[];
  50935. protected _textures: BaseTexture[];
  50936. protected _emissiveTextureAndColor: {
  50937. texture: Nullable<BaseTexture>;
  50938. color: Color4;
  50939. };
  50940. /**
  50941. * The name of the layer
  50942. */
  50943. name: string;
  50944. /**
  50945. * The clear color of the texture used to generate the glow map.
  50946. */
  50947. neutralColor: Color4;
  50948. /**
  50949. * Specifies wether the highlight layer is enabled or not.
  50950. */
  50951. isEnabled: boolean;
  50952. /**
  50953. * Gets the camera attached to the layer.
  50954. */
  50955. readonly camera: Nullable<Camera>;
  50956. /**
  50957. * Gets the rendering group id the layer should render in.
  50958. */
  50959. renderingGroupId: number;
  50960. /**
  50961. * An event triggered when the effect layer has been disposed.
  50962. */
  50963. onDisposeObservable: Observable<EffectLayer>;
  50964. /**
  50965. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50966. */
  50967. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50968. /**
  50969. * An event triggered when the generated texture is being merged in the scene.
  50970. */
  50971. onBeforeComposeObservable: Observable<EffectLayer>;
  50972. /**
  50973. * An event triggered when the generated texture has been merged in the scene.
  50974. */
  50975. onAfterComposeObservable: Observable<EffectLayer>;
  50976. /**
  50977. * An event triggered when the efffect layer changes its size.
  50978. */
  50979. onSizeChangedObservable: Observable<EffectLayer>;
  50980. /** @hidden */
  50981. static _SceneComponentInitialization: (scene: Scene) => void;
  50982. /**
  50983. * Instantiates a new effect Layer and references it in the scene.
  50984. * @param name The name of the layer
  50985. * @param scene The scene to use the layer in
  50986. */
  50987. constructor(
  50988. /** The Friendly of the effect in the scene */
  50989. name: string, scene: Scene);
  50990. /**
  50991. * Get the effect name of the layer.
  50992. * @return The effect name
  50993. */
  50994. abstract getEffectName(): string;
  50995. /**
  50996. * Checks for the readiness of the element composing the layer.
  50997. * @param subMesh the mesh to check for
  50998. * @param useInstances specify wether or not to use instances to render the mesh
  50999. * @return true if ready otherwise, false
  51000. */
  51001. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51002. /**
  51003. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51004. * @returns true if the effect requires stencil during the main canvas render pass.
  51005. */
  51006. abstract needStencil(): boolean;
  51007. /**
  51008. * Create the merge effect. This is the shader use to blit the information back
  51009. * to the main canvas at the end of the scene rendering.
  51010. * @returns The effect containing the shader used to merge the effect on the main canvas
  51011. */
  51012. protected abstract _createMergeEffect(): Effect;
  51013. /**
  51014. * Creates the render target textures and post processes used in the effect layer.
  51015. */
  51016. protected abstract _createTextureAndPostProcesses(): void;
  51017. /**
  51018. * Implementation specific of rendering the generating effect on the main canvas.
  51019. * @param effect The effect used to render through
  51020. */
  51021. protected abstract _internalRender(effect: Effect): void;
  51022. /**
  51023. * Sets the required values for both the emissive texture and and the main color.
  51024. */
  51025. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51026. /**
  51027. * Free any resources and references associated to a mesh.
  51028. * Internal use
  51029. * @param mesh The mesh to free.
  51030. */
  51031. abstract _disposeMesh(mesh: Mesh): void;
  51032. /**
  51033. * Serializes this layer (Glow or Highlight for example)
  51034. * @returns a serialized layer object
  51035. */
  51036. abstract serialize?(): any;
  51037. /**
  51038. * Initializes the effect layer with the required options.
  51039. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51040. */
  51041. protected _init(options: Partial<IEffectLayerOptions>): void;
  51042. /**
  51043. * Generates the index buffer of the full screen quad blending to the main canvas.
  51044. */
  51045. private _generateIndexBuffer;
  51046. /**
  51047. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51048. */
  51049. private _generateVertexBuffer;
  51050. /**
  51051. * Sets the main texture desired size which is the closest power of two
  51052. * of the engine canvas size.
  51053. */
  51054. private _setMainTextureSize;
  51055. /**
  51056. * Creates the main texture for the effect layer.
  51057. */
  51058. protected _createMainTexture(): void;
  51059. /**
  51060. * Adds specific effects defines.
  51061. * @param defines The defines to add specifics to.
  51062. */
  51063. protected _addCustomEffectDefines(defines: string[]): void;
  51064. /**
  51065. * Checks for the readiness of the element composing the layer.
  51066. * @param subMesh the mesh to check for
  51067. * @param useInstances specify wether or not to use instances to render the mesh
  51068. * @param emissiveTexture the associated emissive texture used to generate the glow
  51069. * @return true if ready otherwise, false
  51070. */
  51071. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51072. /**
  51073. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51074. */
  51075. render(): void;
  51076. /**
  51077. * Determine if a given mesh will be used in the current effect.
  51078. * @param mesh mesh to test
  51079. * @returns true if the mesh will be used
  51080. */
  51081. hasMesh(mesh: AbstractMesh): boolean;
  51082. /**
  51083. * Returns true if the layer contains information to display, otherwise false.
  51084. * @returns true if the glow layer should be rendered
  51085. */
  51086. shouldRender(): boolean;
  51087. /**
  51088. * Returns true if the mesh should render, otherwise false.
  51089. * @param mesh The mesh to render
  51090. * @returns true if it should render otherwise false
  51091. */
  51092. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51093. /**
  51094. * Returns true if the mesh can be rendered, otherwise false.
  51095. * @param mesh The mesh to render
  51096. * @param material The material used on the mesh
  51097. * @returns true if it can be rendered otherwise false
  51098. */
  51099. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51100. /**
  51101. * Returns true if the mesh should render, otherwise false.
  51102. * @param mesh The mesh to render
  51103. * @returns true if it should render otherwise false
  51104. */
  51105. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51106. /**
  51107. * Renders the submesh passed in parameter to the generation map.
  51108. */
  51109. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51110. /**
  51111. * Rebuild the required buffers.
  51112. * @hidden Internal use only.
  51113. */
  51114. _rebuild(): void;
  51115. /**
  51116. * Dispose only the render target textures and post process.
  51117. */
  51118. private _disposeTextureAndPostProcesses;
  51119. /**
  51120. * Dispose the highlight layer and free resources.
  51121. */
  51122. dispose(): void;
  51123. /**
  51124. * Gets the class name of the effect layer
  51125. * @returns the string with the class name of the effect layer
  51126. */
  51127. getClassName(): string;
  51128. /**
  51129. * Creates an effect layer from parsed effect layer data
  51130. * @param parsedEffectLayer defines effect layer data
  51131. * @param scene defines the current scene
  51132. * @param rootUrl defines the root URL containing the effect layer information
  51133. * @returns a parsed effect Layer
  51134. */
  51135. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51136. }
  51137. }
  51138. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51139. import { Scene } from "babylonjs/scene";
  51140. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51141. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51142. import { AbstractScene } from "babylonjs/abstractScene";
  51143. module "babylonjs/abstractScene" {
  51144. interface AbstractScene {
  51145. /**
  51146. * The list of effect layers (highlights/glow) added to the scene
  51147. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51148. * @see http://doc.babylonjs.com/how_to/glow_layer
  51149. */
  51150. effectLayers: Array<EffectLayer>;
  51151. /**
  51152. * Removes the given effect layer from this scene.
  51153. * @param toRemove defines the effect layer to remove
  51154. * @returns the index of the removed effect layer
  51155. */
  51156. removeEffectLayer(toRemove: EffectLayer): number;
  51157. /**
  51158. * Adds the given effect layer to this scene
  51159. * @param newEffectLayer defines the effect layer to add
  51160. */
  51161. addEffectLayer(newEffectLayer: EffectLayer): void;
  51162. }
  51163. }
  51164. /**
  51165. * Defines the layer scene component responsible to manage any effect layers
  51166. * in a given scene.
  51167. */
  51168. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51169. /**
  51170. * The component name helpfull to identify the component in the list of scene components.
  51171. */
  51172. readonly name: string;
  51173. /**
  51174. * The scene the component belongs to.
  51175. */
  51176. scene: Scene;
  51177. private _engine;
  51178. private _renderEffects;
  51179. private _needStencil;
  51180. private _previousStencilState;
  51181. /**
  51182. * Creates a new instance of the component for the given scene
  51183. * @param scene Defines the scene to register the component in
  51184. */
  51185. constructor(scene: Scene);
  51186. /**
  51187. * Registers the component in a given scene
  51188. */
  51189. register(): void;
  51190. /**
  51191. * Rebuilds the elements related to this component in case of
  51192. * context lost for instance.
  51193. */
  51194. rebuild(): void;
  51195. /**
  51196. * Serializes the component data to the specified json object
  51197. * @param serializationObject The object to serialize to
  51198. */
  51199. serialize(serializationObject: any): void;
  51200. /**
  51201. * Adds all the elements from the container to the scene
  51202. * @param container the container holding the elements
  51203. */
  51204. addFromContainer(container: AbstractScene): void;
  51205. /**
  51206. * Removes all the elements in the container from the scene
  51207. * @param container contains the elements to remove
  51208. * @param dispose if the removed element should be disposed (default: false)
  51209. */
  51210. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51211. /**
  51212. * Disposes the component and the associated ressources.
  51213. */
  51214. dispose(): void;
  51215. private _isReadyForMesh;
  51216. private _renderMainTexture;
  51217. private _setStencil;
  51218. private _setStencilBack;
  51219. private _draw;
  51220. private _drawCamera;
  51221. private _drawRenderingGroup;
  51222. }
  51223. }
  51224. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51225. /** @hidden */
  51226. export var glowMapMergePixelShader: {
  51227. name: string;
  51228. shader: string;
  51229. };
  51230. }
  51231. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51232. /** @hidden */
  51233. export var glowMapMergeVertexShader: {
  51234. name: string;
  51235. shader: string;
  51236. };
  51237. }
  51238. declare module "babylonjs/Layers/glowLayer" {
  51239. import { Nullable } from "babylonjs/types";
  51240. import { Camera } from "babylonjs/Cameras/camera";
  51241. import { Scene } from "babylonjs/scene";
  51242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51244. import { Mesh } from "babylonjs/Meshes/mesh";
  51245. import { Texture } from "babylonjs/Materials/Textures/texture";
  51246. import { Effect } from "babylonjs/Materials/effect";
  51247. import { Material } from "babylonjs/Materials/material";
  51248. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51249. import { Color4 } from "babylonjs/Maths/math.color";
  51250. import "babylonjs/Shaders/glowMapMerge.fragment";
  51251. import "babylonjs/Shaders/glowMapMerge.vertex";
  51252. import "babylonjs/Layers/effectLayerSceneComponent";
  51253. module "babylonjs/abstractScene" {
  51254. interface AbstractScene {
  51255. /**
  51256. * Return a the first highlight layer of the scene with a given name.
  51257. * @param name The name of the highlight layer to look for.
  51258. * @return The highlight layer if found otherwise null.
  51259. */
  51260. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51261. }
  51262. }
  51263. /**
  51264. * Glow layer options. This helps customizing the behaviour
  51265. * of the glow layer.
  51266. */
  51267. export interface IGlowLayerOptions {
  51268. /**
  51269. * Multiplication factor apply to the canvas size to compute the render target size
  51270. * used to generated the glowing objects (the smaller the faster).
  51271. */
  51272. mainTextureRatio: number;
  51273. /**
  51274. * Enforces a fixed size texture to ensure resize independant blur.
  51275. */
  51276. mainTextureFixedSize?: number;
  51277. /**
  51278. * How big is the kernel of the blur texture.
  51279. */
  51280. blurKernelSize: number;
  51281. /**
  51282. * The camera attached to the layer.
  51283. */
  51284. camera: Nullable<Camera>;
  51285. /**
  51286. * Enable MSAA by chosing the number of samples.
  51287. */
  51288. mainTextureSamples?: number;
  51289. /**
  51290. * The rendering group to draw the layer in.
  51291. */
  51292. renderingGroupId: number;
  51293. }
  51294. /**
  51295. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51296. *
  51297. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51298. * glowy meshes to your scene.
  51299. *
  51300. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51301. */
  51302. export class GlowLayer extends EffectLayer {
  51303. /**
  51304. * Effect Name of the layer.
  51305. */
  51306. static readonly EffectName: string;
  51307. /**
  51308. * The default blur kernel size used for the glow.
  51309. */
  51310. static DefaultBlurKernelSize: number;
  51311. /**
  51312. * The default texture size ratio used for the glow.
  51313. */
  51314. static DefaultTextureRatio: number;
  51315. /**
  51316. * Sets the kernel size of the blur.
  51317. */
  51318. /**
  51319. * Gets the kernel size of the blur.
  51320. */
  51321. blurKernelSize: number;
  51322. /**
  51323. * Sets the glow intensity.
  51324. */
  51325. /**
  51326. * Gets the glow intensity.
  51327. */
  51328. intensity: number;
  51329. private _options;
  51330. private _intensity;
  51331. private _horizontalBlurPostprocess1;
  51332. private _verticalBlurPostprocess1;
  51333. private _horizontalBlurPostprocess2;
  51334. private _verticalBlurPostprocess2;
  51335. private _blurTexture1;
  51336. private _blurTexture2;
  51337. private _postProcesses1;
  51338. private _postProcesses2;
  51339. private _includedOnlyMeshes;
  51340. private _excludedMeshes;
  51341. /**
  51342. * Callback used to let the user override the color selection on a per mesh basis
  51343. */
  51344. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51345. /**
  51346. * Callback used to let the user override the texture selection on a per mesh basis
  51347. */
  51348. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51349. /**
  51350. * Instantiates a new glow Layer and references it to the scene.
  51351. * @param name The name of the layer
  51352. * @param scene The scene to use the layer in
  51353. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51354. */
  51355. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51356. /**
  51357. * Get the effect name of the layer.
  51358. * @return The effect name
  51359. */
  51360. getEffectName(): string;
  51361. /**
  51362. * Create the merge effect. This is the shader use to blit the information back
  51363. * to the main canvas at the end of the scene rendering.
  51364. */
  51365. protected _createMergeEffect(): Effect;
  51366. /**
  51367. * Creates the render target textures and post processes used in the glow layer.
  51368. */
  51369. protected _createTextureAndPostProcesses(): void;
  51370. /**
  51371. * Checks for the readiness of the element composing the layer.
  51372. * @param subMesh the mesh to check for
  51373. * @param useInstances specify wether or not to use instances to render the mesh
  51374. * @param emissiveTexture the associated emissive texture used to generate the glow
  51375. * @return true if ready otherwise, false
  51376. */
  51377. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51378. /**
  51379. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51380. */
  51381. needStencil(): boolean;
  51382. /**
  51383. * Returns true if the mesh can be rendered, otherwise false.
  51384. * @param mesh The mesh to render
  51385. * @param material The material used on the mesh
  51386. * @returns true if it can be rendered otherwise false
  51387. */
  51388. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51389. /**
  51390. * Implementation specific of rendering the generating effect on the main canvas.
  51391. * @param effect The effect used to render through
  51392. */
  51393. protected _internalRender(effect: Effect): void;
  51394. /**
  51395. * Sets the required values for both the emissive texture and and the main color.
  51396. */
  51397. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51398. /**
  51399. * Returns true if the mesh should render, otherwise false.
  51400. * @param mesh The mesh to render
  51401. * @returns true if it should render otherwise false
  51402. */
  51403. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51404. /**
  51405. * Adds specific effects defines.
  51406. * @param defines The defines to add specifics to.
  51407. */
  51408. protected _addCustomEffectDefines(defines: string[]): void;
  51409. /**
  51410. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51411. * @param mesh The mesh to exclude from the glow layer
  51412. */
  51413. addExcludedMesh(mesh: Mesh): void;
  51414. /**
  51415. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51416. * @param mesh The mesh to remove
  51417. */
  51418. removeExcludedMesh(mesh: Mesh): void;
  51419. /**
  51420. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51421. * @param mesh The mesh to include in the glow layer
  51422. */
  51423. addIncludedOnlyMesh(mesh: Mesh): void;
  51424. /**
  51425. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51426. * @param mesh The mesh to remove
  51427. */
  51428. removeIncludedOnlyMesh(mesh: Mesh): void;
  51429. /**
  51430. * Determine if a given mesh will be used in the glow layer
  51431. * @param mesh The mesh to test
  51432. * @returns true if the mesh will be highlighted by the current glow layer
  51433. */
  51434. hasMesh(mesh: AbstractMesh): boolean;
  51435. /**
  51436. * Free any resources and references associated to a mesh.
  51437. * Internal use
  51438. * @param mesh The mesh to free.
  51439. * @hidden
  51440. */
  51441. _disposeMesh(mesh: Mesh): void;
  51442. /**
  51443. * Gets the class name of the effect layer
  51444. * @returns the string with the class name of the effect layer
  51445. */
  51446. getClassName(): string;
  51447. /**
  51448. * Serializes this glow layer
  51449. * @returns a serialized glow layer object
  51450. */
  51451. serialize(): any;
  51452. /**
  51453. * Creates a Glow Layer from parsed glow layer data
  51454. * @param parsedGlowLayer defines glow layer data
  51455. * @param scene defines the current scene
  51456. * @param rootUrl defines the root URL containing the glow layer information
  51457. * @returns a parsed Glow Layer
  51458. */
  51459. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51460. }
  51461. }
  51462. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51463. /** @hidden */
  51464. export var glowBlurPostProcessPixelShader: {
  51465. name: string;
  51466. shader: string;
  51467. };
  51468. }
  51469. declare module "babylonjs/Layers/highlightLayer" {
  51470. import { Observable } from "babylonjs/Misc/observable";
  51471. import { Nullable } from "babylonjs/types";
  51472. import { Camera } from "babylonjs/Cameras/camera";
  51473. import { Scene } from "babylonjs/scene";
  51474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51476. import { Mesh } from "babylonjs/Meshes/mesh";
  51477. import { Effect } from "babylonjs/Materials/effect";
  51478. import { Material } from "babylonjs/Materials/material";
  51479. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51480. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51481. import "babylonjs/Shaders/glowMapMerge.fragment";
  51482. import "babylonjs/Shaders/glowMapMerge.vertex";
  51483. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51484. module "babylonjs/abstractScene" {
  51485. interface AbstractScene {
  51486. /**
  51487. * Return a the first highlight layer of the scene with a given name.
  51488. * @param name The name of the highlight layer to look for.
  51489. * @return The highlight layer if found otherwise null.
  51490. */
  51491. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51492. }
  51493. }
  51494. /**
  51495. * Highlight layer options. This helps customizing the behaviour
  51496. * of the highlight layer.
  51497. */
  51498. export interface IHighlightLayerOptions {
  51499. /**
  51500. * Multiplication factor apply to the canvas size to compute the render target size
  51501. * used to generated the glowing objects (the smaller the faster).
  51502. */
  51503. mainTextureRatio: number;
  51504. /**
  51505. * Enforces a fixed size texture to ensure resize independant blur.
  51506. */
  51507. mainTextureFixedSize?: number;
  51508. /**
  51509. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51510. * of the picture to blur (the smaller the faster).
  51511. */
  51512. blurTextureSizeRatio: number;
  51513. /**
  51514. * How big in texel of the blur texture is the vertical blur.
  51515. */
  51516. blurVerticalSize: number;
  51517. /**
  51518. * How big in texel of the blur texture is the horizontal blur.
  51519. */
  51520. blurHorizontalSize: number;
  51521. /**
  51522. * Alpha blending mode used to apply the blur. Default is combine.
  51523. */
  51524. alphaBlendingMode: number;
  51525. /**
  51526. * The camera attached to the layer.
  51527. */
  51528. camera: Nullable<Camera>;
  51529. /**
  51530. * Should we display highlight as a solid stroke?
  51531. */
  51532. isStroke?: boolean;
  51533. /**
  51534. * The rendering group to draw the layer in.
  51535. */
  51536. renderingGroupId: number;
  51537. }
  51538. /**
  51539. * The highlight layer Helps adding a glow effect around a mesh.
  51540. *
  51541. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51542. * glowy meshes to your scene.
  51543. *
  51544. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51545. */
  51546. export class HighlightLayer extends EffectLayer {
  51547. name: string;
  51548. /**
  51549. * Effect Name of the highlight layer.
  51550. */
  51551. static readonly EffectName: string;
  51552. /**
  51553. * The neutral color used during the preparation of the glow effect.
  51554. * This is black by default as the blend operation is a blend operation.
  51555. */
  51556. static NeutralColor: Color4;
  51557. /**
  51558. * Stencil value used for glowing meshes.
  51559. */
  51560. static GlowingMeshStencilReference: number;
  51561. /**
  51562. * Stencil value used for the other meshes in the scene.
  51563. */
  51564. static NormalMeshStencilReference: number;
  51565. /**
  51566. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51567. */
  51568. innerGlow: boolean;
  51569. /**
  51570. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51571. */
  51572. outerGlow: boolean;
  51573. /**
  51574. * Specifies the horizontal size of the blur.
  51575. */
  51576. /**
  51577. * Gets the horizontal size of the blur.
  51578. */
  51579. blurHorizontalSize: number;
  51580. /**
  51581. * Specifies the vertical size of the blur.
  51582. */
  51583. /**
  51584. * Gets the vertical size of the blur.
  51585. */
  51586. blurVerticalSize: number;
  51587. /**
  51588. * An event triggered when the highlight layer is being blurred.
  51589. */
  51590. onBeforeBlurObservable: Observable<HighlightLayer>;
  51591. /**
  51592. * An event triggered when the highlight layer has been blurred.
  51593. */
  51594. onAfterBlurObservable: Observable<HighlightLayer>;
  51595. private _instanceGlowingMeshStencilReference;
  51596. private _options;
  51597. private _downSamplePostprocess;
  51598. private _horizontalBlurPostprocess;
  51599. private _verticalBlurPostprocess;
  51600. private _blurTexture;
  51601. private _meshes;
  51602. private _excludedMeshes;
  51603. /**
  51604. * Instantiates a new highlight Layer and references it to the scene..
  51605. * @param name The name of the layer
  51606. * @param scene The scene to use the layer in
  51607. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51608. */
  51609. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51610. /**
  51611. * Get the effect name of the layer.
  51612. * @return The effect name
  51613. */
  51614. getEffectName(): string;
  51615. /**
  51616. * Create the merge effect. This is the shader use to blit the information back
  51617. * to the main canvas at the end of the scene rendering.
  51618. */
  51619. protected _createMergeEffect(): Effect;
  51620. /**
  51621. * Creates the render target textures and post processes used in the highlight layer.
  51622. */
  51623. protected _createTextureAndPostProcesses(): void;
  51624. /**
  51625. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51626. */
  51627. needStencil(): boolean;
  51628. /**
  51629. * Checks for the readiness of the element composing the layer.
  51630. * @param subMesh the mesh to check for
  51631. * @param useInstances specify wether or not to use instances to render the mesh
  51632. * @param emissiveTexture the associated emissive texture used to generate the glow
  51633. * @return true if ready otherwise, false
  51634. */
  51635. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51636. /**
  51637. * Implementation specific of rendering the generating effect on the main canvas.
  51638. * @param effect The effect used to render through
  51639. */
  51640. protected _internalRender(effect: Effect): void;
  51641. /**
  51642. * Returns true if the layer contains information to display, otherwise false.
  51643. */
  51644. shouldRender(): boolean;
  51645. /**
  51646. * Returns true if the mesh should render, otherwise false.
  51647. * @param mesh The mesh to render
  51648. * @returns true if it should render otherwise false
  51649. */
  51650. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51651. /**
  51652. * Sets the required values for both the emissive texture and and the main color.
  51653. */
  51654. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51655. /**
  51656. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51657. * @param mesh The mesh to exclude from the highlight layer
  51658. */
  51659. addExcludedMesh(mesh: Mesh): void;
  51660. /**
  51661. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51662. * @param mesh The mesh to highlight
  51663. */
  51664. removeExcludedMesh(mesh: Mesh): void;
  51665. /**
  51666. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51667. * @param mesh mesh to test
  51668. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51669. */
  51670. hasMesh(mesh: AbstractMesh): boolean;
  51671. /**
  51672. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51673. * @param mesh The mesh to highlight
  51674. * @param color The color of the highlight
  51675. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51676. */
  51677. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51678. /**
  51679. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51680. * @param mesh The mesh to highlight
  51681. */
  51682. removeMesh(mesh: Mesh): void;
  51683. /**
  51684. * Force the stencil to the normal expected value for none glowing parts
  51685. */
  51686. private _defaultStencilReference;
  51687. /**
  51688. * Free any resources and references associated to a mesh.
  51689. * Internal use
  51690. * @param mesh The mesh to free.
  51691. * @hidden
  51692. */
  51693. _disposeMesh(mesh: Mesh): void;
  51694. /**
  51695. * Dispose the highlight layer and free resources.
  51696. */
  51697. dispose(): void;
  51698. /**
  51699. * Gets the class name of the effect layer
  51700. * @returns the string with the class name of the effect layer
  51701. */
  51702. getClassName(): string;
  51703. /**
  51704. * Serializes this Highlight layer
  51705. * @returns a serialized Highlight layer object
  51706. */
  51707. serialize(): any;
  51708. /**
  51709. * Creates a Highlight layer from parsed Highlight layer data
  51710. * @param parsedHightlightLayer defines the Highlight layer data
  51711. * @param scene defines the current scene
  51712. * @param rootUrl defines the root URL containing the Highlight layer information
  51713. * @returns a parsed Highlight layer
  51714. */
  51715. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51716. }
  51717. }
  51718. declare module "babylonjs/Layers/layerSceneComponent" {
  51719. import { Scene } from "babylonjs/scene";
  51720. import { ISceneComponent } from "babylonjs/sceneComponent";
  51721. import { Layer } from "babylonjs/Layers/layer";
  51722. import { AbstractScene } from "babylonjs/abstractScene";
  51723. module "babylonjs/abstractScene" {
  51724. interface AbstractScene {
  51725. /**
  51726. * The list of layers (background and foreground) of the scene
  51727. */
  51728. layers: Array<Layer>;
  51729. }
  51730. }
  51731. /**
  51732. * Defines the layer scene component responsible to manage any layers
  51733. * in a given scene.
  51734. */
  51735. export class LayerSceneComponent implements ISceneComponent {
  51736. /**
  51737. * The component name helpfull to identify the component in the list of scene components.
  51738. */
  51739. readonly name: string;
  51740. /**
  51741. * The scene the component belongs to.
  51742. */
  51743. scene: Scene;
  51744. private _engine;
  51745. /**
  51746. * Creates a new instance of the component for the given scene
  51747. * @param scene Defines the scene to register the component in
  51748. */
  51749. constructor(scene: Scene);
  51750. /**
  51751. * Registers the component in a given scene
  51752. */
  51753. register(): void;
  51754. /**
  51755. * Rebuilds the elements related to this component in case of
  51756. * context lost for instance.
  51757. */
  51758. rebuild(): void;
  51759. /**
  51760. * Disposes the component and the associated ressources.
  51761. */
  51762. dispose(): void;
  51763. private _draw;
  51764. private _drawCameraPredicate;
  51765. private _drawCameraBackground;
  51766. private _drawCameraForeground;
  51767. private _drawRenderTargetPredicate;
  51768. private _drawRenderTargetBackground;
  51769. private _drawRenderTargetForeground;
  51770. /**
  51771. * Adds all the elements from the container to the scene
  51772. * @param container the container holding the elements
  51773. */
  51774. addFromContainer(container: AbstractScene): void;
  51775. /**
  51776. * Removes all the elements in the container from the scene
  51777. * @param container contains the elements to remove
  51778. * @param dispose if the removed element should be disposed (default: false)
  51779. */
  51780. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51781. }
  51782. }
  51783. declare module "babylonjs/Shaders/layer.fragment" {
  51784. /** @hidden */
  51785. export var layerPixelShader: {
  51786. name: string;
  51787. shader: string;
  51788. };
  51789. }
  51790. declare module "babylonjs/Shaders/layer.vertex" {
  51791. /** @hidden */
  51792. export var layerVertexShader: {
  51793. name: string;
  51794. shader: string;
  51795. };
  51796. }
  51797. declare module "babylonjs/Layers/layer" {
  51798. import { Observable } from "babylonjs/Misc/observable";
  51799. import { Nullable } from "babylonjs/types";
  51800. import { Scene } from "babylonjs/scene";
  51801. import { Vector2 } from "babylonjs/Maths/math.vector";
  51802. import { Color4 } from "babylonjs/Maths/math.color";
  51803. import { Texture } from "babylonjs/Materials/Textures/texture";
  51804. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51805. import "babylonjs/Shaders/layer.fragment";
  51806. import "babylonjs/Shaders/layer.vertex";
  51807. /**
  51808. * This represents a full screen 2d layer.
  51809. * This can be useful to display a picture in the background of your scene for instance.
  51810. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51811. */
  51812. export class Layer {
  51813. /**
  51814. * Define the name of the layer.
  51815. */
  51816. name: string;
  51817. /**
  51818. * Define the texture the layer should display.
  51819. */
  51820. texture: Nullable<Texture>;
  51821. /**
  51822. * Is the layer in background or foreground.
  51823. */
  51824. isBackground: boolean;
  51825. /**
  51826. * Define the color of the layer (instead of texture).
  51827. */
  51828. color: Color4;
  51829. /**
  51830. * Define the scale of the layer in order to zoom in out of the texture.
  51831. */
  51832. scale: Vector2;
  51833. /**
  51834. * Define an offset for the layer in order to shift the texture.
  51835. */
  51836. offset: Vector2;
  51837. /**
  51838. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51839. */
  51840. alphaBlendingMode: number;
  51841. /**
  51842. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51843. * Alpha test will not mix with the background color in case of transparency.
  51844. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51845. */
  51846. alphaTest: boolean;
  51847. /**
  51848. * Define a mask to restrict the layer to only some of the scene cameras.
  51849. */
  51850. layerMask: number;
  51851. /**
  51852. * Define the list of render target the layer is visible into.
  51853. */
  51854. renderTargetTextures: RenderTargetTexture[];
  51855. /**
  51856. * Define if the layer is only used in renderTarget or if it also
  51857. * renders in the main frame buffer of the canvas.
  51858. */
  51859. renderOnlyInRenderTargetTextures: boolean;
  51860. private _scene;
  51861. private _vertexBuffers;
  51862. private _indexBuffer;
  51863. private _effect;
  51864. private _alphaTestEffect;
  51865. /**
  51866. * An event triggered when the layer is disposed.
  51867. */
  51868. onDisposeObservable: Observable<Layer>;
  51869. private _onDisposeObserver;
  51870. /**
  51871. * Back compatibility with callback before the onDisposeObservable existed.
  51872. * The set callback will be triggered when the layer has been disposed.
  51873. */
  51874. onDispose: () => void;
  51875. /**
  51876. * An event triggered before rendering the scene
  51877. */
  51878. onBeforeRenderObservable: Observable<Layer>;
  51879. private _onBeforeRenderObserver;
  51880. /**
  51881. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51882. * The set callback will be triggered just before rendering the layer.
  51883. */
  51884. onBeforeRender: () => void;
  51885. /**
  51886. * An event triggered after rendering the scene
  51887. */
  51888. onAfterRenderObservable: Observable<Layer>;
  51889. private _onAfterRenderObserver;
  51890. /**
  51891. * Back compatibility with callback before the onAfterRenderObservable existed.
  51892. * The set callback will be triggered just after rendering the layer.
  51893. */
  51894. onAfterRender: () => void;
  51895. /**
  51896. * Instantiates a new layer.
  51897. * This represents a full screen 2d layer.
  51898. * This can be useful to display a picture in the background of your scene for instance.
  51899. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51900. * @param name Define the name of the layer in the scene
  51901. * @param imgUrl Define the url of the texture to display in the layer
  51902. * @param scene Define the scene the layer belongs to
  51903. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51904. * @param color Defines a color for the layer
  51905. */
  51906. constructor(
  51907. /**
  51908. * Define the name of the layer.
  51909. */
  51910. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51911. private _createIndexBuffer;
  51912. /** @hidden */
  51913. _rebuild(): void;
  51914. /**
  51915. * Renders the layer in the scene.
  51916. */
  51917. render(): void;
  51918. /**
  51919. * Disposes and releases the associated ressources.
  51920. */
  51921. dispose(): void;
  51922. }
  51923. }
  51924. declare module "babylonjs/Layers/index" {
  51925. export * from "babylonjs/Layers/effectLayer";
  51926. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51927. export * from "babylonjs/Layers/glowLayer";
  51928. export * from "babylonjs/Layers/highlightLayer";
  51929. export * from "babylonjs/Layers/layer";
  51930. export * from "babylonjs/Layers/layerSceneComponent";
  51931. }
  51932. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51933. /** @hidden */
  51934. export var lensFlarePixelShader: {
  51935. name: string;
  51936. shader: string;
  51937. };
  51938. }
  51939. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51940. /** @hidden */
  51941. export var lensFlareVertexShader: {
  51942. name: string;
  51943. shader: string;
  51944. };
  51945. }
  51946. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51947. import { Scene } from "babylonjs/scene";
  51948. import { Vector3 } from "babylonjs/Maths/math.vector";
  51949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51950. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51951. import "babylonjs/Shaders/lensFlare.fragment";
  51952. import "babylonjs/Shaders/lensFlare.vertex";
  51953. import { Viewport } from "babylonjs/Maths/math.viewport";
  51954. /**
  51955. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51956. * It is usually composed of several `lensFlare`.
  51957. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51958. */
  51959. export class LensFlareSystem {
  51960. /**
  51961. * Define the name of the lens flare system
  51962. */
  51963. name: string;
  51964. /**
  51965. * List of lens flares used in this system.
  51966. */
  51967. lensFlares: LensFlare[];
  51968. /**
  51969. * Define a limit from the border the lens flare can be visible.
  51970. */
  51971. borderLimit: number;
  51972. /**
  51973. * Define a viewport border we do not want to see the lens flare in.
  51974. */
  51975. viewportBorder: number;
  51976. /**
  51977. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51978. */
  51979. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51980. /**
  51981. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51982. */
  51983. layerMask: number;
  51984. /**
  51985. * Define the id of the lens flare system in the scene.
  51986. * (equal to name by default)
  51987. */
  51988. id: string;
  51989. private _scene;
  51990. private _emitter;
  51991. private _vertexBuffers;
  51992. private _indexBuffer;
  51993. private _effect;
  51994. private _positionX;
  51995. private _positionY;
  51996. private _isEnabled;
  51997. /** @hidden */
  51998. static _SceneComponentInitialization: (scene: Scene) => void;
  51999. /**
  52000. * Instantiates a lens flare system.
  52001. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52002. * It is usually composed of several `lensFlare`.
  52003. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52004. * @param name Define the name of the lens flare system in the scene
  52005. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52006. * @param scene Define the scene the lens flare system belongs to
  52007. */
  52008. constructor(
  52009. /**
  52010. * Define the name of the lens flare system
  52011. */
  52012. name: string, emitter: any, scene: Scene);
  52013. /**
  52014. * Define if the lens flare system is enabled.
  52015. */
  52016. isEnabled: boolean;
  52017. /**
  52018. * Get the scene the effects belongs to.
  52019. * @returns the scene holding the lens flare system
  52020. */
  52021. getScene(): Scene;
  52022. /**
  52023. * Get the emitter of the lens flare system.
  52024. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52025. * @returns the emitter of the lens flare system
  52026. */
  52027. getEmitter(): any;
  52028. /**
  52029. * Set the emitter of the lens flare system.
  52030. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52031. * @param newEmitter Define the new emitter of the system
  52032. */
  52033. setEmitter(newEmitter: any): void;
  52034. /**
  52035. * Get the lens flare system emitter position.
  52036. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52037. * @returns the position
  52038. */
  52039. getEmitterPosition(): Vector3;
  52040. /**
  52041. * @hidden
  52042. */
  52043. computeEffectivePosition(globalViewport: Viewport): boolean;
  52044. /** @hidden */
  52045. _isVisible(): boolean;
  52046. /**
  52047. * @hidden
  52048. */
  52049. render(): boolean;
  52050. /**
  52051. * Dispose and release the lens flare with its associated resources.
  52052. */
  52053. dispose(): void;
  52054. /**
  52055. * Parse a lens flare system from a JSON repressentation
  52056. * @param parsedLensFlareSystem Define the JSON to parse
  52057. * @param scene Define the scene the parsed system should be instantiated in
  52058. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52059. * @returns the parsed system
  52060. */
  52061. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52062. /**
  52063. * Serialize the current Lens Flare System into a JSON representation.
  52064. * @returns the serialized JSON
  52065. */
  52066. serialize(): any;
  52067. }
  52068. }
  52069. declare module "babylonjs/LensFlares/lensFlare" {
  52070. import { Nullable } from "babylonjs/types";
  52071. import { Color3 } from "babylonjs/Maths/math.color";
  52072. import { Texture } from "babylonjs/Materials/Textures/texture";
  52073. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52074. /**
  52075. * This represents one of the lens effect in a `lensFlareSystem`.
  52076. * It controls one of the indiviual texture used in the effect.
  52077. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52078. */
  52079. export class LensFlare {
  52080. /**
  52081. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52082. */
  52083. size: number;
  52084. /**
  52085. * 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.
  52086. */
  52087. position: number;
  52088. /**
  52089. * Define the lens color.
  52090. */
  52091. color: Color3;
  52092. /**
  52093. * Define the lens texture.
  52094. */
  52095. texture: Nullable<Texture>;
  52096. /**
  52097. * Define the alpha mode to render this particular lens.
  52098. */
  52099. alphaMode: number;
  52100. private _system;
  52101. /**
  52102. * Creates a new Lens Flare.
  52103. * This represents one of the lens effect in a `lensFlareSystem`.
  52104. * It controls one of the indiviual texture used in the effect.
  52105. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52106. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52107. * @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.
  52108. * @param color Define the lens color
  52109. * @param imgUrl Define the lens texture url
  52110. * @param system Define the `lensFlareSystem` this flare is part of
  52111. * @returns The newly created Lens Flare
  52112. */
  52113. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52114. /**
  52115. * Instantiates a new Lens Flare.
  52116. * This represents one of the lens effect in a `lensFlareSystem`.
  52117. * It controls one of the indiviual texture used in the effect.
  52118. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52119. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52120. * @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.
  52121. * @param color Define the lens color
  52122. * @param imgUrl Define the lens texture url
  52123. * @param system Define the `lensFlareSystem` this flare is part of
  52124. */
  52125. constructor(
  52126. /**
  52127. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52128. */
  52129. size: number,
  52130. /**
  52131. * 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.
  52132. */
  52133. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52134. /**
  52135. * Dispose and release the lens flare with its associated resources.
  52136. */
  52137. dispose(): void;
  52138. }
  52139. }
  52140. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52141. import { Nullable } from "babylonjs/types";
  52142. import { Scene } from "babylonjs/scene";
  52143. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52144. import { AbstractScene } from "babylonjs/abstractScene";
  52145. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52146. module "babylonjs/abstractScene" {
  52147. interface AbstractScene {
  52148. /**
  52149. * The list of lens flare system added to the scene
  52150. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52151. */
  52152. lensFlareSystems: Array<LensFlareSystem>;
  52153. /**
  52154. * Removes the given lens flare system from this scene.
  52155. * @param toRemove The lens flare system to remove
  52156. * @returns The index of the removed lens flare system
  52157. */
  52158. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52159. /**
  52160. * Adds the given lens flare system to this scene
  52161. * @param newLensFlareSystem The lens flare system to add
  52162. */
  52163. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52164. /**
  52165. * Gets a lens flare system using its name
  52166. * @param name defines the name to look for
  52167. * @returns the lens flare system or null if not found
  52168. */
  52169. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52170. /**
  52171. * Gets a lens flare system using its id
  52172. * @param id defines the id to look for
  52173. * @returns the lens flare system or null if not found
  52174. */
  52175. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52176. }
  52177. }
  52178. /**
  52179. * Defines the lens flare scene component responsible to manage any lens flares
  52180. * in a given scene.
  52181. */
  52182. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52183. /**
  52184. * The component name helpfull to identify the component in the list of scene components.
  52185. */
  52186. readonly name: string;
  52187. /**
  52188. * The scene the component belongs to.
  52189. */
  52190. scene: Scene;
  52191. /**
  52192. * Creates a new instance of the component for the given scene
  52193. * @param scene Defines the scene to register the component in
  52194. */
  52195. constructor(scene: Scene);
  52196. /**
  52197. * Registers the component in a given scene
  52198. */
  52199. register(): void;
  52200. /**
  52201. * Rebuilds the elements related to this component in case of
  52202. * context lost for instance.
  52203. */
  52204. rebuild(): void;
  52205. /**
  52206. * Adds all the elements from the container to the scene
  52207. * @param container the container holding the elements
  52208. */
  52209. addFromContainer(container: AbstractScene): void;
  52210. /**
  52211. * Removes all the elements in the container from the scene
  52212. * @param container contains the elements to remove
  52213. * @param dispose if the removed element should be disposed (default: false)
  52214. */
  52215. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52216. /**
  52217. * Serializes the component data to the specified json object
  52218. * @param serializationObject The object to serialize to
  52219. */
  52220. serialize(serializationObject: any): void;
  52221. /**
  52222. * Disposes the component and the associated ressources.
  52223. */
  52224. dispose(): void;
  52225. private _draw;
  52226. }
  52227. }
  52228. declare module "babylonjs/LensFlares/index" {
  52229. export * from "babylonjs/LensFlares/lensFlare";
  52230. export * from "babylonjs/LensFlares/lensFlareSystem";
  52231. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52232. }
  52233. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52234. import { Scene } from "babylonjs/scene";
  52235. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52236. import { AbstractScene } from "babylonjs/abstractScene";
  52237. /**
  52238. * Defines the shadow generator component responsible to manage any shadow generators
  52239. * in a given scene.
  52240. */
  52241. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52242. /**
  52243. * The component name helpfull to identify the component in the list of scene components.
  52244. */
  52245. readonly name: string;
  52246. /**
  52247. * The scene the component belongs to.
  52248. */
  52249. scene: Scene;
  52250. /**
  52251. * Creates a new instance of the component for the given scene
  52252. * @param scene Defines the scene to register the component in
  52253. */
  52254. constructor(scene: Scene);
  52255. /**
  52256. * Registers the component in a given scene
  52257. */
  52258. register(): void;
  52259. /**
  52260. * Rebuilds the elements related to this component in case of
  52261. * context lost for instance.
  52262. */
  52263. rebuild(): void;
  52264. /**
  52265. * Serializes the component data to the specified json object
  52266. * @param serializationObject The object to serialize to
  52267. */
  52268. serialize(serializationObject: any): void;
  52269. /**
  52270. * Adds all the elements from the container to the scene
  52271. * @param container the container holding the elements
  52272. */
  52273. addFromContainer(container: AbstractScene): void;
  52274. /**
  52275. * Removes all the elements in the container from the scene
  52276. * @param container contains the elements to remove
  52277. * @param dispose if the removed element should be disposed (default: false)
  52278. */
  52279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52280. /**
  52281. * Rebuilds the elements related to this component in case of
  52282. * context lost for instance.
  52283. */
  52284. dispose(): void;
  52285. private _gatherRenderTargets;
  52286. }
  52287. }
  52288. declare module "babylonjs/Lights/Shadows/index" {
  52289. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52290. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52291. }
  52292. declare module "babylonjs/Lights/pointLight" {
  52293. import { Scene } from "babylonjs/scene";
  52294. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52296. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52297. import { Effect } from "babylonjs/Materials/effect";
  52298. /**
  52299. * A point light is a light defined by an unique point in world space.
  52300. * The light is emitted in every direction from this point.
  52301. * A good example of a point light is a standard light bulb.
  52302. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52303. */
  52304. export class PointLight extends ShadowLight {
  52305. private _shadowAngle;
  52306. /**
  52307. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52308. * This specifies what angle the shadow will use to be created.
  52309. *
  52310. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52311. */
  52312. /**
  52313. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52314. * This specifies what angle the shadow will use to be created.
  52315. *
  52316. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52317. */
  52318. shadowAngle: number;
  52319. /**
  52320. * Gets the direction if it has been set.
  52321. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52322. */
  52323. /**
  52324. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52325. */
  52326. direction: Vector3;
  52327. /**
  52328. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52329. * A PointLight emits the light in every direction.
  52330. * It can cast shadows.
  52331. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52332. * ```javascript
  52333. * var pointLight = new PointLight("pl", camera.position, scene);
  52334. * ```
  52335. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52336. * @param name The light friendly name
  52337. * @param position The position of the point light in the scene
  52338. * @param scene The scene the lights belongs to
  52339. */
  52340. constructor(name: string, position: Vector3, scene: Scene);
  52341. /**
  52342. * Returns the string "PointLight"
  52343. * @returns the class name
  52344. */
  52345. getClassName(): string;
  52346. /**
  52347. * Returns the integer 0.
  52348. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52349. */
  52350. getTypeID(): number;
  52351. /**
  52352. * Specifies wether or not the shadowmap should be a cube texture.
  52353. * @returns true if the shadowmap needs to be a cube texture.
  52354. */
  52355. needCube(): boolean;
  52356. /**
  52357. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52358. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52359. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52360. */
  52361. getShadowDirection(faceIndex?: number): Vector3;
  52362. /**
  52363. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52364. * - fov = PI / 2
  52365. * - aspect ratio : 1.0
  52366. * - z-near and far equal to the active camera minZ and maxZ.
  52367. * Returns the PointLight.
  52368. */
  52369. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52370. protected _buildUniformLayout(): void;
  52371. /**
  52372. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52373. * @param effect The effect to update
  52374. * @param lightIndex The index of the light in the effect to update
  52375. * @returns The point light
  52376. */
  52377. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52378. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52379. /**
  52380. * Prepares the list of defines specific to the light type.
  52381. * @param defines the list of defines
  52382. * @param lightIndex defines the index of the light for the effect
  52383. */
  52384. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52385. }
  52386. }
  52387. declare module "babylonjs/Lights/index" {
  52388. export * from "babylonjs/Lights/light";
  52389. export * from "babylonjs/Lights/shadowLight";
  52390. export * from "babylonjs/Lights/Shadows/index";
  52391. export * from "babylonjs/Lights/directionalLight";
  52392. export * from "babylonjs/Lights/hemisphericLight";
  52393. export * from "babylonjs/Lights/pointLight";
  52394. export * from "babylonjs/Lights/spotLight";
  52395. }
  52396. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52397. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52398. /**
  52399. * Header information of HDR texture files.
  52400. */
  52401. export interface HDRInfo {
  52402. /**
  52403. * The height of the texture in pixels.
  52404. */
  52405. height: number;
  52406. /**
  52407. * The width of the texture in pixels.
  52408. */
  52409. width: number;
  52410. /**
  52411. * The index of the beginning of the data in the binary file.
  52412. */
  52413. dataPosition: number;
  52414. }
  52415. /**
  52416. * This groups tools to convert HDR texture to native colors array.
  52417. */
  52418. export class HDRTools {
  52419. private static Ldexp;
  52420. private static Rgbe2float;
  52421. private static readStringLine;
  52422. /**
  52423. * Reads header information from an RGBE texture stored in a native array.
  52424. * More information on this format are available here:
  52425. * https://en.wikipedia.org/wiki/RGBE_image_format
  52426. *
  52427. * @param uint8array The binary file stored in native array.
  52428. * @return The header information.
  52429. */
  52430. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52431. /**
  52432. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52433. * This RGBE texture needs to store the information as a panorama.
  52434. *
  52435. * More information on this format are available here:
  52436. * https://en.wikipedia.org/wiki/RGBE_image_format
  52437. *
  52438. * @param buffer The binary file stored in an array buffer.
  52439. * @param size The expected size of the extracted cubemap.
  52440. * @return The Cube Map information.
  52441. */
  52442. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52443. /**
  52444. * Returns the pixels data extracted from an RGBE texture.
  52445. * This pixels will be stored left to right up to down in the R G B order in one array.
  52446. *
  52447. * More information on this format are available here:
  52448. * https://en.wikipedia.org/wiki/RGBE_image_format
  52449. *
  52450. * @param uint8array The binary file stored in an array buffer.
  52451. * @param hdrInfo The header information of the file.
  52452. * @return The pixels data in RGB right to left up to down order.
  52453. */
  52454. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52455. private static RGBE_ReadPixels_RLE;
  52456. }
  52457. }
  52458. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52459. import { Nullable } from "babylonjs/types";
  52460. import { Scene } from "babylonjs/scene";
  52461. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52462. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52463. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52464. /**
  52465. * This represents a texture coming from an HDR input.
  52466. *
  52467. * The only supported format is currently panorama picture stored in RGBE format.
  52468. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52469. */
  52470. export class HDRCubeTexture extends BaseTexture {
  52471. private static _facesMapping;
  52472. private _generateHarmonics;
  52473. private _noMipmap;
  52474. private _textureMatrix;
  52475. private _size;
  52476. private _onLoad;
  52477. private _onError;
  52478. /**
  52479. * The texture URL.
  52480. */
  52481. url: string;
  52482. /**
  52483. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52484. */
  52485. coordinatesMode: number;
  52486. protected _isBlocking: boolean;
  52487. /**
  52488. * Sets wether or not the texture is blocking during loading.
  52489. */
  52490. /**
  52491. * Gets wether or not the texture is blocking during loading.
  52492. */
  52493. isBlocking: boolean;
  52494. protected _rotationY: number;
  52495. /**
  52496. * Sets texture matrix rotation angle around Y axis in radians.
  52497. */
  52498. /**
  52499. * Gets texture matrix rotation angle around Y axis radians.
  52500. */
  52501. rotationY: number;
  52502. /**
  52503. * Gets or sets the center of the bounding box associated with the cube texture
  52504. * It must define where the camera used to render the texture was set
  52505. */
  52506. boundingBoxPosition: Vector3;
  52507. private _boundingBoxSize;
  52508. /**
  52509. * Gets or sets the size of the bounding box associated with the cube texture
  52510. * When defined, the cubemap will switch to local mode
  52511. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52512. * @example https://www.babylonjs-playground.com/#RNASML
  52513. */
  52514. boundingBoxSize: Vector3;
  52515. /**
  52516. * Instantiates an HDRTexture from the following parameters.
  52517. *
  52518. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52519. * @param scene The scene the texture will be used in
  52520. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52521. * @param noMipmap Forces to not generate the mipmap if true
  52522. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52523. * @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)
  52524. * @param reserved Reserved flag for internal use.
  52525. */
  52526. 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>);
  52527. /**
  52528. * Get the current class name of the texture useful for serialization or dynamic coding.
  52529. * @returns "HDRCubeTexture"
  52530. */
  52531. getClassName(): string;
  52532. /**
  52533. * Occurs when the file is raw .hdr file.
  52534. */
  52535. private loadTexture;
  52536. clone(): HDRCubeTexture;
  52537. delayLoad(): void;
  52538. /**
  52539. * Get the texture reflection matrix used to rotate/transform the reflection.
  52540. * @returns the reflection matrix
  52541. */
  52542. getReflectionTextureMatrix(): Matrix;
  52543. /**
  52544. * Set the texture reflection matrix used to rotate/transform the reflection.
  52545. * @param value Define the reflection matrix to set
  52546. */
  52547. setReflectionTextureMatrix(value: Matrix): void;
  52548. /**
  52549. * Parses a JSON representation of an HDR Texture in order to create the texture
  52550. * @param parsedTexture Define the JSON representation
  52551. * @param scene Define the scene the texture should be created in
  52552. * @param rootUrl Define the root url in case we need to load relative dependencies
  52553. * @returns the newly created texture after parsing
  52554. */
  52555. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52556. serialize(): any;
  52557. }
  52558. }
  52559. declare module "babylonjs/Physics/physicsEngine" {
  52560. import { Nullable } from "babylonjs/types";
  52561. import { Vector3 } from "babylonjs/Maths/math.vector";
  52562. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52563. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52564. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52565. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52566. /**
  52567. * Class used to control physics engine
  52568. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52569. */
  52570. export class PhysicsEngine implements IPhysicsEngine {
  52571. private _physicsPlugin;
  52572. /**
  52573. * Global value used to control the smallest number supported by the simulation
  52574. */
  52575. static Epsilon: number;
  52576. private _impostors;
  52577. private _joints;
  52578. /**
  52579. * Gets the gravity vector used by the simulation
  52580. */
  52581. gravity: Vector3;
  52582. /**
  52583. * Factory used to create the default physics plugin.
  52584. * @returns The default physics plugin
  52585. */
  52586. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52587. /**
  52588. * Creates a new Physics Engine
  52589. * @param gravity defines the gravity vector used by the simulation
  52590. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52591. */
  52592. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52593. /**
  52594. * Sets the gravity vector used by the simulation
  52595. * @param gravity defines the gravity vector to use
  52596. */
  52597. setGravity(gravity: Vector3): void;
  52598. /**
  52599. * Set the time step of the physics engine.
  52600. * Default is 1/60.
  52601. * To slow it down, enter 1/600 for example.
  52602. * To speed it up, 1/30
  52603. * @param newTimeStep defines the new timestep to apply to this world.
  52604. */
  52605. setTimeStep(newTimeStep?: number): void;
  52606. /**
  52607. * Get the time step of the physics engine.
  52608. * @returns the current time step
  52609. */
  52610. getTimeStep(): number;
  52611. /**
  52612. * Release all resources
  52613. */
  52614. dispose(): void;
  52615. /**
  52616. * Gets the name of the current physics plugin
  52617. * @returns the name of the plugin
  52618. */
  52619. getPhysicsPluginName(): string;
  52620. /**
  52621. * Adding a new impostor for the impostor tracking.
  52622. * This will be done by the impostor itself.
  52623. * @param impostor the impostor to add
  52624. */
  52625. addImpostor(impostor: PhysicsImpostor): void;
  52626. /**
  52627. * Remove an impostor from the engine.
  52628. * This impostor and its mesh will not longer be updated by the physics engine.
  52629. * @param impostor the impostor to remove
  52630. */
  52631. removeImpostor(impostor: PhysicsImpostor): void;
  52632. /**
  52633. * Add a joint to the physics engine
  52634. * @param mainImpostor defines the main impostor to which the joint is added.
  52635. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52636. * @param joint defines the joint that will connect both impostors.
  52637. */
  52638. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52639. /**
  52640. * Removes a joint from the simulation
  52641. * @param mainImpostor defines the impostor used with the joint
  52642. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52643. * @param joint defines the joint to remove
  52644. */
  52645. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52646. /**
  52647. * Called by the scene. No need to call it.
  52648. * @param delta defines the timespam between frames
  52649. */
  52650. _step(delta: number): void;
  52651. /**
  52652. * Gets the current plugin used to run the simulation
  52653. * @returns current plugin
  52654. */
  52655. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52656. /**
  52657. * Gets the list of physic impostors
  52658. * @returns an array of PhysicsImpostor
  52659. */
  52660. getImpostors(): Array<PhysicsImpostor>;
  52661. /**
  52662. * Gets the impostor for a physics enabled object
  52663. * @param object defines the object impersonated by the impostor
  52664. * @returns the PhysicsImpostor or null if not found
  52665. */
  52666. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52667. /**
  52668. * Gets the impostor for a physics body object
  52669. * @param body defines physics body used by the impostor
  52670. * @returns the PhysicsImpostor or null if not found
  52671. */
  52672. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52673. /**
  52674. * Does a raycast in the physics world
  52675. * @param from when should the ray start?
  52676. * @param to when should the ray end?
  52677. * @returns PhysicsRaycastResult
  52678. */
  52679. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52680. }
  52681. }
  52682. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52683. import { Nullable } from "babylonjs/types";
  52684. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52686. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52687. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52688. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52689. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52690. /** @hidden */
  52691. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52692. private _useDeltaForWorldStep;
  52693. world: any;
  52694. name: string;
  52695. private _physicsMaterials;
  52696. private _fixedTimeStep;
  52697. private _cannonRaycastResult;
  52698. private _raycastResult;
  52699. private _physicsBodysToRemoveAfterStep;
  52700. BJSCANNON: any;
  52701. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52702. setGravity(gravity: Vector3): void;
  52703. setTimeStep(timeStep: number): void;
  52704. getTimeStep(): number;
  52705. executeStep(delta: number): void;
  52706. private _removeMarkedPhysicsBodiesFromWorld;
  52707. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52708. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52709. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52710. private _processChildMeshes;
  52711. removePhysicsBody(impostor: PhysicsImpostor): void;
  52712. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52713. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52714. private _addMaterial;
  52715. private _checkWithEpsilon;
  52716. private _createShape;
  52717. private _createHeightmap;
  52718. private _minus90X;
  52719. private _plus90X;
  52720. private _tmpPosition;
  52721. private _tmpDeltaPosition;
  52722. private _tmpUnityRotation;
  52723. private _updatePhysicsBodyTransformation;
  52724. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52725. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52726. isSupported(): boolean;
  52727. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52728. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52729. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52730. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52731. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52732. getBodyMass(impostor: PhysicsImpostor): number;
  52733. getBodyFriction(impostor: PhysicsImpostor): number;
  52734. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52735. getBodyRestitution(impostor: PhysicsImpostor): number;
  52736. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52737. sleepBody(impostor: PhysicsImpostor): void;
  52738. wakeUpBody(impostor: PhysicsImpostor): void;
  52739. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52740. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52741. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52742. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52743. getRadius(impostor: PhysicsImpostor): number;
  52744. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52745. dispose(): void;
  52746. private _extendNamespace;
  52747. /**
  52748. * Does a raycast in the physics world
  52749. * @param from when should the ray start?
  52750. * @param to when should the ray end?
  52751. * @returns PhysicsRaycastResult
  52752. */
  52753. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52754. }
  52755. }
  52756. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52757. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52758. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52759. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52761. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52762. import { Nullable } from "babylonjs/types";
  52763. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52764. /** @hidden */
  52765. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52766. world: any;
  52767. name: string;
  52768. BJSOIMO: any;
  52769. private _raycastResult;
  52770. constructor(iterations?: number, oimoInjection?: any);
  52771. setGravity(gravity: Vector3): void;
  52772. setTimeStep(timeStep: number): void;
  52773. getTimeStep(): number;
  52774. private _tmpImpostorsArray;
  52775. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52776. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52777. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52778. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52779. private _tmpPositionVector;
  52780. removePhysicsBody(impostor: PhysicsImpostor): void;
  52781. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52782. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52783. isSupported(): boolean;
  52784. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52785. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52786. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52787. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52788. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52789. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52790. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52791. getBodyMass(impostor: PhysicsImpostor): number;
  52792. getBodyFriction(impostor: PhysicsImpostor): number;
  52793. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52794. getBodyRestitution(impostor: PhysicsImpostor): number;
  52795. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52796. sleepBody(impostor: PhysicsImpostor): void;
  52797. wakeUpBody(impostor: PhysicsImpostor): void;
  52798. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52799. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52800. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52801. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52802. getRadius(impostor: PhysicsImpostor): number;
  52803. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52804. dispose(): void;
  52805. /**
  52806. * Does a raycast in the physics world
  52807. * @param from when should the ray start?
  52808. * @param to when should the ray end?
  52809. * @returns PhysicsRaycastResult
  52810. */
  52811. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52812. }
  52813. }
  52814. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52815. import { Nullable } from "babylonjs/types";
  52816. import { Scene } from "babylonjs/scene";
  52817. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52818. import { Color4 } from "babylonjs/Maths/math.color";
  52819. import { Mesh } from "babylonjs/Meshes/mesh";
  52820. /**
  52821. * Class containing static functions to help procedurally build meshes
  52822. */
  52823. export class RibbonBuilder {
  52824. /**
  52825. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52826. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52827. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52828. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52829. * * 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
  52830. * * 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
  52831. * * 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
  52832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52834. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52835. * * 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
  52836. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52837. * * 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
  52838. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52840. * @param name defines the name of the mesh
  52841. * @param options defines the options used to create the mesh
  52842. * @param scene defines the hosting scene
  52843. * @returns the ribbon mesh
  52844. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52846. */
  52847. static CreateRibbon(name: string, options: {
  52848. pathArray: Vector3[][];
  52849. closeArray?: boolean;
  52850. closePath?: boolean;
  52851. offset?: number;
  52852. updatable?: boolean;
  52853. sideOrientation?: number;
  52854. frontUVs?: Vector4;
  52855. backUVs?: Vector4;
  52856. instance?: Mesh;
  52857. invertUV?: boolean;
  52858. uvs?: Vector2[];
  52859. colors?: Color4[];
  52860. }, scene?: Nullable<Scene>): Mesh;
  52861. }
  52862. }
  52863. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52864. import { Nullable } from "babylonjs/types";
  52865. import { Scene } from "babylonjs/scene";
  52866. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52867. import { Mesh } from "babylonjs/Meshes/mesh";
  52868. /**
  52869. * Class containing static functions to help procedurally build meshes
  52870. */
  52871. export class ShapeBuilder {
  52872. /**
  52873. * 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.
  52874. * * 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.
  52875. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52876. * * 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.
  52877. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52878. * * 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
  52879. * * 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
  52880. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52885. * @param name defines the name of the mesh
  52886. * @param options defines the options used to create the mesh
  52887. * @param scene defines the hosting scene
  52888. * @returns the extruded shape mesh
  52889. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52891. */
  52892. static ExtrudeShape(name: string, options: {
  52893. shape: Vector3[];
  52894. path: Vector3[];
  52895. scale?: number;
  52896. rotation?: number;
  52897. cap?: number;
  52898. updatable?: boolean;
  52899. sideOrientation?: number;
  52900. frontUVs?: Vector4;
  52901. backUVs?: Vector4;
  52902. instance?: Mesh;
  52903. invertUV?: boolean;
  52904. }, scene?: Nullable<Scene>): Mesh;
  52905. /**
  52906. * Creates an custom extruded shape mesh.
  52907. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52908. * * 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.
  52909. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52910. * * 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
  52911. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52912. * * 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
  52913. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52914. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52915. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52916. * * 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
  52917. * * 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
  52918. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52921. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52923. * @param name defines the name of the mesh
  52924. * @param options defines the options used to create the mesh
  52925. * @param scene defines the hosting scene
  52926. * @returns the custom extruded shape mesh
  52927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52930. */
  52931. static ExtrudeShapeCustom(name: string, options: {
  52932. shape: Vector3[];
  52933. path: Vector3[];
  52934. scaleFunction?: any;
  52935. rotationFunction?: any;
  52936. ribbonCloseArray?: boolean;
  52937. ribbonClosePath?: boolean;
  52938. cap?: number;
  52939. updatable?: boolean;
  52940. sideOrientation?: number;
  52941. frontUVs?: Vector4;
  52942. backUVs?: Vector4;
  52943. instance?: Mesh;
  52944. invertUV?: boolean;
  52945. }, scene?: Nullable<Scene>): Mesh;
  52946. private static _ExtrudeShapeGeneric;
  52947. }
  52948. }
  52949. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52950. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52951. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52952. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52953. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52954. import { Nullable } from "babylonjs/types";
  52955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52956. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52957. /**
  52958. * AmmoJS Physics plugin
  52959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52960. * @see https://github.com/kripken/ammo.js/
  52961. */
  52962. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52963. private _useDeltaForWorldStep;
  52964. /**
  52965. * Reference to the Ammo library
  52966. */
  52967. bjsAMMO: any;
  52968. /**
  52969. * Created ammoJS world which physics bodies are added to
  52970. */
  52971. world: any;
  52972. /**
  52973. * Name of the plugin
  52974. */
  52975. name: string;
  52976. private _timeStep;
  52977. private _fixedTimeStep;
  52978. private _maxSteps;
  52979. private _tmpQuaternion;
  52980. private _tmpAmmoTransform;
  52981. private _tmpAmmoQuaternion;
  52982. private _tmpAmmoConcreteContactResultCallback;
  52983. private _collisionConfiguration;
  52984. private _dispatcher;
  52985. private _overlappingPairCache;
  52986. private _solver;
  52987. private _softBodySolver;
  52988. private _tmpAmmoVectorA;
  52989. private _tmpAmmoVectorB;
  52990. private _tmpAmmoVectorC;
  52991. private _tmpAmmoVectorD;
  52992. private _tmpContactCallbackResult;
  52993. private _tmpAmmoVectorRCA;
  52994. private _tmpAmmoVectorRCB;
  52995. private _raycastResult;
  52996. private static readonly DISABLE_COLLISION_FLAG;
  52997. private static readonly KINEMATIC_FLAG;
  52998. private static readonly DISABLE_DEACTIVATION_FLAG;
  52999. /**
  53000. * Initializes the ammoJS plugin
  53001. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53002. * @param ammoInjection can be used to inject your own ammo reference
  53003. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53004. */
  53005. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53006. /**
  53007. * Sets the gravity of the physics world (m/(s^2))
  53008. * @param gravity Gravity to set
  53009. */
  53010. setGravity(gravity: Vector3): void;
  53011. /**
  53012. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53013. * @param timeStep timestep to use in seconds
  53014. */
  53015. setTimeStep(timeStep: number): void;
  53016. /**
  53017. * 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)
  53018. * @param fixedTimeStep fixedTimeStep to use in seconds
  53019. */
  53020. setFixedTimeStep(fixedTimeStep: number): void;
  53021. /**
  53022. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53023. * @param maxSteps the maximum number of steps by the physics engine per frame
  53024. */
  53025. setMaxSteps(maxSteps: number): void;
  53026. /**
  53027. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53028. * @returns the current timestep in seconds
  53029. */
  53030. getTimeStep(): number;
  53031. private _isImpostorInContact;
  53032. private _isImpostorPairInContact;
  53033. private _stepSimulation;
  53034. /**
  53035. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53036. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53037. * After the step the babylon meshes are set to the position of the physics imposters
  53038. * @param delta amount of time to step forward
  53039. * @param impostors array of imposters to update before/after the step
  53040. */
  53041. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53042. /**
  53043. * Update babylon mesh to match physics world object
  53044. * @param impostor imposter to match
  53045. */
  53046. private _afterSoftStep;
  53047. /**
  53048. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53049. * @param impostor imposter to match
  53050. */
  53051. private _ropeStep;
  53052. /**
  53053. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53054. * @param impostor imposter to match
  53055. */
  53056. private _softbodyOrClothStep;
  53057. private _tmpVector;
  53058. private _tmpMatrix;
  53059. /**
  53060. * Applies an impulse on the imposter
  53061. * @param impostor imposter to apply impulse to
  53062. * @param force amount of force to be applied to the imposter
  53063. * @param contactPoint the location to apply the impulse on the imposter
  53064. */
  53065. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53066. /**
  53067. * Applies a force on the imposter
  53068. * @param impostor imposter to apply force
  53069. * @param force amount of force to be applied to the imposter
  53070. * @param contactPoint the location to apply the force on the imposter
  53071. */
  53072. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53073. /**
  53074. * Creates a physics body using the plugin
  53075. * @param impostor the imposter to create the physics body on
  53076. */
  53077. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53078. /**
  53079. * Removes the physics body from the imposter and disposes of the body's memory
  53080. * @param impostor imposter to remove the physics body from
  53081. */
  53082. removePhysicsBody(impostor: PhysicsImpostor): void;
  53083. /**
  53084. * Generates a joint
  53085. * @param impostorJoint the imposter joint to create the joint with
  53086. */
  53087. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53088. /**
  53089. * Removes a joint
  53090. * @param impostorJoint the imposter joint to remove the joint from
  53091. */
  53092. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53093. private _addMeshVerts;
  53094. /**
  53095. * Initialise the soft body vertices to match its object's (mesh) vertices
  53096. * Softbody vertices (nodes) are in world space and to match this
  53097. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53098. * @param impostor to create the softbody for
  53099. */
  53100. private _softVertexData;
  53101. /**
  53102. * Create an impostor's soft body
  53103. * @param impostor to create the softbody for
  53104. */
  53105. private _createSoftbody;
  53106. /**
  53107. * Create cloth for an impostor
  53108. * @param impostor to create the softbody for
  53109. */
  53110. private _createCloth;
  53111. /**
  53112. * Create rope for an impostor
  53113. * @param impostor to create the softbody for
  53114. */
  53115. private _createRope;
  53116. private _addHullVerts;
  53117. private _createShape;
  53118. /**
  53119. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53120. * @param impostor imposter containing the physics body and babylon object
  53121. */
  53122. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53123. /**
  53124. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53125. * @param impostor imposter containing the physics body and babylon object
  53126. * @param newPosition new position
  53127. * @param newRotation new rotation
  53128. */
  53129. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53130. /**
  53131. * If this plugin is supported
  53132. * @returns true if its supported
  53133. */
  53134. isSupported(): boolean;
  53135. /**
  53136. * Sets the linear velocity of the physics body
  53137. * @param impostor imposter to set the velocity on
  53138. * @param velocity velocity to set
  53139. */
  53140. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53141. /**
  53142. * Sets the angular velocity of the physics body
  53143. * @param impostor imposter to set the velocity on
  53144. * @param velocity velocity to set
  53145. */
  53146. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53147. /**
  53148. * gets the linear velocity
  53149. * @param impostor imposter to get linear velocity from
  53150. * @returns linear velocity
  53151. */
  53152. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53153. /**
  53154. * gets the angular velocity
  53155. * @param impostor imposter to get angular velocity from
  53156. * @returns angular velocity
  53157. */
  53158. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53159. /**
  53160. * Sets the mass of physics body
  53161. * @param impostor imposter to set the mass on
  53162. * @param mass mass to set
  53163. */
  53164. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53165. /**
  53166. * Gets the mass of the physics body
  53167. * @param impostor imposter to get the mass from
  53168. * @returns mass
  53169. */
  53170. getBodyMass(impostor: PhysicsImpostor): number;
  53171. /**
  53172. * Gets friction of the impostor
  53173. * @param impostor impostor to get friction from
  53174. * @returns friction value
  53175. */
  53176. getBodyFriction(impostor: PhysicsImpostor): number;
  53177. /**
  53178. * Sets friction of the impostor
  53179. * @param impostor impostor to set friction on
  53180. * @param friction friction value
  53181. */
  53182. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53183. /**
  53184. * Gets restitution of the impostor
  53185. * @param impostor impostor to get restitution from
  53186. * @returns restitution value
  53187. */
  53188. getBodyRestitution(impostor: PhysicsImpostor): number;
  53189. /**
  53190. * Sets resitution of the impostor
  53191. * @param impostor impostor to set resitution on
  53192. * @param restitution resitution value
  53193. */
  53194. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53195. /**
  53196. * Gets pressure inside the impostor
  53197. * @param impostor impostor to get pressure from
  53198. * @returns pressure value
  53199. */
  53200. getBodyPressure(impostor: PhysicsImpostor): number;
  53201. /**
  53202. * Sets pressure inside a soft body impostor
  53203. * Cloth and rope must remain 0 pressure
  53204. * @param impostor impostor to set pressure on
  53205. * @param pressure pressure value
  53206. */
  53207. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53208. /**
  53209. * Gets stiffness of the impostor
  53210. * @param impostor impostor to get stiffness from
  53211. * @returns pressure value
  53212. */
  53213. getBodyStiffness(impostor: PhysicsImpostor): number;
  53214. /**
  53215. * Sets stiffness of the impostor
  53216. * @param impostor impostor to set stiffness on
  53217. * @param stiffness stiffness value from 0 to 1
  53218. */
  53219. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53220. /**
  53221. * Gets velocityIterations of the impostor
  53222. * @param impostor impostor to get velocity iterations from
  53223. * @returns velocityIterations value
  53224. */
  53225. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53226. /**
  53227. * Sets velocityIterations of the impostor
  53228. * @param impostor impostor to set velocity iterations on
  53229. * @param velocityIterations velocityIterations value
  53230. */
  53231. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53232. /**
  53233. * Gets positionIterations of the impostor
  53234. * @param impostor impostor to get position iterations from
  53235. * @returns positionIterations value
  53236. */
  53237. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53238. /**
  53239. * Sets positionIterations of the impostor
  53240. * @param impostor impostor to set position on
  53241. * @param positionIterations positionIterations value
  53242. */
  53243. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53244. /**
  53245. * Append an anchor to a cloth object
  53246. * @param impostor is the cloth impostor to add anchor to
  53247. * @param otherImpostor is the rigid impostor to anchor to
  53248. * @param width ratio across width from 0 to 1
  53249. * @param height ratio up height from 0 to 1
  53250. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53251. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53252. */
  53253. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53254. /**
  53255. * Append an hook to a rope object
  53256. * @param impostor is the rope impostor to add hook to
  53257. * @param otherImpostor is the rigid impostor to hook to
  53258. * @param length ratio along the rope from 0 to 1
  53259. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53260. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53261. */
  53262. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53263. /**
  53264. * Sleeps the physics body and stops it from being active
  53265. * @param impostor impostor to sleep
  53266. */
  53267. sleepBody(impostor: PhysicsImpostor): void;
  53268. /**
  53269. * Activates the physics body
  53270. * @param impostor impostor to activate
  53271. */
  53272. wakeUpBody(impostor: PhysicsImpostor): void;
  53273. /**
  53274. * Updates the distance parameters of the joint
  53275. * @param joint joint to update
  53276. * @param maxDistance maximum distance of the joint
  53277. * @param minDistance minimum distance of the joint
  53278. */
  53279. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53280. /**
  53281. * Sets a motor on the joint
  53282. * @param joint joint to set motor on
  53283. * @param speed speed of the motor
  53284. * @param maxForce maximum force of the motor
  53285. * @param motorIndex index of the motor
  53286. */
  53287. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53288. /**
  53289. * Sets the motors limit
  53290. * @param joint joint to set limit on
  53291. * @param upperLimit upper limit
  53292. * @param lowerLimit lower limit
  53293. */
  53294. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53295. /**
  53296. * Syncs the position and rotation of a mesh with the impostor
  53297. * @param mesh mesh to sync
  53298. * @param impostor impostor to update the mesh with
  53299. */
  53300. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53301. /**
  53302. * Gets the radius of the impostor
  53303. * @param impostor impostor to get radius from
  53304. * @returns the radius
  53305. */
  53306. getRadius(impostor: PhysicsImpostor): number;
  53307. /**
  53308. * Gets the box size of the impostor
  53309. * @param impostor impostor to get box size from
  53310. * @param result the resulting box size
  53311. */
  53312. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53313. /**
  53314. * Disposes of the impostor
  53315. */
  53316. dispose(): void;
  53317. /**
  53318. * Does a raycast in the physics world
  53319. * @param from when should the ray start?
  53320. * @param to when should the ray end?
  53321. * @returns PhysicsRaycastResult
  53322. */
  53323. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53324. }
  53325. }
  53326. declare module "babylonjs/Probes/reflectionProbe" {
  53327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53328. import { Vector3 } from "babylonjs/Maths/math.vector";
  53329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53330. import { Nullable } from "babylonjs/types";
  53331. import { Scene } from "babylonjs/scene";
  53332. module "babylonjs/abstractScene" {
  53333. interface AbstractScene {
  53334. /**
  53335. * The list of reflection probes added to the scene
  53336. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53337. */
  53338. reflectionProbes: Array<ReflectionProbe>;
  53339. /**
  53340. * Removes the given reflection probe from this scene.
  53341. * @param toRemove The reflection probe to remove
  53342. * @returns The index of the removed reflection probe
  53343. */
  53344. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53345. /**
  53346. * Adds the given reflection probe to this scene.
  53347. * @param newReflectionProbe The reflection probe to add
  53348. */
  53349. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53350. }
  53351. }
  53352. /**
  53353. * Class used to generate realtime reflection / refraction cube textures
  53354. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53355. */
  53356. export class ReflectionProbe {
  53357. /** defines the name of the probe */
  53358. name: string;
  53359. private _scene;
  53360. private _renderTargetTexture;
  53361. private _projectionMatrix;
  53362. private _viewMatrix;
  53363. private _target;
  53364. private _add;
  53365. private _attachedMesh;
  53366. private _invertYAxis;
  53367. /** Gets or sets probe position (center of the cube map) */
  53368. position: Vector3;
  53369. /**
  53370. * Creates a new reflection probe
  53371. * @param name defines the name of the probe
  53372. * @param size defines the texture resolution (for each face)
  53373. * @param scene defines the hosting scene
  53374. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53375. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53376. */
  53377. constructor(
  53378. /** defines the name of the probe */
  53379. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53380. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53381. samples: number;
  53382. /** Gets or sets the refresh rate to use (on every frame by default) */
  53383. refreshRate: number;
  53384. /**
  53385. * Gets the hosting scene
  53386. * @returns a Scene
  53387. */
  53388. getScene(): Scene;
  53389. /** Gets the internal CubeTexture used to render to */
  53390. readonly cubeTexture: RenderTargetTexture;
  53391. /** Gets the list of meshes to render */
  53392. readonly renderList: Nullable<AbstractMesh[]>;
  53393. /**
  53394. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53395. * @param mesh defines the mesh to attach to
  53396. */
  53397. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53398. /**
  53399. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53400. * @param renderingGroupId The rendering group id corresponding to its index
  53401. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53402. */
  53403. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53404. /**
  53405. * Clean all associated resources
  53406. */
  53407. dispose(): void;
  53408. /**
  53409. * Converts the reflection probe information to a readable string for debug purpose.
  53410. * @param fullDetails Supports for multiple levels of logging within scene loading
  53411. * @returns the human readable reflection probe info
  53412. */
  53413. toString(fullDetails?: boolean): string;
  53414. /**
  53415. * Get the class name of the relfection probe.
  53416. * @returns "ReflectionProbe"
  53417. */
  53418. getClassName(): string;
  53419. /**
  53420. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53421. * @returns The JSON representation of the texture
  53422. */
  53423. serialize(): any;
  53424. /**
  53425. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53426. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53427. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53428. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53429. * @returns The parsed reflection probe if successful
  53430. */
  53431. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53432. }
  53433. }
  53434. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53435. /** @hidden */
  53436. export var _BabylonLoaderRegistered: boolean;
  53437. }
  53438. declare module "babylonjs/Loading/Plugins/index" {
  53439. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53440. }
  53441. declare module "babylonjs/Loading/index" {
  53442. export * from "babylonjs/Loading/loadingScreen";
  53443. export * from "babylonjs/Loading/Plugins/index";
  53444. export * from "babylonjs/Loading/sceneLoader";
  53445. export * from "babylonjs/Loading/sceneLoaderFlags";
  53446. }
  53447. declare module "babylonjs/Materials/Background/index" {
  53448. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53449. }
  53450. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53451. import { Scene } from "babylonjs/scene";
  53452. import { Color3 } from "babylonjs/Maths/math.color";
  53453. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53455. /**
  53456. * The Physically based simple base material of BJS.
  53457. *
  53458. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53459. * It is used as the base class for both the specGloss and metalRough conventions.
  53460. */
  53461. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53462. /**
  53463. * Number of Simultaneous lights allowed on the material.
  53464. */
  53465. maxSimultaneousLights: number;
  53466. /**
  53467. * If sets to true, disables all the lights affecting the material.
  53468. */
  53469. disableLighting: boolean;
  53470. /**
  53471. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53472. */
  53473. environmentTexture: BaseTexture;
  53474. /**
  53475. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53476. */
  53477. invertNormalMapX: boolean;
  53478. /**
  53479. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53480. */
  53481. invertNormalMapY: boolean;
  53482. /**
  53483. * Normal map used in the model.
  53484. */
  53485. normalTexture: BaseTexture;
  53486. /**
  53487. * Emissivie color used to self-illuminate the model.
  53488. */
  53489. emissiveColor: Color3;
  53490. /**
  53491. * Emissivie texture used to self-illuminate the model.
  53492. */
  53493. emissiveTexture: BaseTexture;
  53494. /**
  53495. * Occlusion Channel Strenght.
  53496. */
  53497. occlusionStrength: number;
  53498. /**
  53499. * Occlusion Texture of the material (adding extra occlusion effects).
  53500. */
  53501. occlusionTexture: BaseTexture;
  53502. /**
  53503. * Defines the alpha limits in alpha test mode.
  53504. */
  53505. alphaCutOff: number;
  53506. /**
  53507. * Gets the current double sided mode.
  53508. */
  53509. /**
  53510. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53511. */
  53512. doubleSided: boolean;
  53513. /**
  53514. * Stores the pre-calculated light information of a mesh in a texture.
  53515. */
  53516. lightmapTexture: BaseTexture;
  53517. /**
  53518. * If true, the light map contains occlusion information instead of lighting info.
  53519. */
  53520. useLightmapAsShadowmap: boolean;
  53521. /**
  53522. * Instantiates a new PBRMaterial instance.
  53523. *
  53524. * @param name The material name
  53525. * @param scene The scene the material will be use in.
  53526. */
  53527. constructor(name: string, scene: Scene);
  53528. getClassName(): string;
  53529. }
  53530. }
  53531. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53532. import { Scene } from "babylonjs/scene";
  53533. import { Color3 } from "babylonjs/Maths/math.color";
  53534. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53535. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53536. /**
  53537. * The PBR material of BJS following the metal roughness convention.
  53538. *
  53539. * This fits to the PBR convention in the GLTF definition:
  53540. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53541. */
  53542. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53543. /**
  53544. * The base color has two different interpretations depending on the value of metalness.
  53545. * When the material is a metal, the base color is the specific measured reflectance value
  53546. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53547. * of the material.
  53548. */
  53549. baseColor: Color3;
  53550. /**
  53551. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53552. * well as opacity information in the alpha channel.
  53553. */
  53554. baseTexture: BaseTexture;
  53555. /**
  53556. * Specifies the metallic scalar value of the material.
  53557. * Can also be used to scale the metalness values of the metallic texture.
  53558. */
  53559. metallic: number;
  53560. /**
  53561. * Specifies the roughness scalar value of the material.
  53562. * Can also be used to scale the roughness values of the metallic texture.
  53563. */
  53564. roughness: number;
  53565. /**
  53566. * Texture containing both the metallic value in the B channel and the
  53567. * roughness value in the G channel to keep better precision.
  53568. */
  53569. metallicRoughnessTexture: BaseTexture;
  53570. /**
  53571. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53572. *
  53573. * @param name The material name
  53574. * @param scene The scene the material will be use in.
  53575. */
  53576. constructor(name: string, scene: Scene);
  53577. /**
  53578. * Return the currrent class name of the material.
  53579. */
  53580. getClassName(): string;
  53581. /**
  53582. * Makes a duplicate of the current material.
  53583. * @param name - name to use for the new material.
  53584. */
  53585. clone(name: string): PBRMetallicRoughnessMaterial;
  53586. /**
  53587. * Serialize the material to a parsable JSON object.
  53588. */
  53589. serialize(): any;
  53590. /**
  53591. * Parses a JSON object correponding to the serialize function.
  53592. */
  53593. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53594. }
  53595. }
  53596. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53597. import { Scene } from "babylonjs/scene";
  53598. import { Color3 } from "babylonjs/Maths/math.color";
  53599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53600. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53601. /**
  53602. * The PBR material of BJS following the specular glossiness convention.
  53603. *
  53604. * This fits to the PBR convention in the GLTF definition:
  53605. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53606. */
  53607. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53608. /**
  53609. * Specifies the diffuse color of the material.
  53610. */
  53611. diffuseColor: Color3;
  53612. /**
  53613. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53614. * channel.
  53615. */
  53616. diffuseTexture: BaseTexture;
  53617. /**
  53618. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53619. */
  53620. specularColor: Color3;
  53621. /**
  53622. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53623. */
  53624. glossiness: number;
  53625. /**
  53626. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53627. */
  53628. specularGlossinessTexture: BaseTexture;
  53629. /**
  53630. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53631. *
  53632. * @param name The material name
  53633. * @param scene The scene the material will be use in.
  53634. */
  53635. constructor(name: string, scene: Scene);
  53636. /**
  53637. * Return the currrent class name of the material.
  53638. */
  53639. getClassName(): string;
  53640. /**
  53641. * Makes a duplicate of the current material.
  53642. * @param name - name to use for the new material.
  53643. */
  53644. clone(name: string): PBRSpecularGlossinessMaterial;
  53645. /**
  53646. * Serialize the material to a parsable JSON object.
  53647. */
  53648. serialize(): any;
  53649. /**
  53650. * Parses a JSON object correponding to the serialize function.
  53651. */
  53652. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53653. }
  53654. }
  53655. declare module "babylonjs/Materials/PBR/index" {
  53656. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53657. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53658. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53659. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53660. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53661. }
  53662. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53663. import { Nullable } from "babylonjs/types";
  53664. import { Scene } from "babylonjs/scene";
  53665. import { Matrix } from "babylonjs/Maths/math.vector";
  53666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53667. /**
  53668. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53669. * It can help converting any input color in a desired output one. This can then be used to create effects
  53670. * from sepia, black and white to sixties or futuristic rendering...
  53671. *
  53672. * The only supported format is currently 3dl.
  53673. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53674. */
  53675. export class ColorGradingTexture extends BaseTexture {
  53676. /**
  53677. * The current texture matrix. (will always be identity in color grading texture)
  53678. */
  53679. private _textureMatrix;
  53680. /**
  53681. * The texture URL.
  53682. */
  53683. url: string;
  53684. /**
  53685. * Empty line regex stored for GC.
  53686. */
  53687. private static _noneEmptyLineRegex;
  53688. private _engine;
  53689. /**
  53690. * Instantiates a ColorGradingTexture from the following parameters.
  53691. *
  53692. * @param url The location of the color gradind data (currently only supporting 3dl)
  53693. * @param scene The scene the texture will be used in
  53694. */
  53695. constructor(url: string, scene: Scene);
  53696. /**
  53697. * Returns the texture matrix used in most of the material.
  53698. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53699. */
  53700. getTextureMatrix(): Matrix;
  53701. /**
  53702. * Occurs when the file being loaded is a .3dl LUT file.
  53703. */
  53704. private load3dlTexture;
  53705. /**
  53706. * Starts the loading process of the texture.
  53707. */
  53708. private loadTexture;
  53709. /**
  53710. * Clones the color gradind texture.
  53711. */
  53712. clone(): ColorGradingTexture;
  53713. /**
  53714. * Called during delayed load for textures.
  53715. */
  53716. delayLoad(): void;
  53717. /**
  53718. * Parses a color grading texture serialized by Babylon.
  53719. * @param parsedTexture The texture information being parsedTexture
  53720. * @param scene The scene to load the texture in
  53721. * @param rootUrl The root url of the data assets to load
  53722. * @return A color gradind texture
  53723. */
  53724. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53725. /**
  53726. * Serializes the LUT texture to json format.
  53727. */
  53728. serialize(): any;
  53729. }
  53730. }
  53731. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53733. import { Scene } from "babylonjs/scene";
  53734. import { Nullable } from "babylonjs/types";
  53735. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53736. /**
  53737. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53738. */
  53739. export class EquiRectangularCubeTexture extends BaseTexture {
  53740. /** The six faces of the cube. */
  53741. private static _FacesMapping;
  53742. private _noMipmap;
  53743. private _onLoad;
  53744. private _onError;
  53745. /** The size of the cubemap. */
  53746. private _size;
  53747. /** The buffer of the image. */
  53748. private _buffer;
  53749. /** The width of the input image. */
  53750. private _width;
  53751. /** The height of the input image. */
  53752. private _height;
  53753. /** The URL to the image. */
  53754. url: string;
  53755. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53756. coordinatesMode: number;
  53757. /**
  53758. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53759. * @param url The location of the image
  53760. * @param scene The scene the texture will be used in
  53761. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53762. * @param noMipmap Forces to not generate the mipmap if true
  53763. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53764. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53765. * @param onLoad — defines a callback called when texture is loaded
  53766. * @param onError — defines a callback called if there is an error
  53767. */
  53768. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53769. /**
  53770. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53771. */
  53772. private loadImage;
  53773. /**
  53774. * Convert the image buffer into a cubemap and create a CubeTexture.
  53775. */
  53776. private loadTexture;
  53777. /**
  53778. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53779. * @param buffer The ArrayBuffer that should be converted.
  53780. * @returns The buffer as Float32Array.
  53781. */
  53782. private getFloat32ArrayFromArrayBuffer;
  53783. /**
  53784. * Get the current class name of the texture useful for serialization or dynamic coding.
  53785. * @returns "EquiRectangularCubeTexture"
  53786. */
  53787. getClassName(): string;
  53788. /**
  53789. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53790. * @returns A clone of the current EquiRectangularCubeTexture.
  53791. */
  53792. clone(): EquiRectangularCubeTexture;
  53793. }
  53794. }
  53795. declare module "babylonjs/Misc/tga" {
  53796. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53797. /**
  53798. * Based on jsTGALoader - Javascript loader for TGA file
  53799. * By Vincent Thibault
  53800. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53801. */
  53802. export class TGATools {
  53803. private static _TYPE_INDEXED;
  53804. private static _TYPE_RGB;
  53805. private static _TYPE_GREY;
  53806. private static _TYPE_RLE_INDEXED;
  53807. private static _TYPE_RLE_RGB;
  53808. private static _TYPE_RLE_GREY;
  53809. private static _ORIGIN_MASK;
  53810. private static _ORIGIN_SHIFT;
  53811. private static _ORIGIN_BL;
  53812. private static _ORIGIN_BR;
  53813. private static _ORIGIN_UL;
  53814. private static _ORIGIN_UR;
  53815. /**
  53816. * Gets the header of a TGA file
  53817. * @param data defines the TGA data
  53818. * @returns the header
  53819. */
  53820. static GetTGAHeader(data: Uint8Array): any;
  53821. /**
  53822. * Uploads TGA content to a Babylon Texture
  53823. * @hidden
  53824. */
  53825. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53826. /** @hidden */
  53827. 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;
  53828. /** @hidden */
  53829. 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;
  53830. /** @hidden */
  53831. 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;
  53832. /** @hidden */
  53833. 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;
  53834. /** @hidden */
  53835. 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;
  53836. /** @hidden */
  53837. 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;
  53838. }
  53839. }
  53840. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53841. import { Nullable } from "babylonjs/types";
  53842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53843. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53844. /**
  53845. * Implementation of the TGA Texture Loader.
  53846. * @hidden
  53847. */
  53848. export class _TGATextureLoader implements IInternalTextureLoader {
  53849. /**
  53850. * Defines wether the loader supports cascade loading the different faces.
  53851. */
  53852. readonly supportCascades: boolean;
  53853. /**
  53854. * This returns if the loader support the current file information.
  53855. * @param extension defines the file extension of the file being loaded
  53856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53857. * @param fallback defines the fallback internal texture if any
  53858. * @param isBase64 defines whether the texture is encoded as a base64
  53859. * @param isBuffer defines whether the texture data are stored as a buffer
  53860. * @returns true if the loader can load the specified file
  53861. */
  53862. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53863. /**
  53864. * Transform the url before loading if required.
  53865. * @param rootUrl the url of the texture
  53866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53867. * @returns the transformed texture
  53868. */
  53869. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53870. /**
  53871. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53872. * @param rootUrl the url of the texture
  53873. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53874. * @returns the fallback texture
  53875. */
  53876. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53877. /**
  53878. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53879. * @param data contains the texture data
  53880. * @param texture defines the BabylonJS internal texture
  53881. * @param createPolynomials will be true if polynomials have been requested
  53882. * @param onLoad defines the callback to trigger once the texture is ready
  53883. * @param onError defines the callback to trigger in case of error
  53884. */
  53885. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53886. /**
  53887. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53888. * @param data contains the texture data
  53889. * @param texture defines the BabylonJS internal texture
  53890. * @param callback defines the method to call once ready to upload
  53891. */
  53892. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53893. }
  53894. }
  53895. declare module "babylonjs/Misc/basis" {
  53896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53897. /**
  53898. * Info about the .basis files
  53899. */
  53900. class BasisFileInfo {
  53901. /**
  53902. * If the file has alpha
  53903. */
  53904. hasAlpha: boolean;
  53905. /**
  53906. * Info about each image of the basis file
  53907. */
  53908. images: Array<{
  53909. levels: Array<{
  53910. width: number;
  53911. height: number;
  53912. transcodedPixels: ArrayBufferView;
  53913. }>;
  53914. }>;
  53915. }
  53916. /**
  53917. * Result of transcoding a basis file
  53918. */
  53919. class TranscodeResult {
  53920. /**
  53921. * Info about the .basis file
  53922. */
  53923. fileInfo: BasisFileInfo;
  53924. /**
  53925. * Format to use when loading the file
  53926. */
  53927. format: number;
  53928. }
  53929. /**
  53930. * Configuration options for the Basis transcoder
  53931. */
  53932. export class BasisTranscodeConfiguration {
  53933. /**
  53934. * Supported compression formats used to determine the supported output format of the transcoder
  53935. */
  53936. supportedCompressionFormats?: {
  53937. /**
  53938. * etc1 compression format
  53939. */
  53940. etc1?: boolean;
  53941. /**
  53942. * s3tc compression format
  53943. */
  53944. s3tc?: boolean;
  53945. /**
  53946. * pvrtc compression format
  53947. */
  53948. pvrtc?: boolean;
  53949. /**
  53950. * etc2 compression format
  53951. */
  53952. etc2?: boolean;
  53953. };
  53954. /**
  53955. * If mipmap levels should be loaded for transcoded images (Default: true)
  53956. */
  53957. loadMipmapLevels?: boolean;
  53958. /**
  53959. * Index of a single image to load (Default: all images)
  53960. */
  53961. loadSingleImage?: number;
  53962. }
  53963. /**
  53964. * Used to load .Basis files
  53965. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53966. */
  53967. export class BasisTools {
  53968. private static _IgnoreSupportedFormats;
  53969. /**
  53970. * URL to use when loading the basis transcoder
  53971. */
  53972. static JSModuleURL: string;
  53973. /**
  53974. * URL to use when loading the wasm module for the transcoder
  53975. */
  53976. static WasmModuleURL: string;
  53977. /**
  53978. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53979. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53980. * @returns internal format corresponding to the Basis format
  53981. */
  53982. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53983. private static _WorkerPromise;
  53984. private static _Worker;
  53985. private static _actionId;
  53986. private static _CreateWorkerAsync;
  53987. /**
  53988. * Transcodes a loaded image file to compressed pixel data
  53989. * @param imageData image data to transcode
  53990. * @param config configuration options for the transcoding
  53991. * @returns a promise resulting in the transcoded image
  53992. */
  53993. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53994. /**
  53995. * Loads a texture from the transcode result
  53996. * @param texture texture load to
  53997. * @param transcodeResult the result of transcoding the basis file to load from
  53998. */
  53999. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54000. }
  54001. }
  54002. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54003. import { Nullable } from "babylonjs/types";
  54004. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54005. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54006. /**
  54007. * Loader for .basis file format
  54008. */
  54009. export class _BasisTextureLoader implements IInternalTextureLoader {
  54010. /**
  54011. * Defines whether the loader supports cascade loading the different faces.
  54012. */
  54013. readonly supportCascades: boolean;
  54014. /**
  54015. * This returns if the loader support the current file information.
  54016. * @param extension defines the file extension of the file being loaded
  54017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54018. * @param fallback defines the fallback internal texture if any
  54019. * @param isBase64 defines whether the texture is encoded as a base64
  54020. * @param isBuffer defines whether the texture data are stored as a buffer
  54021. * @returns true if the loader can load the specified file
  54022. */
  54023. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54024. /**
  54025. * Transform the url before loading if required.
  54026. * @param rootUrl the url of the texture
  54027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54028. * @returns the transformed texture
  54029. */
  54030. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54031. /**
  54032. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54033. * @param rootUrl the url of the texture
  54034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54035. * @returns the fallback texture
  54036. */
  54037. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54038. /**
  54039. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54040. * @param data contains the texture data
  54041. * @param texture defines the BabylonJS internal texture
  54042. * @param createPolynomials will be true if polynomials have been requested
  54043. * @param onLoad defines the callback to trigger once the texture is ready
  54044. * @param onError defines the callback to trigger in case of error
  54045. */
  54046. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54047. /**
  54048. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54049. * @param data contains the texture data
  54050. * @param texture defines the BabylonJS internal texture
  54051. * @param callback defines the method to call once ready to upload
  54052. */
  54053. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54054. }
  54055. }
  54056. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54057. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54058. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54059. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54060. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54061. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54062. }
  54063. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54064. import { Scene } from "babylonjs/scene";
  54065. import { Texture } from "babylonjs/Materials/Textures/texture";
  54066. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54067. /**
  54068. * 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.
  54069. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54070. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54071. */
  54072. export class CustomProceduralTexture extends ProceduralTexture {
  54073. private _animate;
  54074. private _time;
  54075. private _config;
  54076. private _texturePath;
  54077. /**
  54078. * Instantiates a new Custom Procedural Texture.
  54079. * 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.
  54080. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54081. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54082. * @param name Define the name of the texture
  54083. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54084. * @param size Define the size of the texture to create
  54085. * @param scene Define the scene the texture belongs to
  54086. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54087. * @param generateMipMaps Define if the texture should creates mip maps or not
  54088. */
  54089. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54090. private _loadJson;
  54091. /**
  54092. * Is the texture ready to be used ? (rendered at least once)
  54093. * @returns true if ready, otherwise, false.
  54094. */
  54095. isReady(): boolean;
  54096. /**
  54097. * Render the texture to its associated render target.
  54098. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54099. */
  54100. render(useCameraPostProcess?: boolean): void;
  54101. /**
  54102. * Update the list of dependant textures samplers in the shader.
  54103. */
  54104. updateTextures(): void;
  54105. /**
  54106. * Update the uniform values of the procedural texture in the shader.
  54107. */
  54108. updateShaderUniforms(): void;
  54109. /**
  54110. * Define if the texture animates or not.
  54111. */
  54112. animate: boolean;
  54113. }
  54114. }
  54115. declare module "babylonjs/Shaders/noise.fragment" {
  54116. /** @hidden */
  54117. export var noisePixelShader: {
  54118. name: string;
  54119. shader: string;
  54120. };
  54121. }
  54122. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54123. import { Nullable } from "babylonjs/types";
  54124. import { Scene } from "babylonjs/scene";
  54125. import { Texture } from "babylonjs/Materials/Textures/texture";
  54126. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54127. import "babylonjs/Shaders/noise.fragment";
  54128. /**
  54129. * Class used to generate noise procedural textures
  54130. */
  54131. export class NoiseProceduralTexture extends ProceduralTexture {
  54132. private _time;
  54133. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54134. brightness: number;
  54135. /** Defines the number of octaves to process */
  54136. octaves: number;
  54137. /** Defines the level of persistence (0.8 by default) */
  54138. persistence: number;
  54139. /** Gets or sets animation speed factor (default is 1) */
  54140. animationSpeedFactor: number;
  54141. /**
  54142. * Creates a new NoiseProceduralTexture
  54143. * @param name defines the name fo the texture
  54144. * @param size defines the size of the texture (default is 256)
  54145. * @param scene defines the hosting scene
  54146. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54147. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54148. */
  54149. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54150. private _updateShaderUniforms;
  54151. protected _getDefines(): string;
  54152. /** Generate the current state of the procedural texture */
  54153. render(useCameraPostProcess?: boolean): void;
  54154. /**
  54155. * Serializes this noise procedural texture
  54156. * @returns a serialized noise procedural texture object
  54157. */
  54158. serialize(): any;
  54159. /**
  54160. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54161. * @param parsedTexture defines parsed texture data
  54162. * @param scene defines the current scene
  54163. * @param rootUrl defines the root URL containing noise procedural texture information
  54164. * @returns a parsed NoiseProceduralTexture
  54165. */
  54166. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54167. }
  54168. }
  54169. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54170. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54171. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54172. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54173. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54174. }
  54175. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54176. import { Nullable } from "babylonjs/types";
  54177. import { Scene } from "babylonjs/scene";
  54178. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54179. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54180. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54181. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54182. /**
  54183. * Raw cube texture where the raw buffers are passed in
  54184. */
  54185. export class RawCubeTexture extends CubeTexture {
  54186. /**
  54187. * Creates a cube texture where the raw buffers are passed in.
  54188. * @param scene defines the scene the texture is attached to
  54189. * @param data defines the array of data to use to create each face
  54190. * @param size defines the size of the textures
  54191. * @param format defines the format of the data
  54192. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54193. * @param generateMipMaps defines if the engine should generate the mip levels
  54194. * @param invertY defines if data must be stored with Y axis inverted
  54195. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54196. * @param compression defines the compression used (null by default)
  54197. */
  54198. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54199. /**
  54200. * Updates the raw cube texture.
  54201. * @param data defines the data to store
  54202. * @param format defines the data format
  54203. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54204. * @param invertY defines if data must be stored with Y axis inverted
  54205. * @param compression defines the compression used (null by default)
  54206. * @param level defines which level of the texture to update
  54207. */
  54208. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54209. /**
  54210. * Updates a raw cube texture with RGBD encoded data.
  54211. * @param data defines the array of data [mipmap][face] to use to create each face
  54212. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54213. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54214. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54215. * @returns a promsie that resolves when the operation is complete
  54216. */
  54217. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54218. /**
  54219. * Clones the raw cube texture.
  54220. * @return a new cube texture
  54221. */
  54222. clone(): CubeTexture;
  54223. /** @hidden */
  54224. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54225. }
  54226. }
  54227. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54228. import { Scene } from "babylonjs/scene";
  54229. import { Texture } from "babylonjs/Materials/Textures/texture";
  54230. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54231. /**
  54232. * Class used to store 3D textures containing user data
  54233. */
  54234. export class RawTexture3D extends Texture {
  54235. /** Gets or sets the texture format to use */
  54236. format: number;
  54237. private _engine;
  54238. /**
  54239. * Create a new RawTexture3D
  54240. * @param data defines the data of the texture
  54241. * @param width defines the width of the texture
  54242. * @param height defines the height of the texture
  54243. * @param depth defines the depth of the texture
  54244. * @param format defines the texture format to use
  54245. * @param scene defines the hosting scene
  54246. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54247. * @param invertY defines if texture must be stored with Y axis inverted
  54248. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54249. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54250. */
  54251. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54252. /** Gets or sets the texture format to use */
  54253. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54254. /**
  54255. * Update the texture with new data
  54256. * @param data defines the data to store in the texture
  54257. */
  54258. update(data: ArrayBufferView): void;
  54259. }
  54260. }
  54261. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54262. import { Scene } from "babylonjs/scene";
  54263. import { Plane } from "babylonjs/Maths/math.plane";
  54264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54265. /**
  54266. * Creates a refraction texture used by refraction channel of the standard material.
  54267. * It is like a mirror but to see through a material.
  54268. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54269. */
  54270. export class RefractionTexture extends RenderTargetTexture {
  54271. /**
  54272. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54273. * 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.
  54274. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54275. */
  54276. refractionPlane: Plane;
  54277. /**
  54278. * Define how deep under the surface we should see.
  54279. */
  54280. depth: number;
  54281. /**
  54282. * Creates a refraction texture used by refraction channel of the standard material.
  54283. * It is like a mirror but to see through a material.
  54284. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54285. * @param name Define the texture name
  54286. * @param size Define the size of the underlying texture
  54287. * @param scene Define the scene the refraction belongs to
  54288. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54289. */
  54290. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54291. /**
  54292. * Clone the refraction texture.
  54293. * @returns the cloned texture
  54294. */
  54295. clone(): RefractionTexture;
  54296. /**
  54297. * Serialize the texture to a JSON representation you could use in Parse later on
  54298. * @returns the serialized JSON representation
  54299. */
  54300. serialize(): any;
  54301. }
  54302. }
  54303. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54304. import { Nullable } from "babylonjs/types";
  54305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54306. import { Matrix } from "babylonjs/Maths/math.vector";
  54307. import { Engine } from "babylonjs/Engines/engine";
  54308. import { Scene } from "babylonjs/scene";
  54309. /**
  54310. * Defines the options related to the creation of an HtmlElementTexture
  54311. */
  54312. export interface IHtmlElementTextureOptions {
  54313. /**
  54314. * Defines wether mip maps should be created or not.
  54315. */
  54316. generateMipMaps?: boolean;
  54317. /**
  54318. * Defines the sampling mode of the texture.
  54319. */
  54320. samplingMode?: number;
  54321. /**
  54322. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54323. */
  54324. engine: Nullable<Engine>;
  54325. /**
  54326. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54327. */
  54328. scene: Nullable<Scene>;
  54329. }
  54330. /**
  54331. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54332. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54333. * is automatically managed.
  54334. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54335. * in your application.
  54336. *
  54337. * As the update is not automatic, you need to call them manually.
  54338. */
  54339. export class HtmlElementTexture extends BaseTexture {
  54340. /**
  54341. * The texture URL.
  54342. */
  54343. element: HTMLVideoElement | HTMLCanvasElement;
  54344. private static readonly DefaultOptions;
  54345. private _textureMatrix;
  54346. private _engine;
  54347. private _isVideo;
  54348. private _generateMipMaps;
  54349. private _samplingMode;
  54350. /**
  54351. * Instantiates a HtmlElementTexture from the following parameters.
  54352. *
  54353. * @param name Defines the name of the texture
  54354. * @param element Defines the video or canvas the texture is filled with
  54355. * @param options Defines the other none mandatory texture creation options
  54356. */
  54357. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54358. private _createInternalTexture;
  54359. /**
  54360. * Returns the texture matrix used in most of the material.
  54361. */
  54362. getTextureMatrix(): Matrix;
  54363. /**
  54364. * Updates the content of the texture.
  54365. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54366. */
  54367. update(invertY?: Nullable<boolean>): void;
  54368. }
  54369. }
  54370. declare module "babylonjs/Materials/Textures/index" {
  54371. export * from "babylonjs/Materials/Textures/baseTexture";
  54372. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54373. export * from "babylonjs/Materials/Textures/cubeTexture";
  54374. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54375. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54376. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54377. export * from "babylonjs/Materials/Textures/internalTexture";
  54378. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54379. export * from "babylonjs/Materials/Textures/Loaders/index";
  54380. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54381. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54382. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54383. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54384. export * from "babylonjs/Materials/Textures/rawTexture";
  54385. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54386. export * from "babylonjs/Materials/Textures/refractionTexture";
  54387. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54388. export * from "babylonjs/Materials/Textures/texture";
  54389. export * from "babylonjs/Materials/Textures/videoTexture";
  54390. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54391. }
  54392. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  54393. /**
  54394. * Enum used to define the target of a block
  54395. */
  54396. export enum NodeMaterialBlockTargets {
  54397. /** Vertex shader */
  54398. Vertex = 1,
  54399. /** Fragment shader */
  54400. Fragment = 2,
  54401. /** Neutral */
  54402. Neutral = 4,
  54403. /** Vertex and Fragment */
  54404. VertexAndFragment = 3
  54405. }
  54406. }
  54407. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  54408. /**
  54409. * Defines the kind of connection point for node based material
  54410. */
  54411. export enum NodeMaterialBlockConnectionPointTypes {
  54412. /** Float */
  54413. Float = 1,
  54414. /** Int */
  54415. Int = 2,
  54416. /** Vector2 */
  54417. Vector2 = 4,
  54418. /** Vector3 */
  54419. Vector3 = 8,
  54420. /** Vector4 */
  54421. Vector4 = 16,
  54422. /** Color3 */
  54423. Color3 = 32,
  54424. /** Color4 */
  54425. Color4 = 64,
  54426. /** Matrix */
  54427. Matrix = 128,
  54428. /** Detect type based on connection */
  54429. AutoDetect = 1024,
  54430. /** Output type that will be defined by input type */
  54431. BasedOnInput = 2048
  54432. }
  54433. }
  54434. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54436. /**
  54437. * Root class for all node material optimizers
  54438. */
  54439. export class NodeMaterialOptimizer {
  54440. /**
  54441. * Function used to optimize a NodeMaterial graph
  54442. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54443. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54444. */
  54445. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54446. }
  54447. }
  54448. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54452. import { Scene } from "babylonjs/scene";
  54453. /**
  54454. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54455. */
  54456. export class TransformBlock extends NodeMaterialBlock {
  54457. /**
  54458. * Defines the value to use to complement W value to transform it to a Vector4
  54459. */
  54460. complementW: number;
  54461. /**
  54462. * Defines the value to use to complement z value to transform it to a Vector4
  54463. */
  54464. complementZ: number;
  54465. /**
  54466. * Creates a new TransformBlock
  54467. * @param name defines the block name
  54468. */
  54469. constructor(name: string);
  54470. /**
  54471. * Gets the current class name
  54472. * @returns the class name
  54473. */
  54474. getClassName(): string;
  54475. /**
  54476. * Gets the vector input
  54477. */
  54478. readonly vector: NodeMaterialConnectionPoint;
  54479. /**
  54480. * Gets the output component
  54481. */
  54482. readonly output: NodeMaterialConnectionPoint;
  54483. /**
  54484. * Gets the matrix transform input
  54485. */
  54486. readonly transform: NodeMaterialConnectionPoint;
  54487. protected _buildBlock(state: NodeMaterialBuildState): this;
  54488. serialize(): any;
  54489. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54490. protected _dumpPropertiesCode(): string;
  54491. }
  54492. }
  54493. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54496. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54497. /**
  54498. * Block used to output the vertex position
  54499. */
  54500. export class VertexOutputBlock extends NodeMaterialBlock {
  54501. /**
  54502. * Creates a new VertexOutputBlock
  54503. * @param name defines the block name
  54504. */
  54505. constructor(name: string);
  54506. /**
  54507. * Gets the current class name
  54508. * @returns the class name
  54509. */
  54510. getClassName(): string;
  54511. /**
  54512. * Gets the vector input component
  54513. */
  54514. readonly vector: NodeMaterialConnectionPoint;
  54515. protected _buildBlock(state: NodeMaterialBuildState): this;
  54516. }
  54517. }
  54518. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54522. /**
  54523. * Block used to output the final color
  54524. */
  54525. export class FragmentOutputBlock extends NodeMaterialBlock {
  54526. /**
  54527. * Create a new FragmentOutputBlock
  54528. * @param name defines the block name
  54529. */
  54530. constructor(name: string);
  54531. /**
  54532. * Gets the current class name
  54533. * @returns the class name
  54534. */
  54535. getClassName(): string;
  54536. /**
  54537. * Gets the rgba input component
  54538. */
  54539. readonly rgba: NodeMaterialConnectionPoint;
  54540. /**
  54541. * Gets the rgb input component
  54542. */
  54543. readonly rgb: NodeMaterialConnectionPoint;
  54544. /**
  54545. * Gets the a input component
  54546. */
  54547. readonly a: NodeMaterialConnectionPoint;
  54548. protected _buildBlock(state: NodeMaterialBuildState): this;
  54549. }
  54550. }
  54551. declare module "babylonjs/Materials/Node/nodeMaterialSystemValues" {
  54552. /**
  54553. * Enum used to define system values e.g. values automatically provided by the system
  54554. */
  54555. export enum NodeMaterialSystemValues {
  54556. /** World */
  54557. World = 1,
  54558. /** View */
  54559. View = 2,
  54560. /** Projection */
  54561. Projection = 3,
  54562. /** ViewProjection */
  54563. ViewProjection = 4,
  54564. /** WorldView */
  54565. WorldView = 5,
  54566. /** WorldViewProjection */
  54567. WorldViewProjection = 6,
  54568. /** CameraPosition */
  54569. CameraPosition = 7,
  54570. /** Fog Color */
  54571. FogColor = 8
  54572. }
  54573. }
  54574. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54576. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54577. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54580. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54581. import { Effect } from "babylonjs/Materials/effect";
  54582. import { Mesh } from "babylonjs/Meshes/mesh";
  54583. import { Nullable } from "babylonjs/types";
  54584. import { Scene } from "babylonjs/scene";
  54585. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54586. /**
  54587. * Block used to read a reflection texture from a sampler
  54588. */
  54589. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54590. private _define3DName;
  54591. private _defineCubicName;
  54592. private _defineExplicitName;
  54593. private _defineProjectionName;
  54594. private _defineLocalCubicName;
  54595. private _defineSphericalName;
  54596. private _definePlanarName;
  54597. private _defineEquirectangularName;
  54598. private _defineMirroredEquirectangularFixedName;
  54599. private _defineEquirectangularFixedName;
  54600. private _defineSkyboxName;
  54601. private _cubeSamplerName;
  54602. private _2DSamplerName;
  54603. private _positionUVWName;
  54604. private _directionWName;
  54605. private _reflectionCoordsName;
  54606. private _reflection2DCoordsName;
  54607. private _reflectionColorName;
  54608. private _reflectionMatrixName;
  54609. /**
  54610. * Gets or sets the texture associated with the node
  54611. */
  54612. texture: Nullable<BaseTexture>;
  54613. /**
  54614. * Create a new TextureBlock
  54615. * @param name defines the block name
  54616. */
  54617. constructor(name: string);
  54618. /**
  54619. * Gets the current class name
  54620. * @returns the class name
  54621. */
  54622. getClassName(): string;
  54623. /**
  54624. * Gets the world position input component
  54625. */
  54626. readonly position: NodeMaterialConnectionPoint;
  54627. /**
  54628. * Gets the world position input component
  54629. */
  54630. readonly worldPosition: NodeMaterialConnectionPoint;
  54631. /**
  54632. * Gets the world normal input component
  54633. */
  54634. readonly worldNormal: NodeMaterialConnectionPoint;
  54635. /**
  54636. * Gets the world input component
  54637. */
  54638. readonly world: NodeMaterialConnectionPoint;
  54639. /**
  54640. * Gets the camera (or eye) position component
  54641. */
  54642. readonly cameraPosition: NodeMaterialConnectionPoint;
  54643. /**
  54644. * Gets the view input component
  54645. */
  54646. readonly view: NodeMaterialConnectionPoint;
  54647. /**
  54648. * Gets the rgb output component
  54649. */
  54650. readonly rgb: NodeMaterialConnectionPoint;
  54651. /**
  54652. * Gets the r output component
  54653. */
  54654. readonly r: NodeMaterialConnectionPoint;
  54655. /**
  54656. * Gets the g output component
  54657. */
  54658. readonly g: NodeMaterialConnectionPoint;
  54659. /**
  54660. * Gets the b output component
  54661. */
  54662. readonly b: NodeMaterialConnectionPoint;
  54663. autoConfigure(material: NodeMaterial): void;
  54664. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54665. isReady(): boolean;
  54666. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54667. private _injectVertexCode;
  54668. private _writeOutput;
  54669. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54670. serialize(): any;
  54671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54672. }
  54673. }
  54674. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54676. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54677. import { Scene } from "babylonjs/scene";
  54678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54679. import { Matrix } from "babylonjs/Maths/math.vector";
  54680. import { Mesh } from "babylonjs/Meshes/mesh";
  54681. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54682. import { Observable } from "babylonjs/Misc/observable";
  54683. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54684. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54685. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54686. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54687. import { Nullable } from "babylonjs/types";
  54688. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54689. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54690. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54691. /**
  54692. * Interface used to configure the node material editor
  54693. */
  54694. export interface INodeMaterialEditorOptions {
  54695. /** Define the URl to load node editor script */
  54696. editorURL?: string;
  54697. }
  54698. /** @hidden */
  54699. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54700. /** BONES */
  54701. NUM_BONE_INFLUENCERS: number;
  54702. BonesPerMesh: number;
  54703. BONETEXTURE: boolean;
  54704. /** MORPH TARGETS */
  54705. MORPHTARGETS: boolean;
  54706. MORPHTARGETS_NORMAL: boolean;
  54707. MORPHTARGETS_TANGENT: boolean;
  54708. MORPHTARGETS_UV: boolean;
  54709. NUM_MORPH_INFLUENCERS: number;
  54710. /** IMAGE PROCESSING */
  54711. IMAGEPROCESSING: boolean;
  54712. VIGNETTE: boolean;
  54713. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54714. VIGNETTEBLENDMODEOPAQUE: boolean;
  54715. TONEMAPPING: boolean;
  54716. TONEMAPPING_ACES: boolean;
  54717. CONTRAST: boolean;
  54718. EXPOSURE: boolean;
  54719. COLORCURVES: boolean;
  54720. COLORGRADING: boolean;
  54721. COLORGRADING3D: boolean;
  54722. SAMPLER3DGREENDEPTH: boolean;
  54723. SAMPLER3DBGRMAP: boolean;
  54724. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54725. /** MISC. */
  54726. BUMPDIRECTUV: number;
  54727. constructor();
  54728. setValue(name: string, value: boolean): void;
  54729. }
  54730. /**
  54731. * Class used to configure NodeMaterial
  54732. */
  54733. export interface INodeMaterialOptions {
  54734. /**
  54735. * Defines if blocks should emit comments
  54736. */
  54737. emitComments: boolean;
  54738. }
  54739. /**
  54740. * Class used to create a node based material built by assembling shader blocks
  54741. */
  54742. export class NodeMaterial extends PushMaterial {
  54743. private static _BuildIdGenerator;
  54744. private _options;
  54745. private _vertexCompilationState;
  54746. private _fragmentCompilationState;
  54747. private _sharedData;
  54748. private _buildId;
  54749. private _buildWasSuccessful;
  54750. private _cachedWorldViewMatrix;
  54751. private _cachedWorldViewProjectionMatrix;
  54752. private _optimizers;
  54753. private _animationFrame;
  54754. /** Define the URl to load node editor script */
  54755. static EditorURL: string;
  54756. private BJSNODEMATERIALEDITOR;
  54757. /** Get the inspector from bundle or global */
  54758. private _getGlobalNodeMaterialEditor;
  54759. /**
  54760. * 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)
  54761. */
  54762. ignoreAlpha: boolean;
  54763. /**
  54764. * Defines the maximum number of lights that can be used in the material
  54765. */
  54766. maxSimultaneousLights: number;
  54767. /**
  54768. * Observable raised when the material is built
  54769. */
  54770. onBuildObservable: Observable<NodeMaterial>;
  54771. /**
  54772. * Gets or sets the root nodes of the material vertex shader
  54773. */
  54774. _vertexOutputNodes: NodeMaterialBlock[];
  54775. /**
  54776. * Gets or sets the root nodes of the material fragment (pixel) shader
  54777. */
  54778. _fragmentOutputNodes: NodeMaterialBlock[];
  54779. /** Gets or sets options to control the node material overall behavior */
  54780. options: INodeMaterialOptions;
  54781. /**
  54782. * Default configuration related to image processing available in the standard Material.
  54783. */
  54784. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54785. /**
  54786. * Gets the image processing configuration used either in this material.
  54787. */
  54788. /**
  54789. * Sets the Default image processing configuration used either in the this material.
  54790. *
  54791. * If sets to null, the scene one is in use.
  54792. */
  54793. imageProcessingConfiguration: ImageProcessingConfiguration;
  54794. /**
  54795. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54796. */
  54797. attachedBlocks: NodeMaterialBlock[];
  54798. /**
  54799. * Create a new node based material
  54800. * @param name defines the material name
  54801. * @param scene defines the hosting scene
  54802. * @param options defines creation option
  54803. */
  54804. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54805. /**
  54806. * Gets the current class name of the material e.g. "NodeMaterial"
  54807. * @returns the class name
  54808. */
  54809. getClassName(): string;
  54810. /**
  54811. * Keep track of the image processing observer to allow dispose and replace.
  54812. */
  54813. private _imageProcessingObserver;
  54814. /**
  54815. * Attaches a new image processing configuration to the Standard Material.
  54816. * @param configuration
  54817. */
  54818. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54819. /**
  54820. * Get a block by its name
  54821. * @param name defines the name of the block to retrieve
  54822. * @returns the required block or null if not found
  54823. */
  54824. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54825. /**
  54826. * Get a block by its name
  54827. * @param predicate defines the predicate used to find the good candidate
  54828. * @returns the required block or null if not found
  54829. */
  54830. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54831. /**
  54832. * Get an input block by its name
  54833. * @param predicate defines the predicate used to find the good candidate
  54834. * @returns the required input block or null if not found
  54835. */
  54836. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54837. /**
  54838. * Gets the list of input blocks attached to this material
  54839. * @returns an array of InputBlocks
  54840. */
  54841. getInputBlocks(): InputBlock[];
  54842. /**
  54843. * Adds a new optimizer to the list of optimizers
  54844. * @param optimizer defines the optimizers to add
  54845. * @returns the current material
  54846. */
  54847. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54848. /**
  54849. * Remove an optimizer from the list of optimizers
  54850. * @param optimizer defines the optimizers to remove
  54851. * @returns the current material
  54852. */
  54853. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54854. /**
  54855. * Add a new block to the list of output nodes
  54856. * @param node defines the node to add
  54857. * @returns the current material
  54858. */
  54859. addOutputNode(node: NodeMaterialBlock): this;
  54860. /**
  54861. * Remove a block from the list of root nodes
  54862. * @param node defines the node to remove
  54863. * @returns the current material
  54864. */
  54865. removeOutputNode(node: NodeMaterialBlock): this;
  54866. private _addVertexOutputNode;
  54867. private _removeVertexOutputNode;
  54868. private _addFragmentOutputNode;
  54869. private _removeFragmentOutputNode;
  54870. /**
  54871. * Specifies if the material will require alpha blending
  54872. * @returns a boolean specifying if alpha blending is needed
  54873. */
  54874. needAlphaBlending(): boolean;
  54875. /**
  54876. * Specifies if this material should be rendered in alpha test mode
  54877. * @returns a boolean specifying if an alpha test is needed.
  54878. */
  54879. needAlphaTesting(): boolean;
  54880. private _initializeBlock;
  54881. private _resetDualBlocks;
  54882. /**
  54883. * Build the material and generates the inner effect
  54884. * @param verbose defines if the build should log activity
  54885. */
  54886. build(verbose?: boolean): void;
  54887. /**
  54888. * Runs an otpimization phase to try to improve the shader code
  54889. */
  54890. optimize(): void;
  54891. private _prepareDefinesForAttributes;
  54892. /**
  54893. * Get if the submesh is ready to be used and all its information available.
  54894. * Child classes can use it to update shaders
  54895. * @param mesh defines the mesh to check
  54896. * @param subMesh defines which submesh to check
  54897. * @param useInstances specifies that instances should be used
  54898. * @returns a boolean indicating that the submesh is ready or not
  54899. */
  54900. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54901. /**
  54902. * Get a string representing the shaders built by the current node graph
  54903. */
  54904. readonly compiledShaders: string;
  54905. /**
  54906. * Binds the world matrix to the material
  54907. * @param world defines the world transformation matrix
  54908. */
  54909. bindOnlyWorldMatrix(world: Matrix): void;
  54910. /**
  54911. * Binds the submesh to this material by preparing the effect and shader to draw
  54912. * @param world defines the world transformation matrix
  54913. * @param mesh defines the mesh containing the submesh
  54914. * @param subMesh defines the submesh to bind the material to
  54915. */
  54916. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54917. /**
  54918. * Gets the active textures from the material
  54919. * @returns an array of textures
  54920. */
  54921. getActiveTextures(): BaseTexture[];
  54922. /**
  54923. * Gets the list of texture blocks
  54924. * @returns an array of texture blocks
  54925. */
  54926. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54927. /**
  54928. * Specifies if the material uses a texture
  54929. * @param texture defines the texture to check against the material
  54930. * @returns a boolean specifying if the material uses the texture
  54931. */
  54932. hasTexture(texture: BaseTexture): boolean;
  54933. /**
  54934. * Disposes the material
  54935. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54936. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54937. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54938. */
  54939. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54940. /** Creates the node editor window. */
  54941. private _createNodeEditor;
  54942. /**
  54943. * Launch the node material editor
  54944. * @param config Define the configuration of the editor
  54945. * @return a promise fulfilled when the node editor is visible
  54946. */
  54947. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54948. /**
  54949. * Clear the current material
  54950. */
  54951. clear(): void;
  54952. /**
  54953. * Clear the current material and set it to a default state
  54954. */
  54955. setToDefault(): void;
  54956. /**
  54957. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54958. * @param url defines the url to load from
  54959. * @returns a promise that will fullfil when the material is fully loaded
  54960. */
  54961. loadAsync(url: string): Promise<unknown>;
  54962. private _gatherBlocks;
  54963. /**
  54964. * Generate a string containing the code declaration required to create an equivalent of this material
  54965. * @returns a string
  54966. */
  54967. generateCode(): string;
  54968. /**
  54969. * Serializes this material in a JSON representation
  54970. * @returns the serialized material object
  54971. */
  54972. serialize(): any;
  54973. private _restoreConnections;
  54974. /**
  54975. * Clear the current graph and load a new one from a serialization object
  54976. * @param source defines the JSON representation of the material
  54977. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54978. */
  54979. loadFromSerialization(source: any, rootUrl?: string): void;
  54980. /**
  54981. * Creates a node material from parsed material data
  54982. * @param source defines the JSON representation of the material
  54983. * @param scene defines the hosting scene
  54984. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54985. * @returns a new node material
  54986. */
  54987. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54988. /**
  54989. * Creates a new node material set to default basic configuration
  54990. * @param name defines the name of the material
  54991. * @param scene defines the hosting scene
  54992. * @returns a new NodeMaterial
  54993. */
  54994. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54995. }
  54996. }
  54997. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55000. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55001. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55003. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55004. import { Effect } from "babylonjs/Materials/effect";
  55005. import { Mesh } from "babylonjs/Meshes/mesh";
  55006. import { Nullable } from "babylonjs/types";
  55007. import { Texture } from "babylonjs/Materials/Textures/texture";
  55008. import { Scene } from "babylonjs/scene";
  55009. /**
  55010. * Block used to read a texture from a sampler
  55011. */
  55012. export class TextureBlock extends NodeMaterialBlock {
  55013. private _defineName;
  55014. private _samplerName;
  55015. private _transformedUVName;
  55016. private _textureTransformName;
  55017. private _textureInfoName;
  55018. private _mainUVName;
  55019. private _mainUVDefineName;
  55020. /**
  55021. * Gets or sets the texture associated with the node
  55022. */
  55023. texture: Nullable<Texture>;
  55024. /**
  55025. * Create a new TextureBlock
  55026. * @param name defines the block name
  55027. */
  55028. constructor(name: string);
  55029. /**
  55030. * Gets the current class name
  55031. * @returns the class name
  55032. */
  55033. getClassName(): string;
  55034. /**
  55035. * Gets the uv input component
  55036. */
  55037. readonly uv: NodeMaterialConnectionPoint;
  55038. /**
  55039. * Gets the rgba output component
  55040. */
  55041. readonly rgba: NodeMaterialConnectionPoint;
  55042. /**
  55043. * Gets the rgb output component
  55044. */
  55045. readonly rgb: NodeMaterialConnectionPoint;
  55046. /**
  55047. * Gets the r output component
  55048. */
  55049. readonly r: NodeMaterialConnectionPoint;
  55050. /**
  55051. * Gets the g output component
  55052. */
  55053. readonly g: NodeMaterialConnectionPoint;
  55054. /**
  55055. * Gets the b output component
  55056. */
  55057. readonly b: NodeMaterialConnectionPoint;
  55058. /**
  55059. * Gets the a output component
  55060. */
  55061. readonly a: NodeMaterialConnectionPoint;
  55062. readonly target: NodeMaterialBlockTargets;
  55063. autoConfigure(material: NodeMaterial): void;
  55064. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55065. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55066. isReady(): boolean;
  55067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55068. private readonly _isMixed;
  55069. private _injectVertexCode;
  55070. private _writeOutput;
  55071. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55072. protected _dumpPropertiesCode(): string;
  55073. serialize(): any;
  55074. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55075. }
  55076. }
  55077. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55079. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55080. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55081. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55082. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55083. import { Scene } from "babylonjs/scene";
  55084. /**
  55085. * Class used to store shared data between 2 NodeMaterialBuildState
  55086. */
  55087. export class NodeMaterialBuildStateSharedData {
  55088. /**
  55089. * Gets the list of emitted varyings
  55090. */
  55091. temps: string[];
  55092. /**
  55093. * Gets the list of emitted varyings
  55094. */
  55095. varyings: string[];
  55096. /**
  55097. * Gets the varying declaration string
  55098. */
  55099. varyingDeclaration: string;
  55100. /**
  55101. * Input blocks
  55102. */
  55103. inputBlocks: InputBlock[];
  55104. /**
  55105. * Input blocks
  55106. */
  55107. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55108. /**
  55109. * Bindable blocks (Blocks that need to set data to the effect)
  55110. */
  55111. bindableBlocks: NodeMaterialBlock[];
  55112. /**
  55113. * List of blocks that can provide a compilation fallback
  55114. */
  55115. blocksWithFallbacks: NodeMaterialBlock[];
  55116. /**
  55117. * List of blocks that can provide a define update
  55118. */
  55119. blocksWithDefines: NodeMaterialBlock[];
  55120. /**
  55121. * List of blocks that can provide a repeatable content
  55122. */
  55123. repeatableContentBlocks: NodeMaterialBlock[];
  55124. /**
  55125. * List of blocks that can provide a dynamic list of uniforms
  55126. */
  55127. dynamicUniformBlocks: NodeMaterialBlock[];
  55128. /**
  55129. * List of blocks that can block the isReady function for the material
  55130. */
  55131. blockingBlocks: NodeMaterialBlock[];
  55132. /**
  55133. * Gets the list of animated inputs
  55134. */
  55135. animatedInputs: InputBlock[];
  55136. /**
  55137. * Build Id used to avoid multiple recompilations
  55138. */
  55139. buildId: number;
  55140. /** List of emitted variables */
  55141. variableNames: {
  55142. [key: string]: number;
  55143. };
  55144. /** List of emitted defines */
  55145. defineNames: {
  55146. [key: string]: number;
  55147. };
  55148. /** Should emit comments? */
  55149. emitComments: boolean;
  55150. /** Emit build activity */
  55151. verbose: boolean;
  55152. /** Gets or sets the hosting scene */
  55153. scene: Scene;
  55154. /**
  55155. * Gets the compilation hints emitted at compilation time
  55156. */
  55157. hints: {
  55158. needWorldViewMatrix: boolean;
  55159. needWorldViewProjectionMatrix: boolean;
  55160. needAlphaBlending: boolean;
  55161. needAlphaTesting: boolean;
  55162. };
  55163. /**
  55164. * List of compilation checks
  55165. */
  55166. checks: {
  55167. emitVertex: boolean;
  55168. emitFragment: boolean;
  55169. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55170. };
  55171. /** Creates a new shared data */
  55172. constructor();
  55173. /**
  55174. * Emits console errors and exceptions if there is a failing check
  55175. */
  55176. emitErrors(): void;
  55177. }
  55178. }
  55179. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55180. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55181. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55182. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55183. /**
  55184. * Class used to store node based material build state
  55185. */
  55186. export class NodeMaterialBuildState {
  55187. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55188. supportUniformBuffers: boolean;
  55189. /**
  55190. * Gets the list of emitted attributes
  55191. */
  55192. attributes: string[];
  55193. /**
  55194. * Gets the list of emitted uniforms
  55195. */
  55196. uniforms: string[];
  55197. /**
  55198. * Gets the list of emitted uniform buffers
  55199. */
  55200. uniformBuffers: string[];
  55201. /**
  55202. * Gets the list of emitted samplers
  55203. */
  55204. samplers: string[];
  55205. /**
  55206. * Gets the list of emitted functions
  55207. */
  55208. functions: {
  55209. [key: string]: string;
  55210. };
  55211. /**
  55212. * Gets the list of emitted extensions
  55213. */
  55214. extensions: {
  55215. [key: string]: string;
  55216. };
  55217. /**
  55218. * Gets the target of the compilation state
  55219. */
  55220. target: NodeMaterialBlockTargets;
  55221. /**
  55222. * Gets the list of emitted counters
  55223. */
  55224. counters: {
  55225. [key: string]: number;
  55226. };
  55227. /**
  55228. * Shared data between multiple NodeMaterialBuildState instances
  55229. */
  55230. sharedData: NodeMaterialBuildStateSharedData;
  55231. /** @hidden */
  55232. _vertexState: NodeMaterialBuildState;
  55233. /** @hidden */
  55234. _attributeDeclaration: string;
  55235. /** @hidden */
  55236. _uniformDeclaration: string;
  55237. /** @hidden */
  55238. _samplerDeclaration: string;
  55239. /** @hidden */
  55240. _varyingTransfer: string;
  55241. private _repeatableContentAnchorIndex;
  55242. /** @hidden */
  55243. _builtCompilationString: string;
  55244. /**
  55245. * Gets the emitted compilation strings
  55246. */
  55247. compilationString: string;
  55248. /**
  55249. * Finalize the compilation strings
  55250. * @param state defines the current compilation state
  55251. */
  55252. finalize(state: NodeMaterialBuildState): void;
  55253. /** @hidden */
  55254. readonly _repeatableContentAnchor: string;
  55255. /** @hidden */
  55256. _getFreeVariableName(prefix: string): string;
  55257. /** @hidden */
  55258. _getFreeDefineName(prefix: string): string;
  55259. /** @hidden */
  55260. _excludeVariableName(name: string): void;
  55261. /** @hidden */
  55262. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55263. /** @hidden */
  55264. _emitExtension(name: string, extension: string): void;
  55265. /** @hidden */
  55266. _emitFunction(name: string, code: string, comments: string): void;
  55267. /** @hidden */
  55268. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55269. replaceStrings?: {
  55270. search: RegExp;
  55271. replace: string;
  55272. }[];
  55273. repeatKey?: string;
  55274. }): string;
  55275. /** @hidden */
  55276. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55277. repeatKey?: string;
  55278. removeAttributes?: boolean;
  55279. removeUniforms?: boolean;
  55280. removeVaryings?: boolean;
  55281. removeIfDef?: boolean;
  55282. replaceStrings?: {
  55283. search: RegExp;
  55284. replace: string;
  55285. }[];
  55286. }, storeKey?: string): void;
  55287. /** @hidden */
  55288. _registerTempVariable(name: string): boolean;
  55289. /** @hidden */
  55290. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55291. /** @hidden */
  55292. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55293. }
  55294. }
  55295. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55296. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55297. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55298. import { Nullable } from "babylonjs/types";
  55299. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55300. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55301. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55303. import { Mesh } from "babylonjs/Meshes/mesh";
  55304. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55305. import { Scene } from "babylonjs/scene";
  55306. /**
  55307. * Defines a block that can be used inside a node based material
  55308. */
  55309. export class NodeMaterialBlock {
  55310. private _buildId;
  55311. private _buildTarget;
  55312. private _target;
  55313. private _isFinalMerger;
  55314. private _isInput;
  55315. /** @hidden */
  55316. _codeVariableName: string;
  55317. /** @hidden */
  55318. _inputs: NodeMaterialConnectionPoint[];
  55319. /** @hidden */
  55320. _outputs: NodeMaterialConnectionPoint[];
  55321. /** @hidden */
  55322. _preparationId: number;
  55323. /**
  55324. * Gets or sets the name of the block
  55325. */
  55326. name: string;
  55327. /**
  55328. * Gets or sets the unique id of the node
  55329. */
  55330. uniqueId: number;
  55331. /**
  55332. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55333. */
  55334. readonly isFinalMerger: boolean;
  55335. /**
  55336. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55337. */
  55338. readonly isInput: boolean;
  55339. /**
  55340. * Gets or sets the build Id
  55341. */
  55342. buildId: number;
  55343. /**
  55344. * Gets or sets the target of the block
  55345. */
  55346. target: NodeMaterialBlockTargets;
  55347. /**
  55348. * Gets the list of input points
  55349. */
  55350. readonly inputs: NodeMaterialConnectionPoint[];
  55351. /** Gets the list of output points */
  55352. readonly outputs: NodeMaterialConnectionPoint[];
  55353. /**
  55354. * Find an input by its name
  55355. * @param name defines the name of the input to look for
  55356. * @returns the input or null if not found
  55357. */
  55358. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55359. /**
  55360. * Find an output by its name
  55361. * @param name defines the name of the outputto look for
  55362. * @returns the output or null if not found
  55363. */
  55364. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55365. /**
  55366. * Creates a new NodeMaterialBlock
  55367. * @param name defines the block name
  55368. * @param target defines the target of that block (Vertex by default)
  55369. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55370. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55371. */
  55372. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55373. /**
  55374. * Initialize the block and prepare the context for build
  55375. * @param state defines the state that will be used for the build
  55376. */
  55377. initialize(state: NodeMaterialBuildState): void;
  55378. /**
  55379. * Bind data to effect. Will only be called for blocks with isBindable === true
  55380. * @param effect defines the effect to bind data to
  55381. * @param nodeMaterial defines the hosting NodeMaterial
  55382. * @param mesh defines the mesh that will be rendered
  55383. */
  55384. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55385. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55386. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55387. protected _writeFloat(value: number): string;
  55388. /**
  55389. * Gets the current class name e.g. "NodeMaterialBlock"
  55390. * @returns the class name
  55391. */
  55392. getClassName(): string;
  55393. /**
  55394. * Register a new input. Must be called inside a block constructor
  55395. * @param name defines the connection point name
  55396. * @param type defines the connection point type
  55397. * @param isOptional defines a boolean indicating that this input can be omitted
  55398. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55399. * @returns the current block
  55400. */
  55401. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55402. /**
  55403. * Register a new output. Must be called inside a block constructor
  55404. * @param name defines the connection point name
  55405. * @param type defines the connection point type
  55406. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55407. * @returns the current block
  55408. */
  55409. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55410. /**
  55411. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55412. * @param forOutput defines an optional connection point to check compatibility with
  55413. * @returns the first available input or null
  55414. */
  55415. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55416. /**
  55417. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55418. * @param forBlock defines an optional block to check compatibility with
  55419. * @returns the first available input or null
  55420. */
  55421. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55422. /**
  55423. * Gets the sibling of the given output
  55424. * @param current defines the current output
  55425. * @returns the next output in the list or null
  55426. */
  55427. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55428. /**
  55429. * Connect current block with another block
  55430. * @param other defines the block to connect with
  55431. * @param options define the various options to help pick the right connections
  55432. * @returns the current block
  55433. */
  55434. connectTo(other: NodeMaterialBlock, options?: {
  55435. input?: string;
  55436. output?: string;
  55437. outputSwizzle?: string;
  55438. }): this | undefined;
  55439. protected _buildBlock(state: NodeMaterialBuildState): void;
  55440. /**
  55441. * Add uniforms, samplers and uniform buffers at compilation time
  55442. * @param state defines the state to update
  55443. * @param nodeMaterial defines the node material requesting the update
  55444. * @param defines defines the material defines to update
  55445. */
  55446. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55447. /**
  55448. * Add potential fallbacks if shader compilation fails
  55449. * @param mesh defines the mesh to be rendered
  55450. * @param fallbacks defines the current prioritized list of fallbacks
  55451. */
  55452. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55453. /**
  55454. * Initialize defines for shader compilation
  55455. * @param mesh defines the mesh to be rendered
  55456. * @param nodeMaterial defines the node material requesting the update
  55457. * @param defines defines the material defines to update
  55458. * @param useInstances specifies that instances should be used
  55459. */
  55460. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55461. /**
  55462. * Update defines for shader compilation
  55463. * @param mesh defines the mesh to be rendered
  55464. * @param nodeMaterial defines the node material requesting the update
  55465. * @param defines defines the material defines to update
  55466. * @param useInstances specifies that instances should be used
  55467. */
  55468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55469. /**
  55470. * Lets the block try to connect some inputs automatically
  55471. * @param material defines the hosting NodeMaterial
  55472. */
  55473. autoConfigure(material: NodeMaterial): void;
  55474. /**
  55475. * Function called when a block is declared as repeatable content generator
  55476. * @param vertexShaderState defines the current compilation state for the vertex shader
  55477. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55478. * @param mesh defines the mesh to be rendered
  55479. * @param defines defines the material defines to update
  55480. */
  55481. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55482. /**
  55483. * Checks if the block is ready
  55484. * @param mesh defines the mesh to be rendered
  55485. * @param nodeMaterial defines the node material requesting the update
  55486. * @param defines defines the material defines to update
  55487. * @param useInstances specifies that instances should be used
  55488. * @returns true if the block is ready
  55489. */
  55490. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55491. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55492. private _processBuild;
  55493. /**
  55494. * Compile the current node and generate the shader code
  55495. * @param state defines the current compilation state (uniforms, samplers, current string)
  55496. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55497. * @returns true if already built
  55498. */
  55499. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55500. protected _inputRename(name: string): string;
  55501. protected _outputRename(name: string): string;
  55502. protected _dumpPropertiesCode(): string;
  55503. /** @hidden */
  55504. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55505. /**
  55506. * Clone the current block to a new identical block
  55507. * @param scene defines the hosting scene
  55508. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55509. * @returns a copy of the current block
  55510. */
  55511. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55512. /**
  55513. * Serializes this block in a JSON representation
  55514. * @returns the serialized block object
  55515. */
  55516. serialize(): any;
  55517. /** @hidden */
  55518. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55519. }
  55520. }
  55521. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  55522. /**
  55523. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55524. */
  55525. export enum NodeMaterialBlockConnectionPointMode {
  55526. /** Value is an uniform */
  55527. Uniform = 0,
  55528. /** Value is a mesh attribute */
  55529. Attribute = 1,
  55530. /** Value is a varying between vertex and fragment shaders */
  55531. Varying = 2,
  55532. /** Mode is undefined */
  55533. Undefined = 3
  55534. }
  55535. }
  55536. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55537. /**
  55538. * Enum defining the type of animations supported by InputBlock
  55539. */
  55540. export enum AnimatedInputBlockTypes {
  55541. /** No animation */
  55542. None = 0,
  55543. /** Time based animation. Will only work for floats */
  55544. Time = 1
  55545. }
  55546. }
  55547. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55549. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55550. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/nodeMaterialSystemValues";
  55551. import { Nullable } from "babylonjs/types";
  55552. import { Effect } from "babylonjs/Materials/effect";
  55553. import { Matrix } from "babylonjs/Maths/math.vector";
  55554. import { Scene } from "babylonjs/scene";
  55555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55557. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55558. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55559. /**
  55560. * Block used to expose an input value
  55561. */
  55562. export class InputBlock extends NodeMaterialBlock {
  55563. private _mode;
  55564. private _associatedVariableName;
  55565. private _storedValue;
  55566. private _valueCallback;
  55567. private _type;
  55568. private _animationType;
  55569. /** Gets or set a value used to limit the range of float values */
  55570. min: number;
  55571. /** Gets or set a value used to limit the range of float values */
  55572. max: number;
  55573. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55574. matrixMode: number;
  55575. /** @hidden */
  55576. _systemValue: Nullable<NodeMaterialSystemValues>;
  55577. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55578. visibleInInspector: boolean;
  55579. /**
  55580. * Gets or sets the connection point type (default is float)
  55581. */
  55582. readonly type: NodeMaterialBlockConnectionPointTypes;
  55583. /**
  55584. * Creates a new InputBlock
  55585. * @param name defines the block name
  55586. * @param target defines the target of that block (Vertex by default)
  55587. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55588. */
  55589. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55590. /**
  55591. * Gets the output component
  55592. */
  55593. readonly output: NodeMaterialConnectionPoint;
  55594. /**
  55595. * Set the source of this connection point to a vertex attribute
  55596. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55597. * @returns the current connection point
  55598. */
  55599. setAsAttribute(attributeName?: string): InputBlock;
  55600. /**
  55601. * Set the source of this connection point to a system value
  55602. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55603. * @returns the current connection point
  55604. */
  55605. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55606. /**
  55607. * Gets or sets the value of that point.
  55608. * Please note that this value will be ignored if valueCallback is defined
  55609. */
  55610. value: any;
  55611. /**
  55612. * Gets or sets a callback used to get the value of that point.
  55613. * Please note that setting this value will force the connection point to ignore the value property
  55614. */
  55615. valueCallback: () => any;
  55616. /**
  55617. * Gets or sets the associated variable name in the shader
  55618. */
  55619. associatedVariableName: string;
  55620. /** Gets or sets the type of animation applied to the input */
  55621. animationType: AnimatedInputBlockTypes;
  55622. /**
  55623. * Gets a boolean indicating that this connection point not defined yet
  55624. */
  55625. readonly isUndefined: boolean;
  55626. /**
  55627. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55628. * In this case the connection point name must be the name of the uniform to use.
  55629. * Can only be set on inputs
  55630. */
  55631. isUniform: boolean;
  55632. /**
  55633. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55634. * In this case the connection point name must be the name of the attribute to use
  55635. * Can only be set on inputs
  55636. */
  55637. isAttribute: boolean;
  55638. /**
  55639. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55640. * Can only be set on exit points
  55641. */
  55642. isVarying: boolean;
  55643. /**
  55644. * Gets a boolean indicating that the current connection point is a system value
  55645. */
  55646. readonly isSystemValue: boolean;
  55647. /**
  55648. * Gets or sets the current well known value or null if not defined as a system value
  55649. */
  55650. systemValue: Nullable<NodeMaterialSystemValues>;
  55651. /**
  55652. * Gets the current class name
  55653. * @returns the class name
  55654. */
  55655. getClassName(): string;
  55656. /**
  55657. * Animate the input if animationType !== None
  55658. * @param scene defines the rendering scene
  55659. */
  55660. animate(scene: Scene): void;
  55661. private _emitDefine;
  55662. initialize(state: NodeMaterialBuildState): void;
  55663. /**
  55664. * Set the input block to its default value (based on its type)
  55665. */
  55666. setDefaultValue(): void;
  55667. protected _dumpPropertiesCode(): string;
  55668. private _emit;
  55669. /** @hidden */
  55670. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55671. /** @hidden */
  55672. _transmit(effect: Effect, scene: Scene): void;
  55673. protected _buildBlock(state: NodeMaterialBuildState): void;
  55674. serialize(): any;
  55675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55676. }
  55677. }
  55678. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55679. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55680. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55681. import { Nullable } from "babylonjs/types";
  55682. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55684. /**
  55685. * Defines a connection point for a block
  55686. */
  55687. export class NodeMaterialConnectionPoint {
  55688. /** @hidden */
  55689. _ownerBlock: NodeMaterialBlock;
  55690. /** @hidden */
  55691. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55692. private _endpoints;
  55693. private _associatedVariableName;
  55694. /** @hidden */
  55695. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55696. /** @hidden */
  55697. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55698. private _type;
  55699. /** @hidden */
  55700. _enforceAssociatedVariableName: boolean;
  55701. /**
  55702. * Gets or sets the additional types supported byt this connection point
  55703. */
  55704. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55705. /**
  55706. * Gets or sets the associated variable name in the shader
  55707. */
  55708. associatedVariableName: string;
  55709. /**
  55710. * Gets or sets the connection point type (default is float)
  55711. */
  55712. type: NodeMaterialBlockConnectionPointTypes;
  55713. /**
  55714. * Gets or sets the connection point name
  55715. */
  55716. name: string;
  55717. /**
  55718. * Gets or sets a boolean indicating that this connection point can be omitted
  55719. */
  55720. isOptional: boolean;
  55721. /**
  55722. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55723. */
  55724. define: string;
  55725. /** Gets or sets the target of that connection point */
  55726. target: NodeMaterialBlockTargets;
  55727. /**
  55728. * Gets a boolean indicating that the current point is connected
  55729. */
  55730. readonly isConnected: boolean;
  55731. /**
  55732. * Gets a boolean indicating that the current point is connected to an input block
  55733. */
  55734. readonly isConnectedToInputBlock: boolean;
  55735. /**
  55736. * Gets a the connected input block (if any)
  55737. */
  55738. readonly connectInputBlock: Nullable<InputBlock>;
  55739. /** Get the other side of the connection (if any) */
  55740. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55741. /** Get the block that owns this connection point */
  55742. readonly ownerBlock: NodeMaterialBlock;
  55743. /** Get the block connected on the other side of this connection (if any) */
  55744. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55745. /** Get the block connected on the endpoints of this connection (if any) */
  55746. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55747. /** Gets the list of connected endpoints */
  55748. readonly endpoints: NodeMaterialConnectionPoint[];
  55749. /** Gets a boolean indicating if that output point is connected to at least one input */
  55750. readonly hasEndpoints: boolean;
  55751. /**
  55752. * Creates a new connection point
  55753. * @param name defines the connection point name
  55754. * @param ownerBlock defines the block hosting this connection point
  55755. */
  55756. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55757. /**
  55758. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55759. * @returns the class name
  55760. */
  55761. getClassName(): string;
  55762. /**
  55763. * Gets an boolean indicating if the current point can be connected to another point
  55764. * @param connectionPoint defines the other connection point
  55765. * @returns true if the connection is possible
  55766. */
  55767. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55768. /**
  55769. * Connect this point to another connection point
  55770. * @param connectionPoint defines the other connection point
  55771. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55772. * @returns the current connection point
  55773. */
  55774. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55775. /**
  55776. * Disconnect this point from one of his endpoint
  55777. * @param endpoint defines the other connection point
  55778. * @returns the current connection point
  55779. */
  55780. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55781. /**
  55782. * Serializes this point in a JSON representation
  55783. * @returns the serialized point object
  55784. */
  55785. serialize(): any;
  55786. }
  55787. }
  55788. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55789. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55790. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55792. import { Mesh } from "babylonjs/Meshes/mesh";
  55793. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55794. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55795. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55796. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55797. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55798. /**
  55799. * Block used to add support for vertex skinning (bones)
  55800. */
  55801. export class BonesBlock extends NodeMaterialBlock {
  55802. /**
  55803. * Creates a new BonesBlock
  55804. * @param name defines the block name
  55805. */
  55806. constructor(name: string);
  55807. /**
  55808. * Initialize the block and prepare the context for build
  55809. * @param state defines the state that will be used for the build
  55810. */
  55811. initialize(state: NodeMaterialBuildState): void;
  55812. /**
  55813. * Gets the current class name
  55814. * @returns the class name
  55815. */
  55816. getClassName(): string;
  55817. /**
  55818. * Gets the matrix indices input component
  55819. */
  55820. readonly matricesIndices: NodeMaterialConnectionPoint;
  55821. /**
  55822. * Gets the matrix weights input component
  55823. */
  55824. readonly matricesWeights: NodeMaterialConnectionPoint;
  55825. /**
  55826. * Gets the extra matrix indices input component
  55827. */
  55828. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55829. /**
  55830. * Gets the extra matrix weights input component
  55831. */
  55832. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55833. /**
  55834. * Gets the world input component
  55835. */
  55836. readonly world: NodeMaterialConnectionPoint;
  55837. /**
  55838. * Gets the output component
  55839. */
  55840. readonly output: NodeMaterialConnectionPoint;
  55841. autoConfigure(material: NodeMaterial): void;
  55842. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55845. protected _buildBlock(state: NodeMaterialBuildState): this;
  55846. }
  55847. }
  55848. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55850. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55853. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55854. /**
  55855. * Block used to add support for instances
  55856. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55857. */
  55858. export class InstancesBlock extends NodeMaterialBlock {
  55859. /**
  55860. * Creates a new InstancesBlock
  55861. * @param name defines the block name
  55862. */
  55863. constructor(name: string);
  55864. /**
  55865. * Gets the current class name
  55866. * @returns the class name
  55867. */
  55868. getClassName(): string;
  55869. /**
  55870. * Gets the first world row input component
  55871. */
  55872. readonly world0: NodeMaterialConnectionPoint;
  55873. /**
  55874. * Gets the second world row input component
  55875. */
  55876. readonly world1: NodeMaterialConnectionPoint;
  55877. /**
  55878. * Gets the third world row input component
  55879. */
  55880. readonly world2: NodeMaterialConnectionPoint;
  55881. /**
  55882. * Gets the forth world row input component
  55883. */
  55884. readonly world3: NodeMaterialConnectionPoint;
  55885. /**
  55886. * Gets the world input component
  55887. */
  55888. readonly world: NodeMaterialConnectionPoint;
  55889. /**
  55890. * Gets the output component
  55891. */
  55892. readonly output: NodeMaterialConnectionPoint;
  55893. autoConfigure(material: NodeMaterial): void;
  55894. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55895. protected _buildBlock(state: NodeMaterialBuildState): this;
  55896. }
  55897. }
  55898. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55903. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55904. import { Effect } from "babylonjs/Materials/effect";
  55905. import { Mesh } from "babylonjs/Meshes/mesh";
  55906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55907. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55908. /**
  55909. * Block used to add morph targets support to vertex shader
  55910. */
  55911. export class MorphTargetsBlock extends NodeMaterialBlock {
  55912. private _repeatableContentAnchor;
  55913. private _repeatebleContentGenerated;
  55914. /**
  55915. * Create a new MorphTargetsBlock
  55916. * @param name defines the block name
  55917. */
  55918. constructor(name: string);
  55919. /**
  55920. * Gets the current class name
  55921. * @returns the class name
  55922. */
  55923. getClassName(): string;
  55924. /**
  55925. * Gets the position input component
  55926. */
  55927. readonly position: NodeMaterialConnectionPoint;
  55928. /**
  55929. * Gets the normal input component
  55930. */
  55931. readonly normal: NodeMaterialConnectionPoint;
  55932. /**
  55933. * Gets the tangent input component
  55934. */
  55935. readonly tangent: NodeMaterialConnectionPoint;
  55936. /**
  55937. * Gets the tangent input component
  55938. */
  55939. readonly uv: NodeMaterialConnectionPoint;
  55940. /**
  55941. * Gets the position output component
  55942. */
  55943. readonly positionOutput: NodeMaterialConnectionPoint;
  55944. /**
  55945. * Gets the normal output component
  55946. */
  55947. readonly normalOutput: NodeMaterialConnectionPoint;
  55948. /**
  55949. * Gets the tangent output component
  55950. */
  55951. readonly tangentOutput: NodeMaterialConnectionPoint;
  55952. /**
  55953. * Gets the tangent output component
  55954. */
  55955. readonly uvOutput: NodeMaterialConnectionPoint;
  55956. initialize(state: NodeMaterialBuildState): void;
  55957. autoConfigure(material: NodeMaterial): void;
  55958. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55959. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55960. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55961. protected _buildBlock(state: NodeMaterialBuildState): this;
  55962. }
  55963. }
  55964. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  55965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55968. import { Nullable } from "babylonjs/types";
  55969. import { Scene } from "babylonjs/scene";
  55970. import { Effect } from "babylonjs/Materials/effect";
  55971. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  55972. import { Mesh } from "babylonjs/Meshes/mesh";
  55973. import { Light } from "babylonjs/Lights/light";
  55974. /**
  55975. * Block used to get data information from a light
  55976. */
  55977. export class LightInformationBlock extends NodeMaterialBlock {
  55978. private _lightDataUniformName;
  55979. private _lightColorUniformName;
  55980. /**
  55981. * Gets or sets the light associated with this block
  55982. */
  55983. light: Nullable<Light>;
  55984. /**
  55985. * Creates a new LightInformationBlock
  55986. * @param name defines the block name
  55987. */
  55988. constructor(name: string);
  55989. /**
  55990. * Gets the current class name
  55991. * @returns the class name
  55992. */
  55993. getClassName(): string;
  55994. /**
  55995. * Gets the world position input component
  55996. */
  55997. readonly worldPosition: NodeMaterialConnectionPoint;
  55998. /**
  55999. * Gets the direction output component
  56000. */
  56001. readonly direction: NodeMaterialConnectionPoint;
  56002. /**
  56003. * Gets the direction output component
  56004. */
  56005. readonly color: NodeMaterialConnectionPoint;
  56006. /**
  56007. * Gets the direction output component
  56008. */
  56009. readonly intensity: NodeMaterialConnectionPoint;
  56010. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56011. protected _buildBlock(state: NodeMaterialBuildState): this;
  56012. serialize(): any;
  56013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56014. }
  56015. }
  56016. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56017. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56018. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56019. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56020. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56021. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56022. }
  56023. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  56024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56027. import { Scene } from "babylonjs/scene";
  56028. /**
  56029. * Block used to add an alpha test in the fragment shader
  56030. */
  56031. export class AlphaTestBlock extends NodeMaterialBlock {
  56032. /**
  56033. * Gets or sets the alpha value where alpha testing happens
  56034. */
  56035. alphaCutOff: number;
  56036. /**
  56037. * Create a new AlphaTestBlock
  56038. * @param name defines the block name
  56039. */
  56040. constructor(name: string);
  56041. /**
  56042. * Gets the current class name
  56043. * @returns the class name
  56044. */
  56045. getClassName(): string;
  56046. /**
  56047. * Gets the color input component
  56048. */
  56049. readonly color: NodeMaterialConnectionPoint;
  56050. /**
  56051. * Gets the alpha input component
  56052. */
  56053. readonly alpha: NodeMaterialConnectionPoint;
  56054. protected _buildBlock(state: NodeMaterialBuildState): this;
  56055. protected _dumpPropertiesCode(): string;
  56056. serialize(): any;
  56057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56058. }
  56059. }
  56060. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56065. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56066. import { Effect } from "babylonjs/Materials/effect";
  56067. import { Mesh } from "babylonjs/Meshes/mesh";
  56068. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56069. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56070. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56071. /**
  56072. * Block used to add image processing support to fragment shader
  56073. */
  56074. export class ImageProcessingBlock extends NodeMaterialBlock {
  56075. /**
  56076. * Create a new ImageProcessingBlock
  56077. * @param name defines the block name
  56078. */
  56079. constructor(name: string);
  56080. /**
  56081. * Gets the current class name
  56082. * @returns the class name
  56083. */
  56084. getClassName(): string;
  56085. /**
  56086. * Gets the color input component
  56087. */
  56088. readonly color: NodeMaterialConnectionPoint;
  56089. /**
  56090. * Gets the output component
  56091. */
  56092. readonly output: NodeMaterialConnectionPoint;
  56093. /**
  56094. * Initialize the block and prepare the context for build
  56095. * @param state defines the state that will be used for the build
  56096. */
  56097. initialize(state: NodeMaterialBuildState): void;
  56098. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56099. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56100. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56101. protected _buildBlock(state: NodeMaterialBuildState): this;
  56102. }
  56103. }
  56104. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56108. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56110. import { Effect } from "babylonjs/Materials/effect";
  56111. import { Mesh } from "babylonjs/Meshes/mesh";
  56112. import { Scene } from "babylonjs/scene";
  56113. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56114. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56115. /**
  56116. * Block used to pertub normals based on a normal map
  56117. */
  56118. export class PerturbNormalBlock extends NodeMaterialBlock {
  56119. private _tangentSpaceParameterName;
  56120. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56121. invertX: boolean;
  56122. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56123. invertY: boolean;
  56124. /**
  56125. * Create a new PerturbNormalBlock
  56126. * @param name defines the block name
  56127. */
  56128. constructor(name: string);
  56129. /**
  56130. * Gets the current class name
  56131. * @returns the class name
  56132. */
  56133. getClassName(): string;
  56134. /**
  56135. * Gets the world position input component
  56136. */
  56137. readonly worldPosition: NodeMaterialConnectionPoint;
  56138. /**
  56139. * Gets the world normal input component
  56140. */
  56141. readonly worldNormal: NodeMaterialConnectionPoint;
  56142. /**
  56143. * Gets the uv input component
  56144. */
  56145. readonly uv: NodeMaterialConnectionPoint;
  56146. /**
  56147. * Gets the normal map color input component
  56148. */
  56149. readonly normalMapColor: NodeMaterialConnectionPoint;
  56150. /**
  56151. * Gets the strength input component
  56152. */
  56153. readonly strength: NodeMaterialConnectionPoint;
  56154. /**
  56155. * Gets the output component
  56156. */
  56157. readonly output: NodeMaterialConnectionPoint;
  56158. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56159. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56160. autoConfigure(material: NodeMaterial): void;
  56161. protected _buildBlock(state: NodeMaterialBuildState): this;
  56162. protected _dumpPropertiesCode(): string;
  56163. serialize(): any;
  56164. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56165. }
  56166. }
  56167. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56168. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56169. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  56170. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56171. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56172. }
  56173. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56174. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56175. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56176. import { Mesh } from "babylonjs/Meshes/mesh";
  56177. import { Effect } from "babylonjs/Materials/effect";
  56178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56180. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56181. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56182. /**
  56183. * Block used to add support for scene fog
  56184. */
  56185. export class FogBlock extends NodeMaterialBlock {
  56186. private _fogDistanceName;
  56187. private _fogParameters;
  56188. /**
  56189. * Create a new FogBlock
  56190. * @param name defines the block name
  56191. */
  56192. constructor(name: string);
  56193. /**
  56194. * Gets the current class name
  56195. * @returns the class name
  56196. */
  56197. getClassName(): string;
  56198. /**
  56199. * Gets the world position input component
  56200. */
  56201. readonly worldPosition: NodeMaterialConnectionPoint;
  56202. /**
  56203. * Gets the view input component
  56204. */
  56205. readonly view: NodeMaterialConnectionPoint;
  56206. /**
  56207. * Gets the color input component
  56208. */
  56209. readonly input: NodeMaterialConnectionPoint;
  56210. /**
  56211. * Gets the fog color input component
  56212. */
  56213. readonly fogColor: NodeMaterialConnectionPoint;
  56214. /**
  56215. * Gets the output component
  56216. */
  56217. readonly output: NodeMaterialConnectionPoint;
  56218. autoConfigure(material: NodeMaterial): void;
  56219. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56220. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56221. protected _buildBlock(state: NodeMaterialBuildState): this;
  56222. }
  56223. }
  56224. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56227. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56229. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56230. import { Effect } from "babylonjs/Materials/effect";
  56231. import { Mesh } from "babylonjs/Meshes/mesh";
  56232. import { Light } from "babylonjs/Lights/light";
  56233. import { Nullable } from "babylonjs/types";
  56234. import { Scene } from "babylonjs/scene";
  56235. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56236. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56237. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56238. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56239. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56240. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56241. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56242. /**
  56243. * Block used to add light in the fragment shader
  56244. */
  56245. export class LightBlock extends NodeMaterialBlock {
  56246. private _lightId;
  56247. /**
  56248. * Gets or sets the light associated with this block
  56249. */
  56250. light: Nullable<Light>;
  56251. /**
  56252. * Create a new LightBlock
  56253. * @param name defines the block name
  56254. */
  56255. constructor(name: string);
  56256. /**
  56257. * Gets the current class name
  56258. * @returns the class name
  56259. */
  56260. getClassName(): string;
  56261. /**
  56262. * Gets the world position input component
  56263. */
  56264. readonly worldPosition: NodeMaterialConnectionPoint;
  56265. /**
  56266. * Gets the world normal input component
  56267. */
  56268. readonly worldNormal: NodeMaterialConnectionPoint;
  56269. /**
  56270. * Gets the camera (or eye) position component
  56271. */
  56272. readonly cameraPosition: NodeMaterialConnectionPoint;
  56273. /**
  56274. * Gets the diffuse output component
  56275. */
  56276. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56277. /**
  56278. * Gets the specular output component
  56279. */
  56280. readonly specularOutput: NodeMaterialConnectionPoint;
  56281. autoConfigure(material: NodeMaterial): void;
  56282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56283. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56284. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56285. private _injectVertexCode;
  56286. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56287. serialize(): any;
  56288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56289. }
  56290. }
  56291. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56292. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56293. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56294. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56295. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56296. }
  56297. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56298. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56299. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56300. }
  56301. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56305. /**
  56306. * Block used to multiply 2 values
  56307. */
  56308. export class MultiplyBlock extends NodeMaterialBlock {
  56309. /**
  56310. * Creates a new MultiplyBlock
  56311. * @param name defines the block name
  56312. */
  56313. constructor(name: string);
  56314. /**
  56315. * Gets the current class name
  56316. * @returns the class name
  56317. */
  56318. getClassName(): string;
  56319. /**
  56320. * Gets the left operand input component
  56321. */
  56322. readonly left: NodeMaterialConnectionPoint;
  56323. /**
  56324. * Gets the right operand input component
  56325. */
  56326. readonly right: NodeMaterialConnectionPoint;
  56327. /**
  56328. * Gets the output component
  56329. */
  56330. readonly output: NodeMaterialConnectionPoint;
  56331. protected _buildBlock(state: NodeMaterialBuildState): this;
  56332. }
  56333. }
  56334. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56338. /**
  56339. * Block used to add 2 vectors
  56340. */
  56341. export class AddBlock extends NodeMaterialBlock {
  56342. /**
  56343. * Creates a new AddBlock
  56344. * @param name defines the block name
  56345. */
  56346. constructor(name: string);
  56347. /**
  56348. * Gets the current class name
  56349. * @returns the class name
  56350. */
  56351. getClassName(): string;
  56352. /**
  56353. * Gets the left operand input component
  56354. */
  56355. readonly left: NodeMaterialConnectionPoint;
  56356. /**
  56357. * Gets the right operand input component
  56358. */
  56359. readonly right: NodeMaterialConnectionPoint;
  56360. /**
  56361. * Gets the output component
  56362. */
  56363. readonly output: NodeMaterialConnectionPoint;
  56364. protected _buildBlock(state: NodeMaterialBuildState): this;
  56365. }
  56366. }
  56367. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56370. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56371. /**
  56372. * Block used to scale a vector by a float
  56373. */
  56374. export class ScaleBlock extends NodeMaterialBlock {
  56375. /**
  56376. * Creates a new ScaleBlock
  56377. * @param name defines the block name
  56378. */
  56379. constructor(name: string);
  56380. /**
  56381. * Gets the current class name
  56382. * @returns the class name
  56383. */
  56384. getClassName(): string;
  56385. /**
  56386. * Gets the input component
  56387. */
  56388. readonly input: NodeMaterialConnectionPoint;
  56389. /**
  56390. * Gets the factor input component
  56391. */
  56392. readonly factor: NodeMaterialConnectionPoint;
  56393. /**
  56394. * Gets the output component
  56395. */
  56396. readonly output: NodeMaterialConnectionPoint;
  56397. protected _buildBlock(state: NodeMaterialBuildState): this;
  56398. }
  56399. }
  56400. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56404. import { Scene } from "babylonjs/scene";
  56405. /**
  56406. * Block used to clamp a float
  56407. */
  56408. export class ClampBlock extends NodeMaterialBlock {
  56409. /** Gets or sets the minimum range */
  56410. minimum: number;
  56411. /** Gets or sets the maximum range */
  56412. maximum: number;
  56413. /**
  56414. * Creates a new ClampBlock
  56415. * @param name defines the block name
  56416. */
  56417. constructor(name: string);
  56418. /**
  56419. * Gets the current class name
  56420. * @returns the class name
  56421. */
  56422. getClassName(): string;
  56423. /**
  56424. * Gets the value input component
  56425. */
  56426. readonly value: NodeMaterialConnectionPoint;
  56427. /**
  56428. * Gets the output component
  56429. */
  56430. readonly output: NodeMaterialConnectionPoint;
  56431. protected _buildBlock(state: NodeMaterialBuildState): this;
  56432. protected _dumpPropertiesCode(): string;
  56433. serialize(): any;
  56434. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56435. }
  56436. }
  56437. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56441. /**
  56442. * Block used to apply a cross product between 2 vectors
  56443. */
  56444. export class CrossBlock extends NodeMaterialBlock {
  56445. /**
  56446. * Creates a new CrossBlock
  56447. * @param name defines the block name
  56448. */
  56449. constructor(name: string);
  56450. /**
  56451. * Gets the current class name
  56452. * @returns the class name
  56453. */
  56454. getClassName(): string;
  56455. /**
  56456. * Gets the left operand input component
  56457. */
  56458. readonly left: NodeMaterialConnectionPoint;
  56459. /**
  56460. * Gets the right operand input component
  56461. */
  56462. readonly right: NodeMaterialConnectionPoint;
  56463. /**
  56464. * Gets the output component
  56465. */
  56466. readonly output: NodeMaterialConnectionPoint;
  56467. protected _buildBlock(state: NodeMaterialBuildState): this;
  56468. }
  56469. }
  56470. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56474. /**
  56475. * Block used to apply a dot product between 2 vectors
  56476. */
  56477. export class DotBlock extends NodeMaterialBlock {
  56478. /**
  56479. * Creates a new DotBlock
  56480. * @param name defines the block name
  56481. */
  56482. constructor(name: string);
  56483. /**
  56484. * Gets the current class name
  56485. * @returns the class name
  56486. */
  56487. getClassName(): string;
  56488. /**
  56489. * Gets the left operand input component
  56490. */
  56491. readonly left: NodeMaterialConnectionPoint;
  56492. /**
  56493. * Gets the right operand input component
  56494. */
  56495. readonly right: NodeMaterialConnectionPoint;
  56496. /**
  56497. * Gets the output component
  56498. */
  56499. readonly output: NodeMaterialConnectionPoint;
  56500. protected _buildBlock(state: NodeMaterialBuildState): this;
  56501. }
  56502. }
  56503. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56507. import { Vector2 } from "babylonjs/Maths/math.vector";
  56508. import { Scene } from "babylonjs/scene";
  56509. /**
  56510. * Block used to remap a float from a range to a new one
  56511. */
  56512. export class RemapBlock extends NodeMaterialBlock {
  56513. /**
  56514. * Gets or sets the source range
  56515. */
  56516. sourceRange: Vector2;
  56517. /**
  56518. * Gets or sets the target range
  56519. */
  56520. targetRange: Vector2;
  56521. /**
  56522. * Creates a new RemapBlock
  56523. * @param name defines the block name
  56524. */
  56525. constructor(name: string);
  56526. /**
  56527. * Gets the current class name
  56528. * @returns the class name
  56529. */
  56530. getClassName(): string;
  56531. /**
  56532. * Gets the input component
  56533. */
  56534. readonly input: NodeMaterialConnectionPoint;
  56535. /**
  56536. * Gets the source min input component
  56537. */
  56538. readonly sourceMin: NodeMaterialConnectionPoint;
  56539. /**
  56540. * Gets the source max input component
  56541. */
  56542. readonly sourceMax: NodeMaterialConnectionPoint;
  56543. /**
  56544. * Gets the target min input component
  56545. */
  56546. readonly targetMin: NodeMaterialConnectionPoint;
  56547. /**
  56548. * Gets the target max input component
  56549. */
  56550. readonly targetMax: NodeMaterialConnectionPoint;
  56551. /**
  56552. * Gets the output component
  56553. */
  56554. readonly output: NodeMaterialConnectionPoint;
  56555. protected _buildBlock(state: NodeMaterialBuildState): this;
  56556. protected _dumpPropertiesCode(): string;
  56557. serialize(): any;
  56558. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56559. }
  56560. }
  56561. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56562. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56563. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56565. /**
  56566. * Block used to normalize a vector
  56567. */
  56568. export class NormalizeBlock extends NodeMaterialBlock {
  56569. /**
  56570. * Creates a new NormalizeBlock
  56571. * @param name defines the block name
  56572. */
  56573. constructor(name: string);
  56574. /**
  56575. * Gets the current class name
  56576. * @returns the class name
  56577. */
  56578. getClassName(): string;
  56579. /**
  56580. * Gets the input component
  56581. */
  56582. readonly input: NodeMaterialConnectionPoint;
  56583. /**
  56584. * Gets the output component
  56585. */
  56586. readonly output: NodeMaterialConnectionPoint;
  56587. protected _buildBlock(state: NodeMaterialBuildState): this;
  56588. }
  56589. }
  56590. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56594. import { Scene } from "babylonjs/scene";
  56595. /**
  56596. * Operations supported by the Trigonometry block
  56597. */
  56598. export enum TrigonometryBlockOperations {
  56599. /** Cos */
  56600. Cos = 0,
  56601. /** Sin */
  56602. Sin = 1,
  56603. /** Abs */
  56604. Abs = 2,
  56605. /** Exp */
  56606. Exp = 3,
  56607. /** Exp2 */
  56608. Exp2 = 4,
  56609. /** Round */
  56610. Round = 5,
  56611. /** Floor */
  56612. Floor = 6,
  56613. /** Ceiling */
  56614. Ceiling = 7,
  56615. /** Square root */
  56616. Sqrt = 8
  56617. }
  56618. /**
  56619. * Block used to apply trigonometry operation to floats
  56620. */
  56621. export class TrigonometryBlock extends NodeMaterialBlock {
  56622. /**
  56623. * Gets or sets the operation applied by the block
  56624. */
  56625. operation: TrigonometryBlockOperations;
  56626. /**
  56627. * Creates a new TrigonometryBlock
  56628. * @param name defines the block name
  56629. */
  56630. constructor(name: string);
  56631. /**
  56632. * Gets the current class name
  56633. * @returns the class name
  56634. */
  56635. getClassName(): string;
  56636. /**
  56637. * Gets the input component
  56638. */
  56639. readonly input: NodeMaterialConnectionPoint;
  56640. /**
  56641. * Gets the output component
  56642. */
  56643. readonly output: NodeMaterialConnectionPoint;
  56644. protected _buildBlock(state: NodeMaterialBuildState): this;
  56645. serialize(): any;
  56646. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56647. }
  56648. }
  56649. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56653. /**
  56654. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56655. */
  56656. export class ColorMergerBlock extends NodeMaterialBlock {
  56657. /**
  56658. * Create a new ColorMergerBlock
  56659. * @param name defines the block name
  56660. */
  56661. constructor(name: string);
  56662. /**
  56663. * Gets the current class name
  56664. * @returns the class name
  56665. */
  56666. getClassName(): string;
  56667. /**
  56668. * Gets the r component (input)
  56669. */
  56670. readonly r: NodeMaterialConnectionPoint;
  56671. /**
  56672. * Gets the g component (input)
  56673. */
  56674. readonly g: NodeMaterialConnectionPoint;
  56675. /**
  56676. * Gets the b component (input)
  56677. */
  56678. readonly b: NodeMaterialConnectionPoint;
  56679. /**
  56680. * Gets the a component (input)
  56681. */
  56682. readonly a: NodeMaterialConnectionPoint;
  56683. /**
  56684. * Gets the rgba component (output)
  56685. */
  56686. readonly rgba: NodeMaterialConnectionPoint;
  56687. /**
  56688. * Gets the rgb component (output)
  56689. */
  56690. readonly rgb: NodeMaterialConnectionPoint;
  56691. protected _buildBlock(state: NodeMaterialBuildState): this;
  56692. }
  56693. }
  56694. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56698. /**
  56699. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56700. */
  56701. export class VectorMergerBlock extends NodeMaterialBlock {
  56702. /**
  56703. * Create a new VectorMergerBlock
  56704. * @param name defines the block name
  56705. */
  56706. constructor(name: string);
  56707. /**
  56708. * Gets the current class name
  56709. * @returns the class name
  56710. */
  56711. getClassName(): string;
  56712. /**
  56713. * Gets the x component (input)
  56714. */
  56715. readonly x: NodeMaterialConnectionPoint;
  56716. /**
  56717. * Gets the y component (input)
  56718. */
  56719. readonly y: NodeMaterialConnectionPoint;
  56720. /**
  56721. * Gets the z component (input)
  56722. */
  56723. readonly z: NodeMaterialConnectionPoint;
  56724. /**
  56725. * Gets the w component (input)
  56726. */
  56727. readonly w: NodeMaterialConnectionPoint;
  56728. /**
  56729. * Gets the xyzw component (output)
  56730. */
  56731. readonly xyzw: NodeMaterialConnectionPoint;
  56732. /**
  56733. * Gets the xyz component (output)
  56734. */
  56735. readonly xyz: NodeMaterialConnectionPoint;
  56736. /**
  56737. * Gets the xy component (output)
  56738. */
  56739. readonly xy: NodeMaterialConnectionPoint;
  56740. protected _buildBlock(state: NodeMaterialBuildState): this;
  56741. }
  56742. }
  56743. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56744. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56745. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56747. /**
  56748. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56749. */
  56750. export class ColorSplitterBlock extends NodeMaterialBlock {
  56751. /**
  56752. * Create a new ColorSplitterBlock
  56753. * @param name defines the block name
  56754. */
  56755. constructor(name: string);
  56756. /**
  56757. * Gets the current class name
  56758. * @returns the class name
  56759. */
  56760. getClassName(): string;
  56761. /**
  56762. * Gets the rgba component (input)
  56763. */
  56764. readonly rgba: NodeMaterialConnectionPoint;
  56765. /**
  56766. * Gets the rgb component (input)
  56767. */
  56768. readonly rgbIn: NodeMaterialConnectionPoint;
  56769. /**
  56770. * Gets the rgb component (output)
  56771. */
  56772. readonly rgbOut: NodeMaterialConnectionPoint;
  56773. /**
  56774. * Gets the r component (output)
  56775. */
  56776. readonly r: NodeMaterialConnectionPoint;
  56777. /**
  56778. * Gets the g component (output)
  56779. */
  56780. readonly g: NodeMaterialConnectionPoint;
  56781. /**
  56782. * Gets the b component (output)
  56783. */
  56784. readonly b: NodeMaterialConnectionPoint;
  56785. /**
  56786. * Gets the a component (output)
  56787. */
  56788. readonly a: NodeMaterialConnectionPoint;
  56789. protected _inputRename(name: string): string;
  56790. protected _outputRename(name: string): string;
  56791. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56792. }
  56793. }
  56794. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56798. /**
  56799. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56800. */
  56801. export class VectorSplitterBlock extends NodeMaterialBlock {
  56802. /**
  56803. * Create a new VectorSplitterBlock
  56804. * @param name defines the block name
  56805. */
  56806. constructor(name: string);
  56807. /**
  56808. * Gets the current class name
  56809. * @returns the class name
  56810. */
  56811. getClassName(): string;
  56812. /**
  56813. * Gets the xyzw component (input)
  56814. */
  56815. readonly xyzw: NodeMaterialConnectionPoint;
  56816. /**
  56817. * Gets the xyz component (input)
  56818. */
  56819. readonly xyzIn: NodeMaterialConnectionPoint;
  56820. /**
  56821. * Gets the xy component (input)
  56822. */
  56823. readonly xyIn: NodeMaterialConnectionPoint;
  56824. /**
  56825. * Gets the xyz component (output)
  56826. */
  56827. readonly xyzOut: NodeMaterialConnectionPoint;
  56828. /**
  56829. * Gets the xy component (output)
  56830. */
  56831. readonly xyOut: NodeMaterialConnectionPoint;
  56832. /**
  56833. * Gets the x component (output)
  56834. */
  56835. readonly x: NodeMaterialConnectionPoint;
  56836. /**
  56837. * Gets the y component (output)
  56838. */
  56839. readonly y: NodeMaterialConnectionPoint;
  56840. /**
  56841. * Gets the z component (output)
  56842. */
  56843. readonly z: NodeMaterialConnectionPoint;
  56844. /**
  56845. * Gets the w component (output)
  56846. */
  56847. readonly w: NodeMaterialConnectionPoint;
  56848. protected _inputRename(name: string): string;
  56849. protected _outputRename(name: string): string;
  56850. protected _buildBlock(state: NodeMaterialBuildState): this;
  56851. }
  56852. }
  56853. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56854. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56855. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56856. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56857. /**
  56858. * Block used to lerp 2 values
  56859. */
  56860. export class LerpBlock extends NodeMaterialBlock {
  56861. /**
  56862. * Creates a new LerpBlock
  56863. * @param name defines the block name
  56864. */
  56865. constructor(name: string);
  56866. /**
  56867. * Gets the current class name
  56868. * @returns the class name
  56869. */
  56870. getClassName(): string;
  56871. /**
  56872. * Gets the left operand input component
  56873. */
  56874. readonly left: NodeMaterialConnectionPoint;
  56875. /**
  56876. * Gets the right operand input component
  56877. */
  56878. readonly right: NodeMaterialConnectionPoint;
  56879. /**
  56880. * Gets the gradient operand input component
  56881. */
  56882. readonly gradient: NodeMaterialConnectionPoint;
  56883. /**
  56884. * Gets the output component
  56885. */
  56886. readonly output: NodeMaterialConnectionPoint;
  56887. protected _buildBlock(state: NodeMaterialBuildState): this;
  56888. }
  56889. }
  56890. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56891. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56892. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56893. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56894. /**
  56895. * Block used to divide 2 vectors
  56896. */
  56897. export class DivideBlock extends NodeMaterialBlock {
  56898. /**
  56899. * Creates a new DivideBlock
  56900. * @param name defines the block name
  56901. */
  56902. constructor(name: string);
  56903. /**
  56904. * Gets the current class name
  56905. * @returns the class name
  56906. */
  56907. getClassName(): string;
  56908. /**
  56909. * Gets the left operand input component
  56910. */
  56911. readonly left: NodeMaterialConnectionPoint;
  56912. /**
  56913. * Gets the right operand input component
  56914. */
  56915. readonly right: NodeMaterialConnectionPoint;
  56916. /**
  56917. * Gets the output component
  56918. */
  56919. readonly output: NodeMaterialConnectionPoint;
  56920. protected _buildBlock(state: NodeMaterialBuildState): this;
  56921. }
  56922. }
  56923. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56924. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56925. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56926. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56927. /**
  56928. * Block used to subtract 2 vectors
  56929. */
  56930. export class SubtractBlock extends NodeMaterialBlock {
  56931. /**
  56932. * Creates a new SubtractBlock
  56933. * @param name defines the block name
  56934. */
  56935. constructor(name: string);
  56936. /**
  56937. * Gets the current class name
  56938. * @returns the class name
  56939. */
  56940. getClassName(): string;
  56941. /**
  56942. * Gets the left operand input component
  56943. */
  56944. readonly left: NodeMaterialConnectionPoint;
  56945. /**
  56946. * Gets the right operand input component
  56947. */
  56948. readonly right: NodeMaterialConnectionPoint;
  56949. /**
  56950. * Gets the output component
  56951. */
  56952. readonly output: NodeMaterialConnectionPoint;
  56953. protected _buildBlock(state: NodeMaterialBuildState): this;
  56954. }
  56955. }
  56956. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  56957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56960. /**
  56961. * Block used to step a value
  56962. */
  56963. export class StepBlock extends NodeMaterialBlock {
  56964. /**
  56965. * Creates a new AddBlock
  56966. * @param name defines the block name
  56967. */
  56968. constructor(name: string);
  56969. /**
  56970. * Gets the current class name
  56971. * @returns the class name
  56972. */
  56973. getClassName(): string;
  56974. /**
  56975. * Gets the value operand input component
  56976. */
  56977. readonly value: NodeMaterialConnectionPoint;
  56978. /**
  56979. * Gets the edge operand input component
  56980. */
  56981. readonly edge: NodeMaterialConnectionPoint;
  56982. /**
  56983. * Gets the output component
  56984. */
  56985. readonly output: NodeMaterialConnectionPoint;
  56986. protected _buildBlock(state: NodeMaterialBuildState): this;
  56987. }
  56988. }
  56989. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  56990. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56991. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56993. /**
  56994. * Block used to get the opposite (1 - x) of a value
  56995. */
  56996. export class OneMinusBlock extends NodeMaterialBlock {
  56997. /**
  56998. * Creates a new OneMinusBlock
  56999. * @param name defines the block name
  57000. */
  57001. constructor(name: string);
  57002. /**
  57003. * Gets the current class name
  57004. * @returns the class name
  57005. */
  57006. getClassName(): string;
  57007. /**
  57008. * Gets the input component
  57009. */
  57010. readonly input: NodeMaterialConnectionPoint;
  57011. /**
  57012. * Gets the output component
  57013. */
  57014. readonly output: NodeMaterialConnectionPoint;
  57015. protected _buildBlock(state: NodeMaterialBuildState): this;
  57016. }
  57017. }
  57018. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57020. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57022. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57023. /**
  57024. * Block used to get the view direction
  57025. */
  57026. export class ViewDirectionBlock extends NodeMaterialBlock {
  57027. /**
  57028. * Creates a new ViewDirectionBlock
  57029. * @param name defines the block name
  57030. */
  57031. constructor(name: string);
  57032. /**
  57033. * Gets the current class name
  57034. * @returns the class name
  57035. */
  57036. getClassName(): string;
  57037. /**
  57038. * Gets the world position component
  57039. */
  57040. readonly worldPosition: NodeMaterialConnectionPoint;
  57041. /**
  57042. * Gets the camera position component
  57043. */
  57044. readonly cameraPosition: NodeMaterialConnectionPoint;
  57045. /**
  57046. * Gets the output component
  57047. */
  57048. readonly output: NodeMaterialConnectionPoint;
  57049. autoConfigure(material: NodeMaterial): void;
  57050. protected _buildBlock(state: NodeMaterialBuildState): this;
  57051. }
  57052. }
  57053. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57057. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57058. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57059. /**
  57060. * Block used to compute fresnel value
  57061. */
  57062. export class FresnelBlock extends NodeMaterialBlock {
  57063. /**
  57064. * Create a new FresnelBlock
  57065. * @param name defines the block name
  57066. */
  57067. constructor(name: string);
  57068. /**
  57069. * Gets the current class name
  57070. * @returns the class name
  57071. */
  57072. getClassName(): string;
  57073. /**
  57074. * Gets the world normal input component
  57075. */
  57076. readonly worldNormal: NodeMaterialConnectionPoint;
  57077. /**
  57078. * Gets the view direction input component
  57079. */
  57080. readonly viewDirection: NodeMaterialConnectionPoint;
  57081. /**
  57082. * Gets the bias input component
  57083. */
  57084. readonly bias: NodeMaterialConnectionPoint;
  57085. /**
  57086. * Gets the camera (or eye) position component
  57087. */
  57088. readonly power: NodeMaterialConnectionPoint;
  57089. /**
  57090. * Gets the fresnel output component
  57091. */
  57092. readonly fresnel: NodeMaterialConnectionPoint;
  57093. autoConfigure(material: NodeMaterial): void;
  57094. protected _buildBlock(state: NodeMaterialBuildState): this;
  57095. }
  57096. }
  57097. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57098. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57099. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57100. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57101. /**
  57102. * Block used to get the max of 2 values
  57103. */
  57104. export class MaxBlock extends NodeMaterialBlock {
  57105. /**
  57106. * Creates a new MaxBlock
  57107. * @param name defines the block name
  57108. */
  57109. constructor(name: string);
  57110. /**
  57111. * Gets the current class name
  57112. * @returns the class name
  57113. */
  57114. getClassName(): string;
  57115. /**
  57116. * Gets the left operand input component
  57117. */
  57118. readonly left: NodeMaterialConnectionPoint;
  57119. /**
  57120. * Gets the right operand input component
  57121. */
  57122. readonly right: NodeMaterialConnectionPoint;
  57123. /**
  57124. * Gets the output component
  57125. */
  57126. readonly output: NodeMaterialConnectionPoint;
  57127. protected _buildBlock(state: NodeMaterialBuildState): this;
  57128. }
  57129. }
  57130. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57134. /**
  57135. * Block used to get the min of 2 values
  57136. */
  57137. export class MinBlock extends NodeMaterialBlock {
  57138. /**
  57139. * Creates a new MinBlock
  57140. * @param name defines the block name
  57141. */
  57142. constructor(name: string);
  57143. /**
  57144. * Gets the current class name
  57145. * @returns the class name
  57146. */
  57147. getClassName(): string;
  57148. /**
  57149. * Gets the left operand input component
  57150. */
  57151. readonly left: NodeMaterialConnectionPoint;
  57152. /**
  57153. * Gets the right operand input component
  57154. */
  57155. readonly right: NodeMaterialConnectionPoint;
  57156. /**
  57157. * Gets the output component
  57158. */
  57159. readonly output: NodeMaterialConnectionPoint;
  57160. protected _buildBlock(state: NodeMaterialBuildState): this;
  57161. }
  57162. }
  57163. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57164. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57165. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57166. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57167. /**
  57168. * Block used to get the distance between 2 values
  57169. */
  57170. export class DistanceBlock extends NodeMaterialBlock {
  57171. /**
  57172. * Creates a new DistanceBlock
  57173. * @param name defines the block name
  57174. */
  57175. constructor(name: string);
  57176. /**
  57177. * Gets the current class name
  57178. * @returns the class name
  57179. */
  57180. getClassName(): string;
  57181. /**
  57182. * Gets the left operand input component
  57183. */
  57184. readonly left: NodeMaterialConnectionPoint;
  57185. /**
  57186. * Gets the right operand input component
  57187. */
  57188. readonly right: NodeMaterialConnectionPoint;
  57189. /**
  57190. * Gets the output component
  57191. */
  57192. readonly output: NodeMaterialConnectionPoint;
  57193. protected _buildBlock(state: NodeMaterialBuildState): this;
  57194. }
  57195. }
  57196. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57198. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57200. /**
  57201. * Block used to get the length of a vector
  57202. */
  57203. export class LengthBlock extends NodeMaterialBlock {
  57204. /**
  57205. * Creates a new LengthBlock
  57206. * @param name defines the block name
  57207. */
  57208. constructor(name: string);
  57209. /**
  57210. * Gets the current class name
  57211. * @returns the class name
  57212. */
  57213. getClassName(): string;
  57214. /**
  57215. * Gets the value input component
  57216. */
  57217. readonly value: NodeMaterialConnectionPoint;
  57218. /**
  57219. * Gets the output component
  57220. */
  57221. readonly output: NodeMaterialConnectionPoint;
  57222. protected _buildBlock(state: NodeMaterialBuildState): this;
  57223. }
  57224. }
  57225. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57226. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57227. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57229. /**
  57230. * Block used to get negative version of a value (i.e. x * -1)
  57231. */
  57232. export class NegateBlock extends NodeMaterialBlock {
  57233. /**
  57234. * Creates a new NegateBlock
  57235. * @param name defines the block name
  57236. */
  57237. constructor(name: string);
  57238. /**
  57239. * Gets the current class name
  57240. * @returns the class name
  57241. */
  57242. getClassName(): string;
  57243. /**
  57244. * Gets the value input component
  57245. */
  57246. readonly value: NodeMaterialConnectionPoint;
  57247. /**
  57248. * Gets the output component
  57249. */
  57250. readonly output: NodeMaterialConnectionPoint;
  57251. protected _buildBlock(state: NodeMaterialBuildState): this;
  57252. }
  57253. }
  57254. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57258. /**
  57259. * Block used to get the value of the first parameter raised to the power of the second
  57260. */
  57261. export class PowBlock extends NodeMaterialBlock {
  57262. /**
  57263. * Creates a new PowBlock
  57264. * @param name defines the block name
  57265. */
  57266. constructor(name: string);
  57267. /**
  57268. * Gets the current class name
  57269. * @returns the class name
  57270. */
  57271. getClassName(): string;
  57272. /**
  57273. * Gets the value operand input component
  57274. */
  57275. readonly value: NodeMaterialConnectionPoint;
  57276. /**
  57277. * Gets the power operand input component
  57278. */
  57279. readonly power: NodeMaterialConnectionPoint;
  57280. /**
  57281. * Gets the output component
  57282. */
  57283. readonly output: NodeMaterialConnectionPoint;
  57284. protected _buildBlock(state: NodeMaterialBuildState): this;
  57285. }
  57286. }
  57287. declare module "babylonjs/Materials/Node/Blocks/index" {
  57288. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57289. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57290. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57291. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57292. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57293. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57294. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57295. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57296. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57297. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57298. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57299. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57300. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57301. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57302. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57303. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57304. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57305. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57306. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57307. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57308. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57309. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57310. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57311. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57312. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57313. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57314. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57315. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57316. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57317. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57318. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  57319. }
  57320. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57321. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57322. }
  57323. declare module "babylonjs/Materials/Node/index" {
  57324. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  57325. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  57326. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57327. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57328. export * from "babylonjs/Materials/Node/nodeMaterial";
  57329. export * from "babylonjs/Materials/Node/nodeMaterialSystemValues";
  57330. export * from "babylonjs/Materials/Node/Blocks/index";
  57331. export * from "babylonjs/Materials/Node/Optimizers/index";
  57332. }
  57333. declare module "babylonjs/Materials/effectRenderer" {
  57334. import { Nullable } from "babylonjs/types";
  57335. import { Texture } from "babylonjs/Materials/Textures/texture";
  57336. import { Engine } from "babylonjs/Engines/engine";
  57337. import { Viewport } from "babylonjs/Maths/math.viewport";
  57338. import { Observable } from "babylonjs/Misc/observable";
  57339. import { Effect } from "babylonjs/Materials/effect";
  57340. import "babylonjs/Shaders/postprocess.vertex";
  57341. /**
  57342. * Effect Render Options
  57343. */
  57344. export interface IEffectRendererOptions {
  57345. /**
  57346. * Defines the vertices positions.
  57347. */
  57348. positions?: number[];
  57349. /**
  57350. * Defines the indices.
  57351. */
  57352. indices?: number[];
  57353. }
  57354. /**
  57355. * Helper class to render one or more effects
  57356. */
  57357. export class EffectRenderer {
  57358. private engine;
  57359. private static _DefaultOptions;
  57360. private _vertexBuffers;
  57361. private _indexBuffer;
  57362. private _ringBufferIndex;
  57363. private _ringScreenBuffer;
  57364. private _fullscreenViewport;
  57365. private _getNextFrameBuffer;
  57366. /**
  57367. * Creates an effect renderer
  57368. * @param engine the engine to use for rendering
  57369. * @param options defines the options of the effect renderer
  57370. */
  57371. constructor(engine: Engine, options?: IEffectRendererOptions);
  57372. /**
  57373. * Sets the current viewport in normalized coordinates 0-1
  57374. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57375. */
  57376. setViewport(viewport?: Viewport): void;
  57377. /**
  57378. * Binds the embedded attributes buffer to the effect.
  57379. * @param effect Defines the effect to bind the attributes for
  57380. */
  57381. bindBuffers(effect: Effect): void;
  57382. /**
  57383. * Sets the current effect wrapper to use during draw.
  57384. * The effect needs to be ready before calling this api.
  57385. * This also sets the default full screen position attribute.
  57386. * @param effectWrapper Defines the effect to draw with
  57387. */
  57388. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57389. /**
  57390. * Draws a full screen quad.
  57391. */
  57392. draw(): void;
  57393. /**
  57394. * renders one or more effects to a specified texture
  57395. * @param effectWrappers list of effects to renderer
  57396. * @param outputTexture texture to draw to, if null it will render to the screen
  57397. */
  57398. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57399. /**
  57400. * Disposes of the effect renderer
  57401. */
  57402. dispose(): void;
  57403. }
  57404. /**
  57405. * Options to create an EffectWrapper
  57406. */
  57407. interface EffectWrapperCreationOptions {
  57408. /**
  57409. * Engine to use to create the effect
  57410. */
  57411. engine: Engine;
  57412. /**
  57413. * Fragment shader for the effect
  57414. */
  57415. fragmentShader: string;
  57416. /**
  57417. * Vertex shader for the effect
  57418. */
  57419. vertexShader?: string;
  57420. /**
  57421. * Attributes to use in the shader
  57422. */
  57423. attributeNames?: Array<string>;
  57424. /**
  57425. * Uniforms to use in the shader
  57426. */
  57427. uniformNames?: Array<string>;
  57428. /**
  57429. * Texture sampler names to use in the shader
  57430. */
  57431. samplerNames?: Array<string>;
  57432. /**
  57433. * The friendly name of the effect displayed in Spector.
  57434. */
  57435. name?: string;
  57436. }
  57437. /**
  57438. * Wraps an effect to be used for rendering
  57439. */
  57440. export class EffectWrapper {
  57441. /**
  57442. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57443. */
  57444. onApplyObservable: Observable<{}>;
  57445. /**
  57446. * The underlying effect
  57447. */
  57448. effect: Effect;
  57449. /**
  57450. * Creates an effect to be renderer
  57451. * @param creationOptions options to create the effect
  57452. */
  57453. constructor(creationOptions: EffectWrapperCreationOptions);
  57454. /**
  57455. * Disposes of the effect wrapper
  57456. */
  57457. dispose(): void;
  57458. }
  57459. }
  57460. declare module "babylonjs/Materials/index" {
  57461. export * from "babylonjs/Materials/Background/index";
  57462. export * from "babylonjs/Materials/colorCurves";
  57463. export * from "babylonjs/Materials/effect";
  57464. export * from "babylonjs/Materials/fresnelParameters";
  57465. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57466. export * from "babylonjs/Materials/material";
  57467. export * from "babylonjs/Materials/materialDefines";
  57468. export * from "babylonjs/Materials/materialHelper";
  57469. export * from "babylonjs/Materials/multiMaterial";
  57470. export * from "babylonjs/Materials/PBR/index";
  57471. export * from "babylonjs/Materials/pushMaterial";
  57472. export * from "babylonjs/Materials/shaderMaterial";
  57473. export * from "babylonjs/Materials/standardMaterial";
  57474. export * from "babylonjs/Materials/Textures/index";
  57475. export * from "babylonjs/Materials/uniformBuffer";
  57476. export * from "babylonjs/Materials/materialFlags";
  57477. export * from "babylonjs/Materials/Node/index";
  57478. export * from "babylonjs/Materials/effectRenderer";
  57479. }
  57480. declare module "babylonjs/Maths/index" {
  57481. export * from "babylonjs/Maths/math.scalar";
  57482. export * from "babylonjs/Maths/math";
  57483. export * from "babylonjs/Maths/sphericalPolynomial";
  57484. }
  57485. declare module "babylonjs/Misc/workerPool" {
  57486. import { IDisposable } from "babylonjs/scene";
  57487. /**
  57488. * Helper class to push actions to a pool of workers.
  57489. */
  57490. export class WorkerPool implements IDisposable {
  57491. private _workerInfos;
  57492. private _pendingActions;
  57493. /**
  57494. * Constructor
  57495. * @param workers Array of workers to use for actions
  57496. */
  57497. constructor(workers: Array<Worker>);
  57498. /**
  57499. * Terminates all workers and clears any pending actions.
  57500. */
  57501. dispose(): void;
  57502. /**
  57503. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57504. * pended until a worker has completed its action.
  57505. * @param action The action to perform. Call onComplete when the action is complete.
  57506. */
  57507. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57508. private _execute;
  57509. }
  57510. }
  57511. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57512. import { IDisposable } from "babylonjs/scene";
  57513. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57514. /**
  57515. * Configuration for Draco compression
  57516. */
  57517. export interface IDracoCompressionConfiguration {
  57518. /**
  57519. * Configuration for the decoder.
  57520. */
  57521. decoder: {
  57522. /**
  57523. * The url to the WebAssembly module.
  57524. */
  57525. wasmUrl?: string;
  57526. /**
  57527. * The url to the WebAssembly binary.
  57528. */
  57529. wasmBinaryUrl?: string;
  57530. /**
  57531. * The url to the fallback JavaScript module.
  57532. */
  57533. fallbackUrl?: string;
  57534. };
  57535. }
  57536. /**
  57537. * Draco compression (https://google.github.io/draco/)
  57538. *
  57539. * This class wraps the Draco module.
  57540. *
  57541. * **Encoder**
  57542. *
  57543. * The encoder is not currently implemented.
  57544. *
  57545. * **Decoder**
  57546. *
  57547. * 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.
  57548. *
  57549. * To update the configuration, use the following code:
  57550. * ```javascript
  57551. * DracoCompression.Configuration = {
  57552. * decoder: {
  57553. * wasmUrl: "<url to the WebAssembly library>",
  57554. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57555. * fallbackUrl: "<url to the fallback JavaScript library>",
  57556. * }
  57557. * };
  57558. * ```
  57559. *
  57560. * 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.
  57561. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57562. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57563. *
  57564. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57565. * ```javascript
  57566. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57567. * ```
  57568. *
  57569. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57570. */
  57571. export class DracoCompression implements IDisposable {
  57572. private _workerPoolPromise?;
  57573. private _decoderModulePromise?;
  57574. /**
  57575. * The configuration. Defaults to the following urls:
  57576. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57577. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57578. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57579. */
  57580. static Configuration: IDracoCompressionConfiguration;
  57581. /**
  57582. * Returns true if the decoder configuration is available.
  57583. */
  57584. static readonly DecoderAvailable: boolean;
  57585. /**
  57586. * Default number of workers to create when creating the draco compression object.
  57587. */
  57588. static DefaultNumWorkers: number;
  57589. private static GetDefaultNumWorkers;
  57590. private static _Default;
  57591. /**
  57592. * Default instance for the draco compression object.
  57593. */
  57594. static readonly Default: DracoCompression;
  57595. /**
  57596. * Constructor
  57597. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57598. */
  57599. constructor(numWorkers?: number);
  57600. /**
  57601. * Stop all async operations and release resources.
  57602. */
  57603. dispose(): void;
  57604. /**
  57605. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57606. * @returns a promise that resolves when ready
  57607. */
  57608. whenReadyAsync(): Promise<void>;
  57609. /**
  57610. * Decode Draco compressed mesh data to vertex data.
  57611. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57612. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57613. * @returns A promise that resolves with the decoded vertex data
  57614. */
  57615. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57616. [kind: string]: number;
  57617. }): Promise<VertexData>;
  57618. }
  57619. }
  57620. declare module "babylonjs/Meshes/Compression/index" {
  57621. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57622. }
  57623. declare module "babylonjs/Meshes/csg" {
  57624. import { Nullable } from "babylonjs/types";
  57625. import { Scene } from "babylonjs/scene";
  57626. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57627. import { Mesh } from "babylonjs/Meshes/mesh";
  57628. import { Material } from "babylonjs/Materials/material";
  57629. /**
  57630. * Class for building Constructive Solid Geometry
  57631. */
  57632. export class CSG {
  57633. private polygons;
  57634. /**
  57635. * The world matrix
  57636. */
  57637. matrix: Matrix;
  57638. /**
  57639. * Stores the position
  57640. */
  57641. position: Vector3;
  57642. /**
  57643. * Stores the rotation
  57644. */
  57645. rotation: Vector3;
  57646. /**
  57647. * Stores the rotation quaternion
  57648. */
  57649. rotationQuaternion: Nullable<Quaternion>;
  57650. /**
  57651. * Stores the scaling vector
  57652. */
  57653. scaling: Vector3;
  57654. /**
  57655. * Convert the Mesh to CSG
  57656. * @param mesh The Mesh to convert to CSG
  57657. * @returns A new CSG from the Mesh
  57658. */
  57659. static FromMesh(mesh: Mesh): CSG;
  57660. /**
  57661. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57662. * @param polygons Polygons used to construct a CSG solid
  57663. */
  57664. private static FromPolygons;
  57665. /**
  57666. * Clones, or makes a deep copy, of the CSG
  57667. * @returns A new CSG
  57668. */
  57669. clone(): CSG;
  57670. /**
  57671. * Unions this CSG with another CSG
  57672. * @param csg The CSG to union against this CSG
  57673. * @returns The unioned CSG
  57674. */
  57675. union(csg: CSG): CSG;
  57676. /**
  57677. * Unions this CSG with another CSG in place
  57678. * @param csg The CSG to union against this CSG
  57679. */
  57680. unionInPlace(csg: CSG): void;
  57681. /**
  57682. * Subtracts this CSG with another CSG
  57683. * @param csg The CSG to subtract against this CSG
  57684. * @returns A new CSG
  57685. */
  57686. subtract(csg: CSG): CSG;
  57687. /**
  57688. * Subtracts this CSG with another CSG in place
  57689. * @param csg The CSG to subtact against this CSG
  57690. */
  57691. subtractInPlace(csg: CSG): void;
  57692. /**
  57693. * Intersect this CSG with another CSG
  57694. * @param csg The CSG to intersect against this CSG
  57695. * @returns A new CSG
  57696. */
  57697. intersect(csg: CSG): CSG;
  57698. /**
  57699. * Intersects this CSG with another CSG in place
  57700. * @param csg The CSG to intersect against this CSG
  57701. */
  57702. intersectInPlace(csg: CSG): void;
  57703. /**
  57704. * Return a new CSG solid with solid and empty space switched. This solid is
  57705. * not modified.
  57706. * @returns A new CSG solid with solid and empty space switched
  57707. */
  57708. inverse(): CSG;
  57709. /**
  57710. * Inverses the CSG in place
  57711. */
  57712. inverseInPlace(): void;
  57713. /**
  57714. * This is used to keep meshes transformations so they can be restored
  57715. * when we build back a Babylon Mesh
  57716. * NB : All CSG operations are performed in world coordinates
  57717. * @param csg The CSG to copy the transform attributes from
  57718. * @returns This CSG
  57719. */
  57720. copyTransformAttributes(csg: CSG): CSG;
  57721. /**
  57722. * Build Raw mesh from CSG
  57723. * Coordinates here are in world space
  57724. * @param name The name of the mesh geometry
  57725. * @param scene The Scene
  57726. * @param keepSubMeshes Specifies if the submeshes should be kept
  57727. * @returns A new Mesh
  57728. */
  57729. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57730. /**
  57731. * Build Mesh from CSG taking material and transforms into account
  57732. * @param name The name of the Mesh
  57733. * @param material The material of the Mesh
  57734. * @param scene The Scene
  57735. * @param keepSubMeshes Specifies if submeshes should be kept
  57736. * @returns The new Mesh
  57737. */
  57738. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57739. }
  57740. }
  57741. declare module "babylonjs/Meshes/trailMesh" {
  57742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57743. import { Mesh } from "babylonjs/Meshes/mesh";
  57744. import { Scene } from "babylonjs/scene";
  57745. /**
  57746. * Class used to create a trail following a mesh
  57747. */
  57748. export class TrailMesh extends Mesh {
  57749. private _generator;
  57750. private _autoStart;
  57751. private _running;
  57752. private _diameter;
  57753. private _length;
  57754. private _sectionPolygonPointsCount;
  57755. private _sectionVectors;
  57756. private _sectionNormalVectors;
  57757. private _beforeRenderObserver;
  57758. /**
  57759. * @constructor
  57760. * @param name The value used by scene.getMeshByName() to do a lookup.
  57761. * @param generator The mesh to generate a trail.
  57762. * @param scene The scene to add this mesh to.
  57763. * @param diameter Diameter of trailing mesh. Default is 1.
  57764. * @param length Length of trailing mesh. Default is 60.
  57765. * @param autoStart Automatically start trailing mesh. Default true.
  57766. */
  57767. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57768. /**
  57769. * "TrailMesh"
  57770. * @returns "TrailMesh"
  57771. */
  57772. getClassName(): string;
  57773. private _createMesh;
  57774. /**
  57775. * Start trailing mesh.
  57776. */
  57777. start(): void;
  57778. /**
  57779. * Stop trailing mesh.
  57780. */
  57781. stop(): void;
  57782. /**
  57783. * Update trailing mesh geometry.
  57784. */
  57785. update(): void;
  57786. /**
  57787. * Returns a new TrailMesh object.
  57788. * @param name is a string, the name given to the new mesh
  57789. * @param newGenerator use new generator object for cloned trail mesh
  57790. * @returns a new mesh
  57791. */
  57792. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57793. /**
  57794. * Serializes this trail mesh
  57795. * @param serializationObject object to write serialization to
  57796. */
  57797. serialize(serializationObject: any): void;
  57798. /**
  57799. * Parses a serialized trail mesh
  57800. * @param parsedMesh the serialized mesh
  57801. * @param scene the scene to create the trail mesh in
  57802. * @returns the created trail mesh
  57803. */
  57804. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57805. }
  57806. }
  57807. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57808. import { Nullable } from "babylonjs/types";
  57809. import { Scene } from "babylonjs/scene";
  57810. import { Vector4 } from "babylonjs/Maths/math.vector";
  57811. import { Color4 } from "babylonjs/Maths/math.color";
  57812. import { Mesh } from "babylonjs/Meshes/mesh";
  57813. /**
  57814. * Class containing static functions to help procedurally build meshes
  57815. */
  57816. export class TiledBoxBuilder {
  57817. /**
  57818. * Creates a box mesh
  57819. * 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)
  57820. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57824. * @param name defines the name of the mesh
  57825. * @param options defines the options used to create the mesh
  57826. * @param scene defines the hosting scene
  57827. * @returns the box mesh
  57828. */
  57829. static CreateTiledBox(name: string, options: {
  57830. pattern?: number;
  57831. width?: number;
  57832. height?: number;
  57833. depth?: number;
  57834. tileSize?: number;
  57835. tileWidth?: number;
  57836. tileHeight?: number;
  57837. alignHorizontal?: number;
  57838. alignVertical?: number;
  57839. faceUV?: Vector4[];
  57840. faceColors?: Color4[];
  57841. sideOrientation?: number;
  57842. updatable?: boolean;
  57843. }, scene?: Nullable<Scene>): Mesh;
  57844. }
  57845. }
  57846. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57847. import { Vector4 } from "babylonjs/Maths/math.vector";
  57848. import { Mesh } from "babylonjs/Meshes/mesh";
  57849. /**
  57850. * Class containing static functions to help procedurally build meshes
  57851. */
  57852. export class TorusKnotBuilder {
  57853. /**
  57854. * Creates a torus knot mesh
  57855. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57856. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57857. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57858. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57862. * @param name defines the name of the mesh
  57863. * @param options defines the options used to create the mesh
  57864. * @param scene defines the hosting scene
  57865. * @returns the torus knot mesh
  57866. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57867. */
  57868. static CreateTorusKnot(name: string, options: {
  57869. radius?: number;
  57870. tube?: number;
  57871. radialSegments?: number;
  57872. tubularSegments?: number;
  57873. p?: number;
  57874. q?: number;
  57875. updatable?: boolean;
  57876. sideOrientation?: number;
  57877. frontUVs?: Vector4;
  57878. backUVs?: Vector4;
  57879. }, scene: any): Mesh;
  57880. }
  57881. }
  57882. declare module "babylonjs/Meshes/polygonMesh" {
  57883. import { Scene } from "babylonjs/scene";
  57884. import { Vector2 } from "babylonjs/Maths/math.vector";
  57885. import { Mesh } from "babylonjs/Meshes/mesh";
  57886. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57887. import { Path2 } from "babylonjs/Maths/math.path";
  57888. /**
  57889. * Polygon
  57890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57891. */
  57892. export class Polygon {
  57893. /**
  57894. * Creates a rectangle
  57895. * @param xmin bottom X coord
  57896. * @param ymin bottom Y coord
  57897. * @param xmax top X coord
  57898. * @param ymax top Y coord
  57899. * @returns points that make the resulting rectation
  57900. */
  57901. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57902. /**
  57903. * Creates a circle
  57904. * @param radius radius of circle
  57905. * @param cx scale in x
  57906. * @param cy scale in y
  57907. * @param numberOfSides number of sides that make up the circle
  57908. * @returns points that make the resulting circle
  57909. */
  57910. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57911. /**
  57912. * Creates a polygon from input string
  57913. * @param input Input polygon data
  57914. * @returns the parsed points
  57915. */
  57916. static Parse(input: string): Vector2[];
  57917. /**
  57918. * Starts building a polygon from x and y coordinates
  57919. * @param x x coordinate
  57920. * @param y y coordinate
  57921. * @returns the started path2
  57922. */
  57923. static StartingAt(x: number, y: number): Path2;
  57924. }
  57925. /**
  57926. * Builds a polygon
  57927. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57928. */
  57929. export class PolygonMeshBuilder {
  57930. private _points;
  57931. private _outlinepoints;
  57932. private _holes;
  57933. private _name;
  57934. private _scene;
  57935. private _epoints;
  57936. private _eholes;
  57937. private _addToepoint;
  57938. /**
  57939. * Babylon reference to the earcut plugin.
  57940. */
  57941. bjsEarcut: any;
  57942. /**
  57943. * Creates a PolygonMeshBuilder
  57944. * @param name name of the builder
  57945. * @param contours Path of the polygon
  57946. * @param scene scene to add to when creating the mesh
  57947. * @param earcutInjection can be used to inject your own earcut reference
  57948. */
  57949. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57950. /**
  57951. * Adds a whole within the polygon
  57952. * @param hole Array of points defining the hole
  57953. * @returns this
  57954. */
  57955. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57956. /**
  57957. * Creates the polygon
  57958. * @param updatable If the mesh should be updatable
  57959. * @param depth The depth of the mesh created
  57960. * @returns the created mesh
  57961. */
  57962. build(updatable?: boolean, depth?: number): Mesh;
  57963. /**
  57964. * Creates the polygon
  57965. * @param depth The depth of the mesh created
  57966. * @returns the created VertexData
  57967. */
  57968. buildVertexData(depth?: number): VertexData;
  57969. /**
  57970. * Adds a side to the polygon
  57971. * @param positions points that make the polygon
  57972. * @param normals normals of the polygon
  57973. * @param uvs uvs of the polygon
  57974. * @param indices indices of the polygon
  57975. * @param bounds bounds of the polygon
  57976. * @param points points of the polygon
  57977. * @param depth depth of the polygon
  57978. * @param flip flip of the polygon
  57979. */
  57980. private addSide;
  57981. }
  57982. }
  57983. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57984. import { Scene } from "babylonjs/scene";
  57985. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57986. import { Color4 } from "babylonjs/Maths/math.color";
  57987. import { Mesh } from "babylonjs/Meshes/mesh";
  57988. import { Nullable } from "babylonjs/types";
  57989. /**
  57990. * Class containing static functions to help procedurally build meshes
  57991. */
  57992. export class PolygonBuilder {
  57993. /**
  57994. * Creates a polygon mesh
  57995. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57996. * * 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
  57997. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58000. * * Remember you can only change the shape positions, not their number when updating a polygon
  58001. * @param name defines the name of the mesh
  58002. * @param options defines the options used to create the mesh
  58003. * @param scene defines the hosting scene
  58004. * @param earcutInjection can be used to inject your own earcut reference
  58005. * @returns the polygon mesh
  58006. */
  58007. static CreatePolygon(name: string, options: {
  58008. shape: Vector3[];
  58009. holes?: Vector3[][];
  58010. depth?: number;
  58011. faceUV?: Vector4[];
  58012. faceColors?: Color4[];
  58013. updatable?: boolean;
  58014. sideOrientation?: number;
  58015. frontUVs?: Vector4;
  58016. backUVs?: Vector4;
  58017. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58018. /**
  58019. * Creates an extruded polygon mesh, with depth in the Y direction.
  58020. * * 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)
  58021. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58022. * @param name defines the name of the mesh
  58023. * @param options defines the options used to create the mesh
  58024. * @param scene defines the hosting scene
  58025. * @param earcutInjection can be used to inject your own earcut reference
  58026. * @returns the polygon mesh
  58027. */
  58028. static ExtrudePolygon(name: string, options: {
  58029. shape: Vector3[];
  58030. holes?: Vector3[][];
  58031. depth?: number;
  58032. faceUV?: Vector4[];
  58033. faceColors?: Color4[];
  58034. updatable?: boolean;
  58035. sideOrientation?: number;
  58036. frontUVs?: Vector4;
  58037. backUVs?: Vector4;
  58038. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58039. }
  58040. }
  58041. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58042. import { Scene } from "babylonjs/scene";
  58043. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58044. import { Mesh } from "babylonjs/Meshes/mesh";
  58045. import { Nullable } from "babylonjs/types";
  58046. /**
  58047. * Class containing static functions to help procedurally build meshes
  58048. */
  58049. export class LatheBuilder {
  58050. /**
  58051. * Creates lathe mesh.
  58052. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58053. * * 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
  58054. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58055. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58056. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58057. * * 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
  58058. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58059. * * 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
  58060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58062. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58064. * @param name defines the name of the mesh
  58065. * @param options defines the options used to create the mesh
  58066. * @param scene defines the hosting scene
  58067. * @returns the lathe mesh
  58068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58069. */
  58070. static CreateLathe(name: string, options: {
  58071. shape: Vector3[];
  58072. radius?: number;
  58073. tessellation?: number;
  58074. clip?: number;
  58075. arc?: number;
  58076. closed?: boolean;
  58077. updatable?: boolean;
  58078. sideOrientation?: number;
  58079. frontUVs?: Vector4;
  58080. backUVs?: Vector4;
  58081. cap?: number;
  58082. invertUV?: boolean;
  58083. }, scene?: Nullable<Scene>): Mesh;
  58084. }
  58085. }
  58086. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58087. import { Nullable } from "babylonjs/types";
  58088. import { Scene } from "babylonjs/scene";
  58089. import { Vector4 } from "babylonjs/Maths/math.vector";
  58090. import { Mesh } from "babylonjs/Meshes/mesh";
  58091. /**
  58092. * Class containing static functions to help procedurally build meshes
  58093. */
  58094. export class TiledPlaneBuilder {
  58095. /**
  58096. * Creates a tiled plane mesh
  58097. * * The parameter `pattern` will, depending on value, do nothing or
  58098. * * * flip (reflect about central vertical) alternate tiles across and up
  58099. * * * flip every tile on alternate rows
  58100. * * * rotate (180 degs) alternate tiles across and up
  58101. * * * rotate every tile on alternate rows
  58102. * * * flip and rotate alternate tiles across and up
  58103. * * * flip and rotate every tile on alternate rows
  58104. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58105. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58108. * * 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)
  58109. * * 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)
  58110. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58111. * @param name defines the name of the mesh
  58112. * @param options defines the options used to create the mesh
  58113. * @param scene defines the hosting scene
  58114. * @returns the box mesh
  58115. */
  58116. static CreateTiledPlane(name: string, options: {
  58117. pattern?: number;
  58118. tileSize?: number;
  58119. tileWidth?: number;
  58120. tileHeight?: number;
  58121. size?: number;
  58122. width?: number;
  58123. height?: number;
  58124. alignHorizontal?: number;
  58125. alignVertical?: number;
  58126. sideOrientation?: number;
  58127. frontUVs?: Vector4;
  58128. backUVs?: Vector4;
  58129. updatable?: boolean;
  58130. }, scene?: Nullable<Scene>): Mesh;
  58131. }
  58132. }
  58133. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58134. import { Nullable } from "babylonjs/types";
  58135. import { Scene } from "babylonjs/scene";
  58136. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58137. import { Mesh } from "babylonjs/Meshes/mesh";
  58138. /**
  58139. * Class containing static functions to help procedurally build meshes
  58140. */
  58141. export class TubeBuilder {
  58142. /**
  58143. * Creates a tube mesh.
  58144. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58145. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58146. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58147. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58148. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58149. * * 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)
  58150. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58151. * * 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
  58152. * * 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
  58153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58155. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58157. * @param name defines the name of the mesh
  58158. * @param options defines the options used to create the mesh
  58159. * @param scene defines the hosting scene
  58160. * @returns the tube mesh
  58161. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58162. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58163. */
  58164. static CreateTube(name: string, options: {
  58165. path: Vector3[];
  58166. radius?: number;
  58167. tessellation?: number;
  58168. radiusFunction?: {
  58169. (i: number, distance: number): number;
  58170. };
  58171. cap?: number;
  58172. arc?: number;
  58173. updatable?: boolean;
  58174. sideOrientation?: number;
  58175. frontUVs?: Vector4;
  58176. backUVs?: Vector4;
  58177. instance?: Mesh;
  58178. invertUV?: boolean;
  58179. }, scene?: Nullable<Scene>): Mesh;
  58180. }
  58181. }
  58182. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58183. import { Scene } from "babylonjs/scene";
  58184. import { Vector4 } from "babylonjs/Maths/math.vector";
  58185. import { Mesh } from "babylonjs/Meshes/mesh";
  58186. import { Nullable } from "babylonjs/types";
  58187. /**
  58188. * Class containing static functions to help procedurally build meshes
  58189. */
  58190. export class IcoSphereBuilder {
  58191. /**
  58192. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58193. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58194. * * 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`)
  58195. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58196. * * 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
  58197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58200. * @param name defines the name of the mesh
  58201. * @param options defines the options used to create the mesh
  58202. * @param scene defines the hosting scene
  58203. * @returns the icosahedron mesh
  58204. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58205. */
  58206. static CreateIcoSphere(name: string, options: {
  58207. radius?: number;
  58208. radiusX?: number;
  58209. radiusY?: number;
  58210. radiusZ?: number;
  58211. flat?: boolean;
  58212. subdivisions?: number;
  58213. sideOrientation?: number;
  58214. frontUVs?: Vector4;
  58215. backUVs?: Vector4;
  58216. updatable?: boolean;
  58217. }, scene?: Nullable<Scene>): Mesh;
  58218. }
  58219. }
  58220. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58221. import { Vector3 } from "babylonjs/Maths/math.vector";
  58222. import { Mesh } from "babylonjs/Meshes/mesh";
  58223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58224. /**
  58225. * Class containing static functions to help procedurally build meshes
  58226. */
  58227. export class DecalBuilder {
  58228. /**
  58229. * Creates a decal mesh.
  58230. * 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
  58231. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58232. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58233. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58234. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58235. * @param name defines the name of the mesh
  58236. * @param sourceMesh defines the mesh where the decal must be applied
  58237. * @param options defines the options used to create the mesh
  58238. * @param scene defines the hosting scene
  58239. * @returns the decal mesh
  58240. * @see https://doc.babylonjs.com/how_to/decals
  58241. */
  58242. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58243. position?: Vector3;
  58244. normal?: Vector3;
  58245. size?: Vector3;
  58246. angle?: number;
  58247. }): Mesh;
  58248. }
  58249. }
  58250. declare module "babylonjs/Meshes/meshBuilder" {
  58251. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58252. import { Nullable } from "babylonjs/types";
  58253. import { Scene } from "babylonjs/scene";
  58254. import { Mesh } from "babylonjs/Meshes/mesh";
  58255. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58256. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58258. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58259. import { Plane } from "babylonjs/Maths/math.plane";
  58260. /**
  58261. * Class containing static functions to help procedurally build meshes
  58262. */
  58263. export class MeshBuilder {
  58264. /**
  58265. * Creates a box mesh
  58266. * * The parameter `size` sets the size (float) of each box side (default 1)
  58267. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58268. * * 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)
  58269. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58273. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58274. * @param name defines the name of the mesh
  58275. * @param options defines the options used to create the mesh
  58276. * @param scene defines the hosting scene
  58277. * @returns the box mesh
  58278. */
  58279. static CreateBox(name: string, options: {
  58280. size?: number;
  58281. width?: number;
  58282. height?: number;
  58283. depth?: number;
  58284. faceUV?: Vector4[];
  58285. faceColors?: Color4[];
  58286. sideOrientation?: number;
  58287. frontUVs?: Vector4;
  58288. backUVs?: Vector4;
  58289. updatable?: boolean;
  58290. }, scene?: Nullable<Scene>): Mesh;
  58291. /**
  58292. * Creates a tiled box mesh
  58293. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58295. * @param name defines the name of the mesh
  58296. * @param options defines the options used to create the mesh
  58297. * @param scene defines the hosting scene
  58298. * @returns the tiled box mesh
  58299. */
  58300. static CreateTiledBox(name: string, options: {
  58301. pattern?: number;
  58302. size?: number;
  58303. width?: number;
  58304. height?: number;
  58305. depth: number;
  58306. tileSize?: number;
  58307. tileWidth?: number;
  58308. tileHeight?: number;
  58309. faceUV?: Vector4[];
  58310. faceColors?: Color4[];
  58311. alignHorizontal?: number;
  58312. alignVertical?: number;
  58313. sideOrientation?: number;
  58314. updatable?: boolean;
  58315. }, scene?: Nullable<Scene>): Mesh;
  58316. /**
  58317. * Creates a sphere mesh
  58318. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58319. * * 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`)
  58320. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58321. * * 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
  58322. * * 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)
  58323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58326. * @param name defines the name of the mesh
  58327. * @param options defines the options used to create the mesh
  58328. * @param scene defines the hosting scene
  58329. * @returns the sphere mesh
  58330. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58331. */
  58332. static CreateSphere(name: string, options: {
  58333. segments?: number;
  58334. diameter?: number;
  58335. diameterX?: number;
  58336. diameterY?: number;
  58337. diameterZ?: number;
  58338. arc?: number;
  58339. slice?: number;
  58340. sideOrientation?: number;
  58341. frontUVs?: Vector4;
  58342. backUVs?: Vector4;
  58343. updatable?: boolean;
  58344. }, scene?: Nullable<Scene>): Mesh;
  58345. /**
  58346. * Creates a plane polygonal mesh. By default, this is a disc
  58347. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58348. * * 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
  58349. * * 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
  58350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58353. * @param name defines the name of the mesh
  58354. * @param options defines the options used to create the mesh
  58355. * @param scene defines the hosting scene
  58356. * @returns the plane polygonal mesh
  58357. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58358. */
  58359. static CreateDisc(name: string, options: {
  58360. radius?: number;
  58361. tessellation?: number;
  58362. arc?: number;
  58363. updatable?: boolean;
  58364. sideOrientation?: number;
  58365. frontUVs?: Vector4;
  58366. backUVs?: Vector4;
  58367. }, scene?: Nullable<Scene>): Mesh;
  58368. /**
  58369. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58370. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58371. * * 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`)
  58372. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58373. * * 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
  58374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58377. * @param name defines the name of the mesh
  58378. * @param options defines the options used to create the mesh
  58379. * @param scene defines the hosting scene
  58380. * @returns the icosahedron mesh
  58381. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58382. */
  58383. static CreateIcoSphere(name: string, options: {
  58384. radius?: number;
  58385. radiusX?: number;
  58386. radiusY?: number;
  58387. radiusZ?: number;
  58388. flat?: boolean;
  58389. subdivisions?: number;
  58390. sideOrientation?: number;
  58391. frontUVs?: Vector4;
  58392. backUVs?: Vector4;
  58393. updatable?: boolean;
  58394. }, scene?: Nullable<Scene>): Mesh;
  58395. /**
  58396. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58397. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58398. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58399. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58400. * * 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
  58401. * * 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
  58402. * * 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
  58403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58405. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58406. * * 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
  58407. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58408. * * 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
  58409. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58411. * @param name defines the name of the mesh
  58412. * @param options defines the options used to create the mesh
  58413. * @param scene defines the hosting scene
  58414. * @returns the ribbon mesh
  58415. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58417. */
  58418. static CreateRibbon(name: string, options: {
  58419. pathArray: Vector3[][];
  58420. closeArray?: boolean;
  58421. closePath?: boolean;
  58422. offset?: number;
  58423. updatable?: boolean;
  58424. sideOrientation?: number;
  58425. frontUVs?: Vector4;
  58426. backUVs?: Vector4;
  58427. instance?: Mesh;
  58428. invertUV?: boolean;
  58429. uvs?: Vector2[];
  58430. colors?: Color4[];
  58431. }, scene?: Nullable<Scene>): Mesh;
  58432. /**
  58433. * Creates a cylinder or a cone mesh
  58434. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58435. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58436. * * 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.
  58437. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58438. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58439. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58440. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58441. * * 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).
  58442. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58443. * * 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).
  58444. * * 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
  58445. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58446. * * 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
  58447. * * 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.
  58448. * * If `enclose` is false, a ring surface is one element.
  58449. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58450. * * 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
  58451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58454. * @param name defines the name of the mesh
  58455. * @param options defines the options used to create the mesh
  58456. * @param scene defines the hosting scene
  58457. * @returns the cylinder mesh
  58458. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58459. */
  58460. static CreateCylinder(name: string, options: {
  58461. height?: number;
  58462. diameterTop?: number;
  58463. diameterBottom?: number;
  58464. diameter?: number;
  58465. tessellation?: number;
  58466. subdivisions?: number;
  58467. arc?: number;
  58468. faceColors?: Color4[];
  58469. faceUV?: Vector4[];
  58470. updatable?: boolean;
  58471. hasRings?: boolean;
  58472. enclose?: boolean;
  58473. cap?: number;
  58474. sideOrientation?: number;
  58475. frontUVs?: Vector4;
  58476. backUVs?: Vector4;
  58477. }, scene?: Nullable<Scene>): Mesh;
  58478. /**
  58479. * Creates a torus mesh
  58480. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58481. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58482. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58486. * @param name defines the name of the mesh
  58487. * @param options defines the options used to create the mesh
  58488. * @param scene defines the hosting scene
  58489. * @returns the torus mesh
  58490. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58491. */
  58492. static CreateTorus(name: string, options: {
  58493. diameter?: number;
  58494. thickness?: number;
  58495. tessellation?: number;
  58496. updatable?: boolean;
  58497. sideOrientation?: number;
  58498. frontUVs?: Vector4;
  58499. backUVs?: Vector4;
  58500. }, scene?: Nullable<Scene>): Mesh;
  58501. /**
  58502. * Creates a torus knot mesh
  58503. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58504. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58505. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58506. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58510. * @param name defines the name of the mesh
  58511. * @param options defines the options used to create the mesh
  58512. * @param scene defines the hosting scene
  58513. * @returns the torus knot mesh
  58514. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58515. */
  58516. static CreateTorusKnot(name: string, options: {
  58517. radius?: number;
  58518. tube?: number;
  58519. radialSegments?: number;
  58520. tubularSegments?: number;
  58521. p?: number;
  58522. q?: number;
  58523. updatable?: boolean;
  58524. sideOrientation?: number;
  58525. frontUVs?: Vector4;
  58526. backUVs?: Vector4;
  58527. }, scene?: Nullable<Scene>): Mesh;
  58528. /**
  58529. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58530. * * 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
  58531. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58532. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58533. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58534. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58535. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58536. * * 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
  58537. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58540. * @param name defines the name of the new line system
  58541. * @param options defines the options used to create the line system
  58542. * @param scene defines the hosting scene
  58543. * @returns a new line system mesh
  58544. */
  58545. static CreateLineSystem(name: string, options: {
  58546. lines: Vector3[][];
  58547. updatable?: boolean;
  58548. instance?: Nullable<LinesMesh>;
  58549. colors?: Nullable<Color4[][]>;
  58550. useVertexAlpha?: boolean;
  58551. }, scene: Nullable<Scene>): LinesMesh;
  58552. /**
  58553. * Creates a line mesh
  58554. * 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
  58555. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58556. * * The parameter `points` is an array successive Vector3
  58557. * * 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
  58558. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58559. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58560. * * When updating an instance, remember that only point positions can change, not the number of points
  58561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58563. * @param name defines the name of the new line system
  58564. * @param options defines the options used to create the line system
  58565. * @param scene defines the hosting scene
  58566. * @returns a new line mesh
  58567. */
  58568. static CreateLines(name: string, options: {
  58569. points: Vector3[];
  58570. updatable?: boolean;
  58571. instance?: Nullable<LinesMesh>;
  58572. colors?: Color4[];
  58573. useVertexAlpha?: boolean;
  58574. }, scene?: Nullable<Scene>): LinesMesh;
  58575. /**
  58576. * Creates a dashed line mesh
  58577. * * 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
  58578. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58579. * * The parameter `points` is an array successive Vector3
  58580. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58581. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58582. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58583. * * 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
  58584. * * When updating an instance, remember that only point positions can change, not the number of points
  58585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58586. * @param name defines the name of the mesh
  58587. * @param options defines the options used to create the mesh
  58588. * @param scene defines the hosting scene
  58589. * @returns the dashed line mesh
  58590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58591. */
  58592. static CreateDashedLines(name: string, options: {
  58593. points: Vector3[];
  58594. dashSize?: number;
  58595. gapSize?: number;
  58596. dashNb?: number;
  58597. updatable?: boolean;
  58598. instance?: LinesMesh;
  58599. }, scene?: Nullable<Scene>): LinesMesh;
  58600. /**
  58601. * 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.
  58602. * * 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.
  58603. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58604. * * 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.
  58605. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58606. * * 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
  58607. * * 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
  58608. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58611. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58613. * @param name defines the name of the mesh
  58614. * @param options defines the options used to create the mesh
  58615. * @param scene defines the hosting scene
  58616. * @returns the extruded shape mesh
  58617. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58619. */
  58620. static ExtrudeShape(name: string, options: {
  58621. shape: Vector3[];
  58622. path: Vector3[];
  58623. scale?: number;
  58624. rotation?: number;
  58625. cap?: number;
  58626. updatable?: boolean;
  58627. sideOrientation?: number;
  58628. frontUVs?: Vector4;
  58629. backUVs?: Vector4;
  58630. instance?: Mesh;
  58631. invertUV?: boolean;
  58632. }, scene?: Nullable<Scene>): Mesh;
  58633. /**
  58634. * Creates an custom extruded shape mesh.
  58635. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58636. * * 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.
  58637. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58638. * * 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
  58639. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58640. * * 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
  58641. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58642. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58643. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58644. * * 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
  58645. * * 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
  58646. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58648. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58649. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58651. * @param name defines the name of the mesh
  58652. * @param options defines the options used to create the mesh
  58653. * @param scene defines the hosting scene
  58654. * @returns the custom extruded shape mesh
  58655. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58656. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58658. */
  58659. static ExtrudeShapeCustom(name: string, options: {
  58660. shape: Vector3[];
  58661. path: Vector3[];
  58662. scaleFunction?: any;
  58663. rotationFunction?: any;
  58664. ribbonCloseArray?: boolean;
  58665. ribbonClosePath?: boolean;
  58666. cap?: number;
  58667. updatable?: boolean;
  58668. sideOrientation?: number;
  58669. frontUVs?: Vector4;
  58670. backUVs?: Vector4;
  58671. instance?: Mesh;
  58672. invertUV?: boolean;
  58673. }, scene?: Nullable<Scene>): Mesh;
  58674. /**
  58675. * Creates lathe mesh.
  58676. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58677. * * 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
  58678. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58679. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58680. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58681. * * 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
  58682. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58683. * * 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
  58684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58686. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58688. * @param name defines the name of the mesh
  58689. * @param options defines the options used to create the mesh
  58690. * @param scene defines the hosting scene
  58691. * @returns the lathe mesh
  58692. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58693. */
  58694. static CreateLathe(name: string, options: {
  58695. shape: Vector3[];
  58696. radius?: number;
  58697. tessellation?: number;
  58698. clip?: number;
  58699. arc?: number;
  58700. closed?: boolean;
  58701. updatable?: boolean;
  58702. sideOrientation?: number;
  58703. frontUVs?: Vector4;
  58704. backUVs?: Vector4;
  58705. cap?: number;
  58706. invertUV?: boolean;
  58707. }, scene?: Nullable<Scene>): Mesh;
  58708. /**
  58709. * Creates a tiled plane mesh
  58710. * * You can set a limited pattern arrangement with the tiles
  58711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58714. * @param name defines the name of the mesh
  58715. * @param options defines the options used to create the mesh
  58716. * @param scene defines the hosting scene
  58717. * @returns the plane mesh
  58718. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58719. */
  58720. static CreateTiledPlane(name: string, options: {
  58721. pattern?: number;
  58722. tileSize?: number;
  58723. tileWidth?: number;
  58724. tileHeight?: number;
  58725. size?: number;
  58726. width?: number;
  58727. height?: number;
  58728. alignHorizontal?: number;
  58729. alignVertical?: number;
  58730. sideOrientation?: number;
  58731. frontUVs?: Vector4;
  58732. backUVs?: Vector4;
  58733. updatable?: boolean;
  58734. }, scene?: Nullable<Scene>): Mesh;
  58735. /**
  58736. * Creates a plane mesh
  58737. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58738. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58739. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58743. * @param name defines the name of the mesh
  58744. * @param options defines the options used to create the mesh
  58745. * @param scene defines the hosting scene
  58746. * @returns the plane mesh
  58747. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58748. */
  58749. static CreatePlane(name: string, options: {
  58750. size?: number;
  58751. width?: number;
  58752. height?: number;
  58753. sideOrientation?: number;
  58754. frontUVs?: Vector4;
  58755. backUVs?: Vector4;
  58756. updatable?: boolean;
  58757. sourcePlane?: Plane;
  58758. }, scene?: Nullable<Scene>): Mesh;
  58759. /**
  58760. * Creates a ground mesh
  58761. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58762. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58764. * @param name defines the name of the mesh
  58765. * @param options defines the options used to create the mesh
  58766. * @param scene defines the hosting scene
  58767. * @returns the ground mesh
  58768. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58769. */
  58770. static CreateGround(name: string, options: {
  58771. width?: number;
  58772. height?: number;
  58773. subdivisions?: number;
  58774. subdivisionsX?: number;
  58775. subdivisionsY?: number;
  58776. updatable?: boolean;
  58777. }, scene?: Nullable<Scene>): Mesh;
  58778. /**
  58779. * Creates a tiled ground mesh
  58780. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58781. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58782. * * 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
  58783. * * 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
  58784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58785. * @param name defines the name of the mesh
  58786. * @param options defines the options used to create the mesh
  58787. * @param scene defines the hosting scene
  58788. * @returns the tiled ground mesh
  58789. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58790. */
  58791. static CreateTiledGround(name: string, options: {
  58792. xmin: number;
  58793. zmin: number;
  58794. xmax: number;
  58795. zmax: number;
  58796. subdivisions?: {
  58797. w: number;
  58798. h: number;
  58799. };
  58800. precision?: {
  58801. w: number;
  58802. h: number;
  58803. };
  58804. updatable?: boolean;
  58805. }, scene?: Nullable<Scene>): Mesh;
  58806. /**
  58807. * Creates a ground mesh from a height map
  58808. * * The parameter `url` sets the URL of the height map image resource.
  58809. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58810. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58811. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58812. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58813. * * 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.
  58814. * * 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).
  58815. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58817. * @param name defines the name of the mesh
  58818. * @param url defines the url to the height map
  58819. * @param options defines the options used to create the mesh
  58820. * @param scene defines the hosting scene
  58821. * @returns the ground mesh
  58822. * @see https://doc.babylonjs.com/babylon101/height_map
  58823. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58824. */
  58825. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58826. width?: number;
  58827. height?: number;
  58828. subdivisions?: number;
  58829. minHeight?: number;
  58830. maxHeight?: number;
  58831. colorFilter?: Color3;
  58832. alphaFilter?: number;
  58833. updatable?: boolean;
  58834. onReady?: (mesh: GroundMesh) => void;
  58835. }, scene?: Nullable<Scene>): GroundMesh;
  58836. /**
  58837. * Creates a polygon mesh
  58838. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58839. * * 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
  58840. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58843. * * Remember you can only change the shape positions, not their number when updating a polygon
  58844. * @param name defines the name of the mesh
  58845. * @param options defines the options used to create the mesh
  58846. * @param scene defines the hosting scene
  58847. * @param earcutInjection can be used to inject your own earcut reference
  58848. * @returns the polygon mesh
  58849. */
  58850. static CreatePolygon(name: string, options: {
  58851. shape: Vector3[];
  58852. holes?: Vector3[][];
  58853. depth?: number;
  58854. faceUV?: Vector4[];
  58855. faceColors?: Color4[];
  58856. updatable?: boolean;
  58857. sideOrientation?: number;
  58858. frontUVs?: Vector4;
  58859. backUVs?: Vector4;
  58860. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58861. /**
  58862. * Creates an extruded polygon mesh, with depth in the Y direction.
  58863. * * 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)
  58864. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58865. * @param name defines the name of the mesh
  58866. * @param options defines the options used to create the mesh
  58867. * @param scene defines the hosting scene
  58868. * @param earcutInjection can be used to inject your own earcut reference
  58869. * @returns the polygon mesh
  58870. */
  58871. static ExtrudePolygon(name: string, options: {
  58872. shape: Vector3[];
  58873. holes?: Vector3[][];
  58874. depth?: number;
  58875. faceUV?: Vector4[];
  58876. faceColors?: Color4[];
  58877. updatable?: boolean;
  58878. sideOrientation?: number;
  58879. frontUVs?: Vector4;
  58880. backUVs?: Vector4;
  58881. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58882. /**
  58883. * Creates a tube mesh.
  58884. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58885. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58886. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58887. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58888. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58889. * * 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)
  58890. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58891. * * 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
  58892. * * 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
  58893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58895. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58897. * @param name defines the name of the mesh
  58898. * @param options defines the options used to create the mesh
  58899. * @param scene defines the hosting scene
  58900. * @returns the tube mesh
  58901. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58902. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58903. */
  58904. static CreateTube(name: string, options: {
  58905. path: Vector3[];
  58906. radius?: number;
  58907. tessellation?: number;
  58908. radiusFunction?: {
  58909. (i: number, distance: number): number;
  58910. };
  58911. cap?: number;
  58912. arc?: number;
  58913. updatable?: boolean;
  58914. sideOrientation?: number;
  58915. frontUVs?: Vector4;
  58916. backUVs?: Vector4;
  58917. instance?: Mesh;
  58918. invertUV?: boolean;
  58919. }, scene?: Nullable<Scene>): Mesh;
  58920. /**
  58921. * Creates a polyhedron mesh
  58922. * * 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
  58923. * * The parameter `size` (positive float, default 1) sets the polygon size
  58924. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58925. * * 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`
  58926. * * 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
  58927. * * 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)`)
  58928. * * 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
  58929. * * 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
  58930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58933. * @param name defines the name of the mesh
  58934. * @param options defines the options used to create the mesh
  58935. * @param scene defines the hosting scene
  58936. * @returns the polyhedron mesh
  58937. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58938. */
  58939. static CreatePolyhedron(name: string, options: {
  58940. type?: number;
  58941. size?: number;
  58942. sizeX?: number;
  58943. sizeY?: number;
  58944. sizeZ?: number;
  58945. custom?: any;
  58946. faceUV?: Vector4[];
  58947. faceColors?: Color4[];
  58948. flat?: boolean;
  58949. updatable?: boolean;
  58950. sideOrientation?: number;
  58951. frontUVs?: Vector4;
  58952. backUVs?: Vector4;
  58953. }, scene?: Nullable<Scene>): Mesh;
  58954. /**
  58955. * Creates a decal mesh.
  58956. * 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
  58957. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58958. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58959. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58960. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58961. * @param name defines the name of the mesh
  58962. * @param sourceMesh defines the mesh where the decal must be applied
  58963. * @param options defines the options used to create the mesh
  58964. * @param scene defines the hosting scene
  58965. * @returns the decal mesh
  58966. * @see https://doc.babylonjs.com/how_to/decals
  58967. */
  58968. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58969. position?: Vector3;
  58970. normal?: Vector3;
  58971. size?: Vector3;
  58972. angle?: number;
  58973. }): Mesh;
  58974. }
  58975. }
  58976. declare module "babylonjs/Meshes/meshSimplification" {
  58977. import { Mesh } from "babylonjs/Meshes/mesh";
  58978. /**
  58979. * A simplifier interface for future simplification implementations
  58980. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58981. */
  58982. export interface ISimplifier {
  58983. /**
  58984. * Simplification of a given mesh according to the given settings.
  58985. * Since this requires computation, it is assumed that the function runs async.
  58986. * @param settings The settings of the simplification, including quality and distance
  58987. * @param successCallback A callback that will be called after the mesh was simplified.
  58988. * @param errorCallback in case of an error, this callback will be called. optional.
  58989. */
  58990. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58991. }
  58992. /**
  58993. * Expected simplification settings.
  58994. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58995. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58996. */
  58997. export interface ISimplificationSettings {
  58998. /**
  58999. * Gets or sets the expected quality
  59000. */
  59001. quality: number;
  59002. /**
  59003. * Gets or sets the distance when this optimized version should be used
  59004. */
  59005. distance: number;
  59006. /**
  59007. * Gets an already optimized mesh
  59008. */
  59009. optimizeMesh?: boolean;
  59010. }
  59011. /**
  59012. * Class used to specify simplification options
  59013. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59014. */
  59015. export class SimplificationSettings implements ISimplificationSettings {
  59016. /** expected quality */
  59017. quality: number;
  59018. /** distance when this optimized version should be used */
  59019. distance: number;
  59020. /** already optimized mesh */
  59021. optimizeMesh?: boolean | undefined;
  59022. /**
  59023. * Creates a SimplificationSettings
  59024. * @param quality expected quality
  59025. * @param distance distance when this optimized version should be used
  59026. * @param optimizeMesh already optimized mesh
  59027. */
  59028. constructor(
  59029. /** expected quality */
  59030. quality: number,
  59031. /** distance when this optimized version should be used */
  59032. distance: number,
  59033. /** already optimized mesh */
  59034. optimizeMesh?: boolean | undefined);
  59035. }
  59036. /**
  59037. * Interface used to define a simplification task
  59038. */
  59039. export interface ISimplificationTask {
  59040. /**
  59041. * Array of settings
  59042. */
  59043. settings: Array<ISimplificationSettings>;
  59044. /**
  59045. * Simplification type
  59046. */
  59047. simplificationType: SimplificationType;
  59048. /**
  59049. * Mesh to simplify
  59050. */
  59051. mesh: Mesh;
  59052. /**
  59053. * Callback called on success
  59054. */
  59055. successCallback?: () => void;
  59056. /**
  59057. * Defines if parallel processing can be used
  59058. */
  59059. parallelProcessing: boolean;
  59060. }
  59061. /**
  59062. * Queue used to order the simplification tasks
  59063. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59064. */
  59065. export class SimplificationQueue {
  59066. private _simplificationArray;
  59067. /**
  59068. * Gets a boolean indicating that the process is still running
  59069. */
  59070. running: boolean;
  59071. /**
  59072. * Creates a new queue
  59073. */
  59074. constructor();
  59075. /**
  59076. * Adds a new simplification task
  59077. * @param task defines a task to add
  59078. */
  59079. addTask(task: ISimplificationTask): void;
  59080. /**
  59081. * Execute next task
  59082. */
  59083. executeNext(): void;
  59084. /**
  59085. * Execute a simplification task
  59086. * @param task defines the task to run
  59087. */
  59088. runSimplification(task: ISimplificationTask): void;
  59089. private getSimplifier;
  59090. }
  59091. /**
  59092. * The implemented types of simplification
  59093. * At the moment only Quadratic Error Decimation is implemented
  59094. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59095. */
  59096. export enum SimplificationType {
  59097. /** Quadratic error decimation */
  59098. QUADRATIC = 0
  59099. }
  59100. }
  59101. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59102. import { Scene } from "babylonjs/scene";
  59103. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59104. import { ISceneComponent } from "babylonjs/sceneComponent";
  59105. module "babylonjs/scene" {
  59106. interface Scene {
  59107. /** @hidden (Backing field) */
  59108. _simplificationQueue: SimplificationQueue;
  59109. /**
  59110. * Gets or sets the simplification queue attached to the scene
  59111. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59112. */
  59113. simplificationQueue: SimplificationQueue;
  59114. }
  59115. }
  59116. module "babylonjs/Meshes/mesh" {
  59117. interface Mesh {
  59118. /**
  59119. * Simplify the mesh according to the given array of settings.
  59120. * Function will return immediately and will simplify async
  59121. * @param settings a collection of simplification settings
  59122. * @param parallelProcessing should all levels calculate parallel or one after the other
  59123. * @param simplificationType the type of simplification to run
  59124. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59125. * @returns the current mesh
  59126. */
  59127. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59128. }
  59129. }
  59130. /**
  59131. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59132. * created in a scene
  59133. */
  59134. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59135. /**
  59136. * The component name helpfull to identify the component in the list of scene components.
  59137. */
  59138. readonly name: string;
  59139. /**
  59140. * The scene the component belongs to.
  59141. */
  59142. scene: Scene;
  59143. /**
  59144. * Creates a new instance of the component for the given scene
  59145. * @param scene Defines the scene to register the component in
  59146. */
  59147. constructor(scene: Scene);
  59148. /**
  59149. * Registers the component in a given scene
  59150. */
  59151. register(): void;
  59152. /**
  59153. * Rebuilds the elements related to this component in case of
  59154. * context lost for instance.
  59155. */
  59156. rebuild(): void;
  59157. /**
  59158. * Disposes the component and the associated ressources
  59159. */
  59160. dispose(): void;
  59161. private _beforeCameraUpdate;
  59162. }
  59163. }
  59164. declare module "babylonjs/Meshes/Builders/index" {
  59165. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59166. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59167. export * from "babylonjs/Meshes/Builders/discBuilder";
  59168. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59169. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59170. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59171. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59172. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59173. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59174. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59175. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59176. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59177. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59178. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59179. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59180. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59181. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59182. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59183. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59184. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59185. }
  59186. declare module "babylonjs/Meshes/index" {
  59187. export * from "babylonjs/Meshes/abstractMesh";
  59188. export * from "babylonjs/Meshes/buffer";
  59189. export * from "babylonjs/Meshes/Compression/index";
  59190. export * from "babylonjs/Meshes/csg";
  59191. export * from "babylonjs/Meshes/geometry";
  59192. export * from "babylonjs/Meshes/groundMesh";
  59193. export * from "babylonjs/Meshes/trailMesh";
  59194. export * from "babylonjs/Meshes/instancedMesh";
  59195. export * from "babylonjs/Meshes/linesMesh";
  59196. export * from "babylonjs/Meshes/mesh";
  59197. export * from "babylonjs/Meshes/mesh.vertexData";
  59198. export * from "babylonjs/Meshes/meshBuilder";
  59199. export * from "babylonjs/Meshes/meshSimplification";
  59200. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59201. export * from "babylonjs/Meshes/polygonMesh";
  59202. export * from "babylonjs/Meshes/subMesh";
  59203. export * from "babylonjs/Meshes/meshLODLevel";
  59204. export * from "babylonjs/Meshes/transformNode";
  59205. export * from "babylonjs/Meshes/Builders/index";
  59206. export * from "babylonjs/Meshes/dataBuffer";
  59207. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59208. }
  59209. declare module "babylonjs/Morph/index" {
  59210. export * from "babylonjs/Morph/morphTarget";
  59211. export * from "babylonjs/Morph/morphTargetManager";
  59212. }
  59213. declare module "babylonjs/Navigation/INavigationEngine" {
  59214. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59215. import { Vector3 } from "babylonjs/Maths/math";
  59216. import { Mesh } from "babylonjs/Meshes/mesh";
  59217. import { Scene } from "babylonjs/scene";
  59218. /**
  59219. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59220. */
  59221. export interface INavigationEnginePlugin {
  59222. /**
  59223. * plugin name
  59224. */
  59225. name: string;
  59226. /**
  59227. * Creates a navigation mesh
  59228. * @param meshes array of all the geometry used to compute the navigatio mesh
  59229. * @param parameters bunch of parameters used to filter geometry
  59230. */
  59231. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59232. /**
  59233. * Create a navigation mesh debug mesh
  59234. * @param scene is where the mesh will be added
  59235. * @returns debug display mesh
  59236. */
  59237. createDebugNavMesh(scene: Scene): Mesh;
  59238. /**
  59239. * Get a navigation mesh constrained position, closest to the parameter position
  59240. * @param position world position
  59241. * @returns the closest point to position constrained by the navigation mesh
  59242. */
  59243. getClosestPoint(position: Vector3): Vector3;
  59244. /**
  59245. * Get a navigation mesh constrained position, within a particular radius
  59246. * @param position world position
  59247. * @param maxRadius the maximum distance to the constrained world position
  59248. * @returns the closest point to position constrained by the navigation mesh
  59249. */
  59250. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59251. /**
  59252. * Compute the final position from a segment made of destination-position
  59253. * @param position world position
  59254. * @param destination world position
  59255. * @returns the resulting point along the navmesh
  59256. */
  59257. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59258. /**
  59259. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59260. * @param start world position
  59261. * @param end world position
  59262. * @returns array containing world position composing the path
  59263. */
  59264. computePath(start: Vector3, end: Vector3): Vector3[];
  59265. /**
  59266. * If this plugin is supported
  59267. * @returns true if plugin is supported
  59268. */
  59269. isSupported(): boolean;
  59270. /**
  59271. * Create a new Crowd so you can add agents
  59272. * @param maxAgents the maximum agent count in the crowd
  59273. * @param maxAgentRadius the maximum radius an agent can have
  59274. * @param scene to attach the crowd to
  59275. * @returns the crowd you can add agents to
  59276. */
  59277. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59278. /**
  59279. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59280. * The queries will try to find a solution within those bounds
  59281. * default is (1,1,1)
  59282. * @param extent x,y,z value that define the extent around the queries point of reference
  59283. */
  59284. setDefaultQueryExtent(extent: Vector3): void;
  59285. /**
  59286. * Get the Bounding box extent specified by setDefaultQueryExtent
  59287. * @returns the box extent values
  59288. */
  59289. getDefaultQueryExtent(): Vector3;
  59290. /**
  59291. * Release all resources
  59292. */
  59293. dispose(): void;
  59294. }
  59295. /**
  59296. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59297. */
  59298. export interface ICrowd {
  59299. /**
  59300. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59301. * You can attach anything to that node. The node position is updated in the scene update tick.
  59302. * @param pos world position that will be constrained by the navigation mesh
  59303. * @param parameters agent parameters
  59304. * @param transform hooked to the agent that will be update by the scene
  59305. * @returns agent index
  59306. */
  59307. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59308. /**
  59309. * Returns the agent position in world space
  59310. * @param index agent index returned by addAgent
  59311. * @returns world space position
  59312. */
  59313. getAgentPosition(index: number): Vector3;
  59314. /**
  59315. * Gets the agent velocity in world space
  59316. * @param index agent index returned by addAgent
  59317. * @returns world space velocity
  59318. */
  59319. getAgentVelocity(index: number): Vector3;
  59320. /**
  59321. * remove a particular agent previously created
  59322. * @param index agent index returned by addAgent
  59323. */
  59324. removeAgent(index: number): void;
  59325. /**
  59326. * get the list of all agents attached to this crowd
  59327. * @returns list of agent indices
  59328. */
  59329. getAgents(): number[];
  59330. /**
  59331. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59332. * @param deltaTime in seconds
  59333. */
  59334. update(deltaTime: number): void;
  59335. /**
  59336. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59337. * @param index agent index returned by addAgent
  59338. * @param destination targeted world position
  59339. */
  59340. agentGoto(index: number, destination: Vector3): void;
  59341. /**
  59342. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59343. * The queries will try to find a solution within those bounds
  59344. * default is (1,1,1)
  59345. * @param extent x,y,z value that define the extent around the queries point of reference
  59346. */
  59347. setDefaultQueryExtent(extent: Vector3): void;
  59348. /**
  59349. * Get the Bounding box extent specified by setDefaultQueryExtent
  59350. * @returns the box extent values
  59351. */
  59352. getDefaultQueryExtent(): Vector3;
  59353. /**
  59354. * Release all resources
  59355. */
  59356. dispose(): void;
  59357. }
  59358. /**
  59359. * Configures an agent
  59360. */
  59361. export interface IAgentParameters {
  59362. /**
  59363. * Agent radius. [Limit: >= 0]
  59364. */
  59365. radius: number;
  59366. /**
  59367. * Agent height. [Limit: > 0]
  59368. */
  59369. height: number;
  59370. /**
  59371. * Maximum allowed acceleration. [Limit: >= 0]
  59372. */
  59373. maxAcceleration: number;
  59374. /**
  59375. * Maximum allowed speed. [Limit: >= 0]
  59376. */
  59377. maxSpeed: number;
  59378. /**
  59379. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59380. */
  59381. collisionQueryRange: number;
  59382. /**
  59383. * The path visibility optimization range. [Limit: > 0]
  59384. */
  59385. pathOptimizationRange: number;
  59386. /**
  59387. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59388. */
  59389. separationWeight: number;
  59390. }
  59391. /**
  59392. * Configures the navigation mesh creation
  59393. */
  59394. export interface INavMeshParameters {
  59395. /**
  59396. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59397. */
  59398. cs: number;
  59399. /**
  59400. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59401. */
  59402. ch: number;
  59403. /**
  59404. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59405. */
  59406. walkableSlopeAngle: number;
  59407. /**
  59408. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59409. * be considered walkable. [Limit: >= 3] [Units: vx]
  59410. */
  59411. walkableHeight: number;
  59412. /**
  59413. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59414. */
  59415. walkableClimb: number;
  59416. /**
  59417. * The distance to erode/shrink the walkable area of the heightfield away from
  59418. * obstructions. [Limit: >=0] [Units: vx]
  59419. */
  59420. walkableRadius: number;
  59421. /**
  59422. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59423. */
  59424. maxEdgeLen: number;
  59425. /**
  59426. * The maximum distance a simplfied contour's border edges should deviate
  59427. * the original raw contour. [Limit: >=0] [Units: vx]
  59428. */
  59429. maxSimplificationError: number;
  59430. /**
  59431. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59432. */
  59433. minRegionArea: number;
  59434. /**
  59435. * Any regions with a span count smaller than this value will, if possible,
  59436. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59437. */
  59438. mergeRegionArea: number;
  59439. /**
  59440. * The maximum number of vertices allowed for polygons generated during the
  59441. * contour to polygon conversion process. [Limit: >= 3]
  59442. */
  59443. maxVertsPerPoly: number;
  59444. /**
  59445. * Sets the sampling distance to use when generating the detail mesh.
  59446. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59447. */
  59448. detailSampleDist: number;
  59449. /**
  59450. * The maximum distance the detail mesh surface should deviate from heightfield
  59451. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59452. */
  59453. detailSampleMaxError: number;
  59454. }
  59455. }
  59456. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59457. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59458. import { Mesh } from "babylonjs/Meshes/mesh";
  59459. import { Scene } from "babylonjs/scene";
  59460. import { Vector3 } from "babylonjs/Maths/math";
  59461. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59462. /**
  59463. * RecastJS navigation plugin
  59464. */
  59465. export class RecastJSPlugin implements INavigationEnginePlugin {
  59466. /**
  59467. * Reference to the Recast library
  59468. */
  59469. bjsRECAST: any;
  59470. /**
  59471. * plugin name
  59472. */
  59473. name: string;
  59474. /**
  59475. * the first navmesh created. We might extend this to support multiple navmeshes
  59476. */
  59477. navMesh: any;
  59478. /**
  59479. * Initializes the recastJS plugin
  59480. * @param recastInjection can be used to inject your own recast reference
  59481. */
  59482. constructor(recastInjection?: any);
  59483. /**
  59484. * Creates a navigation mesh
  59485. * @param meshes array of all the geometry used to compute the navigatio mesh
  59486. * @param parameters bunch of parameters used to filter geometry
  59487. */
  59488. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59489. /**
  59490. * Create a navigation mesh debug mesh
  59491. * @param scene is where the mesh will be added
  59492. * @returns debug display mesh
  59493. */
  59494. createDebugNavMesh(scene: Scene): Mesh;
  59495. /**
  59496. * Get a navigation mesh constrained position, closest to the parameter position
  59497. * @param position world position
  59498. * @returns the closest point to position constrained by the navigation mesh
  59499. */
  59500. getClosestPoint(position: Vector3): Vector3;
  59501. /**
  59502. * Get a navigation mesh constrained position, within a particular radius
  59503. * @param position world position
  59504. * @param maxRadius the maximum distance to the constrained world position
  59505. * @returns the closest point to position constrained by the navigation mesh
  59506. */
  59507. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59508. /**
  59509. * Compute the final position from a segment made of destination-position
  59510. * @param position world position
  59511. * @param destination world position
  59512. * @returns the resulting point along the navmesh
  59513. */
  59514. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59515. /**
  59516. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59517. * @param start world position
  59518. * @param end world position
  59519. * @returns array containing world position composing the path
  59520. */
  59521. computePath(start: Vector3, end: Vector3): Vector3[];
  59522. /**
  59523. * Create a new Crowd so you can add agents
  59524. * @param maxAgents the maximum agent count in the crowd
  59525. * @param maxAgentRadius the maximum radius an agent can have
  59526. * @param scene to attach the crowd to
  59527. * @returns the crowd you can add agents to
  59528. */
  59529. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59530. /**
  59531. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59532. * The queries will try to find a solution within those bounds
  59533. * default is (1,1,1)
  59534. * @param extent x,y,z value that define the extent around the queries point of reference
  59535. */
  59536. setDefaultQueryExtent(extent: Vector3): void;
  59537. /**
  59538. * Get the Bounding box extent specified by setDefaultQueryExtent
  59539. * @returns the box extent values
  59540. */
  59541. getDefaultQueryExtent(): Vector3;
  59542. /**
  59543. * Disposes
  59544. */
  59545. dispose(): void;
  59546. /**
  59547. * If this plugin is supported
  59548. * @returns true if plugin is supported
  59549. */
  59550. isSupported(): boolean;
  59551. }
  59552. /**
  59553. * Recast detour crowd implementation
  59554. */
  59555. export class RecastJSCrowd implements ICrowd {
  59556. /**
  59557. * Recast/detour plugin
  59558. */
  59559. bjsRECASTPlugin: RecastJSPlugin;
  59560. /**
  59561. * Link to the detour crowd
  59562. */
  59563. recastCrowd: any;
  59564. /**
  59565. * One transform per agent
  59566. */
  59567. transforms: TransformNode[];
  59568. /**
  59569. * All agents created
  59570. */
  59571. agents: number[];
  59572. /**
  59573. * Link to the scene is kept to unregister the crowd from the scene
  59574. */
  59575. private _scene;
  59576. /**
  59577. * Observer for crowd updates
  59578. */
  59579. private _onBeforeAnimationsObserver;
  59580. /**
  59581. * Constructor
  59582. * @param plugin recastJS plugin
  59583. * @param maxAgents the maximum agent count in the crowd
  59584. * @param maxAgentRadius the maximum radius an agent can have
  59585. * @param scene to attach the crowd to
  59586. * @returns the crowd you can add agents to
  59587. */
  59588. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59589. /**
  59590. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59591. * You can attach anything to that node. The node position is updated in the scene update tick.
  59592. * @param pos world position that will be constrained by the navigation mesh
  59593. * @param parameters agent parameters
  59594. * @param transform hooked to the agent that will be update by the scene
  59595. * @returns agent index
  59596. */
  59597. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59598. /**
  59599. * Returns the agent position in world space
  59600. * @param index agent index returned by addAgent
  59601. * @returns world space position
  59602. */
  59603. getAgentPosition(index: number): Vector3;
  59604. /**
  59605. * Returns the agent velocity in world space
  59606. * @param index agent index returned by addAgent
  59607. * @returns world space velocity
  59608. */
  59609. getAgentVelocity(index: number): Vector3;
  59610. /**
  59611. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59612. * @param index agent index returned by addAgent
  59613. * @param destination targeted world position
  59614. */
  59615. agentGoto(index: number, destination: Vector3): void;
  59616. /**
  59617. * remove a particular agent previously created
  59618. * @param index agent index returned by addAgent
  59619. */
  59620. removeAgent(index: number): void;
  59621. /**
  59622. * get the list of all agents attached to this crowd
  59623. * @returns list of agent indices
  59624. */
  59625. getAgents(): number[];
  59626. /**
  59627. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59628. * @param deltaTime in seconds
  59629. */
  59630. update(deltaTime: number): void;
  59631. /**
  59632. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59633. * The queries will try to find a solution within those bounds
  59634. * default is (1,1,1)
  59635. * @param extent x,y,z value that define the extent around the queries point of reference
  59636. */
  59637. setDefaultQueryExtent(extent: Vector3): void;
  59638. /**
  59639. * Get the Bounding box extent specified by setDefaultQueryExtent
  59640. * @returns the box extent values
  59641. */
  59642. getDefaultQueryExtent(): Vector3;
  59643. /**
  59644. * Release all resources
  59645. */
  59646. dispose(): void;
  59647. }
  59648. }
  59649. declare module "babylonjs/Navigation/Plugins/index" {
  59650. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59651. }
  59652. declare module "babylonjs/Navigation/index" {
  59653. export * from "babylonjs/Navigation/INavigationEngine";
  59654. export * from "babylonjs/Navigation/Plugins/index";
  59655. }
  59656. declare module "babylonjs/Offline/database" {
  59657. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59658. /**
  59659. * Class used to enable access to IndexedDB
  59660. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59661. */
  59662. export class Database implements IOfflineProvider {
  59663. private _callbackManifestChecked;
  59664. private _currentSceneUrl;
  59665. private _db;
  59666. private _enableSceneOffline;
  59667. private _enableTexturesOffline;
  59668. private _manifestVersionFound;
  59669. private _mustUpdateRessources;
  59670. private _hasReachedQuota;
  59671. private _isSupported;
  59672. private _idbFactory;
  59673. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59674. private static IsUASupportingBlobStorage;
  59675. /**
  59676. * Gets a boolean indicating if Database storate is enabled (off by default)
  59677. */
  59678. static IDBStorageEnabled: boolean;
  59679. /**
  59680. * Gets a boolean indicating if scene must be saved in the database
  59681. */
  59682. readonly enableSceneOffline: boolean;
  59683. /**
  59684. * Gets a boolean indicating if textures must be saved in the database
  59685. */
  59686. readonly enableTexturesOffline: boolean;
  59687. /**
  59688. * Creates a new Database
  59689. * @param urlToScene defines the url to load the scene
  59690. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59691. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59692. */
  59693. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59694. private static _ParseURL;
  59695. private static _ReturnFullUrlLocation;
  59696. private _checkManifestFile;
  59697. /**
  59698. * Open the database and make it available
  59699. * @param successCallback defines the callback to call on success
  59700. * @param errorCallback defines the callback to call on error
  59701. */
  59702. open(successCallback: () => void, errorCallback: () => void): void;
  59703. /**
  59704. * Loads an image from the database
  59705. * @param url defines the url to load from
  59706. * @param image defines the target DOM image
  59707. */
  59708. loadImage(url: string, image: HTMLImageElement): void;
  59709. private _loadImageFromDBAsync;
  59710. private _saveImageIntoDBAsync;
  59711. private _checkVersionFromDB;
  59712. private _loadVersionFromDBAsync;
  59713. private _saveVersionIntoDBAsync;
  59714. /**
  59715. * Loads a file from database
  59716. * @param url defines the URL to load from
  59717. * @param sceneLoaded defines a callback to call on success
  59718. * @param progressCallBack defines a callback to call when progress changed
  59719. * @param errorCallback defines a callback to call on error
  59720. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59721. */
  59722. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59723. private _loadFileAsync;
  59724. private _saveFileAsync;
  59725. /**
  59726. * Validates if xhr data is correct
  59727. * @param xhr defines the request to validate
  59728. * @param dataType defines the expected data type
  59729. * @returns true if data is correct
  59730. */
  59731. private static _ValidateXHRData;
  59732. }
  59733. }
  59734. declare module "babylonjs/Offline/index" {
  59735. export * from "babylonjs/Offline/database";
  59736. export * from "babylonjs/Offline/IOfflineProvider";
  59737. }
  59738. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59739. /** @hidden */
  59740. export var gpuUpdateParticlesPixelShader: {
  59741. name: string;
  59742. shader: string;
  59743. };
  59744. }
  59745. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59746. /** @hidden */
  59747. export var gpuUpdateParticlesVertexShader: {
  59748. name: string;
  59749. shader: string;
  59750. };
  59751. }
  59752. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59753. /** @hidden */
  59754. export var clipPlaneFragmentDeclaration2: {
  59755. name: string;
  59756. shader: string;
  59757. };
  59758. }
  59759. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59760. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59761. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59762. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59763. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59764. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59765. /** @hidden */
  59766. export var gpuRenderParticlesPixelShader: {
  59767. name: string;
  59768. shader: string;
  59769. };
  59770. }
  59771. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59772. /** @hidden */
  59773. export var clipPlaneVertexDeclaration2: {
  59774. name: string;
  59775. shader: string;
  59776. };
  59777. }
  59778. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59779. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59780. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59781. /** @hidden */
  59782. export var gpuRenderParticlesVertexShader: {
  59783. name: string;
  59784. shader: string;
  59785. };
  59786. }
  59787. declare module "babylonjs/Particles/gpuParticleSystem" {
  59788. import { Nullable } from "babylonjs/types";
  59789. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59790. import { Observable } from "babylonjs/Misc/observable";
  59791. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59792. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59793. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59794. import { Scene, IDisposable } from "babylonjs/scene";
  59795. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59796. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59797. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59798. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59799. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59800. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59801. /**
  59802. * This represents a GPU particle system in Babylon
  59803. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59804. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59805. */
  59806. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59807. /**
  59808. * The layer mask we are rendering the particles through.
  59809. */
  59810. layerMask: number;
  59811. private _capacity;
  59812. private _activeCount;
  59813. private _currentActiveCount;
  59814. private _accumulatedCount;
  59815. private _renderEffect;
  59816. private _updateEffect;
  59817. private _buffer0;
  59818. private _buffer1;
  59819. private _spriteBuffer;
  59820. private _updateVAO;
  59821. private _renderVAO;
  59822. private _targetIndex;
  59823. private _sourceBuffer;
  59824. private _targetBuffer;
  59825. private _engine;
  59826. private _currentRenderId;
  59827. private _started;
  59828. private _stopped;
  59829. private _timeDelta;
  59830. private _randomTexture;
  59831. private _randomTexture2;
  59832. private _attributesStrideSize;
  59833. private _updateEffectOptions;
  59834. private _randomTextureSize;
  59835. private _actualFrame;
  59836. private readonly _rawTextureWidth;
  59837. /**
  59838. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59839. */
  59840. static readonly IsSupported: boolean;
  59841. /**
  59842. * An event triggered when the system is disposed.
  59843. */
  59844. onDisposeObservable: Observable<GPUParticleSystem>;
  59845. /**
  59846. * Gets the maximum number of particles active at the same time.
  59847. * @returns The max number of active particles.
  59848. */
  59849. getCapacity(): number;
  59850. /**
  59851. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59852. * to override the particles.
  59853. */
  59854. forceDepthWrite: boolean;
  59855. /**
  59856. * Gets or set the number of active particles
  59857. */
  59858. activeParticleCount: number;
  59859. private _preWarmDone;
  59860. /**
  59861. * Is this system ready to be used/rendered
  59862. * @return true if the system is ready
  59863. */
  59864. isReady(): boolean;
  59865. /**
  59866. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59867. * @returns True if it has been started, otherwise false.
  59868. */
  59869. isStarted(): boolean;
  59870. /**
  59871. * Starts the particle system and begins to emit
  59872. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59873. */
  59874. start(delay?: number): void;
  59875. /**
  59876. * Stops the particle system.
  59877. */
  59878. stop(): void;
  59879. /**
  59880. * Remove all active particles
  59881. */
  59882. reset(): void;
  59883. /**
  59884. * Returns the string "GPUParticleSystem"
  59885. * @returns a string containing the class name
  59886. */
  59887. getClassName(): string;
  59888. private _colorGradientsTexture;
  59889. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59890. /**
  59891. * Adds a new color gradient
  59892. * @param gradient defines the gradient to use (between 0 and 1)
  59893. * @param color1 defines the color to affect to the specified gradient
  59894. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59895. * @returns the current particle system
  59896. */
  59897. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59898. /**
  59899. * Remove a specific color gradient
  59900. * @param gradient defines the gradient to remove
  59901. * @returns the current particle system
  59902. */
  59903. removeColorGradient(gradient: number): GPUParticleSystem;
  59904. private _angularSpeedGradientsTexture;
  59905. private _sizeGradientsTexture;
  59906. private _velocityGradientsTexture;
  59907. private _limitVelocityGradientsTexture;
  59908. private _dragGradientsTexture;
  59909. private _addFactorGradient;
  59910. /**
  59911. * Adds a new size gradient
  59912. * @param gradient defines the gradient to use (between 0 and 1)
  59913. * @param factor defines the size factor to affect to the specified gradient
  59914. * @returns the current particle system
  59915. */
  59916. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59917. /**
  59918. * Remove a specific size gradient
  59919. * @param gradient defines the gradient to remove
  59920. * @returns the current particle system
  59921. */
  59922. removeSizeGradient(gradient: number): GPUParticleSystem;
  59923. /**
  59924. * Adds a new angular speed gradient
  59925. * @param gradient defines the gradient to use (between 0 and 1)
  59926. * @param factor defines the angular speed to affect to the specified gradient
  59927. * @returns the current particle system
  59928. */
  59929. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59930. /**
  59931. * Remove a specific angular speed gradient
  59932. * @param gradient defines the gradient to remove
  59933. * @returns the current particle system
  59934. */
  59935. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59936. /**
  59937. * Adds a new velocity gradient
  59938. * @param gradient defines the gradient to use (between 0 and 1)
  59939. * @param factor defines the velocity to affect to the specified gradient
  59940. * @returns the current particle system
  59941. */
  59942. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59943. /**
  59944. * Remove a specific velocity gradient
  59945. * @param gradient defines the gradient to remove
  59946. * @returns the current particle system
  59947. */
  59948. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59949. /**
  59950. * Adds a new limit velocity gradient
  59951. * @param gradient defines the gradient to use (between 0 and 1)
  59952. * @param factor defines the limit velocity value to affect to the specified gradient
  59953. * @returns the current particle system
  59954. */
  59955. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59956. /**
  59957. * Remove a specific limit velocity gradient
  59958. * @param gradient defines the gradient to remove
  59959. * @returns the current particle system
  59960. */
  59961. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59962. /**
  59963. * Adds a new drag gradient
  59964. * @param gradient defines the gradient to use (between 0 and 1)
  59965. * @param factor defines the drag value to affect to the specified gradient
  59966. * @returns the current particle system
  59967. */
  59968. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59969. /**
  59970. * Remove a specific drag gradient
  59971. * @param gradient defines the gradient to remove
  59972. * @returns the current particle system
  59973. */
  59974. removeDragGradient(gradient: number): GPUParticleSystem;
  59975. /**
  59976. * Not supported by GPUParticleSystem
  59977. * @param gradient defines the gradient to use (between 0 and 1)
  59978. * @param factor defines the emit rate value to affect to the specified gradient
  59979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59980. * @returns the current particle system
  59981. */
  59982. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59983. /**
  59984. * Not supported by GPUParticleSystem
  59985. * @param gradient defines the gradient to remove
  59986. * @returns the current particle system
  59987. */
  59988. removeEmitRateGradient(gradient: number): IParticleSystem;
  59989. /**
  59990. * Not supported by GPUParticleSystem
  59991. * @param gradient defines the gradient to use (between 0 and 1)
  59992. * @param factor defines the start size value to affect to the specified gradient
  59993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59994. * @returns the current particle system
  59995. */
  59996. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59997. /**
  59998. * Not supported by GPUParticleSystem
  59999. * @param gradient defines the gradient to remove
  60000. * @returns the current particle system
  60001. */
  60002. removeStartSizeGradient(gradient: number): IParticleSystem;
  60003. /**
  60004. * Not supported by GPUParticleSystem
  60005. * @param gradient defines the gradient to use (between 0 and 1)
  60006. * @param min defines the color remap minimal range
  60007. * @param max defines the color remap maximal range
  60008. * @returns the current particle system
  60009. */
  60010. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60011. /**
  60012. * Not supported by GPUParticleSystem
  60013. * @param gradient defines the gradient to remove
  60014. * @returns the current particle system
  60015. */
  60016. removeColorRemapGradient(): IParticleSystem;
  60017. /**
  60018. * Not supported by GPUParticleSystem
  60019. * @param gradient defines the gradient to use (between 0 and 1)
  60020. * @param min defines the alpha remap minimal range
  60021. * @param max defines the alpha remap maximal range
  60022. * @returns the current particle system
  60023. */
  60024. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60025. /**
  60026. * Not supported by GPUParticleSystem
  60027. * @param gradient defines the gradient to remove
  60028. * @returns the current particle system
  60029. */
  60030. removeAlphaRemapGradient(): IParticleSystem;
  60031. /**
  60032. * Not supported by GPUParticleSystem
  60033. * @param gradient defines the gradient to use (between 0 and 1)
  60034. * @param color defines the color to affect to the specified gradient
  60035. * @returns the current particle system
  60036. */
  60037. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60038. /**
  60039. * Not supported by GPUParticleSystem
  60040. * @param gradient defines the gradient to remove
  60041. * @returns the current particle system
  60042. */
  60043. removeRampGradient(): IParticleSystem;
  60044. /**
  60045. * Not supported by GPUParticleSystem
  60046. * @returns the list of ramp gradients
  60047. */
  60048. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60049. /**
  60050. * Not supported by GPUParticleSystem
  60051. * Gets or sets a boolean indicating that ramp gradients must be used
  60052. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60053. */
  60054. useRampGradients: boolean;
  60055. /**
  60056. * Not supported by GPUParticleSystem
  60057. * @param gradient defines the gradient to use (between 0 and 1)
  60058. * @param factor defines the life time factor to affect to the specified gradient
  60059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60060. * @returns the current particle system
  60061. */
  60062. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60063. /**
  60064. * Not supported by GPUParticleSystem
  60065. * @param gradient defines the gradient to remove
  60066. * @returns the current particle system
  60067. */
  60068. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60069. /**
  60070. * Instantiates a GPU particle system.
  60071. * 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.
  60072. * @param name The name of the particle system
  60073. * @param options The options used to create the system
  60074. * @param scene The scene the particle system belongs to
  60075. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60076. */
  60077. constructor(name: string, options: Partial<{
  60078. capacity: number;
  60079. randomTextureSize: number;
  60080. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60081. protected _reset(): void;
  60082. private _createUpdateVAO;
  60083. private _createRenderVAO;
  60084. private _initialize;
  60085. /** @hidden */
  60086. _recreateUpdateEffect(): void;
  60087. /** @hidden */
  60088. _recreateRenderEffect(): void;
  60089. /**
  60090. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60091. * @param preWarm defines if we are in the pre-warmimg phase
  60092. */
  60093. animate(preWarm?: boolean): void;
  60094. private _createFactorGradientTexture;
  60095. private _createSizeGradientTexture;
  60096. private _createAngularSpeedGradientTexture;
  60097. private _createVelocityGradientTexture;
  60098. private _createLimitVelocityGradientTexture;
  60099. private _createDragGradientTexture;
  60100. private _createColorGradientTexture;
  60101. /**
  60102. * Renders the particle system in its current state
  60103. * @param preWarm defines if the system should only update the particles but not render them
  60104. * @returns the current number of particles
  60105. */
  60106. render(preWarm?: boolean): number;
  60107. /**
  60108. * Rebuilds the particle system
  60109. */
  60110. rebuild(): void;
  60111. private _releaseBuffers;
  60112. private _releaseVAOs;
  60113. /**
  60114. * Disposes the particle system and free the associated resources
  60115. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60116. */
  60117. dispose(disposeTexture?: boolean): void;
  60118. /**
  60119. * Clones the particle system.
  60120. * @param name The name of the cloned object
  60121. * @param newEmitter The new emitter to use
  60122. * @returns the cloned particle system
  60123. */
  60124. clone(name: string, newEmitter: any): GPUParticleSystem;
  60125. /**
  60126. * Serializes the particle system to a JSON object.
  60127. * @returns the JSON object
  60128. */
  60129. serialize(): any;
  60130. /**
  60131. * Parses a JSON object to create a GPU particle system.
  60132. * @param parsedParticleSystem The JSON object to parse
  60133. * @param scene The scene to create the particle system in
  60134. * @param rootUrl The root url to use to load external dependencies like texture
  60135. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60136. * @returns the parsed GPU particle system
  60137. */
  60138. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60139. }
  60140. }
  60141. declare module "babylonjs/Particles/particleSystemSet" {
  60142. import { Nullable } from "babylonjs/types";
  60143. import { Color3 } from "babylonjs/Maths/math.color";
  60144. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60146. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60147. import { Scene, IDisposable } from "babylonjs/scene";
  60148. /**
  60149. * Represents a set of particle systems working together to create a specific effect
  60150. */
  60151. export class ParticleSystemSet implements IDisposable {
  60152. private _emitterCreationOptions;
  60153. private _emitterNode;
  60154. /**
  60155. * Gets the particle system list
  60156. */
  60157. systems: IParticleSystem[];
  60158. /**
  60159. * Gets the emitter node used with this set
  60160. */
  60161. readonly emitterNode: Nullable<TransformNode>;
  60162. /**
  60163. * Creates a new emitter mesh as a sphere
  60164. * @param options defines the options used to create the sphere
  60165. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60166. * @param scene defines the hosting scene
  60167. */
  60168. setEmitterAsSphere(options: {
  60169. diameter: number;
  60170. segments: number;
  60171. color: Color3;
  60172. }, renderingGroupId: number, scene: Scene): void;
  60173. /**
  60174. * Starts all particle systems of the set
  60175. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60176. */
  60177. start(emitter?: AbstractMesh): void;
  60178. /**
  60179. * Release all associated resources
  60180. */
  60181. dispose(): void;
  60182. /**
  60183. * Serialize the set into a JSON compatible object
  60184. * @returns a JSON compatible representation of the set
  60185. */
  60186. serialize(): any;
  60187. /**
  60188. * Parse a new ParticleSystemSet from a serialized source
  60189. * @param data defines a JSON compatible representation of the set
  60190. * @param scene defines the hosting scene
  60191. * @param gpu defines if we want GPU particles or CPU particles
  60192. * @returns a new ParticleSystemSet
  60193. */
  60194. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60195. }
  60196. }
  60197. declare module "babylonjs/Particles/particleHelper" {
  60198. import { Nullable } from "babylonjs/types";
  60199. import { Scene } from "babylonjs/scene";
  60200. import { Vector3 } from "babylonjs/Maths/math.vector";
  60201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60202. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60203. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60204. /**
  60205. * This class is made for on one-liner static method to help creating particle system set.
  60206. */
  60207. export class ParticleHelper {
  60208. /**
  60209. * Gets or sets base Assets URL
  60210. */
  60211. static BaseAssetsUrl: string;
  60212. /**
  60213. * Create a default particle system that you can tweak
  60214. * @param emitter defines the emitter to use
  60215. * @param capacity defines the system capacity (default is 500 particles)
  60216. * @param scene defines the hosting scene
  60217. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60218. * @returns the new Particle system
  60219. */
  60220. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60221. /**
  60222. * This is the main static method (one-liner) of this helper to create different particle systems
  60223. * @param type This string represents the type to the particle system to create
  60224. * @param scene The scene where the particle system should live
  60225. * @param gpu If the system will use gpu
  60226. * @returns the ParticleSystemSet created
  60227. */
  60228. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60229. /**
  60230. * Static function used to export a particle system to a ParticleSystemSet variable.
  60231. * Please note that the emitter shape is not exported
  60232. * @param systems defines the particle systems to export
  60233. * @returns the created particle system set
  60234. */
  60235. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60236. }
  60237. }
  60238. declare module "babylonjs/Particles/particleSystemComponent" {
  60239. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60240. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  60241. import "babylonjs/Shaders/particles.vertex";
  60242. module "babylonjs/Engines/engine" {
  60243. interface Engine {
  60244. /**
  60245. * Create an effect to use with particle systems.
  60246. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60247. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60248. * @param uniformsNames defines a list of attribute names
  60249. * @param samplers defines an array of string used to represent textures
  60250. * @param defines defines the string containing the defines to use to compile the shaders
  60251. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60252. * @param onCompiled defines a function to call when the effect creation is successful
  60253. * @param onError defines a function to call when the effect creation has failed
  60254. * @returns the new Effect
  60255. */
  60256. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60257. }
  60258. }
  60259. module "babylonjs/Meshes/mesh" {
  60260. interface Mesh {
  60261. /**
  60262. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60263. * @returns an array of IParticleSystem
  60264. */
  60265. getEmittedParticleSystems(): IParticleSystem[];
  60266. /**
  60267. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60268. * @returns an array of IParticleSystem
  60269. */
  60270. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60271. }
  60272. }
  60273. /**
  60274. * @hidden
  60275. */
  60276. export var _IDoNeedToBeInTheBuild: number;
  60277. }
  60278. declare module "babylonjs/Particles/index" {
  60279. export * from "babylonjs/Particles/baseParticleSystem";
  60280. export * from "babylonjs/Particles/EmitterTypes/index";
  60281. export * from "babylonjs/Particles/gpuParticleSystem";
  60282. export * from "babylonjs/Particles/IParticleSystem";
  60283. export * from "babylonjs/Particles/particle";
  60284. export * from "babylonjs/Particles/particleHelper";
  60285. export * from "babylonjs/Particles/particleSystem";
  60286. export * from "babylonjs/Particles/particleSystemComponent";
  60287. export * from "babylonjs/Particles/particleSystemSet";
  60288. export * from "babylonjs/Particles/solidParticle";
  60289. export * from "babylonjs/Particles/solidParticleSystem";
  60290. export * from "babylonjs/Particles/subEmitter";
  60291. }
  60292. declare module "babylonjs/Physics/physicsEngineComponent" {
  60293. import { Nullable } from "babylonjs/types";
  60294. import { Observable, Observer } from "babylonjs/Misc/observable";
  60295. import { Vector3 } from "babylonjs/Maths/math.vector";
  60296. import { Mesh } from "babylonjs/Meshes/mesh";
  60297. import { ISceneComponent } from "babylonjs/sceneComponent";
  60298. import { Scene } from "babylonjs/scene";
  60299. import { Node } from "babylonjs/node";
  60300. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60301. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60302. module "babylonjs/scene" {
  60303. interface Scene {
  60304. /** @hidden (Backing field) */
  60305. _physicsEngine: Nullable<IPhysicsEngine>;
  60306. /**
  60307. * Gets the current physics engine
  60308. * @returns a IPhysicsEngine or null if none attached
  60309. */
  60310. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60311. /**
  60312. * Enables physics to the current scene
  60313. * @param gravity defines the scene's gravity for the physics engine
  60314. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60315. * @return a boolean indicating if the physics engine was initialized
  60316. */
  60317. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60318. /**
  60319. * Disables and disposes the physics engine associated with the scene
  60320. */
  60321. disablePhysicsEngine(): void;
  60322. /**
  60323. * Gets a boolean indicating if there is an active physics engine
  60324. * @returns a boolean indicating if there is an active physics engine
  60325. */
  60326. isPhysicsEnabled(): boolean;
  60327. /**
  60328. * Deletes a physics compound impostor
  60329. * @param compound defines the compound to delete
  60330. */
  60331. deleteCompoundImpostor(compound: any): void;
  60332. /**
  60333. * An event triggered when physic simulation is about to be run
  60334. */
  60335. onBeforePhysicsObservable: Observable<Scene>;
  60336. /**
  60337. * An event triggered when physic simulation has been done
  60338. */
  60339. onAfterPhysicsObservable: Observable<Scene>;
  60340. }
  60341. }
  60342. module "babylonjs/Meshes/abstractMesh" {
  60343. interface AbstractMesh {
  60344. /** @hidden */
  60345. _physicsImpostor: Nullable<PhysicsImpostor>;
  60346. /**
  60347. * Gets or sets impostor used for physic simulation
  60348. * @see http://doc.babylonjs.com/features/physics_engine
  60349. */
  60350. physicsImpostor: Nullable<PhysicsImpostor>;
  60351. /**
  60352. * Gets the current physics impostor
  60353. * @see http://doc.babylonjs.com/features/physics_engine
  60354. * @returns a physics impostor or null
  60355. */
  60356. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60357. /** Apply a physic impulse to the mesh
  60358. * @param force defines the force to apply
  60359. * @param contactPoint defines where to apply the force
  60360. * @returns the current mesh
  60361. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60362. */
  60363. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60364. /**
  60365. * Creates a physic joint between two meshes
  60366. * @param otherMesh defines the other mesh to use
  60367. * @param pivot1 defines the pivot to use on this mesh
  60368. * @param pivot2 defines the pivot to use on the other mesh
  60369. * @param options defines additional options (can be plugin dependent)
  60370. * @returns the current mesh
  60371. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60372. */
  60373. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60374. /** @hidden */
  60375. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60376. }
  60377. }
  60378. /**
  60379. * Defines the physics engine scene component responsible to manage a physics engine
  60380. */
  60381. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60382. /**
  60383. * The component name helpful to identify the component in the list of scene components.
  60384. */
  60385. readonly name: string;
  60386. /**
  60387. * The scene the component belongs to.
  60388. */
  60389. scene: Scene;
  60390. /**
  60391. * Creates a new instance of the component for the given scene
  60392. * @param scene Defines the scene to register the component in
  60393. */
  60394. constructor(scene: Scene);
  60395. /**
  60396. * Registers the component in a given scene
  60397. */
  60398. register(): void;
  60399. /**
  60400. * Rebuilds the elements related to this component in case of
  60401. * context lost for instance.
  60402. */
  60403. rebuild(): void;
  60404. /**
  60405. * Disposes the component and the associated ressources
  60406. */
  60407. dispose(): void;
  60408. }
  60409. }
  60410. declare module "babylonjs/Physics/physicsHelper" {
  60411. import { Nullable } from "babylonjs/types";
  60412. import { Vector3 } from "babylonjs/Maths/math.vector";
  60413. import { Mesh } from "babylonjs/Meshes/mesh";
  60414. import { Scene } from "babylonjs/scene";
  60415. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60416. /**
  60417. * A helper for physics simulations
  60418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60419. */
  60420. export class PhysicsHelper {
  60421. private _scene;
  60422. private _physicsEngine;
  60423. /**
  60424. * Initializes the Physics helper
  60425. * @param scene Babylon.js scene
  60426. */
  60427. constructor(scene: Scene);
  60428. /**
  60429. * Applies a radial explosion impulse
  60430. * @param origin the origin of the explosion
  60431. * @param radiusOrEventOptions the radius or the options of radial explosion
  60432. * @param strength the explosion strength
  60433. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60434. * @returns A physics radial explosion event, or null
  60435. */
  60436. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60437. /**
  60438. * Applies a radial explosion force
  60439. * @param origin the origin of the explosion
  60440. * @param radiusOrEventOptions the radius or the options of radial explosion
  60441. * @param strength the explosion strength
  60442. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60443. * @returns A physics radial explosion event, or null
  60444. */
  60445. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60446. /**
  60447. * Creates a gravitational field
  60448. * @param origin the origin of the explosion
  60449. * @param radiusOrEventOptions the radius or the options of radial explosion
  60450. * @param strength the explosion strength
  60451. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60452. * @returns A physics gravitational field event, or null
  60453. */
  60454. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60455. /**
  60456. * Creates a physics updraft event
  60457. * @param origin the origin of the updraft
  60458. * @param radiusOrEventOptions the radius or the options of the updraft
  60459. * @param strength the strength of the updraft
  60460. * @param height the height of the updraft
  60461. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60462. * @returns A physics updraft event, or null
  60463. */
  60464. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60465. /**
  60466. * Creates a physics vortex event
  60467. * @param origin the of the vortex
  60468. * @param radiusOrEventOptions the radius or the options of the vortex
  60469. * @param strength the strength of the vortex
  60470. * @param height the height of the vortex
  60471. * @returns a Physics vortex event, or null
  60472. * A physics vortex event or null
  60473. */
  60474. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60475. }
  60476. /**
  60477. * Represents a physics radial explosion event
  60478. */
  60479. class PhysicsRadialExplosionEvent {
  60480. private _scene;
  60481. private _options;
  60482. private _sphere;
  60483. private _dataFetched;
  60484. /**
  60485. * Initializes a radial explosioin event
  60486. * @param _scene BabylonJS scene
  60487. * @param _options The options for the vortex event
  60488. */
  60489. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60490. /**
  60491. * Returns the data related to the radial explosion event (sphere).
  60492. * @returns The radial explosion event data
  60493. */
  60494. getData(): PhysicsRadialExplosionEventData;
  60495. /**
  60496. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60497. * @param impostor A physics imposter
  60498. * @param origin the origin of the explosion
  60499. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60500. */
  60501. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60502. /**
  60503. * Triggers affecterd impostors callbacks
  60504. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60505. */
  60506. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60507. /**
  60508. * Disposes the sphere.
  60509. * @param force Specifies if the sphere should be disposed by force
  60510. */
  60511. dispose(force?: boolean): void;
  60512. /*** Helpers ***/
  60513. private _prepareSphere;
  60514. private _intersectsWithSphere;
  60515. }
  60516. /**
  60517. * Represents a gravitational field event
  60518. */
  60519. class PhysicsGravitationalFieldEvent {
  60520. private _physicsHelper;
  60521. private _scene;
  60522. private _origin;
  60523. private _options;
  60524. private _tickCallback;
  60525. private _sphere;
  60526. private _dataFetched;
  60527. /**
  60528. * Initializes the physics gravitational field event
  60529. * @param _physicsHelper A physics helper
  60530. * @param _scene BabylonJS scene
  60531. * @param _origin The origin position of the gravitational field event
  60532. * @param _options The options for the vortex event
  60533. */
  60534. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60535. /**
  60536. * Returns the data related to the gravitational field event (sphere).
  60537. * @returns A gravitational field event
  60538. */
  60539. getData(): PhysicsGravitationalFieldEventData;
  60540. /**
  60541. * Enables the gravitational field.
  60542. */
  60543. enable(): void;
  60544. /**
  60545. * Disables the gravitational field.
  60546. */
  60547. disable(): void;
  60548. /**
  60549. * Disposes the sphere.
  60550. * @param force The force to dispose from the gravitational field event
  60551. */
  60552. dispose(force?: boolean): void;
  60553. private _tick;
  60554. }
  60555. /**
  60556. * Represents a physics updraft event
  60557. */
  60558. class PhysicsUpdraftEvent {
  60559. private _scene;
  60560. private _origin;
  60561. private _options;
  60562. private _physicsEngine;
  60563. private _originTop;
  60564. private _originDirection;
  60565. private _tickCallback;
  60566. private _cylinder;
  60567. private _cylinderPosition;
  60568. private _dataFetched;
  60569. /**
  60570. * Initializes the physics updraft event
  60571. * @param _scene BabylonJS scene
  60572. * @param _origin The origin position of the updraft
  60573. * @param _options The options for the updraft event
  60574. */
  60575. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60576. /**
  60577. * Returns the data related to the updraft event (cylinder).
  60578. * @returns A physics updraft event
  60579. */
  60580. getData(): PhysicsUpdraftEventData;
  60581. /**
  60582. * Enables the updraft.
  60583. */
  60584. enable(): void;
  60585. /**
  60586. * Disables the updraft.
  60587. */
  60588. disable(): void;
  60589. /**
  60590. * Disposes the cylinder.
  60591. * @param force Specifies if the updraft should be disposed by force
  60592. */
  60593. dispose(force?: boolean): void;
  60594. private getImpostorHitData;
  60595. private _tick;
  60596. /*** Helpers ***/
  60597. private _prepareCylinder;
  60598. private _intersectsWithCylinder;
  60599. }
  60600. /**
  60601. * Represents a physics vortex event
  60602. */
  60603. class PhysicsVortexEvent {
  60604. private _scene;
  60605. private _origin;
  60606. private _options;
  60607. private _physicsEngine;
  60608. private _originTop;
  60609. private _tickCallback;
  60610. private _cylinder;
  60611. private _cylinderPosition;
  60612. private _dataFetched;
  60613. /**
  60614. * Initializes the physics vortex event
  60615. * @param _scene The BabylonJS scene
  60616. * @param _origin The origin position of the vortex
  60617. * @param _options The options for the vortex event
  60618. */
  60619. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60620. /**
  60621. * Returns the data related to the vortex event (cylinder).
  60622. * @returns The physics vortex event data
  60623. */
  60624. getData(): PhysicsVortexEventData;
  60625. /**
  60626. * Enables the vortex.
  60627. */
  60628. enable(): void;
  60629. /**
  60630. * Disables the cortex.
  60631. */
  60632. disable(): void;
  60633. /**
  60634. * Disposes the sphere.
  60635. * @param force
  60636. */
  60637. dispose(force?: boolean): void;
  60638. private getImpostorHitData;
  60639. private _tick;
  60640. /*** Helpers ***/
  60641. private _prepareCylinder;
  60642. private _intersectsWithCylinder;
  60643. }
  60644. /**
  60645. * Options fot the radial explosion event
  60646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60647. */
  60648. export class PhysicsRadialExplosionEventOptions {
  60649. /**
  60650. * The radius of the sphere for the radial explosion.
  60651. */
  60652. radius: number;
  60653. /**
  60654. * The strenth of the explosion.
  60655. */
  60656. strength: number;
  60657. /**
  60658. * The strenght of the force in correspondence to the distance of the affected object
  60659. */
  60660. falloff: PhysicsRadialImpulseFalloff;
  60661. /**
  60662. * Sphere options for the radial explosion.
  60663. */
  60664. sphere: {
  60665. segments: number;
  60666. diameter: number;
  60667. };
  60668. /**
  60669. * Sphere options for the radial explosion.
  60670. */
  60671. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60672. }
  60673. /**
  60674. * Options fot the updraft event
  60675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60676. */
  60677. export class PhysicsUpdraftEventOptions {
  60678. /**
  60679. * The radius of the cylinder for the vortex
  60680. */
  60681. radius: number;
  60682. /**
  60683. * The strenth of the updraft.
  60684. */
  60685. strength: number;
  60686. /**
  60687. * The height of the cylinder for the updraft.
  60688. */
  60689. height: number;
  60690. /**
  60691. * The mode for the the updraft.
  60692. */
  60693. updraftMode: PhysicsUpdraftMode;
  60694. }
  60695. /**
  60696. * Options fot the vortex event
  60697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60698. */
  60699. export class PhysicsVortexEventOptions {
  60700. /**
  60701. * The radius of the cylinder for the vortex
  60702. */
  60703. radius: number;
  60704. /**
  60705. * The strenth of the vortex.
  60706. */
  60707. strength: number;
  60708. /**
  60709. * The height of the cylinder for the vortex.
  60710. */
  60711. height: number;
  60712. /**
  60713. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60714. */
  60715. centripetalForceThreshold: number;
  60716. /**
  60717. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60718. */
  60719. centripetalForceMultiplier: number;
  60720. /**
  60721. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60722. */
  60723. centrifugalForceMultiplier: number;
  60724. /**
  60725. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60726. */
  60727. updraftForceMultiplier: number;
  60728. }
  60729. /**
  60730. * The strenght of the force in correspondence to the distance of the affected object
  60731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60732. */
  60733. export enum PhysicsRadialImpulseFalloff {
  60734. /** Defines that impulse is constant in strength across it's whole radius */
  60735. Constant = 0,
  60736. /** Defines that impulse gets weaker if it's further from the origin */
  60737. Linear = 1
  60738. }
  60739. /**
  60740. * The strength of the force in correspondence to the distance of the affected object
  60741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60742. */
  60743. export enum PhysicsUpdraftMode {
  60744. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60745. Center = 0,
  60746. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60747. Perpendicular = 1
  60748. }
  60749. /**
  60750. * Interface for a physics hit data
  60751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60752. */
  60753. export interface PhysicsHitData {
  60754. /**
  60755. * The force applied at the contact point
  60756. */
  60757. force: Vector3;
  60758. /**
  60759. * The contact point
  60760. */
  60761. contactPoint: Vector3;
  60762. /**
  60763. * The distance from the origin to the contact point
  60764. */
  60765. distanceFromOrigin: number;
  60766. }
  60767. /**
  60768. * Interface for radial explosion event data
  60769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60770. */
  60771. export interface PhysicsRadialExplosionEventData {
  60772. /**
  60773. * A sphere used for the radial explosion event
  60774. */
  60775. sphere: Mesh;
  60776. }
  60777. /**
  60778. * Interface for gravitational field event data
  60779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60780. */
  60781. export interface PhysicsGravitationalFieldEventData {
  60782. /**
  60783. * A sphere mesh used for the gravitational field event
  60784. */
  60785. sphere: Mesh;
  60786. }
  60787. /**
  60788. * Interface for updraft event data
  60789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60790. */
  60791. export interface PhysicsUpdraftEventData {
  60792. /**
  60793. * A cylinder used for the updraft event
  60794. */
  60795. cylinder: Mesh;
  60796. }
  60797. /**
  60798. * Interface for vortex event data
  60799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60800. */
  60801. export interface PhysicsVortexEventData {
  60802. /**
  60803. * A cylinder used for the vortex event
  60804. */
  60805. cylinder: Mesh;
  60806. }
  60807. /**
  60808. * Interface for an affected physics impostor
  60809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60810. */
  60811. export interface PhysicsAffectedImpostorWithData {
  60812. /**
  60813. * The impostor affected by the effect
  60814. */
  60815. impostor: PhysicsImpostor;
  60816. /**
  60817. * The data about the hit/horce from the explosion
  60818. */
  60819. hitData: PhysicsHitData;
  60820. }
  60821. }
  60822. declare module "babylonjs/Physics/Plugins/index" {
  60823. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60824. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60825. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60826. }
  60827. declare module "babylonjs/Physics/index" {
  60828. export * from "babylonjs/Physics/IPhysicsEngine";
  60829. export * from "babylonjs/Physics/physicsEngine";
  60830. export * from "babylonjs/Physics/physicsEngineComponent";
  60831. export * from "babylonjs/Physics/physicsHelper";
  60832. export * from "babylonjs/Physics/physicsImpostor";
  60833. export * from "babylonjs/Physics/physicsJoint";
  60834. export * from "babylonjs/Physics/Plugins/index";
  60835. }
  60836. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60837. /** @hidden */
  60838. export var blackAndWhitePixelShader: {
  60839. name: string;
  60840. shader: string;
  60841. };
  60842. }
  60843. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60844. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60845. import { Camera } from "babylonjs/Cameras/camera";
  60846. import { Engine } from "babylonjs/Engines/engine";
  60847. import "babylonjs/Shaders/blackAndWhite.fragment";
  60848. /**
  60849. * Post process used to render in black and white
  60850. */
  60851. export class BlackAndWhitePostProcess extends PostProcess {
  60852. /**
  60853. * Linear about to convert he result to black and white (default: 1)
  60854. */
  60855. degree: number;
  60856. /**
  60857. * Creates a black and white post process
  60858. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60859. * @param name The name of the effect.
  60860. * @param options The required width/height ratio to downsize to before computing the render pass.
  60861. * @param camera The camera to apply the render pass to.
  60862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60863. * @param engine The engine which the post process will be applied. (default: current engine)
  60864. * @param reusable If the post process can be reused on the same frame. (default: false)
  60865. */
  60866. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60867. }
  60868. }
  60869. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60870. import { Nullable } from "babylonjs/types";
  60871. import { Camera } from "babylonjs/Cameras/camera";
  60872. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60873. import { Engine } from "babylonjs/Engines/engine";
  60874. /**
  60875. * This represents a set of one or more post processes in Babylon.
  60876. * A post process can be used to apply a shader to a texture after it is rendered.
  60877. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60878. */
  60879. export class PostProcessRenderEffect {
  60880. private _postProcesses;
  60881. private _getPostProcesses;
  60882. private _singleInstance;
  60883. private _cameras;
  60884. private _indicesForCamera;
  60885. /**
  60886. * Name of the effect
  60887. * @hidden
  60888. */
  60889. _name: string;
  60890. /**
  60891. * Instantiates a post process render effect.
  60892. * A post process can be used to apply a shader to a texture after it is rendered.
  60893. * @param engine The engine the effect is tied to
  60894. * @param name The name of the effect
  60895. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60896. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60897. */
  60898. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60899. /**
  60900. * Checks if all the post processes in the effect are supported.
  60901. */
  60902. readonly isSupported: boolean;
  60903. /**
  60904. * Updates the current state of the effect
  60905. * @hidden
  60906. */
  60907. _update(): void;
  60908. /**
  60909. * Attaches the effect on cameras
  60910. * @param cameras The camera to attach to.
  60911. * @hidden
  60912. */
  60913. _attachCameras(cameras: Camera): void;
  60914. /**
  60915. * Attaches the effect on cameras
  60916. * @param cameras The camera to attach to.
  60917. * @hidden
  60918. */
  60919. _attachCameras(cameras: Camera[]): void;
  60920. /**
  60921. * Detaches the effect on cameras
  60922. * @param cameras The camera to detatch from.
  60923. * @hidden
  60924. */
  60925. _detachCameras(cameras: Camera): void;
  60926. /**
  60927. * Detatches the effect on cameras
  60928. * @param cameras The camera to detatch from.
  60929. * @hidden
  60930. */
  60931. _detachCameras(cameras: Camera[]): void;
  60932. /**
  60933. * Enables the effect on given cameras
  60934. * @param cameras The camera to enable.
  60935. * @hidden
  60936. */
  60937. _enable(cameras: Camera): void;
  60938. /**
  60939. * Enables the effect on given cameras
  60940. * @param cameras The camera to enable.
  60941. * @hidden
  60942. */
  60943. _enable(cameras: Nullable<Camera[]>): void;
  60944. /**
  60945. * Disables the effect on the given cameras
  60946. * @param cameras The camera to disable.
  60947. * @hidden
  60948. */
  60949. _disable(cameras: Camera): void;
  60950. /**
  60951. * Disables the effect on the given cameras
  60952. * @param cameras The camera to disable.
  60953. * @hidden
  60954. */
  60955. _disable(cameras: Nullable<Camera[]>): void;
  60956. /**
  60957. * Gets a list of the post processes contained in the effect.
  60958. * @param camera The camera to get the post processes on.
  60959. * @returns The list of the post processes in the effect.
  60960. */
  60961. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60962. }
  60963. }
  60964. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60965. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60966. /** @hidden */
  60967. export var extractHighlightsPixelShader: {
  60968. name: string;
  60969. shader: string;
  60970. };
  60971. }
  60972. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60973. import { Nullable } from "babylonjs/types";
  60974. import { Camera } from "babylonjs/Cameras/camera";
  60975. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60976. import { Engine } from "babylonjs/Engines/engine";
  60977. import "babylonjs/Shaders/extractHighlights.fragment";
  60978. /**
  60979. * 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.
  60980. */
  60981. export class ExtractHighlightsPostProcess extends PostProcess {
  60982. /**
  60983. * The luminance threshold, pixels below this value will be set to black.
  60984. */
  60985. threshold: number;
  60986. /** @hidden */
  60987. _exposure: number;
  60988. /**
  60989. * Post process which has the input texture to be used when performing highlight extraction
  60990. * @hidden
  60991. */
  60992. _inputPostProcess: Nullable<PostProcess>;
  60993. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60994. }
  60995. }
  60996. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  60997. /** @hidden */
  60998. export var bloomMergePixelShader: {
  60999. name: string;
  61000. shader: string;
  61001. };
  61002. }
  61003. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61004. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61005. import { Nullable } from "babylonjs/types";
  61006. import { Engine } from "babylonjs/Engines/engine";
  61007. import { Camera } from "babylonjs/Cameras/camera";
  61008. import "babylonjs/Shaders/bloomMerge.fragment";
  61009. /**
  61010. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61011. */
  61012. export class BloomMergePostProcess extends PostProcess {
  61013. /** Weight of the bloom to be added to the original input. */
  61014. weight: number;
  61015. /**
  61016. * Creates a new instance of @see BloomMergePostProcess
  61017. * @param name The name of the effect.
  61018. * @param originalFromInput Post process which's input will be used for the merge.
  61019. * @param blurred Blurred highlights post process which's output will be used.
  61020. * @param weight Weight of the bloom to be added to the original input.
  61021. * @param options The required width/height ratio to downsize to before computing the render pass.
  61022. * @param camera The camera to apply the render pass to.
  61023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61024. * @param engine The engine which the post process will be applied. (default: current engine)
  61025. * @param reusable If the post process can be reused on the same frame. (default: false)
  61026. * @param textureType Type of textures used when performing the post process. (default: 0)
  61027. * @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)
  61028. */
  61029. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61030. /** Weight of the bloom to be added to the original input. */
  61031. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61032. }
  61033. }
  61034. declare module "babylonjs/PostProcesses/bloomEffect" {
  61035. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61036. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61037. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61038. import { Camera } from "babylonjs/Cameras/camera";
  61039. import { Scene } from "babylonjs/scene";
  61040. /**
  61041. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61042. */
  61043. export class BloomEffect extends PostProcessRenderEffect {
  61044. private bloomScale;
  61045. /**
  61046. * @hidden Internal
  61047. */
  61048. _effects: Array<PostProcess>;
  61049. /**
  61050. * @hidden Internal
  61051. */
  61052. _downscale: ExtractHighlightsPostProcess;
  61053. private _blurX;
  61054. private _blurY;
  61055. private _merge;
  61056. /**
  61057. * The luminance threshold to find bright areas of the image to bloom.
  61058. */
  61059. threshold: number;
  61060. /**
  61061. * The strength of the bloom.
  61062. */
  61063. weight: number;
  61064. /**
  61065. * Specifies the size of the bloom blur kernel, relative to the final output size
  61066. */
  61067. kernel: number;
  61068. /**
  61069. * Creates a new instance of @see BloomEffect
  61070. * @param scene The scene the effect belongs to.
  61071. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61072. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61073. * @param bloomWeight The the strength of bloom.
  61074. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61075. * @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)
  61076. */
  61077. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61078. /**
  61079. * Disposes each of the internal effects for a given camera.
  61080. * @param camera The camera to dispose the effect on.
  61081. */
  61082. disposeEffects(camera: Camera): void;
  61083. /**
  61084. * @hidden Internal
  61085. */
  61086. _updateEffects(): void;
  61087. /**
  61088. * Internal
  61089. * @returns if all the contained post processes are ready.
  61090. * @hidden
  61091. */
  61092. _isReady(): boolean;
  61093. }
  61094. }
  61095. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61096. /** @hidden */
  61097. export var chromaticAberrationPixelShader: {
  61098. name: string;
  61099. shader: string;
  61100. };
  61101. }
  61102. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61103. import { Vector2 } from "babylonjs/Maths/math.vector";
  61104. import { Nullable } from "babylonjs/types";
  61105. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61106. import { Camera } from "babylonjs/Cameras/camera";
  61107. import { Engine } from "babylonjs/Engines/engine";
  61108. import "babylonjs/Shaders/chromaticAberration.fragment";
  61109. /**
  61110. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61111. */
  61112. export class ChromaticAberrationPostProcess extends PostProcess {
  61113. /**
  61114. * The amount of seperation of rgb channels (default: 30)
  61115. */
  61116. aberrationAmount: number;
  61117. /**
  61118. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61119. */
  61120. radialIntensity: number;
  61121. /**
  61122. * 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))
  61123. */
  61124. direction: Vector2;
  61125. /**
  61126. * 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))
  61127. */
  61128. centerPosition: Vector2;
  61129. /**
  61130. * Creates a new instance ChromaticAberrationPostProcess
  61131. * @param name The name of the effect.
  61132. * @param screenWidth The width of the screen to apply the effect on.
  61133. * @param screenHeight The height of the screen to apply the effect on.
  61134. * @param options The required width/height ratio to downsize to before computing the render pass.
  61135. * @param camera The camera to apply the render pass to.
  61136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61137. * @param engine The engine which the post process will be applied. (default: current engine)
  61138. * @param reusable If the post process can be reused on the same frame. (default: false)
  61139. * @param textureType Type of textures used when performing the post process. (default: 0)
  61140. * @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)
  61141. */
  61142. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61143. }
  61144. }
  61145. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61146. /** @hidden */
  61147. export var circleOfConfusionPixelShader: {
  61148. name: string;
  61149. shader: string;
  61150. };
  61151. }
  61152. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61153. import { Nullable } from "babylonjs/types";
  61154. import { Engine } from "babylonjs/Engines/engine";
  61155. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61156. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61157. import { Camera } from "babylonjs/Cameras/camera";
  61158. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61159. /**
  61160. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61161. */
  61162. export class CircleOfConfusionPostProcess extends PostProcess {
  61163. /**
  61164. * 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.
  61165. */
  61166. lensSize: number;
  61167. /**
  61168. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61169. */
  61170. fStop: number;
  61171. /**
  61172. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61173. */
  61174. focusDistance: number;
  61175. /**
  61176. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61177. */
  61178. focalLength: number;
  61179. private _depthTexture;
  61180. /**
  61181. * Creates a new instance CircleOfConfusionPostProcess
  61182. * @param name The name of the effect.
  61183. * @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.
  61184. * @param options The required width/height ratio to downsize to before computing the render pass.
  61185. * @param camera The camera to apply the render pass to.
  61186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61187. * @param engine The engine which the post process will be applied. (default: current engine)
  61188. * @param reusable If the post process can be reused on the same frame. (default: false)
  61189. * @param textureType Type of textures used when performing the post process. (default: 0)
  61190. * @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)
  61191. */
  61192. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61193. /**
  61194. * 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.
  61195. */
  61196. depthTexture: RenderTargetTexture;
  61197. }
  61198. }
  61199. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61200. /** @hidden */
  61201. export var colorCorrectionPixelShader: {
  61202. name: string;
  61203. shader: string;
  61204. };
  61205. }
  61206. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61207. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61208. import { Engine } from "babylonjs/Engines/engine";
  61209. import { Camera } from "babylonjs/Cameras/camera";
  61210. import "babylonjs/Shaders/colorCorrection.fragment";
  61211. /**
  61212. *
  61213. * This post-process allows the modification of rendered colors by using
  61214. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61215. *
  61216. * The object needs to be provided an url to a texture containing the color
  61217. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61218. * Use an image editing software to tweak the LUT to match your needs.
  61219. *
  61220. * For an example of a color LUT, see here:
  61221. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61222. * For explanations on color grading, see here:
  61223. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61224. *
  61225. */
  61226. export class ColorCorrectionPostProcess extends PostProcess {
  61227. private _colorTableTexture;
  61228. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61229. }
  61230. }
  61231. declare module "babylonjs/Shaders/convolution.fragment" {
  61232. /** @hidden */
  61233. export var convolutionPixelShader: {
  61234. name: string;
  61235. shader: string;
  61236. };
  61237. }
  61238. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61239. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61240. import { Nullable } from "babylonjs/types";
  61241. import { Camera } from "babylonjs/Cameras/camera";
  61242. import { Engine } from "babylonjs/Engines/engine";
  61243. import "babylonjs/Shaders/convolution.fragment";
  61244. /**
  61245. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61246. * input texture to perform effects such as edge detection or sharpening
  61247. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61248. */
  61249. export class ConvolutionPostProcess extends PostProcess {
  61250. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61251. kernel: number[];
  61252. /**
  61253. * Creates a new instance ConvolutionPostProcess
  61254. * @param name The name of the effect.
  61255. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61256. * @param options The required width/height ratio to downsize to before computing the render pass.
  61257. * @param camera The camera to apply the render pass to.
  61258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61259. * @param engine The engine which the post process will be applied. (default: current engine)
  61260. * @param reusable If the post process can be reused on the same frame. (default: false)
  61261. * @param textureType Type of textures used when performing the post process. (default: 0)
  61262. */
  61263. constructor(name: string,
  61264. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61265. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61266. /**
  61267. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61268. */
  61269. static EdgeDetect0Kernel: number[];
  61270. /**
  61271. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61272. */
  61273. static EdgeDetect1Kernel: number[];
  61274. /**
  61275. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61276. */
  61277. static EdgeDetect2Kernel: number[];
  61278. /**
  61279. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61280. */
  61281. static SharpenKernel: number[];
  61282. /**
  61283. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61284. */
  61285. static EmbossKernel: number[];
  61286. /**
  61287. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61288. */
  61289. static GaussianKernel: number[];
  61290. }
  61291. }
  61292. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61293. import { Nullable } from "babylonjs/types";
  61294. import { Vector2 } from "babylonjs/Maths/math.vector";
  61295. import { Camera } from "babylonjs/Cameras/camera";
  61296. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61297. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61298. import { Engine } from "babylonjs/Engines/engine";
  61299. import { Scene } from "babylonjs/scene";
  61300. /**
  61301. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61302. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61303. * based on samples that have a large difference in distance than the center pixel.
  61304. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61305. */
  61306. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61307. direction: Vector2;
  61308. /**
  61309. * Creates a new instance CircleOfConfusionPostProcess
  61310. * @param name The name of the effect.
  61311. * @param scene The scene the effect belongs to.
  61312. * @param direction The direction the blur should be applied.
  61313. * @param kernel The size of the kernel used to blur.
  61314. * @param options The required width/height ratio to downsize to before computing the render pass.
  61315. * @param camera The camera to apply the render pass to.
  61316. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61317. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61319. * @param engine The engine which the post process will be applied. (default: current engine)
  61320. * @param reusable If the post process can be reused on the same frame. (default: false)
  61321. * @param textureType Type of textures used when performing the post process. (default: 0)
  61322. * @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)
  61323. */
  61324. 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);
  61325. }
  61326. }
  61327. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61328. /** @hidden */
  61329. export var depthOfFieldMergePixelShader: {
  61330. name: string;
  61331. shader: string;
  61332. };
  61333. }
  61334. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61335. import { Nullable } from "babylonjs/types";
  61336. import { Camera } from "babylonjs/Cameras/camera";
  61337. import { Effect } from "babylonjs/Materials/effect";
  61338. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61339. import { Engine } from "babylonjs/Engines/engine";
  61340. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61341. /**
  61342. * Options to be set when merging outputs from the default pipeline.
  61343. */
  61344. export class DepthOfFieldMergePostProcessOptions {
  61345. /**
  61346. * The original image to merge on top of
  61347. */
  61348. originalFromInput: PostProcess;
  61349. /**
  61350. * Parameters to perform the merge of the depth of field effect
  61351. */
  61352. depthOfField?: {
  61353. circleOfConfusion: PostProcess;
  61354. blurSteps: Array<PostProcess>;
  61355. };
  61356. /**
  61357. * Parameters to perform the merge of bloom effect
  61358. */
  61359. bloom?: {
  61360. blurred: PostProcess;
  61361. weight: number;
  61362. };
  61363. }
  61364. /**
  61365. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61366. */
  61367. export class DepthOfFieldMergePostProcess extends PostProcess {
  61368. private blurSteps;
  61369. /**
  61370. * Creates a new instance of DepthOfFieldMergePostProcess
  61371. * @param name The name of the effect.
  61372. * @param originalFromInput Post process which's input will be used for the merge.
  61373. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61374. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61375. * @param options The required width/height ratio to downsize to before computing the render pass.
  61376. * @param camera The camera to apply the render pass to.
  61377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61378. * @param engine The engine which the post process will be applied. (default: current engine)
  61379. * @param reusable If the post process can be reused on the same frame. (default: false)
  61380. * @param textureType Type of textures used when performing the post process. (default: 0)
  61381. * @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)
  61382. */
  61383. 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);
  61384. /**
  61385. * Updates the effect with the current post process compile time values and recompiles the shader.
  61386. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61387. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61388. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61389. * @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
  61390. * @param onCompiled Called when the shader has been compiled.
  61391. * @param onError Called if there is an error when compiling a shader.
  61392. */
  61393. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61394. }
  61395. }
  61396. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61397. import { Nullable } from "babylonjs/types";
  61398. import { Camera } from "babylonjs/Cameras/camera";
  61399. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61400. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61401. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61402. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61403. import { Scene } from "babylonjs/scene";
  61404. /**
  61405. * Specifies the level of max blur that should be applied when using the depth of field effect
  61406. */
  61407. export enum DepthOfFieldEffectBlurLevel {
  61408. /**
  61409. * Subtle blur
  61410. */
  61411. Low = 0,
  61412. /**
  61413. * Medium blur
  61414. */
  61415. Medium = 1,
  61416. /**
  61417. * Large blur
  61418. */
  61419. High = 2
  61420. }
  61421. /**
  61422. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61423. */
  61424. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61425. private _circleOfConfusion;
  61426. /**
  61427. * @hidden Internal, blurs from high to low
  61428. */
  61429. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61430. private _depthOfFieldBlurY;
  61431. private _dofMerge;
  61432. /**
  61433. * @hidden Internal post processes in depth of field effect
  61434. */
  61435. _effects: Array<PostProcess>;
  61436. /**
  61437. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61438. */
  61439. focalLength: number;
  61440. /**
  61441. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61442. */
  61443. fStop: number;
  61444. /**
  61445. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61446. */
  61447. focusDistance: number;
  61448. /**
  61449. * 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.
  61450. */
  61451. lensSize: number;
  61452. /**
  61453. * Creates a new instance DepthOfFieldEffect
  61454. * @param scene The scene the effect belongs to.
  61455. * @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.
  61456. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61457. * @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)
  61458. */
  61459. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61460. /**
  61461. * Get the current class name of the current effet
  61462. * @returns "DepthOfFieldEffect"
  61463. */
  61464. getClassName(): string;
  61465. /**
  61466. * 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.
  61467. */
  61468. depthTexture: RenderTargetTexture;
  61469. /**
  61470. * Disposes each of the internal effects for a given camera.
  61471. * @param camera The camera to dispose the effect on.
  61472. */
  61473. disposeEffects(camera: Camera): void;
  61474. /**
  61475. * @hidden Internal
  61476. */
  61477. _updateEffects(): void;
  61478. /**
  61479. * Internal
  61480. * @returns if all the contained post processes are ready.
  61481. * @hidden
  61482. */
  61483. _isReady(): boolean;
  61484. }
  61485. }
  61486. declare module "babylonjs/Shaders/displayPass.fragment" {
  61487. /** @hidden */
  61488. export var displayPassPixelShader: {
  61489. name: string;
  61490. shader: string;
  61491. };
  61492. }
  61493. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61494. import { Nullable } from "babylonjs/types";
  61495. import { Camera } from "babylonjs/Cameras/camera";
  61496. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61497. import { Engine } from "babylonjs/Engines/engine";
  61498. import "babylonjs/Shaders/displayPass.fragment";
  61499. /**
  61500. * DisplayPassPostProcess which produces an output the same as it's input
  61501. */
  61502. export class DisplayPassPostProcess extends PostProcess {
  61503. /**
  61504. * Creates the DisplayPassPostProcess
  61505. * @param name The name of the effect.
  61506. * @param options The required width/height ratio to downsize to before computing the render pass.
  61507. * @param camera The camera to apply the render pass to.
  61508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61509. * @param engine The engine which the post process will be applied. (default: current engine)
  61510. * @param reusable If the post process can be reused on the same frame. (default: false)
  61511. */
  61512. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61513. }
  61514. }
  61515. declare module "babylonjs/Shaders/filter.fragment" {
  61516. /** @hidden */
  61517. export var filterPixelShader: {
  61518. name: string;
  61519. shader: string;
  61520. };
  61521. }
  61522. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61523. import { Nullable } from "babylonjs/types";
  61524. import { Matrix } from "babylonjs/Maths/math.vector";
  61525. import { Camera } from "babylonjs/Cameras/camera";
  61526. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61527. import { Engine } from "babylonjs/Engines/engine";
  61528. import "babylonjs/Shaders/filter.fragment";
  61529. /**
  61530. * Applies a kernel filter to the image
  61531. */
  61532. export class FilterPostProcess extends PostProcess {
  61533. /** The matrix to be applied to the image */
  61534. kernelMatrix: Matrix;
  61535. /**
  61536. *
  61537. * @param name The name of the effect.
  61538. * @param kernelMatrix The matrix to be applied to the image
  61539. * @param options The required width/height ratio to downsize to before computing the render pass.
  61540. * @param camera The camera to apply the render pass to.
  61541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61542. * @param engine The engine which the post process will be applied. (default: current engine)
  61543. * @param reusable If the post process can be reused on the same frame. (default: false)
  61544. */
  61545. constructor(name: string,
  61546. /** The matrix to be applied to the image */
  61547. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61548. }
  61549. }
  61550. declare module "babylonjs/Shaders/fxaa.fragment" {
  61551. /** @hidden */
  61552. export var fxaaPixelShader: {
  61553. name: string;
  61554. shader: string;
  61555. };
  61556. }
  61557. declare module "babylonjs/Shaders/fxaa.vertex" {
  61558. /** @hidden */
  61559. export var fxaaVertexShader: {
  61560. name: string;
  61561. shader: string;
  61562. };
  61563. }
  61564. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61565. import { Nullable } from "babylonjs/types";
  61566. import { Camera } from "babylonjs/Cameras/camera";
  61567. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61568. import { Engine } from "babylonjs/Engines/engine";
  61569. import "babylonjs/Shaders/fxaa.fragment";
  61570. import "babylonjs/Shaders/fxaa.vertex";
  61571. /**
  61572. * Fxaa post process
  61573. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61574. */
  61575. export class FxaaPostProcess extends PostProcess {
  61576. /** @hidden */
  61577. texelWidth: number;
  61578. /** @hidden */
  61579. texelHeight: number;
  61580. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61581. private _getDefines;
  61582. }
  61583. }
  61584. declare module "babylonjs/Shaders/grain.fragment" {
  61585. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61586. /** @hidden */
  61587. export var grainPixelShader: {
  61588. name: string;
  61589. shader: string;
  61590. };
  61591. }
  61592. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61593. import { Nullable } from "babylonjs/types";
  61594. import { Camera } from "babylonjs/Cameras/camera";
  61595. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61596. import { Engine } from "babylonjs/Engines/engine";
  61597. import "babylonjs/Shaders/grain.fragment";
  61598. /**
  61599. * The GrainPostProcess adds noise to the image at mid luminance levels
  61600. */
  61601. export class GrainPostProcess extends PostProcess {
  61602. /**
  61603. * The intensity of the grain added (default: 30)
  61604. */
  61605. intensity: number;
  61606. /**
  61607. * If the grain should be randomized on every frame
  61608. */
  61609. animated: boolean;
  61610. /**
  61611. * Creates a new instance of @see GrainPostProcess
  61612. * @param name The name of the effect.
  61613. * @param options The required width/height ratio to downsize to before computing the render pass.
  61614. * @param camera The camera to apply the render pass to.
  61615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61616. * @param engine The engine which the post process will be applied. (default: current engine)
  61617. * @param reusable If the post process can be reused on the same frame. (default: false)
  61618. * @param textureType Type of textures used when performing the post process. (default: 0)
  61619. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  61620. */
  61621. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61622. }
  61623. }
  61624. declare module "babylonjs/Shaders/highlights.fragment" {
  61625. /** @hidden */
  61626. export var highlightsPixelShader: {
  61627. name: string;
  61628. shader: string;
  61629. };
  61630. }
  61631. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61632. import { Nullable } from "babylonjs/types";
  61633. import { Camera } from "babylonjs/Cameras/camera";
  61634. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61635. import { Engine } from "babylonjs/Engines/engine";
  61636. import "babylonjs/Shaders/highlights.fragment";
  61637. /**
  61638. * Extracts highlights from the image
  61639. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61640. */
  61641. export class HighlightsPostProcess extends PostProcess {
  61642. /**
  61643. * Extracts highlights from the image
  61644. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61645. * @param name The name of the effect.
  61646. * @param options The required width/height ratio to downsize to before computing the render pass.
  61647. * @param camera The camera to apply the render pass to.
  61648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61649. * @param engine The engine which the post process will be applied. (default: current engine)
  61650. * @param reusable If the post process can be reused on the same frame. (default: false)
  61651. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61652. */
  61653. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61654. }
  61655. }
  61656. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61657. /** @hidden */
  61658. export var mrtFragmentDeclaration: {
  61659. name: string;
  61660. shader: string;
  61661. };
  61662. }
  61663. declare module "babylonjs/Shaders/geometry.fragment" {
  61664. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61665. /** @hidden */
  61666. export var geometryPixelShader: {
  61667. name: string;
  61668. shader: string;
  61669. };
  61670. }
  61671. declare module "babylonjs/Shaders/geometry.vertex" {
  61672. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61673. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61674. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61675. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61676. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61677. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61678. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61679. /** @hidden */
  61680. export var geometryVertexShader: {
  61681. name: string;
  61682. shader: string;
  61683. };
  61684. }
  61685. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61686. import { Matrix } from "babylonjs/Maths/math.vector";
  61687. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61688. import { Mesh } from "babylonjs/Meshes/mesh";
  61689. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61690. import { Effect } from "babylonjs/Materials/effect";
  61691. import { Scene } from "babylonjs/scene";
  61692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61693. import "babylonjs/Shaders/geometry.fragment";
  61694. import "babylonjs/Shaders/geometry.vertex";
  61695. /** @hidden */
  61696. interface ISavedTransformationMatrix {
  61697. world: Matrix;
  61698. viewProjection: Matrix;
  61699. }
  61700. /**
  61701. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61702. */
  61703. export class GeometryBufferRenderer {
  61704. /**
  61705. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61706. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61707. */
  61708. static readonly POSITION_TEXTURE_TYPE: number;
  61709. /**
  61710. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61711. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61712. */
  61713. static readonly VELOCITY_TEXTURE_TYPE: number;
  61714. /**
  61715. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61716. * in order to compute objects velocities when enableVelocity is set to "true"
  61717. * @hidden
  61718. */
  61719. _previousTransformationMatrices: {
  61720. [index: number]: ISavedTransformationMatrix;
  61721. };
  61722. /**
  61723. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61724. * in order to compute objects velocities when enableVelocity is set to "true"
  61725. * @hidden
  61726. */
  61727. _previousBonesTransformationMatrices: {
  61728. [index: number]: Float32Array;
  61729. };
  61730. /**
  61731. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61732. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61733. */
  61734. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61735. private _scene;
  61736. private _multiRenderTarget;
  61737. private _ratio;
  61738. private _enablePosition;
  61739. private _enableVelocity;
  61740. private _positionIndex;
  61741. private _velocityIndex;
  61742. protected _effect: Effect;
  61743. protected _cachedDefines: string;
  61744. /**
  61745. * Set the render list (meshes to be rendered) used in the G buffer.
  61746. */
  61747. renderList: Mesh[];
  61748. /**
  61749. * Gets wether or not G buffer are supported by the running hardware.
  61750. * This requires draw buffer supports
  61751. */
  61752. readonly isSupported: boolean;
  61753. /**
  61754. * Returns the index of the given texture type in the G-Buffer textures array
  61755. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61756. * @returns the index of the given texture type in the G-Buffer textures array
  61757. */
  61758. getTextureIndex(textureType: number): number;
  61759. /**
  61760. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61761. */
  61762. /**
  61763. * Sets whether or not objects positions are enabled for the G buffer.
  61764. */
  61765. enablePosition: boolean;
  61766. /**
  61767. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61768. */
  61769. /**
  61770. * Sets wether or not objects velocities are enabled for the G buffer.
  61771. */
  61772. enableVelocity: boolean;
  61773. /**
  61774. * Gets the scene associated with the buffer.
  61775. */
  61776. readonly scene: Scene;
  61777. /**
  61778. * Gets the ratio used by the buffer during its creation.
  61779. * How big is the buffer related to the main canvas.
  61780. */
  61781. readonly ratio: number;
  61782. /** @hidden */
  61783. static _SceneComponentInitialization: (scene: Scene) => void;
  61784. /**
  61785. * Creates a new G Buffer for the scene
  61786. * @param scene The scene the buffer belongs to
  61787. * @param ratio How big is the buffer related to the main canvas.
  61788. */
  61789. constructor(scene: Scene, ratio?: number);
  61790. /**
  61791. * Checks wether everything is ready to render a submesh to the G buffer.
  61792. * @param subMesh the submesh to check readiness for
  61793. * @param useInstances is the mesh drawn using instance or not
  61794. * @returns true if ready otherwise false
  61795. */
  61796. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61797. /**
  61798. * Gets the current underlying G Buffer.
  61799. * @returns the buffer
  61800. */
  61801. getGBuffer(): MultiRenderTarget;
  61802. /**
  61803. * Gets the number of samples used to render the buffer (anti aliasing).
  61804. */
  61805. /**
  61806. * Sets the number of samples used to render the buffer (anti aliasing).
  61807. */
  61808. samples: number;
  61809. /**
  61810. * Disposes the renderer and frees up associated resources.
  61811. */
  61812. dispose(): void;
  61813. protected _createRenderTargets(): void;
  61814. private _copyBonesTransformationMatrices;
  61815. }
  61816. }
  61817. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61818. import { Nullable } from "babylonjs/types";
  61819. import { Scene } from "babylonjs/scene";
  61820. import { ISceneComponent } from "babylonjs/sceneComponent";
  61821. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61822. module "babylonjs/scene" {
  61823. interface Scene {
  61824. /** @hidden (Backing field) */
  61825. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61826. /**
  61827. * Gets or Sets the current geometry buffer associated to the scene.
  61828. */
  61829. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61830. /**
  61831. * Enables a GeometryBufferRender and associates it with the scene
  61832. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61833. * @returns the GeometryBufferRenderer
  61834. */
  61835. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61836. /**
  61837. * Disables the GeometryBufferRender associated with the scene
  61838. */
  61839. disableGeometryBufferRenderer(): void;
  61840. }
  61841. }
  61842. /**
  61843. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61844. * in several rendering techniques.
  61845. */
  61846. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61847. /**
  61848. * The component name helpful to identify the component in the list of scene components.
  61849. */
  61850. readonly name: string;
  61851. /**
  61852. * The scene the component belongs to.
  61853. */
  61854. scene: Scene;
  61855. /**
  61856. * Creates a new instance of the component for the given scene
  61857. * @param scene Defines the scene to register the component in
  61858. */
  61859. constructor(scene: Scene);
  61860. /**
  61861. * Registers the component in a given scene
  61862. */
  61863. register(): void;
  61864. /**
  61865. * Rebuilds the elements related to this component in case of
  61866. * context lost for instance.
  61867. */
  61868. rebuild(): void;
  61869. /**
  61870. * Disposes the component and the associated ressources
  61871. */
  61872. dispose(): void;
  61873. private _gatherRenderTargets;
  61874. }
  61875. }
  61876. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61877. /** @hidden */
  61878. export var motionBlurPixelShader: {
  61879. name: string;
  61880. shader: string;
  61881. };
  61882. }
  61883. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61884. import { Nullable } from "babylonjs/types";
  61885. import { Camera } from "babylonjs/Cameras/camera";
  61886. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61887. import { Scene } from "babylonjs/scene";
  61888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61889. import "babylonjs/Animations/animatable";
  61890. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61891. import "babylonjs/Shaders/motionBlur.fragment";
  61892. import { Engine } from "babylonjs/Engines/engine";
  61893. /**
  61894. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61895. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61896. * As an example, all you have to do is to create the post-process:
  61897. * var mb = new BABYLON.MotionBlurPostProcess(
  61898. * 'mb', // The name of the effect.
  61899. * scene, // The scene containing the objects to blur according to their velocity.
  61900. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61901. * camera // The camera to apply the render pass to.
  61902. * );
  61903. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61904. */
  61905. export class MotionBlurPostProcess extends PostProcess {
  61906. /**
  61907. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61908. */
  61909. motionStrength: number;
  61910. /**
  61911. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61912. */
  61913. /**
  61914. * Sets the number of iterations to be used for motion blur quality
  61915. */
  61916. motionBlurSamples: number;
  61917. private _motionBlurSamples;
  61918. private _geometryBufferRenderer;
  61919. /**
  61920. * Creates a new instance MotionBlurPostProcess
  61921. * @param name The name of the effect.
  61922. * @param scene The scene containing the objects to blur according to their velocity.
  61923. * @param options The required width/height ratio to downsize to before computing the render pass.
  61924. * @param camera The camera to apply the render pass to.
  61925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61926. * @param engine The engine which the post process will be applied. (default: current engine)
  61927. * @param reusable If the post process can be reused on the same frame. (default: false)
  61928. * @param textureType Type of textures used when performing the post process. (default: 0)
  61929. * @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)
  61930. */
  61931. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61932. /**
  61933. * Excludes the given skinned mesh from computing bones velocities.
  61934. * 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.
  61935. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61936. */
  61937. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61938. /**
  61939. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61940. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61941. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61942. */
  61943. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61944. /**
  61945. * Disposes the post process.
  61946. * @param camera The camera to dispose the post process on.
  61947. */
  61948. dispose(camera?: Camera): void;
  61949. }
  61950. }
  61951. declare module "babylonjs/Shaders/refraction.fragment" {
  61952. /** @hidden */
  61953. export var refractionPixelShader: {
  61954. name: string;
  61955. shader: string;
  61956. };
  61957. }
  61958. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61959. import { Color3 } from "babylonjs/Maths/math.color";
  61960. import { Camera } from "babylonjs/Cameras/camera";
  61961. import { Texture } from "babylonjs/Materials/Textures/texture";
  61962. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61963. import { Engine } from "babylonjs/Engines/engine";
  61964. import "babylonjs/Shaders/refraction.fragment";
  61965. /**
  61966. * Post process which applies a refractin texture
  61967. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61968. */
  61969. export class RefractionPostProcess extends PostProcess {
  61970. /** the base color of the refraction (used to taint the rendering) */
  61971. color: Color3;
  61972. /** simulated refraction depth */
  61973. depth: number;
  61974. /** the coefficient of the base color (0 to remove base color tainting) */
  61975. colorLevel: number;
  61976. private _refTexture;
  61977. private _ownRefractionTexture;
  61978. /**
  61979. * Gets or sets the refraction texture
  61980. * Please note that you are responsible for disposing the texture if you set it manually
  61981. */
  61982. refractionTexture: Texture;
  61983. /**
  61984. * Initializes the RefractionPostProcess
  61985. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61986. * @param name The name of the effect.
  61987. * @param refractionTextureUrl Url of the refraction texture to use
  61988. * @param color the base color of the refraction (used to taint the rendering)
  61989. * @param depth simulated refraction depth
  61990. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61991. * @param camera The camera to apply the render pass to.
  61992. * @param options The required width/height ratio to downsize to before computing the render pass.
  61993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61994. * @param engine The engine which the post process will be applied. (default: current engine)
  61995. * @param reusable If the post process can be reused on the same frame. (default: false)
  61996. */
  61997. constructor(name: string, refractionTextureUrl: string,
  61998. /** the base color of the refraction (used to taint the rendering) */
  61999. color: Color3,
  62000. /** simulated refraction depth */
  62001. depth: number,
  62002. /** the coefficient of the base color (0 to remove base color tainting) */
  62003. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62004. /**
  62005. * Disposes of the post process
  62006. * @param camera Camera to dispose post process on
  62007. */
  62008. dispose(camera: Camera): void;
  62009. }
  62010. }
  62011. declare module "babylonjs/Shaders/sharpen.fragment" {
  62012. /** @hidden */
  62013. export var sharpenPixelShader: {
  62014. name: string;
  62015. shader: string;
  62016. };
  62017. }
  62018. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62019. import { Nullable } from "babylonjs/types";
  62020. import { Camera } from "babylonjs/Cameras/camera";
  62021. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62022. import "babylonjs/Shaders/sharpen.fragment";
  62023. import { Engine } from "babylonjs/Engines/engine";
  62024. /**
  62025. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62026. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62027. */
  62028. export class SharpenPostProcess extends PostProcess {
  62029. /**
  62030. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62031. */
  62032. colorAmount: number;
  62033. /**
  62034. * How much sharpness should be applied (default: 0.3)
  62035. */
  62036. edgeAmount: number;
  62037. /**
  62038. * Creates a new instance ConvolutionPostProcess
  62039. * @param name The name of the effect.
  62040. * @param options The required width/height ratio to downsize to before computing the render pass.
  62041. * @param camera The camera to apply the render pass to.
  62042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62043. * @param engine The engine which the post process will be applied. (default: current engine)
  62044. * @param reusable If the post process can be reused on the same frame. (default: false)
  62045. * @param textureType Type of textures used when performing the post process. (default: 0)
  62046. * @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)
  62047. */
  62048. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62049. }
  62050. }
  62051. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62052. import { Nullable } from "babylonjs/types";
  62053. import { Camera } from "babylonjs/Cameras/camera";
  62054. import { Engine } from "babylonjs/Engines/engine";
  62055. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62056. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62057. /**
  62058. * PostProcessRenderPipeline
  62059. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62060. */
  62061. export class PostProcessRenderPipeline {
  62062. private engine;
  62063. private _renderEffects;
  62064. private _renderEffectsForIsolatedPass;
  62065. /**
  62066. * List of inspectable custom properties (used by the Inspector)
  62067. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62068. */
  62069. inspectableCustomProperties: IInspectable[];
  62070. /**
  62071. * @hidden
  62072. */
  62073. protected _cameras: Camera[];
  62074. /** @hidden */
  62075. _name: string;
  62076. /**
  62077. * Gets pipeline name
  62078. */
  62079. readonly name: string;
  62080. /**
  62081. * Initializes a PostProcessRenderPipeline
  62082. * @param engine engine to add the pipeline to
  62083. * @param name name of the pipeline
  62084. */
  62085. constructor(engine: Engine, name: string);
  62086. /**
  62087. * Gets the class name
  62088. * @returns "PostProcessRenderPipeline"
  62089. */
  62090. getClassName(): string;
  62091. /**
  62092. * If all the render effects in the pipeline are supported
  62093. */
  62094. readonly isSupported: boolean;
  62095. /**
  62096. * Adds an effect to the pipeline
  62097. * @param renderEffect the effect to add
  62098. */
  62099. addEffect(renderEffect: PostProcessRenderEffect): void;
  62100. /** @hidden */
  62101. _rebuild(): void;
  62102. /** @hidden */
  62103. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62104. /** @hidden */
  62105. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62106. /** @hidden */
  62107. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62108. /** @hidden */
  62109. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62110. /** @hidden */
  62111. _attachCameras(cameras: Camera, unique: boolean): void;
  62112. /** @hidden */
  62113. _attachCameras(cameras: Camera[], unique: boolean): void;
  62114. /** @hidden */
  62115. _detachCameras(cameras: Camera): void;
  62116. /** @hidden */
  62117. _detachCameras(cameras: Nullable<Camera[]>): void;
  62118. /** @hidden */
  62119. _update(): void;
  62120. /** @hidden */
  62121. _reset(): void;
  62122. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62123. /**
  62124. * Disposes of the pipeline
  62125. */
  62126. dispose(): void;
  62127. }
  62128. }
  62129. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62130. import { Camera } from "babylonjs/Cameras/camera";
  62131. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62132. /**
  62133. * PostProcessRenderPipelineManager class
  62134. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62135. */
  62136. export class PostProcessRenderPipelineManager {
  62137. private _renderPipelines;
  62138. /**
  62139. * Initializes a PostProcessRenderPipelineManager
  62140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62141. */
  62142. constructor();
  62143. /**
  62144. * Gets the list of supported render pipelines
  62145. */
  62146. readonly supportedPipelines: PostProcessRenderPipeline[];
  62147. /**
  62148. * Adds a pipeline to the manager
  62149. * @param renderPipeline The pipeline to add
  62150. */
  62151. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62152. /**
  62153. * Attaches a camera to the pipeline
  62154. * @param renderPipelineName The name of the pipeline to attach to
  62155. * @param cameras the camera to attach
  62156. * @param unique if the camera can be attached multiple times to the pipeline
  62157. */
  62158. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62159. /**
  62160. * Detaches a camera from the pipeline
  62161. * @param renderPipelineName The name of the pipeline to detach from
  62162. * @param cameras the camera to detach
  62163. */
  62164. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62165. /**
  62166. * Enables an effect by name on a pipeline
  62167. * @param renderPipelineName the name of the pipeline to enable the effect in
  62168. * @param renderEffectName the name of the effect to enable
  62169. * @param cameras the cameras that the effect should be enabled on
  62170. */
  62171. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62172. /**
  62173. * Disables an effect by name on a pipeline
  62174. * @param renderPipelineName the name of the pipeline to disable the effect in
  62175. * @param renderEffectName the name of the effect to disable
  62176. * @param cameras the cameras that the effect should be disabled on
  62177. */
  62178. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62179. /**
  62180. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62181. */
  62182. update(): void;
  62183. /** @hidden */
  62184. _rebuild(): void;
  62185. /**
  62186. * Disposes of the manager and pipelines
  62187. */
  62188. dispose(): void;
  62189. }
  62190. }
  62191. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62192. import { ISceneComponent } from "babylonjs/sceneComponent";
  62193. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62194. import { Scene } from "babylonjs/scene";
  62195. module "babylonjs/scene" {
  62196. interface Scene {
  62197. /** @hidden (Backing field) */
  62198. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62199. /**
  62200. * Gets the postprocess render pipeline manager
  62201. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62202. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62203. */
  62204. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62205. }
  62206. }
  62207. /**
  62208. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62209. */
  62210. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62211. /**
  62212. * The component name helpfull to identify the component in the list of scene components.
  62213. */
  62214. readonly name: string;
  62215. /**
  62216. * The scene the component belongs to.
  62217. */
  62218. scene: Scene;
  62219. /**
  62220. * Creates a new instance of the component for the given scene
  62221. * @param scene Defines the scene to register the component in
  62222. */
  62223. constructor(scene: Scene);
  62224. /**
  62225. * Registers the component in a given scene
  62226. */
  62227. register(): void;
  62228. /**
  62229. * Rebuilds the elements related to this component in case of
  62230. * context lost for instance.
  62231. */
  62232. rebuild(): void;
  62233. /**
  62234. * Disposes the component and the associated ressources
  62235. */
  62236. dispose(): void;
  62237. private _gatherRenderTargets;
  62238. }
  62239. }
  62240. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62241. import { Nullable } from "babylonjs/types";
  62242. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62243. import { Camera } from "babylonjs/Cameras/camera";
  62244. import { IDisposable } from "babylonjs/scene";
  62245. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62246. import { Scene } from "babylonjs/scene";
  62247. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62248. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62249. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62250. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62251. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62252. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62253. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62254. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62255. import { Animation } from "babylonjs/Animations/animation";
  62256. /**
  62257. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62258. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62259. */
  62260. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62261. private _scene;
  62262. private _camerasToBeAttached;
  62263. /**
  62264. * ID of the sharpen post process,
  62265. */
  62266. private readonly SharpenPostProcessId;
  62267. /**
  62268. * @ignore
  62269. * ID of the image processing post process;
  62270. */
  62271. readonly ImageProcessingPostProcessId: string;
  62272. /**
  62273. * @ignore
  62274. * ID of the Fast Approximate Anti-Aliasing post process;
  62275. */
  62276. readonly FxaaPostProcessId: string;
  62277. /**
  62278. * ID of the chromatic aberration post process,
  62279. */
  62280. private readonly ChromaticAberrationPostProcessId;
  62281. /**
  62282. * ID of the grain post process
  62283. */
  62284. private readonly GrainPostProcessId;
  62285. /**
  62286. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62287. */
  62288. sharpen: SharpenPostProcess;
  62289. private _sharpenEffect;
  62290. private bloom;
  62291. /**
  62292. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62293. */
  62294. depthOfField: DepthOfFieldEffect;
  62295. /**
  62296. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62297. */
  62298. fxaa: FxaaPostProcess;
  62299. /**
  62300. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62301. */
  62302. imageProcessing: ImageProcessingPostProcess;
  62303. /**
  62304. * Chromatic aberration post process which will shift rgb colors in the image
  62305. */
  62306. chromaticAberration: ChromaticAberrationPostProcess;
  62307. private _chromaticAberrationEffect;
  62308. /**
  62309. * Grain post process which add noise to the image
  62310. */
  62311. grain: GrainPostProcess;
  62312. private _grainEffect;
  62313. /**
  62314. * Glow post process which adds a glow to emissive areas of the image
  62315. */
  62316. private _glowLayer;
  62317. /**
  62318. * Animations which can be used to tweak settings over a period of time
  62319. */
  62320. animations: Animation[];
  62321. private _imageProcessingConfigurationObserver;
  62322. private _sharpenEnabled;
  62323. private _bloomEnabled;
  62324. private _depthOfFieldEnabled;
  62325. private _depthOfFieldBlurLevel;
  62326. private _fxaaEnabled;
  62327. private _imageProcessingEnabled;
  62328. private _defaultPipelineTextureType;
  62329. private _bloomScale;
  62330. private _chromaticAberrationEnabled;
  62331. private _grainEnabled;
  62332. private _buildAllowed;
  62333. /**
  62334. * Gets active scene
  62335. */
  62336. readonly scene: Scene;
  62337. /**
  62338. * Enable or disable the sharpen process from the pipeline
  62339. */
  62340. sharpenEnabled: boolean;
  62341. private _resizeObserver;
  62342. private _hardwareScaleLevel;
  62343. private _bloomKernel;
  62344. /**
  62345. * Specifies the size of the bloom blur kernel, relative to the final output size
  62346. */
  62347. bloomKernel: number;
  62348. /**
  62349. * Specifies the weight of the bloom in the final rendering
  62350. */
  62351. private _bloomWeight;
  62352. /**
  62353. * Specifies the luma threshold for the area that will be blurred by the bloom
  62354. */
  62355. private _bloomThreshold;
  62356. private _hdr;
  62357. /**
  62358. * The strength of the bloom.
  62359. */
  62360. bloomWeight: number;
  62361. /**
  62362. * The strength of the bloom.
  62363. */
  62364. bloomThreshold: number;
  62365. /**
  62366. * The scale of the bloom, lower value will provide better performance.
  62367. */
  62368. bloomScale: number;
  62369. /**
  62370. * Enable or disable the bloom from the pipeline
  62371. */
  62372. bloomEnabled: boolean;
  62373. private _rebuildBloom;
  62374. /**
  62375. * If the depth of field is enabled.
  62376. */
  62377. depthOfFieldEnabled: boolean;
  62378. /**
  62379. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62380. */
  62381. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62382. /**
  62383. * If the anti aliasing is enabled.
  62384. */
  62385. fxaaEnabled: boolean;
  62386. private _samples;
  62387. /**
  62388. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62389. */
  62390. samples: number;
  62391. /**
  62392. * If image processing is enabled.
  62393. */
  62394. imageProcessingEnabled: boolean;
  62395. /**
  62396. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62397. */
  62398. glowLayerEnabled: boolean;
  62399. /**
  62400. * Gets the glow layer (or null if not defined)
  62401. */
  62402. readonly glowLayer: Nullable<GlowLayer>;
  62403. /**
  62404. * Enable or disable the chromaticAberration process from the pipeline
  62405. */
  62406. chromaticAberrationEnabled: boolean;
  62407. /**
  62408. * Enable or disable the grain process from the pipeline
  62409. */
  62410. grainEnabled: boolean;
  62411. /**
  62412. * @constructor
  62413. * @param name - The rendering pipeline name (default: "")
  62414. * @param hdr - If high dynamic range textures should be used (default: true)
  62415. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62416. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62417. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62418. */
  62419. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62420. /**
  62421. * Get the class name
  62422. * @returns "DefaultRenderingPipeline"
  62423. */
  62424. getClassName(): string;
  62425. /**
  62426. * Force the compilation of the entire pipeline.
  62427. */
  62428. prepare(): void;
  62429. private _hasCleared;
  62430. private _prevPostProcess;
  62431. private _prevPrevPostProcess;
  62432. private _setAutoClearAndTextureSharing;
  62433. private _depthOfFieldSceneObserver;
  62434. private _buildPipeline;
  62435. private _disposePostProcesses;
  62436. /**
  62437. * Adds a camera to the pipeline
  62438. * @param camera the camera to be added
  62439. */
  62440. addCamera(camera: Camera): void;
  62441. /**
  62442. * Removes a camera from the pipeline
  62443. * @param camera the camera to remove
  62444. */
  62445. removeCamera(camera: Camera): void;
  62446. /**
  62447. * Dispose of the pipeline and stop all post processes
  62448. */
  62449. dispose(): void;
  62450. /**
  62451. * Serialize the rendering pipeline (Used when exporting)
  62452. * @returns the serialized object
  62453. */
  62454. serialize(): any;
  62455. /**
  62456. * Parse the serialized pipeline
  62457. * @param source Source pipeline.
  62458. * @param scene The scene to load the pipeline to.
  62459. * @param rootUrl The URL of the serialized pipeline.
  62460. * @returns An instantiated pipeline from the serialized object.
  62461. */
  62462. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62463. }
  62464. }
  62465. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62466. /** @hidden */
  62467. export var lensHighlightsPixelShader: {
  62468. name: string;
  62469. shader: string;
  62470. };
  62471. }
  62472. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62473. /** @hidden */
  62474. export var depthOfFieldPixelShader: {
  62475. name: string;
  62476. shader: string;
  62477. };
  62478. }
  62479. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62480. import { Camera } from "babylonjs/Cameras/camera";
  62481. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62482. import { Scene } from "babylonjs/scene";
  62483. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62484. import "babylonjs/Shaders/chromaticAberration.fragment";
  62485. import "babylonjs/Shaders/lensHighlights.fragment";
  62486. import "babylonjs/Shaders/depthOfField.fragment";
  62487. /**
  62488. * BABYLON.JS Chromatic Aberration GLSL Shader
  62489. * Author: Olivier Guyot
  62490. * Separates very slightly R, G and B colors on the edges of the screen
  62491. * Inspired by Francois Tarlier & Martins Upitis
  62492. */
  62493. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62494. /**
  62495. * @ignore
  62496. * The chromatic aberration PostProcess id in the pipeline
  62497. */
  62498. LensChromaticAberrationEffect: string;
  62499. /**
  62500. * @ignore
  62501. * The highlights enhancing PostProcess id in the pipeline
  62502. */
  62503. HighlightsEnhancingEffect: string;
  62504. /**
  62505. * @ignore
  62506. * The depth-of-field PostProcess id in the pipeline
  62507. */
  62508. LensDepthOfFieldEffect: string;
  62509. private _scene;
  62510. private _depthTexture;
  62511. private _grainTexture;
  62512. private _chromaticAberrationPostProcess;
  62513. private _highlightsPostProcess;
  62514. private _depthOfFieldPostProcess;
  62515. private _edgeBlur;
  62516. private _grainAmount;
  62517. private _chromaticAberration;
  62518. private _distortion;
  62519. private _highlightsGain;
  62520. private _highlightsThreshold;
  62521. private _dofDistance;
  62522. private _dofAperture;
  62523. private _dofDarken;
  62524. private _dofPentagon;
  62525. private _blurNoise;
  62526. /**
  62527. * @constructor
  62528. *
  62529. * Effect parameters are as follow:
  62530. * {
  62531. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62532. * edge_blur: number; // from 0 to x (1 for realism)
  62533. * distortion: number; // from 0 to x (1 for realism)
  62534. * grain_amount: number; // from 0 to 1
  62535. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62536. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62537. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62538. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62539. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62540. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62541. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62542. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62543. * }
  62544. * Note: if an effect parameter is unset, effect is disabled
  62545. *
  62546. * @param name The rendering pipeline name
  62547. * @param parameters - An object containing all parameters (see above)
  62548. * @param scene The scene linked to this pipeline
  62549. * @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)
  62550. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62551. */
  62552. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62553. /**
  62554. * Get the class name
  62555. * @returns "LensRenderingPipeline"
  62556. */
  62557. getClassName(): string;
  62558. /**
  62559. * Gets associated scene
  62560. */
  62561. readonly scene: Scene;
  62562. /**
  62563. * Gets or sets the edge blur
  62564. */
  62565. edgeBlur: number;
  62566. /**
  62567. * Gets or sets the grain amount
  62568. */
  62569. grainAmount: number;
  62570. /**
  62571. * Gets or sets the chromatic aberration amount
  62572. */
  62573. chromaticAberration: number;
  62574. /**
  62575. * Gets or sets the depth of field aperture
  62576. */
  62577. dofAperture: number;
  62578. /**
  62579. * Gets or sets the edge distortion
  62580. */
  62581. edgeDistortion: number;
  62582. /**
  62583. * Gets or sets the depth of field distortion
  62584. */
  62585. dofDistortion: number;
  62586. /**
  62587. * Gets or sets the darken out of focus amount
  62588. */
  62589. darkenOutOfFocus: number;
  62590. /**
  62591. * Gets or sets a boolean indicating if blur noise is enabled
  62592. */
  62593. blurNoise: boolean;
  62594. /**
  62595. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62596. */
  62597. pentagonBokeh: boolean;
  62598. /**
  62599. * Gets or sets the highlight grain amount
  62600. */
  62601. highlightsGain: number;
  62602. /**
  62603. * Gets or sets the highlight threshold
  62604. */
  62605. highlightsThreshold: number;
  62606. /**
  62607. * Sets the amount of blur at the edges
  62608. * @param amount blur amount
  62609. */
  62610. setEdgeBlur(amount: number): void;
  62611. /**
  62612. * Sets edge blur to 0
  62613. */
  62614. disableEdgeBlur(): void;
  62615. /**
  62616. * Sets the amout of grain
  62617. * @param amount Amount of grain
  62618. */
  62619. setGrainAmount(amount: number): void;
  62620. /**
  62621. * Set grain amount to 0
  62622. */
  62623. disableGrain(): void;
  62624. /**
  62625. * Sets the chromatic aberration amount
  62626. * @param amount amount of chromatic aberration
  62627. */
  62628. setChromaticAberration(amount: number): void;
  62629. /**
  62630. * Sets chromatic aberration amount to 0
  62631. */
  62632. disableChromaticAberration(): void;
  62633. /**
  62634. * Sets the EdgeDistortion amount
  62635. * @param amount amount of EdgeDistortion
  62636. */
  62637. setEdgeDistortion(amount: number): void;
  62638. /**
  62639. * Sets edge distortion to 0
  62640. */
  62641. disableEdgeDistortion(): void;
  62642. /**
  62643. * Sets the FocusDistance amount
  62644. * @param amount amount of FocusDistance
  62645. */
  62646. setFocusDistance(amount: number): void;
  62647. /**
  62648. * Disables depth of field
  62649. */
  62650. disableDepthOfField(): void;
  62651. /**
  62652. * Sets the Aperture amount
  62653. * @param amount amount of Aperture
  62654. */
  62655. setAperture(amount: number): void;
  62656. /**
  62657. * Sets the DarkenOutOfFocus amount
  62658. * @param amount amount of DarkenOutOfFocus
  62659. */
  62660. setDarkenOutOfFocus(amount: number): void;
  62661. private _pentagonBokehIsEnabled;
  62662. /**
  62663. * Creates a pentagon bokeh effect
  62664. */
  62665. enablePentagonBokeh(): void;
  62666. /**
  62667. * Disables the pentagon bokeh effect
  62668. */
  62669. disablePentagonBokeh(): void;
  62670. /**
  62671. * Enables noise blur
  62672. */
  62673. enableNoiseBlur(): void;
  62674. /**
  62675. * Disables noise blur
  62676. */
  62677. disableNoiseBlur(): void;
  62678. /**
  62679. * Sets the HighlightsGain amount
  62680. * @param amount amount of HighlightsGain
  62681. */
  62682. setHighlightsGain(amount: number): void;
  62683. /**
  62684. * Sets the HighlightsThreshold amount
  62685. * @param amount amount of HighlightsThreshold
  62686. */
  62687. setHighlightsThreshold(amount: number): void;
  62688. /**
  62689. * Disables highlights
  62690. */
  62691. disableHighlights(): void;
  62692. /**
  62693. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62694. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62695. */
  62696. dispose(disableDepthRender?: boolean): void;
  62697. private _createChromaticAberrationPostProcess;
  62698. private _createHighlightsPostProcess;
  62699. private _createDepthOfFieldPostProcess;
  62700. private _createGrainTexture;
  62701. }
  62702. }
  62703. declare module "babylonjs/Shaders/ssao2.fragment" {
  62704. /** @hidden */
  62705. export var ssao2PixelShader: {
  62706. name: string;
  62707. shader: string;
  62708. };
  62709. }
  62710. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62711. /** @hidden */
  62712. export var ssaoCombinePixelShader: {
  62713. name: string;
  62714. shader: string;
  62715. };
  62716. }
  62717. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62718. import { Camera } from "babylonjs/Cameras/camera";
  62719. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62720. import { Scene } from "babylonjs/scene";
  62721. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62722. import "babylonjs/Shaders/ssao2.fragment";
  62723. import "babylonjs/Shaders/ssaoCombine.fragment";
  62724. /**
  62725. * Render pipeline to produce ssao effect
  62726. */
  62727. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62728. /**
  62729. * @ignore
  62730. * The PassPostProcess id in the pipeline that contains the original scene color
  62731. */
  62732. SSAOOriginalSceneColorEffect: string;
  62733. /**
  62734. * @ignore
  62735. * The SSAO PostProcess id in the pipeline
  62736. */
  62737. SSAORenderEffect: string;
  62738. /**
  62739. * @ignore
  62740. * The horizontal blur PostProcess id in the pipeline
  62741. */
  62742. SSAOBlurHRenderEffect: string;
  62743. /**
  62744. * @ignore
  62745. * The vertical blur PostProcess id in the pipeline
  62746. */
  62747. SSAOBlurVRenderEffect: string;
  62748. /**
  62749. * @ignore
  62750. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62751. */
  62752. SSAOCombineRenderEffect: string;
  62753. /**
  62754. * The output strength of the SSAO post-process. Default value is 1.0.
  62755. */
  62756. totalStrength: number;
  62757. /**
  62758. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62759. */
  62760. maxZ: number;
  62761. /**
  62762. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62763. */
  62764. minZAspect: number;
  62765. private _samples;
  62766. /**
  62767. * Number of samples used for the SSAO calculations. Default value is 8
  62768. */
  62769. samples: number;
  62770. private _textureSamples;
  62771. /**
  62772. * Number of samples to use for antialiasing
  62773. */
  62774. textureSamples: number;
  62775. /**
  62776. * Ratio object used for SSAO ratio and blur ratio
  62777. */
  62778. private _ratio;
  62779. /**
  62780. * Dynamically generated sphere sampler.
  62781. */
  62782. private _sampleSphere;
  62783. /**
  62784. * Blur filter offsets
  62785. */
  62786. private _samplerOffsets;
  62787. private _expensiveBlur;
  62788. /**
  62789. * If bilateral blur should be used
  62790. */
  62791. expensiveBlur: boolean;
  62792. /**
  62793. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62794. */
  62795. radius: number;
  62796. /**
  62797. * The base color of the SSAO post-process
  62798. * The final result is "base + ssao" between [0, 1]
  62799. */
  62800. base: number;
  62801. /**
  62802. * Support test.
  62803. */
  62804. static readonly IsSupported: boolean;
  62805. private _scene;
  62806. private _depthTexture;
  62807. private _normalTexture;
  62808. private _randomTexture;
  62809. private _originalColorPostProcess;
  62810. private _ssaoPostProcess;
  62811. private _blurHPostProcess;
  62812. private _blurVPostProcess;
  62813. private _ssaoCombinePostProcess;
  62814. private _firstUpdate;
  62815. /**
  62816. * Gets active scene
  62817. */
  62818. readonly scene: Scene;
  62819. /**
  62820. * @constructor
  62821. * @param name The rendering pipeline name
  62822. * @param scene The scene linked to this pipeline
  62823. * @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 }
  62824. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62825. */
  62826. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62827. /**
  62828. * Get the class name
  62829. * @returns "SSAO2RenderingPipeline"
  62830. */
  62831. getClassName(): string;
  62832. /**
  62833. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62834. */
  62835. dispose(disableGeometryBufferRenderer?: boolean): void;
  62836. private _createBlurPostProcess;
  62837. /** @hidden */
  62838. _rebuild(): void;
  62839. private _bits;
  62840. private _radicalInverse_VdC;
  62841. private _hammersley;
  62842. private _hemisphereSample_uniform;
  62843. private _generateHemisphere;
  62844. private _createSSAOPostProcess;
  62845. private _createSSAOCombinePostProcess;
  62846. private _createRandomTexture;
  62847. /**
  62848. * Serialize the rendering pipeline (Used when exporting)
  62849. * @returns the serialized object
  62850. */
  62851. serialize(): any;
  62852. /**
  62853. * Parse the serialized pipeline
  62854. * @param source Source pipeline.
  62855. * @param scene The scene to load the pipeline to.
  62856. * @param rootUrl The URL of the serialized pipeline.
  62857. * @returns An instantiated pipeline from the serialized object.
  62858. */
  62859. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62860. }
  62861. }
  62862. declare module "babylonjs/Shaders/ssao.fragment" {
  62863. /** @hidden */
  62864. export var ssaoPixelShader: {
  62865. name: string;
  62866. shader: string;
  62867. };
  62868. }
  62869. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62870. import { Camera } from "babylonjs/Cameras/camera";
  62871. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62872. import { Scene } from "babylonjs/scene";
  62873. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62874. import "babylonjs/Shaders/ssao.fragment";
  62875. import "babylonjs/Shaders/ssaoCombine.fragment";
  62876. /**
  62877. * Render pipeline to produce ssao effect
  62878. */
  62879. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62880. /**
  62881. * @ignore
  62882. * The PassPostProcess id in the pipeline that contains the original scene color
  62883. */
  62884. SSAOOriginalSceneColorEffect: string;
  62885. /**
  62886. * @ignore
  62887. * The SSAO PostProcess id in the pipeline
  62888. */
  62889. SSAORenderEffect: string;
  62890. /**
  62891. * @ignore
  62892. * The horizontal blur PostProcess id in the pipeline
  62893. */
  62894. SSAOBlurHRenderEffect: string;
  62895. /**
  62896. * @ignore
  62897. * The vertical blur PostProcess id in the pipeline
  62898. */
  62899. SSAOBlurVRenderEffect: string;
  62900. /**
  62901. * @ignore
  62902. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62903. */
  62904. SSAOCombineRenderEffect: string;
  62905. /**
  62906. * The output strength of the SSAO post-process. Default value is 1.0.
  62907. */
  62908. totalStrength: number;
  62909. /**
  62910. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62911. */
  62912. radius: number;
  62913. /**
  62914. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62915. * Must not be equal to fallOff and superior to fallOff.
  62916. * Default value is 0.0075
  62917. */
  62918. area: number;
  62919. /**
  62920. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62921. * Must not be equal to area and inferior to area.
  62922. * Default value is 0.000001
  62923. */
  62924. fallOff: number;
  62925. /**
  62926. * The base color of the SSAO post-process
  62927. * The final result is "base + ssao" between [0, 1]
  62928. */
  62929. base: number;
  62930. private _scene;
  62931. private _depthTexture;
  62932. private _randomTexture;
  62933. private _originalColorPostProcess;
  62934. private _ssaoPostProcess;
  62935. private _blurHPostProcess;
  62936. private _blurVPostProcess;
  62937. private _ssaoCombinePostProcess;
  62938. private _firstUpdate;
  62939. /**
  62940. * Gets active scene
  62941. */
  62942. readonly scene: Scene;
  62943. /**
  62944. * @constructor
  62945. * @param name - The rendering pipeline name
  62946. * @param scene - The scene linked to this pipeline
  62947. * @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 }
  62948. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62949. */
  62950. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62951. /**
  62952. * Get the class name
  62953. * @returns "SSAORenderingPipeline"
  62954. */
  62955. getClassName(): string;
  62956. /**
  62957. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62958. */
  62959. dispose(disableDepthRender?: boolean): void;
  62960. private _createBlurPostProcess;
  62961. /** @hidden */
  62962. _rebuild(): void;
  62963. private _createSSAOPostProcess;
  62964. private _createSSAOCombinePostProcess;
  62965. private _createRandomTexture;
  62966. }
  62967. }
  62968. declare module "babylonjs/Shaders/standard.fragment" {
  62969. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62970. /** @hidden */
  62971. export var standardPixelShader: {
  62972. name: string;
  62973. shader: string;
  62974. };
  62975. }
  62976. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62977. import { Nullable } from "babylonjs/types";
  62978. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62979. import { Camera } from "babylonjs/Cameras/camera";
  62980. import { Texture } from "babylonjs/Materials/Textures/texture";
  62981. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62982. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62983. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62984. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62985. import { IDisposable } from "babylonjs/scene";
  62986. import { SpotLight } from "babylonjs/Lights/spotLight";
  62987. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62988. import { Scene } from "babylonjs/scene";
  62989. import { Animation } from "babylonjs/Animations/animation";
  62990. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62991. import "babylonjs/Shaders/standard.fragment";
  62992. /**
  62993. * Standard rendering pipeline
  62994. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62995. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62996. */
  62997. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62998. /**
  62999. * Public members
  63000. */
  63001. /**
  63002. * Post-process which contains the original scene color before the pipeline applies all the effects
  63003. */
  63004. originalPostProcess: Nullable<PostProcess>;
  63005. /**
  63006. * Post-process used to down scale an image x4
  63007. */
  63008. downSampleX4PostProcess: Nullable<PostProcess>;
  63009. /**
  63010. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63011. */
  63012. brightPassPostProcess: Nullable<PostProcess>;
  63013. /**
  63014. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63015. */
  63016. blurHPostProcesses: PostProcess[];
  63017. /**
  63018. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63019. */
  63020. blurVPostProcesses: PostProcess[];
  63021. /**
  63022. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63023. */
  63024. textureAdderPostProcess: Nullable<PostProcess>;
  63025. /**
  63026. * Post-process used to create volumetric lighting effect
  63027. */
  63028. volumetricLightPostProcess: Nullable<PostProcess>;
  63029. /**
  63030. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63031. */
  63032. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63033. /**
  63034. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63035. */
  63036. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63037. /**
  63038. * Post-process used to merge the volumetric light effect and the real scene color
  63039. */
  63040. volumetricLightMergePostProces: Nullable<PostProcess>;
  63041. /**
  63042. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63043. */
  63044. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63045. /**
  63046. * Base post-process used to calculate the average luminance of the final image for HDR
  63047. */
  63048. luminancePostProcess: Nullable<PostProcess>;
  63049. /**
  63050. * Post-processes used to create down sample post-processes in order to get
  63051. * the average luminance of the final image for HDR
  63052. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63053. */
  63054. luminanceDownSamplePostProcesses: PostProcess[];
  63055. /**
  63056. * Post-process used to create a HDR effect (light adaptation)
  63057. */
  63058. hdrPostProcess: Nullable<PostProcess>;
  63059. /**
  63060. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63061. */
  63062. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63063. /**
  63064. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63065. */
  63066. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63067. /**
  63068. * Post-process used to merge the final HDR post-process and the real scene color
  63069. */
  63070. hdrFinalPostProcess: Nullable<PostProcess>;
  63071. /**
  63072. * Post-process used to create a lens flare effect
  63073. */
  63074. lensFlarePostProcess: Nullable<PostProcess>;
  63075. /**
  63076. * Post-process that merges the result of the lens flare post-process and the real scene color
  63077. */
  63078. lensFlareComposePostProcess: Nullable<PostProcess>;
  63079. /**
  63080. * Post-process used to create a motion blur effect
  63081. */
  63082. motionBlurPostProcess: Nullable<PostProcess>;
  63083. /**
  63084. * Post-process used to create a depth of field effect
  63085. */
  63086. depthOfFieldPostProcess: Nullable<PostProcess>;
  63087. /**
  63088. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63089. */
  63090. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63091. /**
  63092. * Represents the brightness threshold in order to configure the illuminated surfaces
  63093. */
  63094. brightThreshold: number;
  63095. /**
  63096. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63097. */
  63098. blurWidth: number;
  63099. /**
  63100. * Sets if the blur for highlighted surfaces must be only horizontal
  63101. */
  63102. horizontalBlur: boolean;
  63103. /**
  63104. * Gets the overall exposure used by the pipeline
  63105. */
  63106. /**
  63107. * Sets the overall exposure used by the pipeline
  63108. */
  63109. exposure: number;
  63110. /**
  63111. * Texture used typically to simulate "dirty" on camera lens
  63112. */
  63113. lensTexture: Nullable<Texture>;
  63114. /**
  63115. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63116. */
  63117. volumetricLightCoefficient: number;
  63118. /**
  63119. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63120. */
  63121. volumetricLightPower: number;
  63122. /**
  63123. * Used the set the blur intensity to smooth the volumetric lights
  63124. */
  63125. volumetricLightBlurScale: number;
  63126. /**
  63127. * Light (spot or directional) used to generate the volumetric lights rays
  63128. * The source light must have a shadow generate so the pipeline can get its
  63129. * depth map
  63130. */
  63131. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63132. /**
  63133. * For eye adaptation, represents the minimum luminance the eye can see
  63134. */
  63135. hdrMinimumLuminance: number;
  63136. /**
  63137. * For eye adaptation, represents the decrease luminance speed
  63138. */
  63139. hdrDecreaseRate: number;
  63140. /**
  63141. * For eye adaptation, represents the increase luminance speed
  63142. */
  63143. hdrIncreaseRate: number;
  63144. /**
  63145. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63146. */
  63147. /**
  63148. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63149. */
  63150. hdrAutoExposure: boolean;
  63151. /**
  63152. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63153. */
  63154. lensColorTexture: Nullable<Texture>;
  63155. /**
  63156. * The overall strengh for the lens flare effect
  63157. */
  63158. lensFlareStrength: number;
  63159. /**
  63160. * Dispersion coefficient for lens flare ghosts
  63161. */
  63162. lensFlareGhostDispersal: number;
  63163. /**
  63164. * Main lens flare halo width
  63165. */
  63166. lensFlareHaloWidth: number;
  63167. /**
  63168. * Based on the lens distortion effect, defines how much the lens flare result
  63169. * is distorted
  63170. */
  63171. lensFlareDistortionStrength: number;
  63172. /**
  63173. * Configures the blur intensity used for for lens flare (halo)
  63174. */
  63175. lensFlareBlurWidth: number;
  63176. /**
  63177. * Lens star texture must be used to simulate rays on the flares and is available
  63178. * in the documentation
  63179. */
  63180. lensStarTexture: Nullable<Texture>;
  63181. /**
  63182. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63183. * flare effect by taking account of the dirt texture
  63184. */
  63185. lensFlareDirtTexture: Nullable<Texture>;
  63186. /**
  63187. * Represents the focal length for the depth of field effect
  63188. */
  63189. depthOfFieldDistance: number;
  63190. /**
  63191. * Represents the blur intensity for the blurred part of the depth of field effect
  63192. */
  63193. depthOfFieldBlurWidth: number;
  63194. /**
  63195. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63196. */
  63197. /**
  63198. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63199. */
  63200. motionStrength: number;
  63201. /**
  63202. * Gets wether or not the motion blur post-process is object based or screen based.
  63203. */
  63204. /**
  63205. * Sets wether or not the motion blur post-process should be object based or screen based
  63206. */
  63207. objectBasedMotionBlur: boolean;
  63208. /**
  63209. * List of animations for the pipeline (IAnimatable implementation)
  63210. */
  63211. animations: Animation[];
  63212. /**
  63213. * Private members
  63214. */
  63215. private _scene;
  63216. private _currentDepthOfFieldSource;
  63217. private _basePostProcess;
  63218. private _fixedExposure;
  63219. private _currentExposure;
  63220. private _hdrAutoExposure;
  63221. private _hdrCurrentLuminance;
  63222. private _motionStrength;
  63223. private _isObjectBasedMotionBlur;
  63224. private _floatTextureType;
  63225. private _camerasToBeAttached;
  63226. private _ratio;
  63227. private _bloomEnabled;
  63228. private _depthOfFieldEnabled;
  63229. private _vlsEnabled;
  63230. private _lensFlareEnabled;
  63231. private _hdrEnabled;
  63232. private _motionBlurEnabled;
  63233. private _fxaaEnabled;
  63234. private _motionBlurSamples;
  63235. private _volumetricLightStepsCount;
  63236. private _samples;
  63237. /**
  63238. * @ignore
  63239. * Specifies if the bloom pipeline is enabled
  63240. */
  63241. BloomEnabled: boolean;
  63242. /**
  63243. * @ignore
  63244. * Specifies if the depth of field pipeline is enabed
  63245. */
  63246. DepthOfFieldEnabled: boolean;
  63247. /**
  63248. * @ignore
  63249. * Specifies if the lens flare pipeline is enabed
  63250. */
  63251. LensFlareEnabled: boolean;
  63252. /**
  63253. * @ignore
  63254. * Specifies if the HDR pipeline is enabled
  63255. */
  63256. HDREnabled: boolean;
  63257. /**
  63258. * @ignore
  63259. * Specifies if the volumetric lights scattering effect is enabled
  63260. */
  63261. VLSEnabled: boolean;
  63262. /**
  63263. * @ignore
  63264. * Specifies if the motion blur effect is enabled
  63265. */
  63266. MotionBlurEnabled: boolean;
  63267. /**
  63268. * Specifies if anti-aliasing is enabled
  63269. */
  63270. fxaaEnabled: boolean;
  63271. /**
  63272. * Specifies the number of steps used to calculate the volumetric lights
  63273. * Typically in interval [50, 200]
  63274. */
  63275. volumetricLightStepsCount: number;
  63276. /**
  63277. * Specifies the number of samples used for the motion blur effect
  63278. * Typically in interval [16, 64]
  63279. */
  63280. motionBlurSamples: number;
  63281. /**
  63282. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63283. */
  63284. samples: number;
  63285. /**
  63286. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63287. * @constructor
  63288. * @param name The rendering pipeline name
  63289. * @param scene The scene linked to this pipeline
  63290. * @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)
  63291. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63292. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63293. */
  63294. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63295. private _buildPipeline;
  63296. private _createDownSampleX4PostProcess;
  63297. private _createBrightPassPostProcess;
  63298. private _createBlurPostProcesses;
  63299. private _createTextureAdderPostProcess;
  63300. private _createVolumetricLightPostProcess;
  63301. private _createLuminancePostProcesses;
  63302. private _createHdrPostProcess;
  63303. private _createLensFlarePostProcess;
  63304. private _createDepthOfFieldPostProcess;
  63305. private _createMotionBlurPostProcess;
  63306. private _getDepthTexture;
  63307. private _disposePostProcesses;
  63308. /**
  63309. * Dispose of the pipeline and stop all post processes
  63310. */
  63311. dispose(): void;
  63312. /**
  63313. * Serialize the rendering pipeline (Used when exporting)
  63314. * @returns the serialized object
  63315. */
  63316. serialize(): any;
  63317. /**
  63318. * Parse the serialized pipeline
  63319. * @param source Source pipeline.
  63320. * @param scene The scene to load the pipeline to.
  63321. * @param rootUrl The URL of the serialized pipeline.
  63322. * @returns An instantiated pipeline from the serialized object.
  63323. */
  63324. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63325. /**
  63326. * Luminance steps
  63327. */
  63328. static LuminanceSteps: number;
  63329. }
  63330. }
  63331. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63332. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63333. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63334. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63335. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63336. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63337. }
  63338. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63339. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63340. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63341. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63342. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63343. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63344. }
  63345. declare module "babylonjs/Shaders/tonemap.fragment" {
  63346. /** @hidden */
  63347. export var tonemapPixelShader: {
  63348. name: string;
  63349. shader: string;
  63350. };
  63351. }
  63352. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63353. import { Camera } from "babylonjs/Cameras/camera";
  63354. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63355. import "babylonjs/Shaders/tonemap.fragment";
  63356. import { Engine } from "babylonjs/Engines/engine";
  63357. /** Defines operator used for tonemapping */
  63358. export enum TonemappingOperator {
  63359. /** Hable */
  63360. Hable = 0,
  63361. /** Reinhard */
  63362. Reinhard = 1,
  63363. /** HejiDawson */
  63364. HejiDawson = 2,
  63365. /** Photographic */
  63366. Photographic = 3
  63367. }
  63368. /**
  63369. * Defines a post process to apply tone mapping
  63370. */
  63371. export class TonemapPostProcess extends PostProcess {
  63372. private _operator;
  63373. /** Defines the required exposure adjustement */
  63374. exposureAdjustment: number;
  63375. /**
  63376. * Creates a new TonemapPostProcess
  63377. * @param name defines the name of the postprocess
  63378. * @param _operator defines the operator to use
  63379. * @param exposureAdjustment defines the required exposure adjustement
  63380. * @param camera defines the camera to use (can be null)
  63381. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63382. * @param engine defines the hosting engine (can be ignore if camera is set)
  63383. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63384. */
  63385. constructor(name: string, _operator: TonemappingOperator,
  63386. /** Defines the required exposure adjustement */
  63387. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63388. }
  63389. }
  63390. declare module "babylonjs/Shaders/depth.vertex" {
  63391. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63392. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63394. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63395. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63396. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63397. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63398. /** @hidden */
  63399. export var depthVertexShader: {
  63400. name: string;
  63401. shader: string;
  63402. };
  63403. }
  63404. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63405. /** @hidden */
  63406. export var volumetricLightScatteringPixelShader: {
  63407. name: string;
  63408. shader: string;
  63409. };
  63410. }
  63411. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63412. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63413. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63414. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63415. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63417. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63418. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63419. /** @hidden */
  63420. export var volumetricLightScatteringPassVertexShader: {
  63421. name: string;
  63422. shader: string;
  63423. };
  63424. }
  63425. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63426. /** @hidden */
  63427. export var volumetricLightScatteringPassPixelShader: {
  63428. name: string;
  63429. shader: string;
  63430. };
  63431. }
  63432. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63433. import { Vector3 } from "babylonjs/Maths/math.vector";
  63434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63435. import { Mesh } from "babylonjs/Meshes/mesh";
  63436. import { Camera } from "babylonjs/Cameras/camera";
  63437. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63438. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63439. import { Scene } from "babylonjs/scene";
  63440. import "babylonjs/Meshes/Builders/planeBuilder";
  63441. import "babylonjs/Shaders/depth.vertex";
  63442. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63443. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63444. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63445. import { Engine } from "babylonjs/Engines/engine";
  63446. /**
  63447. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63448. */
  63449. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63450. private _volumetricLightScatteringPass;
  63451. private _volumetricLightScatteringRTT;
  63452. private _viewPort;
  63453. private _screenCoordinates;
  63454. private _cachedDefines;
  63455. /**
  63456. * If not undefined, the mesh position is computed from the attached node position
  63457. */
  63458. attachedNode: {
  63459. position: Vector3;
  63460. };
  63461. /**
  63462. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63463. */
  63464. customMeshPosition: Vector3;
  63465. /**
  63466. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63467. */
  63468. useCustomMeshPosition: boolean;
  63469. /**
  63470. * If the post-process should inverse the light scattering direction
  63471. */
  63472. invert: boolean;
  63473. /**
  63474. * The internal mesh used by the post-process
  63475. */
  63476. mesh: Mesh;
  63477. /**
  63478. * @hidden
  63479. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63480. */
  63481. useDiffuseColor: boolean;
  63482. /**
  63483. * Array containing the excluded meshes not rendered in the internal pass
  63484. */
  63485. excludedMeshes: AbstractMesh[];
  63486. /**
  63487. * Controls the overall intensity of the post-process
  63488. */
  63489. exposure: number;
  63490. /**
  63491. * Dissipates each sample's contribution in range [0, 1]
  63492. */
  63493. decay: number;
  63494. /**
  63495. * Controls the overall intensity of each sample
  63496. */
  63497. weight: number;
  63498. /**
  63499. * Controls the density of each sample
  63500. */
  63501. density: number;
  63502. /**
  63503. * @constructor
  63504. * @param name The post-process name
  63505. * @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)
  63506. * @param camera The camera that the post-process will be attached to
  63507. * @param mesh The mesh used to create the light scattering
  63508. * @param samples The post-process quality, default 100
  63509. * @param samplingModeThe post-process filtering mode
  63510. * @param engine The babylon engine
  63511. * @param reusable If the post-process is reusable
  63512. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63513. */
  63514. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63515. /**
  63516. * Returns the string "VolumetricLightScatteringPostProcess"
  63517. * @returns "VolumetricLightScatteringPostProcess"
  63518. */
  63519. getClassName(): string;
  63520. private _isReady;
  63521. /**
  63522. * Sets the new light position for light scattering effect
  63523. * @param position The new custom light position
  63524. */
  63525. setCustomMeshPosition(position: Vector3): void;
  63526. /**
  63527. * Returns the light position for light scattering effect
  63528. * @return Vector3 The custom light position
  63529. */
  63530. getCustomMeshPosition(): Vector3;
  63531. /**
  63532. * Disposes the internal assets and detaches the post-process from the camera
  63533. */
  63534. dispose(camera: Camera): void;
  63535. /**
  63536. * Returns the render target texture used by the post-process
  63537. * @return the render target texture used by the post-process
  63538. */
  63539. getPass(): RenderTargetTexture;
  63540. private _meshExcluded;
  63541. private _createPass;
  63542. private _updateMeshScreenCoordinates;
  63543. /**
  63544. * Creates a default mesh for the Volumeric Light Scattering post-process
  63545. * @param name The mesh name
  63546. * @param scene The scene where to create the mesh
  63547. * @return the default mesh
  63548. */
  63549. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63550. }
  63551. }
  63552. declare module "babylonjs/PostProcesses/index" {
  63553. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63554. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63555. export * from "babylonjs/PostProcesses/bloomEffect";
  63556. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63557. export * from "babylonjs/PostProcesses/blurPostProcess";
  63558. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63559. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63560. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63561. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63562. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63563. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63564. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63565. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63566. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63567. export * from "babylonjs/PostProcesses/filterPostProcess";
  63568. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63569. export * from "babylonjs/PostProcesses/grainPostProcess";
  63570. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63571. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63572. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63573. export * from "babylonjs/PostProcesses/passPostProcess";
  63574. export * from "babylonjs/PostProcesses/postProcess";
  63575. export * from "babylonjs/PostProcesses/postProcessManager";
  63576. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63577. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63578. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63579. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63580. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63581. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63582. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63583. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63584. }
  63585. declare module "babylonjs/Probes/index" {
  63586. export * from "babylonjs/Probes/reflectionProbe";
  63587. }
  63588. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63589. import { Scene } from "babylonjs/scene";
  63590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63591. import { SmartArray } from "babylonjs/Misc/smartArray";
  63592. import { ISceneComponent } from "babylonjs/sceneComponent";
  63593. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63594. import "babylonjs/Meshes/Builders/boxBuilder";
  63595. import "babylonjs/Shaders/color.fragment";
  63596. import "babylonjs/Shaders/color.vertex";
  63597. import { Color3 } from "babylonjs/Maths/math.color";
  63598. module "babylonjs/scene" {
  63599. interface Scene {
  63600. /** @hidden (Backing field) */
  63601. _boundingBoxRenderer: BoundingBoxRenderer;
  63602. /** @hidden (Backing field) */
  63603. _forceShowBoundingBoxes: boolean;
  63604. /**
  63605. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63606. */
  63607. forceShowBoundingBoxes: boolean;
  63608. /**
  63609. * Gets the bounding box renderer associated with the scene
  63610. * @returns a BoundingBoxRenderer
  63611. */
  63612. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63613. }
  63614. }
  63615. module "babylonjs/Meshes/abstractMesh" {
  63616. interface AbstractMesh {
  63617. /** @hidden (Backing field) */
  63618. _showBoundingBox: boolean;
  63619. /**
  63620. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63621. */
  63622. showBoundingBox: boolean;
  63623. }
  63624. }
  63625. /**
  63626. * Component responsible of rendering the bounding box of the meshes in a scene.
  63627. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63628. */
  63629. export class BoundingBoxRenderer implements ISceneComponent {
  63630. /**
  63631. * The component name helpfull to identify the component in the list of scene components.
  63632. */
  63633. readonly name: string;
  63634. /**
  63635. * The scene the component belongs to.
  63636. */
  63637. scene: Scene;
  63638. /**
  63639. * Color of the bounding box lines placed in front of an object
  63640. */
  63641. frontColor: Color3;
  63642. /**
  63643. * Color of the bounding box lines placed behind an object
  63644. */
  63645. backColor: Color3;
  63646. /**
  63647. * Defines if the renderer should show the back lines or not
  63648. */
  63649. showBackLines: boolean;
  63650. /**
  63651. * @hidden
  63652. */
  63653. renderList: SmartArray<BoundingBox>;
  63654. private _colorShader;
  63655. private _vertexBuffers;
  63656. private _indexBuffer;
  63657. private _fillIndexBuffer;
  63658. private _fillIndexData;
  63659. /**
  63660. * Instantiates a new bounding box renderer in a scene.
  63661. * @param scene the scene the renderer renders in
  63662. */
  63663. constructor(scene: Scene);
  63664. /**
  63665. * Registers the component in a given scene
  63666. */
  63667. register(): void;
  63668. private _evaluateSubMesh;
  63669. private _activeMesh;
  63670. private _prepareRessources;
  63671. private _createIndexBuffer;
  63672. /**
  63673. * Rebuilds the elements related to this component in case of
  63674. * context lost for instance.
  63675. */
  63676. rebuild(): void;
  63677. /**
  63678. * @hidden
  63679. */
  63680. reset(): void;
  63681. /**
  63682. * Render the bounding boxes of a specific rendering group
  63683. * @param renderingGroupId defines the rendering group to render
  63684. */
  63685. render(renderingGroupId: number): void;
  63686. /**
  63687. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63688. * @param mesh Define the mesh to render the occlusion bounding box for
  63689. */
  63690. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63691. /**
  63692. * Dispose and release the resources attached to this renderer.
  63693. */
  63694. dispose(): void;
  63695. }
  63696. }
  63697. declare module "babylonjs/Shaders/depth.fragment" {
  63698. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63699. /** @hidden */
  63700. export var depthPixelShader: {
  63701. name: string;
  63702. shader: string;
  63703. };
  63704. }
  63705. declare module "babylonjs/Rendering/depthRenderer" {
  63706. import { Nullable } from "babylonjs/types";
  63707. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63708. import { Scene } from "babylonjs/scene";
  63709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63710. import { Camera } from "babylonjs/Cameras/camera";
  63711. import "babylonjs/Shaders/depth.fragment";
  63712. import "babylonjs/Shaders/depth.vertex";
  63713. /**
  63714. * This represents a depth renderer in Babylon.
  63715. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63716. */
  63717. export class DepthRenderer {
  63718. private _scene;
  63719. private _depthMap;
  63720. private _effect;
  63721. private readonly _storeNonLinearDepth;
  63722. private readonly _clearColor;
  63723. /** Get if the depth renderer is using packed depth or not */
  63724. readonly isPacked: boolean;
  63725. private _cachedDefines;
  63726. private _camera;
  63727. /**
  63728. * Specifiess that the depth renderer will only be used within
  63729. * the camera it is created for.
  63730. * This can help forcing its rendering during the camera processing.
  63731. */
  63732. useOnlyInActiveCamera: boolean;
  63733. /** @hidden */
  63734. static _SceneComponentInitialization: (scene: Scene) => void;
  63735. /**
  63736. * Instantiates a depth renderer
  63737. * @param scene The scene the renderer belongs to
  63738. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63739. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63740. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63741. */
  63742. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63743. /**
  63744. * Creates the depth rendering effect and checks if the effect is ready.
  63745. * @param subMesh The submesh to be used to render the depth map of
  63746. * @param useInstances If multiple world instances should be used
  63747. * @returns if the depth renderer is ready to render the depth map
  63748. */
  63749. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63750. /**
  63751. * Gets the texture which the depth map will be written to.
  63752. * @returns The depth map texture
  63753. */
  63754. getDepthMap(): RenderTargetTexture;
  63755. /**
  63756. * Disposes of the depth renderer.
  63757. */
  63758. dispose(): void;
  63759. }
  63760. }
  63761. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63762. import { Nullable } from "babylonjs/types";
  63763. import { Scene } from "babylonjs/scene";
  63764. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63765. import { Camera } from "babylonjs/Cameras/camera";
  63766. import { ISceneComponent } from "babylonjs/sceneComponent";
  63767. module "babylonjs/scene" {
  63768. interface Scene {
  63769. /** @hidden (Backing field) */
  63770. _depthRenderer: {
  63771. [id: string]: DepthRenderer;
  63772. };
  63773. /**
  63774. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63775. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63776. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63777. * @returns the created depth renderer
  63778. */
  63779. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63780. /**
  63781. * Disables a depth renderer for a given camera
  63782. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63783. */
  63784. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63785. }
  63786. }
  63787. /**
  63788. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63789. * in several rendering techniques.
  63790. */
  63791. export class DepthRendererSceneComponent implements ISceneComponent {
  63792. /**
  63793. * The component name helpfull to identify the component in the list of scene components.
  63794. */
  63795. readonly name: string;
  63796. /**
  63797. * The scene the component belongs to.
  63798. */
  63799. scene: Scene;
  63800. /**
  63801. * Creates a new instance of the component for the given scene
  63802. * @param scene Defines the scene to register the component in
  63803. */
  63804. constructor(scene: Scene);
  63805. /**
  63806. * Registers the component in a given scene
  63807. */
  63808. register(): void;
  63809. /**
  63810. * Rebuilds the elements related to this component in case of
  63811. * context lost for instance.
  63812. */
  63813. rebuild(): void;
  63814. /**
  63815. * Disposes the component and the associated ressources
  63816. */
  63817. dispose(): void;
  63818. private _gatherRenderTargets;
  63819. private _gatherActiveCameraRenderTargets;
  63820. }
  63821. }
  63822. declare module "babylonjs/Shaders/outline.fragment" {
  63823. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63824. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63825. /** @hidden */
  63826. export var outlinePixelShader: {
  63827. name: string;
  63828. shader: string;
  63829. };
  63830. }
  63831. declare module "babylonjs/Shaders/outline.vertex" {
  63832. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63833. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63834. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63835. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63836. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63837. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63838. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63839. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63840. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63841. /** @hidden */
  63842. export var outlineVertexShader: {
  63843. name: string;
  63844. shader: string;
  63845. };
  63846. }
  63847. declare module "babylonjs/Rendering/outlineRenderer" {
  63848. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63849. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63850. import { Scene } from "babylonjs/scene";
  63851. import { ISceneComponent } from "babylonjs/sceneComponent";
  63852. import "babylonjs/Shaders/outline.fragment";
  63853. import "babylonjs/Shaders/outline.vertex";
  63854. module "babylonjs/scene" {
  63855. interface Scene {
  63856. /** @hidden */
  63857. _outlineRenderer: OutlineRenderer;
  63858. /**
  63859. * Gets the outline renderer associated with the scene
  63860. * @returns a OutlineRenderer
  63861. */
  63862. getOutlineRenderer(): OutlineRenderer;
  63863. }
  63864. }
  63865. module "babylonjs/Meshes/abstractMesh" {
  63866. interface AbstractMesh {
  63867. /** @hidden (Backing field) */
  63868. _renderOutline: boolean;
  63869. /**
  63870. * Gets or sets a boolean indicating if the outline must be rendered as well
  63871. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63872. */
  63873. renderOutline: boolean;
  63874. /** @hidden (Backing field) */
  63875. _renderOverlay: boolean;
  63876. /**
  63877. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63878. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63879. */
  63880. renderOverlay: boolean;
  63881. }
  63882. }
  63883. /**
  63884. * This class is responsible to draw bothe outline/overlay of meshes.
  63885. * It should not be used directly but through the available method on mesh.
  63886. */
  63887. export class OutlineRenderer implements ISceneComponent {
  63888. /**
  63889. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63890. */
  63891. private static _StencilReference;
  63892. /**
  63893. * The name of the component. Each component must have a unique name.
  63894. */
  63895. name: string;
  63896. /**
  63897. * The scene the component belongs to.
  63898. */
  63899. scene: Scene;
  63900. /**
  63901. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63902. */
  63903. zOffset: number;
  63904. private _engine;
  63905. private _effect;
  63906. private _cachedDefines;
  63907. private _savedDepthWrite;
  63908. /**
  63909. * Instantiates a new outline renderer. (There could be only one per scene).
  63910. * @param scene Defines the scene it belongs to
  63911. */
  63912. constructor(scene: Scene);
  63913. /**
  63914. * Register the component to one instance of a scene.
  63915. */
  63916. register(): void;
  63917. /**
  63918. * Rebuilds the elements related to this component in case of
  63919. * context lost for instance.
  63920. */
  63921. rebuild(): void;
  63922. /**
  63923. * Disposes the component and the associated ressources.
  63924. */
  63925. dispose(): void;
  63926. /**
  63927. * Renders the outline in the canvas.
  63928. * @param subMesh Defines the sumesh to render
  63929. * @param batch Defines the batch of meshes in case of instances
  63930. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63931. */
  63932. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63933. /**
  63934. * Returns whether or not the outline renderer is ready for a given submesh.
  63935. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63936. * @param subMesh Defines the submesh to check readyness for
  63937. * @param useInstances Defines wheter wee are trying to render instances or not
  63938. * @returns true if ready otherwise false
  63939. */
  63940. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63941. private _beforeRenderingMesh;
  63942. private _afterRenderingMesh;
  63943. }
  63944. }
  63945. declare module "babylonjs/Rendering/index" {
  63946. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63947. export * from "babylonjs/Rendering/depthRenderer";
  63948. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63949. export * from "babylonjs/Rendering/edgesRenderer";
  63950. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63951. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63952. export * from "babylonjs/Rendering/outlineRenderer";
  63953. export * from "babylonjs/Rendering/renderingGroup";
  63954. export * from "babylonjs/Rendering/renderingManager";
  63955. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63956. }
  63957. declare module "babylonjs/Sprites/spritePackedManager" {
  63958. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63959. import { Scene } from "babylonjs/scene";
  63960. /**
  63961. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63962. * @see http://doc.babylonjs.com/babylon101/sprites
  63963. */
  63964. export class SpritePackedManager extends SpriteManager {
  63965. /** defines the packed manager's name */
  63966. name: string;
  63967. /**
  63968. * Creates a new sprite manager from a packed sprite sheet
  63969. * @param name defines the manager's name
  63970. * @param imgUrl defines the sprite sheet url
  63971. * @param capacity defines the maximum allowed number of sprites
  63972. * @param scene defines the hosting scene
  63973. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63974. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63975. * @param samplingMode defines the smapling mode to use with spritesheet
  63976. * @param fromPacked set to true; do not alter
  63977. */
  63978. constructor(
  63979. /** defines the packed manager's name */
  63980. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63981. }
  63982. }
  63983. declare module "babylonjs/Sprites/index" {
  63984. export * from "babylonjs/Sprites/sprite";
  63985. export * from "babylonjs/Sprites/spriteManager";
  63986. export * from "babylonjs/Sprites/spritePackedManager";
  63987. export * from "babylonjs/Sprites/spriteSceneComponent";
  63988. }
  63989. declare module "babylonjs/Misc/assetsManager" {
  63990. import { Scene } from "babylonjs/scene";
  63991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63992. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63993. import { Skeleton } from "babylonjs/Bones/skeleton";
  63994. import { Observable } from "babylonjs/Misc/observable";
  63995. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63996. import { Texture } from "babylonjs/Materials/Textures/texture";
  63997. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63998. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  63999. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64000. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64001. /**
  64002. * Defines the list of states available for a task inside a AssetsManager
  64003. */
  64004. export enum AssetTaskState {
  64005. /**
  64006. * Initialization
  64007. */
  64008. INIT = 0,
  64009. /**
  64010. * Running
  64011. */
  64012. RUNNING = 1,
  64013. /**
  64014. * Done
  64015. */
  64016. DONE = 2,
  64017. /**
  64018. * Error
  64019. */
  64020. ERROR = 3
  64021. }
  64022. /**
  64023. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64024. */
  64025. export abstract class AbstractAssetTask {
  64026. /**
  64027. * Task name
  64028. */ name: string;
  64029. /**
  64030. * Callback called when the task is successful
  64031. */
  64032. onSuccess: (task: any) => void;
  64033. /**
  64034. * Callback called when the task is not successful
  64035. */
  64036. onError: (task: any, message?: string, exception?: any) => void;
  64037. /**
  64038. * Creates a new AssetsManager
  64039. * @param name defines the name of the task
  64040. */
  64041. constructor(
  64042. /**
  64043. * Task name
  64044. */ name: string);
  64045. private _isCompleted;
  64046. private _taskState;
  64047. private _errorObject;
  64048. /**
  64049. * Get if the task is completed
  64050. */
  64051. readonly isCompleted: boolean;
  64052. /**
  64053. * Gets the current state of the task
  64054. */
  64055. readonly taskState: AssetTaskState;
  64056. /**
  64057. * Gets the current error object (if task is in error)
  64058. */
  64059. readonly errorObject: {
  64060. message?: string;
  64061. exception?: any;
  64062. };
  64063. /**
  64064. * Internal only
  64065. * @hidden
  64066. */
  64067. _setErrorObject(message?: string, exception?: any): void;
  64068. /**
  64069. * Execute the current task
  64070. * @param scene defines the scene where you want your assets to be loaded
  64071. * @param onSuccess is a callback called when the task is successfully executed
  64072. * @param onError is a callback called if an error occurs
  64073. */
  64074. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64075. /**
  64076. * Execute the current task
  64077. * @param scene defines the scene where you want your assets to be loaded
  64078. * @param onSuccess is a callback called when the task is successfully executed
  64079. * @param onError is a callback called if an error occurs
  64080. */
  64081. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64082. /**
  64083. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64084. * This can be used with failed tasks that have the reason for failure fixed.
  64085. */
  64086. reset(): void;
  64087. private onErrorCallback;
  64088. private onDoneCallback;
  64089. }
  64090. /**
  64091. * Define the interface used by progress events raised during assets loading
  64092. */
  64093. export interface IAssetsProgressEvent {
  64094. /**
  64095. * Defines the number of remaining tasks to process
  64096. */
  64097. remainingCount: number;
  64098. /**
  64099. * Defines the total number of tasks
  64100. */
  64101. totalCount: number;
  64102. /**
  64103. * Defines the task that was just processed
  64104. */
  64105. task: AbstractAssetTask;
  64106. }
  64107. /**
  64108. * Class used to share progress information about assets loading
  64109. */
  64110. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64111. /**
  64112. * Defines the number of remaining tasks to process
  64113. */
  64114. remainingCount: number;
  64115. /**
  64116. * Defines the total number of tasks
  64117. */
  64118. totalCount: number;
  64119. /**
  64120. * Defines the task that was just processed
  64121. */
  64122. task: AbstractAssetTask;
  64123. /**
  64124. * Creates a AssetsProgressEvent
  64125. * @param remainingCount defines the number of remaining tasks to process
  64126. * @param totalCount defines the total number of tasks
  64127. * @param task defines the task that was just processed
  64128. */
  64129. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64130. }
  64131. /**
  64132. * Define a task used by AssetsManager to load meshes
  64133. */
  64134. export class MeshAssetTask extends AbstractAssetTask {
  64135. /**
  64136. * Defines the name of the task
  64137. */
  64138. name: string;
  64139. /**
  64140. * Defines the list of mesh's names you want to load
  64141. */
  64142. meshesNames: any;
  64143. /**
  64144. * Defines the root url to use as a base to load your meshes and associated resources
  64145. */
  64146. rootUrl: string;
  64147. /**
  64148. * Defines the filename of the scene to load from
  64149. */
  64150. sceneFilename: string;
  64151. /**
  64152. * Gets the list of loaded meshes
  64153. */
  64154. loadedMeshes: Array<AbstractMesh>;
  64155. /**
  64156. * Gets the list of loaded particle systems
  64157. */
  64158. loadedParticleSystems: Array<IParticleSystem>;
  64159. /**
  64160. * Gets the list of loaded skeletons
  64161. */
  64162. loadedSkeletons: Array<Skeleton>;
  64163. /**
  64164. * Gets the list of loaded animation groups
  64165. */
  64166. loadedAnimationGroups: Array<AnimationGroup>;
  64167. /**
  64168. * Callback called when the task is successful
  64169. */
  64170. onSuccess: (task: MeshAssetTask) => void;
  64171. /**
  64172. * Callback called when the task is successful
  64173. */
  64174. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64175. /**
  64176. * Creates a new MeshAssetTask
  64177. * @param name defines the name of the task
  64178. * @param meshesNames defines the list of mesh's names you want to load
  64179. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64180. * @param sceneFilename defines the filename of the scene to load from
  64181. */
  64182. constructor(
  64183. /**
  64184. * Defines the name of the task
  64185. */
  64186. name: string,
  64187. /**
  64188. * Defines the list of mesh's names you want to load
  64189. */
  64190. meshesNames: any,
  64191. /**
  64192. * Defines the root url to use as a base to load your meshes and associated resources
  64193. */
  64194. rootUrl: string,
  64195. /**
  64196. * Defines the filename of the scene to load from
  64197. */
  64198. sceneFilename: string);
  64199. /**
  64200. * Execute the current task
  64201. * @param scene defines the scene where you want your assets to be loaded
  64202. * @param onSuccess is a callback called when the task is successfully executed
  64203. * @param onError is a callback called if an error occurs
  64204. */
  64205. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64206. }
  64207. /**
  64208. * Define a task used by AssetsManager to load text content
  64209. */
  64210. export class TextFileAssetTask extends AbstractAssetTask {
  64211. /**
  64212. * Defines the name of the task
  64213. */
  64214. name: string;
  64215. /**
  64216. * Defines the location of the file to load
  64217. */
  64218. url: string;
  64219. /**
  64220. * Gets the loaded text string
  64221. */
  64222. text: string;
  64223. /**
  64224. * Callback called when the task is successful
  64225. */
  64226. onSuccess: (task: TextFileAssetTask) => void;
  64227. /**
  64228. * Callback called when the task is successful
  64229. */
  64230. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64231. /**
  64232. * Creates a new TextFileAssetTask object
  64233. * @param name defines the name of the task
  64234. * @param url defines the location of the file to load
  64235. */
  64236. constructor(
  64237. /**
  64238. * Defines the name of the task
  64239. */
  64240. name: string,
  64241. /**
  64242. * Defines the location of the file to load
  64243. */
  64244. url: string);
  64245. /**
  64246. * Execute the current task
  64247. * @param scene defines the scene where you want your assets to be loaded
  64248. * @param onSuccess is a callback called when the task is successfully executed
  64249. * @param onError is a callback called if an error occurs
  64250. */
  64251. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64252. }
  64253. /**
  64254. * Define a task used by AssetsManager to load binary data
  64255. */
  64256. export class BinaryFileAssetTask extends AbstractAssetTask {
  64257. /**
  64258. * Defines the name of the task
  64259. */
  64260. name: string;
  64261. /**
  64262. * Defines the location of the file to load
  64263. */
  64264. url: string;
  64265. /**
  64266. * Gets the lodaded data (as an array buffer)
  64267. */
  64268. data: ArrayBuffer;
  64269. /**
  64270. * Callback called when the task is successful
  64271. */
  64272. onSuccess: (task: BinaryFileAssetTask) => void;
  64273. /**
  64274. * Callback called when the task is successful
  64275. */
  64276. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64277. /**
  64278. * Creates a new BinaryFileAssetTask object
  64279. * @param name defines the name of the new task
  64280. * @param url defines the location of the file to load
  64281. */
  64282. constructor(
  64283. /**
  64284. * Defines the name of the task
  64285. */
  64286. name: string,
  64287. /**
  64288. * Defines the location of the file to load
  64289. */
  64290. url: string);
  64291. /**
  64292. * Execute the current task
  64293. * @param scene defines the scene where you want your assets to be loaded
  64294. * @param onSuccess is a callback called when the task is successfully executed
  64295. * @param onError is a callback called if an error occurs
  64296. */
  64297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64298. }
  64299. /**
  64300. * Define a task used by AssetsManager to load images
  64301. */
  64302. export class ImageAssetTask extends AbstractAssetTask {
  64303. /**
  64304. * Defines the name of the task
  64305. */
  64306. name: string;
  64307. /**
  64308. * Defines the location of the image to load
  64309. */
  64310. url: string;
  64311. /**
  64312. * Gets the loaded images
  64313. */
  64314. image: HTMLImageElement;
  64315. /**
  64316. * Callback called when the task is successful
  64317. */
  64318. onSuccess: (task: ImageAssetTask) => void;
  64319. /**
  64320. * Callback called when the task is successful
  64321. */
  64322. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64323. /**
  64324. * Creates a new ImageAssetTask
  64325. * @param name defines the name of the task
  64326. * @param url defines the location of the image to load
  64327. */
  64328. constructor(
  64329. /**
  64330. * Defines the name of the task
  64331. */
  64332. name: string,
  64333. /**
  64334. * Defines the location of the image to load
  64335. */
  64336. url: string);
  64337. /**
  64338. * Execute the current task
  64339. * @param scene defines the scene where you want your assets to be loaded
  64340. * @param onSuccess is a callback called when the task is successfully executed
  64341. * @param onError is a callback called if an error occurs
  64342. */
  64343. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64344. }
  64345. /**
  64346. * Defines the interface used by texture loading tasks
  64347. */
  64348. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64349. /**
  64350. * Gets the loaded texture
  64351. */
  64352. texture: TEX;
  64353. }
  64354. /**
  64355. * Define a task used by AssetsManager to load 2D textures
  64356. */
  64357. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64358. /**
  64359. * Defines the name of the task
  64360. */
  64361. name: string;
  64362. /**
  64363. * Defines the location of the file to load
  64364. */
  64365. url: string;
  64366. /**
  64367. * Defines if mipmap should not be generated (default is false)
  64368. */
  64369. noMipmap?: boolean | undefined;
  64370. /**
  64371. * Defines if texture must be inverted on Y axis (default is false)
  64372. */
  64373. invertY?: boolean | undefined;
  64374. /**
  64375. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64376. */
  64377. samplingMode: number;
  64378. /**
  64379. * Gets the loaded texture
  64380. */
  64381. texture: Texture;
  64382. /**
  64383. * Callback called when the task is successful
  64384. */
  64385. onSuccess: (task: TextureAssetTask) => void;
  64386. /**
  64387. * Callback called when the task is successful
  64388. */
  64389. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64390. /**
  64391. * Creates a new TextureAssetTask object
  64392. * @param name defines the name of the task
  64393. * @param url defines the location of the file to load
  64394. * @param noMipmap defines if mipmap should not be generated (default is false)
  64395. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64396. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64397. */
  64398. constructor(
  64399. /**
  64400. * Defines the name of the task
  64401. */
  64402. name: string,
  64403. /**
  64404. * Defines the location of the file to load
  64405. */
  64406. url: string,
  64407. /**
  64408. * Defines if mipmap should not be generated (default is false)
  64409. */
  64410. noMipmap?: boolean | undefined,
  64411. /**
  64412. * Defines if texture must be inverted on Y axis (default is false)
  64413. */
  64414. invertY?: boolean | undefined,
  64415. /**
  64416. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64417. */
  64418. samplingMode?: number);
  64419. /**
  64420. * Execute the current task
  64421. * @param scene defines the scene where you want your assets to be loaded
  64422. * @param onSuccess is a callback called when the task is successfully executed
  64423. * @param onError is a callback called if an error occurs
  64424. */
  64425. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64426. }
  64427. /**
  64428. * Define a task used by AssetsManager to load cube textures
  64429. */
  64430. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64431. /**
  64432. * Defines the name of the task
  64433. */
  64434. name: string;
  64435. /**
  64436. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64437. */
  64438. url: string;
  64439. /**
  64440. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64441. */
  64442. extensions?: string[] | undefined;
  64443. /**
  64444. * Defines if mipmaps should not be generated (default is false)
  64445. */
  64446. noMipmap?: boolean | undefined;
  64447. /**
  64448. * Defines the explicit list of files (undefined by default)
  64449. */
  64450. files?: string[] | undefined;
  64451. /**
  64452. * Gets the loaded texture
  64453. */
  64454. texture: CubeTexture;
  64455. /**
  64456. * Callback called when the task is successful
  64457. */
  64458. onSuccess: (task: CubeTextureAssetTask) => void;
  64459. /**
  64460. * Callback called when the task is successful
  64461. */
  64462. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64463. /**
  64464. * Creates a new CubeTextureAssetTask
  64465. * @param name defines the name of the task
  64466. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64467. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64468. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64469. * @param files defines the explicit list of files (undefined by default)
  64470. */
  64471. constructor(
  64472. /**
  64473. * Defines the name of the task
  64474. */
  64475. name: string,
  64476. /**
  64477. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64478. */
  64479. url: string,
  64480. /**
  64481. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64482. */
  64483. extensions?: string[] | undefined,
  64484. /**
  64485. * Defines if mipmaps should not be generated (default is false)
  64486. */
  64487. noMipmap?: boolean | undefined,
  64488. /**
  64489. * Defines the explicit list of files (undefined by default)
  64490. */
  64491. files?: string[] | undefined);
  64492. /**
  64493. * Execute the current task
  64494. * @param scene defines the scene where you want your assets to be loaded
  64495. * @param onSuccess is a callback called when the task is successfully executed
  64496. * @param onError is a callback called if an error occurs
  64497. */
  64498. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64499. }
  64500. /**
  64501. * Define a task used by AssetsManager to load HDR cube textures
  64502. */
  64503. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64504. /**
  64505. * Defines the name of the task
  64506. */
  64507. name: string;
  64508. /**
  64509. * Defines the location of the file to load
  64510. */
  64511. url: string;
  64512. /**
  64513. * Defines the desired size (the more it increases the longer the generation will be)
  64514. */
  64515. size: number;
  64516. /**
  64517. * Defines if mipmaps should not be generated (default is false)
  64518. */
  64519. noMipmap: boolean;
  64520. /**
  64521. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64522. */
  64523. generateHarmonics: boolean;
  64524. /**
  64525. * 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)
  64526. */
  64527. gammaSpace: boolean;
  64528. /**
  64529. * Internal Use Only
  64530. */
  64531. reserved: boolean;
  64532. /**
  64533. * Gets the loaded texture
  64534. */
  64535. texture: HDRCubeTexture;
  64536. /**
  64537. * Callback called when the task is successful
  64538. */
  64539. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64540. /**
  64541. * Callback called when the task is successful
  64542. */
  64543. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64544. /**
  64545. * Creates a new HDRCubeTextureAssetTask object
  64546. * @param name defines the name of the task
  64547. * @param url defines the location of the file to load
  64548. * @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.
  64549. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64550. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64551. * @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)
  64552. * @param reserved Internal use only
  64553. */
  64554. constructor(
  64555. /**
  64556. * Defines the name of the task
  64557. */
  64558. name: string,
  64559. /**
  64560. * Defines the location of the file to load
  64561. */
  64562. url: string,
  64563. /**
  64564. * Defines the desired size (the more it increases the longer the generation will be)
  64565. */
  64566. size: number,
  64567. /**
  64568. * Defines if mipmaps should not be generated (default is false)
  64569. */
  64570. noMipmap?: boolean,
  64571. /**
  64572. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64573. */
  64574. generateHarmonics?: boolean,
  64575. /**
  64576. * 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)
  64577. */
  64578. gammaSpace?: boolean,
  64579. /**
  64580. * Internal Use Only
  64581. */
  64582. reserved?: boolean);
  64583. /**
  64584. * Execute the current task
  64585. * @param scene defines the scene where you want your assets to be loaded
  64586. * @param onSuccess is a callback called when the task is successfully executed
  64587. * @param onError is a callback called if an error occurs
  64588. */
  64589. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64590. }
  64591. /**
  64592. * Define a task used by AssetsManager to load Equirectangular cube textures
  64593. */
  64594. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64595. /**
  64596. * Defines the name of the task
  64597. */
  64598. name: string;
  64599. /**
  64600. * Defines the location of the file to load
  64601. */
  64602. url: string;
  64603. /**
  64604. * Defines the desired size (the more it increases the longer the generation will be)
  64605. */
  64606. size: number;
  64607. /**
  64608. * Defines if mipmaps should not be generated (default is false)
  64609. */
  64610. noMipmap: boolean;
  64611. /**
  64612. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64613. * but the standard material would require them in Gamma space) (default is true)
  64614. */
  64615. gammaSpace: boolean;
  64616. /**
  64617. * Gets the loaded texture
  64618. */
  64619. texture: EquiRectangularCubeTexture;
  64620. /**
  64621. * Callback called when the task is successful
  64622. */
  64623. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64624. /**
  64625. * Callback called when the task is successful
  64626. */
  64627. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64628. /**
  64629. * Creates a new EquiRectangularCubeTextureAssetTask object
  64630. * @param name defines the name of the task
  64631. * @param url defines the location of the file to load
  64632. * @param size defines the desired size (the more it increases the longer the generation will be)
  64633. * If the size is omitted this implies you are using a preprocessed cubemap.
  64634. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64635. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64636. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64637. * (default is true)
  64638. */
  64639. constructor(
  64640. /**
  64641. * Defines the name of the task
  64642. */
  64643. name: string,
  64644. /**
  64645. * Defines the location of the file to load
  64646. */
  64647. url: string,
  64648. /**
  64649. * Defines the desired size (the more it increases the longer the generation will be)
  64650. */
  64651. size: number,
  64652. /**
  64653. * Defines if mipmaps should not be generated (default is false)
  64654. */
  64655. noMipmap?: boolean,
  64656. /**
  64657. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64658. * but the standard material would require them in Gamma space) (default is true)
  64659. */
  64660. gammaSpace?: boolean);
  64661. /**
  64662. * Execute the current task
  64663. * @param scene defines the scene where you want your assets to be loaded
  64664. * @param onSuccess is a callback called when the task is successfully executed
  64665. * @param onError is a callback called if an error occurs
  64666. */
  64667. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64668. }
  64669. /**
  64670. * This class can be used to easily import assets into a scene
  64671. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64672. */
  64673. export class AssetsManager {
  64674. private _scene;
  64675. private _isLoading;
  64676. protected _tasks: AbstractAssetTask[];
  64677. protected _waitingTasksCount: number;
  64678. protected _totalTasksCount: number;
  64679. /**
  64680. * Callback called when all tasks are processed
  64681. */
  64682. onFinish: (tasks: AbstractAssetTask[]) => void;
  64683. /**
  64684. * Callback called when a task is successful
  64685. */
  64686. onTaskSuccess: (task: AbstractAssetTask) => void;
  64687. /**
  64688. * Callback called when a task had an error
  64689. */
  64690. onTaskError: (task: AbstractAssetTask) => void;
  64691. /**
  64692. * Callback called when a task is done (whatever the result is)
  64693. */
  64694. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64695. /**
  64696. * Observable called when all tasks are processed
  64697. */
  64698. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64699. /**
  64700. * Observable called when a task had an error
  64701. */
  64702. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64703. /**
  64704. * Observable called when all tasks were executed
  64705. */
  64706. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64707. /**
  64708. * Observable called when a task is done (whatever the result is)
  64709. */
  64710. onProgressObservable: Observable<IAssetsProgressEvent>;
  64711. /**
  64712. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64713. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64714. */
  64715. useDefaultLoadingScreen: boolean;
  64716. /**
  64717. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64718. * when all assets have been downloaded.
  64719. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64720. */
  64721. autoHideLoadingUI: boolean;
  64722. /**
  64723. * Creates a new AssetsManager
  64724. * @param scene defines the scene to work on
  64725. */
  64726. constructor(scene: Scene);
  64727. /**
  64728. * Add a MeshAssetTask to the list of active tasks
  64729. * @param taskName defines the name of the new task
  64730. * @param meshesNames defines the name of meshes to load
  64731. * @param rootUrl defines the root url to use to locate files
  64732. * @param sceneFilename defines the filename of the scene file
  64733. * @returns a new MeshAssetTask object
  64734. */
  64735. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64736. /**
  64737. * Add a TextFileAssetTask to the list of active tasks
  64738. * @param taskName defines the name of the new task
  64739. * @param url defines the url of the file to load
  64740. * @returns a new TextFileAssetTask object
  64741. */
  64742. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64743. /**
  64744. * Add a BinaryFileAssetTask to the list of active tasks
  64745. * @param taskName defines the name of the new task
  64746. * @param url defines the url of the file to load
  64747. * @returns a new BinaryFileAssetTask object
  64748. */
  64749. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64750. /**
  64751. * Add a ImageAssetTask to the list of active tasks
  64752. * @param taskName defines the name of the new task
  64753. * @param url defines the url of the file to load
  64754. * @returns a new ImageAssetTask object
  64755. */
  64756. addImageTask(taskName: string, url: string): ImageAssetTask;
  64757. /**
  64758. * Add a TextureAssetTask to the list of active tasks
  64759. * @param taskName defines the name of the new task
  64760. * @param url defines the url of the file to load
  64761. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64762. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64763. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64764. * @returns a new TextureAssetTask object
  64765. */
  64766. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64767. /**
  64768. * Add a CubeTextureAssetTask to the list of active tasks
  64769. * @param taskName defines the name of the new task
  64770. * @param url defines the url of the file to load
  64771. * @param extensions defines the extension to use to load the cube map (can be null)
  64772. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64773. * @param files defines the list of files to load (can be null)
  64774. * @returns a new CubeTextureAssetTask object
  64775. */
  64776. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64777. /**
  64778. *
  64779. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64780. * @param taskName defines the name of the new task
  64781. * @param url defines the url of the file to load
  64782. * @param size defines the size you want for the cubemap (can be null)
  64783. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64784. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64785. * @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)
  64786. * @param reserved Internal use only
  64787. * @returns a new HDRCubeTextureAssetTask object
  64788. */
  64789. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64790. /**
  64791. *
  64792. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64793. * @param taskName defines the name of the new task
  64794. * @param url defines the url of the file to load
  64795. * @param size defines the size you want for the cubemap (can be null)
  64796. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64797. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64798. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64799. * @returns a new EquiRectangularCubeTextureAssetTask object
  64800. */
  64801. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64802. /**
  64803. * Remove a task from the assets manager.
  64804. * @param task the task to remove
  64805. */
  64806. removeTask(task: AbstractAssetTask): void;
  64807. private _decreaseWaitingTasksCount;
  64808. private _runTask;
  64809. /**
  64810. * Reset the AssetsManager and remove all tasks
  64811. * @return the current instance of the AssetsManager
  64812. */
  64813. reset(): AssetsManager;
  64814. /**
  64815. * Start the loading process
  64816. * @return the current instance of the AssetsManager
  64817. */
  64818. load(): AssetsManager;
  64819. /**
  64820. * Start the loading process as an async operation
  64821. * @return a promise returning the list of failed tasks
  64822. */
  64823. loadAsync(): Promise<void>;
  64824. }
  64825. }
  64826. declare module "babylonjs/Misc/deferred" {
  64827. /**
  64828. * Wrapper class for promise with external resolve and reject.
  64829. */
  64830. export class Deferred<T> {
  64831. /**
  64832. * The promise associated with this deferred object.
  64833. */
  64834. readonly promise: Promise<T>;
  64835. private _resolve;
  64836. private _reject;
  64837. /**
  64838. * The resolve method of the promise associated with this deferred object.
  64839. */
  64840. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64841. /**
  64842. * The reject method of the promise associated with this deferred object.
  64843. */
  64844. readonly reject: (reason?: any) => void;
  64845. /**
  64846. * Constructor for this deferred object.
  64847. */
  64848. constructor();
  64849. }
  64850. }
  64851. declare module "babylonjs/Misc/meshExploder" {
  64852. import { Mesh } from "babylonjs/Meshes/mesh";
  64853. /**
  64854. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64855. */
  64856. export class MeshExploder {
  64857. private _centerMesh;
  64858. private _meshes;
  64859. private _meshesOrigins;
  64860. private _toCenterVectors;
  64861. private _scaledDirection;
  64862. private _newPosition;
  64863. private _centerPosition;
  64864. /**
  64865. * Explodes meshes from a center mesh.
  64866. * @param meshes The meshes to explode.
  64867. * @param centerMesh The mesh to be center of explosion.
  64868. */
  64869. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64870. private _setCenterMesh;
  64871. /**
  64872. * Get class name
  64873. * @returns "MeshExploder"
  64874. */
  64875. getClassName(): string;
  64876. /**
  64877. * "Exploded meshes"
  64878. * @returns Array of meshes with the centerMesh at index 0.
  64879. */
  64880. getMeshes(): Array<Mesh>;
  64881. /**
  64882. * Explodes meshes giving a specific direction
  64883. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64884. */
  64885. explode(direction?: number): void;
  64886. }
  64887. }
  64888. declare module "babylonjs/Misc/filesInput" {
  64889. import { Engine } from "babylonjs/Engines/engine";
  64890. import { Scene } from "babylonjs/scene";
  64891. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64892. /**
  64893. * Class used to help managing file picking and drag'n'drop
  64894. */
  64895. export class FilesInput {
  64896. /**
  64897. * List of files ready to be loaded
  64898. */
  64899. static readonly FilesToLoad: {
  64900. [key: string]: File;
  64901. };
  64902. /**
  64903. * Callback called when a file is processed
  64904. */
  64905. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64906. private _engine;
  64907. private _currentScene;
  64908. private _sceneLoadedCallback;
  64909. private _progressCallback;
  64910. private _additionalRenderLoopLogicCallback;
  64911. private _textureLoadingCallback;
  64912. private _startingProcessingFilesCallback;
  64913. private _onReloadCallback;
  64914. private _errorCallback;
  64915. private _elementToMonitor;
  64916. private _sceneFileToLoad;
  64917. private _filesToLoad;
  64918. /**
  64919. * Creates a new FilesInput
  64920. * @param engine defines the rendering engine
  64921. * @param scene defines the hosting scene
  64922. * @param sceneLoadedCallback callback called when scene is loaded
  64923. * @param progressCallback callback called to track progress
  64924. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64925. * @param textureLoadingCallback callback called when a texture is loading
  64926. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64927. * @param onReloadCallback callback called when a reload is requested
  64928. * @param errorCallback callback call if an error occurs
  64929. */
  64930. 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);
  64931. private _dragEnterHandler;
  64932. private _dragOverHandler;
  64933. private _dropHandler;
  64934. /**
  64935. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64936. * @param elementToMonitor defines the DOM element to track
  64937. */
  64938. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64939. /**
  64940. * Release all associated resources
  64941. */
  64942. dispose(): void;
  64943. private renderFunction;
  64944. private drag;
  64945. private drop;
  64946. private _traverseFolder;
  64947. private _processFiles;
  64948. /**
  64949. * Load files from a drop event
  64950. * @param event defines the drop event to use as source
  64951. */
  64952. loadFiles(event: any): void;
  64953. private _processReload;
  64954. /**
  64955. * Reload the current scene from the loaded files
  64956. */
  64957. reload(): void;
  64958. }
  64959. }
  64960. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64961. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64962. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64963. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64964. }
  64965. declare module "babylonjs/Misc/sceneOptimizer" {
  64966. import { Scene, IDisposable } from "babylonjs/scene";
  64967. import { Observable } from "babylonjs/Misc/observable";
  64968. /**
  64969. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64970. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64971. */
  64972. export class SceneOptimization {
  64973. /**
  64974. * Defines the priority of this optimization (0 by default which means first in the list)
  64975. */
  64976. priority: number;
  64977. /**
  64978. * Gets a string describing the action executed by the current optimization
  64979. * @returns description string
  64980. */
  64981. getDescription(): string;
  64982. /**
  64983. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64984. * @param scene defines the current scene where to apply this optimization
  64985. * @param optimizer defines the current optimizer
  64986. * @returns true if everything that can be done was applied
  64987. */
  64988. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64989. /**
  64990. * Creates the SceneOptimization object
  64991. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64992. * @param desc defines the description associated with the optimization
  64993. */
  64994. constructor(
  64995. /**
  64996. * Defines the priority of this optimization (0 by default which means first in the list)
  64997. */
  64998. priority?: number);
  64999. }
  65000. /**
  65001. * Defines an optimization used to reduce the size of render target textures
  65002. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65003. */
  65004. export class TextureOptimization extends SceneOptimization {
  65005. /**
  65006. * Defines the priority of this optimization (0 by default which means first in the list)
  65007. */
  65008. priority: number;
  65009. /**
  65010. * 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
  65011. */
  65012. maximumSize: number;
  65013. /**
  65014. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65015. */
  65016. step: number;
  65017. /**
  65018. * Gets a string describing the action executed by the current optimization
  65019. * @returns description string
  65020. */
  65021. getDescription(): string;
  65022. /**
  65023. * Creates the TextureOptimization object
  65024. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65025. * @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
  65026. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65027. */
  65028. constructor(
  65029. /**
  65030. * Defines the priority of this optimization (0 by default which means first in the list)
  65031. */
  65032. priority?: number,
  65033. /**
  65034. * 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
  65035. */
  65036. maximumSize?: number,
  65037. /**
  65038. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65039. */
  65040. step?: number);
  65041. /**
  65042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65043. * @param scene defines the current scene where to apply this optimization
  65044. * @param optimizer defines the current optimizer
  65045. * @returns true if everything that can be done was applied
  65046. */
  65047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65048. }
  65049. /**
  65050. * Defines an optimization used to increase or decrease the rendering resolution
  65051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65052. */
  65053. export class HardwareScalingOptimization extends SceneOptimization {
  65054. /**
  65055. * Defines the priority of this optimization (0 by default which means first in the list)
  65056. */
  65057. priority: number;
  65058. /**
  65059. * Defines the maximum scale to use (2 by default)
  65060. */
  65061. maximumScale: number;
  65062. /**
  65063. * Defines the step to use between two passes (0.5 by default)
  65064. */
  65065. step: number;
  65066. private _currentScale;
  65067. private _directionOffset;
  65068. /**
  65069. * Gets a string describing the action executed by the current optimization
  65070. * @return description string
  65071. */
  65072. getDescription(): string;
  65073. /**
  65074. * Creates the HardwareScalingOptimization object
  65075. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65076. * @param maximumScale defines the maximum scale to use (2 by default)
  65077. * @param step defines the step to use between two passes (0.5 by default)
  65078. */
  65079. constructor(
  65080. /**
  65081. * Defines the priority of this optimization (0 by default which means first in the list)
  65082. */
  65083. priority?: number,
  65084. /**
  65085. * Defines the maximum scale to use (2 by default)
  65086. */
  65087. maximumScale?: number,
  65088. /**
  65089. * Defines the step to use between two passes (0.5 by default)
  65090. */
  65091. step?: number);
  65092. /**
  65093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65094. * @param scene defines the current scene where to apply this optimization
  65095. * @param optimizer defines the current optimizer
  65096. * @returns true if everything that can be done was applied
  65097. */
  65098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65099. }
  65100. /**
  65101. * Defines an optimization used to remove shadows
  65102. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65103. */
  65104. export class ShadowsOptimization extends SceneOptimization {
  65105. /**
  65106. * Gets a string describing the action executed by the current optimization
  65107. * @return description string
  65108. */
  65109. getDescription(): string;
  65110. /**
  65111. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65112. * @param scene defines the current scene where to apply this optimization
  65113. * @param optimizer defines the current optimizer
  65114. * @returns true if everything that can be done was applied
  65115. */
  65116. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65117. }
  65118. /**
  65119. * Defines an optimization used to turn post-processes off
  65120. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65121. */
  65122. export class PostProcessesOptimization extends SceneOptimization {
  65123. /**
  65124. * Gets a string describing the action executed by the current optimization
  65125. * @return description string
  65126. */
  65127. getDescription(): string;
  65128. /**
  65129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65130. * @param scene defines the current scene where to apply this optimization
  65131. * @param optimizer defines the current optimizer
  65132. * @returns true if everything that can be done was applied
  65133. */
  65134. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65135. }
  65136. /**
  65137. * Defines an optimization used to turn lens flares off
  65138. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65139. */
  65140. export class LensFlaresOptimization extends SceneOptimization {
  65141. /**
  65142. * Gets a string describing the action executed by the current optimization
  65143. * @return description string
  65144. */
  65145. getDescription(): string;
  65146. /**
  65147. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65148. * @param scene defines the current scene where to apply this optimization
  65149. * @param optimizer defines the current optimizer
  65150. * @returns true if everything that can be done was applied
  65151. */
  65152. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65153. }
  65154. /**
  65155. * Defines an optimization based on user defined callback.
  65156. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65157. */
  65158. export class CustomOptimization extends SceneOptimization {
  65159. /**
  65160. * Callback called to apply the custom optimization.
  65161. */
  65162. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65163. /**
  65164. * Callback called to get custom description
  65165. */
  65166. onGetDescription: () => string;
  65167. /**
  65168. * Gets a string describing the action executed by the current optimization
  65169. * @returns description string
  65170. */
  65171. getDescription(): string;
  65172. /**
  65173. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65174. * @param scene defines the current scene where to apply this optimization
  65175. * @param optimizer defines the current optimizer
  65176. * @returns true if everything that can be done was applied
  65177. */
  65178. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65179. }
  65180. /**
  65181. * Defines an optimization used to turn particles off
  65182. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65183. */
  65184. export class ParticlesOptimization extends SceneOptimization {
  65185. /**
  65186. * Gets a string describing the action executed by the current optimization
  65187. * @return description string
  65188. */
  65189. getDescription(): string;
  65190. /**
  65191. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65192. * @param scene defines the current scene where to apply this optimization
  65193. * @param optimizer defines the current optimizer
  65194. * @returns true if everything that can be done was applied
  65195. */
  65196. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65197. }
  65198. /**
  65199. * Defines an optimization used to turn render targets off
  65200. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65201. */
  65202. export class RenderTargetsOptimization extends SceneOptimization {
  65203. /**
  65204. * Gets a string describing the action executed by the current optimization
  65205. * @return description string
  65206. */
  65207. getDescription(): string;
  65208. /**
  65209. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65210. * @param scene defines the current scene where to apply this optimization
  65211. * @param optimizer defines the current optimizer
  65212. * @returns true if everything that can be done was applied
  65213. */
  65214. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65215. }
  65216. /**
  65217. * Defines an optimization used to merge meshes with compatible materials
  65218. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65219. */
  65220. export class MergeMeshesOptimization extends SceneOptimization {
  65221. private static _UpdateSelectionTree;
  65222. /**
  65223. * Gets or sets a boolean which defines if optimization octree has to be updated
  65224. */
  65225. /**
  65226. * Gets or sets a boolean which defines if optimization octree has to be updated
  65227. */
  65228. static UpdateSelectionTree: boolean;
  65229. /**
  65230. * Gets a string describing the action executed by the current optimization
  65231. * @return description string
  65232. */
  65233. getDescription(): string;
  65234. private _canBeMerged;
  65235. /**
  65236. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65237. * @param scene defines the current scene where to apply this optimization
  65238. * @param optimizer defines the current optimizer
  65239. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65240. * @returns true if everything that can be done was applied
  65241. */
  65242. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65243. }
  65244. /**
  65245. * Defines a list of options used by SceneOptimizer
  65246. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65247. */
  65248. export class SceneOptimizerOptions {
  65249. /**
  65250. * Defines the target frame rate to reach (60 by default)
  65251. */
  65252. targetFrameRate: number;
  65253. /**
  65254. * Defines the interval between two checkes (2000ms by default)
  65255. */
  65256. trackerDuration: number;
  65257. /**
  65258. * Gets the list of optimizations to apply
  65259. */
  65260. optimizations: SceneOptimization[];
  65261. /**
  65262. * Creates a new list of options used by SceneOptimizer
  65263. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65264. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65265. */
  65266. constructor(
  65267. /**
  65268. * Defines the target frame rate to reach (60 by default)
  65269. */
  65270. targetFrameRate?: number,
  65271. /**
  65272. * Defines the interval between two checkes (2000ms by default)
  65273. */
  65274. trackerDuration?: number);
  65275. /**
  65276. * Add a new optimization
  65277. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65278. * @returns the current SceneOptimizerOptions
  65279. */
  65280. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65281. /**
  65282. * Add a new custom optimization
  65283. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65284. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65285. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65286. * @returns the current SceneOptimizerOptions
  65287. */
  65288. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65289. /**
  65290. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65291. * @param targetFrameRate defines the target frame rate (60 by default)
  65292. * @returns a SceneOptimizerOptions object
  65293. */
  65294. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65295. /**
  65296. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65297. * @param targetFrameRate defines the target frame rate (60 by default)
  65298. * @returns a SceneOptimizerOptions object
  65299. */
  65300. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65301. /**
  65302. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65303. * @param targetFrameRate defines the target frame rate (60 by default)
  65304. * @returns a SceneOptimizerOptions object
  65305. */
  65306. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65307. }
  65308. /**
  65309. * Class used to run optimizations in order to reach a target frame rate
  65310. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65311. */
  65312. export class SceneOptimizer implements IDisposable {
  65313. private _isRunning;
  65314. private _options;
  65315. private _scene;
  65316. private _currentPriorityLevel;
  65317. private _targetFrameRate;
  65318. private _trackerDuration;
  65319. private _currentFrameRate;
  65320. private _sceneDisposeObserver;
  65321. private _improvementMode;
  65322. /**
  65323. * Defines an observable called when the optimizer reaches the target frame rate
  65324. */
  65325. onSuccessObservable: Observable<SceneOptimizer>;
  65326. /**
  65327. * Defines an observable called when the optimizer enables an optimization
  65328. */
  65329. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65330. /**
  65331. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65332. */
  65333. onFailureObservable: Observable<SceneOptimizer>;
  65334. /**
  65335. * Gets a boolean indicating if the optimizer is in improvement mode
  65336. */
  65337. readonly isInImprovementMode: boolean;
  65338. /**
  65339. * Gets the current priority level (0 at start)
  65340. */
  65341. readonly currentPriorityLevel: number;
  65342. /**
  65343. * Gets the current frame rate checked by the SceneOptimizer
  65344. */
  65345. readonly currentFrameRate: number;
  65346. /**
  65347. * Gets or sets the current target frame rate (60 by default)
  65348. */
  65349. /**
  65350. * Gets or sets the current target frame rate (60 by default)
  65351. */
  65352. targetFrameRate: number;
  65353. /**
  65354. * Gets or sets the current interval between two checks (every 2000ms by default)
  65355. */
  65356. /**
  65357. * Gets or sets the current interval between two checks (every 2000ms by default)
  65358. */
  65359. trackerDuration: number;
  65360. /**
  65361. * Gets the list of active optimizations
  65362. */
  65363. readonly optimizations: SceneOptimization[];
  65364. /**
  65365. * Creates a new SceneOptimizer
  65366. * @param scene defines the scene to work on
  65367. * @param options defines the options to use with the SceneOptimizer
  65368. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65369. * @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)
  65370. */
  65371. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65372. /**
  65373. * Stops the current optimizer
  65374. */
  65375. stop(): void;
  65376. /**
  65377. * Reset the optimizer to initial step (current priority level = 0)
  65378. */
  65379. reset(): void;
  65380. /**
  65381. * Start the optimizer. By default it will try to reach a specific framerate
  65382. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65383. */
  65384. start(): void;
  65385. private _checkCurrentState;
  65386. /**
  65387. * Release all resources
  65388. */
  65389. dispose(): void;
  65390. /**
  65391. * Helper function to create a SceneOptimizer with one single line of code
  65392. * @param scene defines the scene to work on
  65393. * @param options defines the options to use with the SceneOptimizer
  65394. * @param onSuccess defines a callback to call on success
  65395. * @param onFailure defines a callback to call on failure
  65396. * @returns the new SceneOptimizer object
  65397. */
  65398. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65399. }
  65400. }
  65401. declare module "babylonjs/Misc/sceneSerializer" {
  65402. import { Scene } from "babylonjs/scene";
  65403. /**
  65404. * Class used to serialize a scene into a string
  65405. */
  65406. export class SceneSerializer {
  65407. /**
  65408. * Clear cache used by a previous serialization
  65409. */
  65410. static ClearCache(): void;
  65411. /**
  65412. * Serialize a scene into a JSON compatible object
  65413. * @param scene defines the scene to serialize
  65414. * @returns a JSON compatible object
  65415. */
  65416. static Serialize(scene: Scene): any;
  65417. /**
  65418. * Serialize a mesh into a JSON compatible object
  65419. * @param toSerialize defines the mesh to serialize
  65420. * @param withParents defines if parents must be serialized as well
  65421. * @param withChildren defines if children must be serialized as well
  65422. * @returns a JSON compatible object
  65423. */
  65424. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65425. }
  65426. }
  65427. declare module "babylonjs/Misc/textureTools" {
  65428. import { Texture } from "babylonjs/Materials/Textures/texture";
  65429. /**
  65430. * Class used to host texture specific utilities
  65431. */
  65432. export class TextureTools {
  65433. /**
  65434. * Uses the GPU to create a copy texture rescaled at a given size
  65435. * @param texture Texture to copy from
  65436. * @param width defines the desired width
  65437. * @param height defines the desired height
  65438. * @param useBilinearMode defines if bilinear mode has to be used
  65439. * @return the generated texture
  65440. */
  65441. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65442. }
  65443. }
  65444. declare module "babylonjs/Misc/videoRecorder" {
  65445. import { Nullable } from "babylonjs/types";
  65446. import { Engine } from "babylonjs/Engines/engine";
  65447. /**
  65448. * This represents the different options available for the video capture.
  65449. */
  65450. export interface VideoRecorderOptions {
  65451. /** Defines the mime type of the video. */
  65452. mimeType: string;
  65453. /** Defines the FPS the video should be recorded at. */
  65454. fps: number;
  65455. /** Defines the chunk size for the recording data. */
  65456. recordChunckSize: number;
  65457. /** The audio tracks to attach to the recording. */
  65458. audioTracks?: MediaStreamTrack[];
  65459. }
  65460. /**
  65461. * This can help with recording videos from BabylonJS.
  65462. * This is based on the available WebRTC functionalities of the browser.
  65463. *
  65464. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65465. */
  65466. export class VideoRecorder {
  65467. private static readonly _defaultOptions;
  65468. /**
  65469. * Returns whether or not the VideoRecorder is available in your browser.
  65470. * @param engine Defines the Babylon Engine.
  65471. * @returns true if supported otherwise false.
  65472. */
  65473. static IsSupported(engine: Engine): boolean;
  65474. private readonly _options;
  65475. private _canvas;
  65476. private _mediaRecorder;
  65477. private _recordedChunks;
  65478. private _fileName;
  65479. private _resolve;
  65480. private _reject;
  65481. /**
  65482. * True when a recording is already in progress.
  65483. */
  65484. readonly isRecording: boolean;
  65485. /**
  65486. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65487. * @param engine Defines the BabylonJS Engine you wish to record.
  65488. * @param options Defines options that can be used to customize the capture.
  65489. */
  65490. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65491. /**
  65492. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65493. */
  65494. stopRecording(): void;
  65495. /**
  65496. * Starts recording the canvas for a max duration specified in parameters.
  65497. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65498. * If null no automatic download will start and you can rely on the promise to get the data back.
  65499. * @param maxDuration Defines the maximum recording time in seconds.
  65500. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65501. * @return A promise callback at the end of the recording with the video data in Blob.
  65502. */
  65503. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65504. /**
  65505. * Releases internal resources used during the recording.
  65506. */
  65507. dispose(): void;
  65508. private _handleDataAvailable;
  65509. private _handleError;
  65510. private _handleStop;
  65511. }
  65512. }
  65513. declare module "babylonjs/Misc/screenshotTools" {
  65514. import { Camera } from "babylonjs/Cameras/camera";
  65515. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65516. import { Engine } from "babylonjs/Engines/engine";
  65517. /**
  65518. * Class containing a set of static utilities functions for screenshots
  65519. */
  65520. export class ScreenshotTools {
  65521. /**
  65522. * Captures a screenshot of the current rendering
  65523. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65524. * @param engine defines the rendering engine
  65525. * @param camera defines the source camera
  65526. * @param size This parameter can be set to a single number or to an object with the
  65527. * following (optional) properties: precision, width, height. If a single number is passed,
  65528. * it will be used for both width and height. If an object is passed, the screenshot size
  65529. * will be derived from the parameters. The precision property is a multiplier allowing
  65530. * rendering at a higher or lower resolution
  65531. * @param successCallback defines the callback receives a single parameter which contains the
  65532. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65533. * src parameter of an <img> to display it
  65534. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65535. * Check your browser for supported MIME types
  65536. */
  65537. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65538. /**
  65539. * Captures a screenshot of the current rendering
  65540. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65541. * @param engine defines the rendering engine
  65542. * @param camera defines the source camera
  65543. * @param size This parameter can be set to a single number or to an object with the
  65544. * following (optional) properties: precision, width, height. If a single number is passed,
  65545. * it will be used for both width and height. If an object is passed, the screenshot size
  65546. * will be derived from the parameters. The precision property is a multiplier allowing
  65547. * rendering at a higher or lower resolution
  65548. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65549. * Check your browser for supported MIME types
  65550. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65551. * to the src parameter of an <img> to display it
  65552. */
  65553. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65554. /**
  65555. * Generates an image screenshot from the specified camera.
  65556. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65557. * @param engine The engine to use for rendering
  65558. * @param camera The camera to use for rendering
  65559. * @param size This parameter can be set to a single number or to an object with the
  65560. * following (optional) properties: precision, width, height. If a single number is passed,
  65561. * it will be used for both width and height. If an object is passed, the screenshot size
  65562. * will be derived from the parameters. The precision property is a multiplier allowing
  65563. * rendering at a higher or lower resolution
  65564. * @param successCallback The callback receives a single parameter which contains the
  65565. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65566. * src parameter of an <img> to display it
  65567. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65568. * Check your browser for supported MIME types
  65569. * @param samples Texture samples (default: 1)
  65570. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65571. * @param fileName A name for for the downloaded file.
  65572. */
  65573. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65574. /**
  65575. * Generates an image screenshot from the specified camera.
  65576. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65577. * @param engine The engine to use for rendering
  65578. * @param camera The camera to use for rendering
  65579. * @param size This parameter can be set to a single number or to an object with the
  65580. * following (optional) properties: precision, width, height. If a single number is passed,
  65581. * it will be used for both width and height. If an object is passed, the screenshot size
  65582. * will be derived from the parameters. The precision property is a multiplier allowing
  65583. * rendering at a higher or lower resolution
  65584. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65585. * Check your browser for supported MIME types
  65586. * @param samples Texture samples (default: 1)
  65587. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65588. * @param fileName A name for for the downloaded file.
  65589. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65590. * to the src parameter of an <img> to display it
  65591. */
  65592. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65593. /**
  65594. * Gets height and width for screenshot size
  65595. * @private
  65596. */
  65597. private static _getScreenshotSize;
  65598. }
  65599. }
  65600. declare module "babylonjs/Misc/index" {
  65601. export * from "babylonjs/Misc/andOrNotEvaluator";
  65602. export * from "babylonjs/Misc/assetsManager";
  65603. export * from "babylonjs/Misc/dds";
  65604. export * from "babylonjs/Misc/decorators";
  65605. export * from "babylonjs/Misc/deferred";
  65606. export * from "babylonjs/Misc/environmentTextureTools";
  65607. export * from "babylonjs/Misc/meshExploder";
  65608. export * from "babylonjs/Misc/filesInput";
  65609. export * from "babylonjs/Misc/HighDynamicRange/index";
  65610. export * from "babylonjs/Misc/khronosTextureContainer";
  65611. export * from "babylonjs/Misc/observable";
  65612. export * from "babylonjs/Misc/performanceMonitor";
  65613. export * from "babylonjs/Misc/promise";
  65614. export * from "babylonjs/Misc/sceneOptimizer";
  65615. export * from "babylonjs/Misc/sceneSerializer";
  65616. export * from "babylonjs/Misc/smartArray";
  65617. export * from "babylonjs/Misc/stringDictionary";
  65618. export * from "babylonjs/Misc/tags";
  65619. export * from "babylonjs/Misc/textureTools";
  65620. export * from "babylonjs/Misc/tga";
  65621. export * from "babylonjs/Misc/tools";
  65622. export * from "babylonjs/Misc/videoRecorder";
  65623. export * from "babylonjs/Misc/virtualJoystick";
  65624. export * from "babylonjs/Misc/workerPool";
  65625. export * from "babylonjs/Misc/logger";
  65626. export * from "babylonjs/Misc/typeStore";
  65627. export * from "babylonjs/Misc/filesInputStore";
  65628. export * from "babylonjs/Misc/deepCopier";
  65629. export * from "babylonjs/Misc/pivotTools";
  65630. export * from "babylonjs/Misc/precisionDate";
  65631. export * from "babylonjs/Misc/screenshotTools";
  65632. export * from "babylonjs/Misc/typeStore";
  65633. export * from "babylonjs/Misc/webRequest";
  65634. export * from "babylonjs/Misc/iInspectable";
  65635. export * from "babylonjs/Misc/brdfTextureTools";
  65636. export * from "babylonjs/Misc/rgbdTextureTools";
  65637. export * from "babylonjs/Misc/gradients";
  65638. export * from "babylonjs/Misc/perfCounter";
  65639. export * from "babylonjs/Misc/fileRequest";
  65640. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65641. export * from "babylonjs/Misc/retryStrategy";
  65642. export * from "babylonjs/Misc/loadFileError";
  65643. export * from "babylonjs/Misc/interfaces/screenshotSize";
  65644. }
  65645. declare module "babylonjs/index" {
  65646. export * from "babylonjs/abstractScene";
  65647. export * from "babylonjs/Actions/index";
  65648. export * from "babylonjs/Animations/index";
  65649. export * from "babylonjs/assetContainer";
  65650. export * from "babylonjs/Audio/index";
  65651. export * from "babylonjs/Behaviors/index";
  65652. export * from "babylonjs/Bones/index";
  65653. export * from "babylonjs/Cameras/index";
  65654. export * from "babylonjs/Collisions/index";
  65655. export * from "babylonjs/Culling/index";
  65656. export * from "babylonjs/Debug/index";
  65657. export * from "babylonjs/Engines/index";
  65658. export * from "babylonjs/Events/index";
  65659. export * from "babylonjs/Gamepads/index";
  65660. export * from "babylonjs/Gizmos/index";
  65661. export * from "babylonjs/Helpers/index";
  65662. export * from "babylonjs/Instrumentation/index";
  65663. export * from "babylonjs/Layers/index";
  65664. export * from "babylonjs/LensFlares/index";
  65665. export * from "babylonjs/Lights/index";
  65666. export * from "babylonjs/Loading/index";
  65667. export * from "babylonjs/Materials/index";
  65668. export * from "babylonjs/Maths/index";
  65669. export * from "babylonjs/Meshes/index";
  65670. export * from "babylonjs/Morph/index";
  65671. export * from "babylonjs/Navigation/index";
  65672. export * from "babylonjs/node";
  65673. export * from "babylonjs/Offline/index";
  65674. export * from "babylonjs/Particles/index";
  65675. export * from "babylonjs/Physics/index";
  65676. export * from "babylonjs/PostProcesses/index";
  65677. export * from "babylonjs/Probes/index";
  65678. export * from "babylonjs/Rendering/index";
  65679. export * from "babylonjs/scene";
  65680. export * from "babylonjs/sceneComponent";
  65681. export * from "babylonjs/Sprites/index";
  65682. export * from "babylonjs/States/index";
  65683. export * from "babylonjs/Misc/index";
  65684. export * from "babylonjs/types";
  65685. }
  65686. declare module "babylonjs/Animations/pathCursor" {
  65687. import { Vector3 } from "babylonjs/Maths/math.vector";
  65688. import { Path2 } from "babylonjs/Maths/math.path";
  65689. /**
  65690. * A cursor which tracks a point on a path
  65691. */
  65692. export class PathCursor {
  65693. private path;
  65694. /**
  65695. * Stores path cursor callbacks for when an onchange event is triggered
  65696. */
  65697. private _onchange;
  65698. /**
  65699. * The value of the path cursor
  65700. */
  65701. value: number;
  65702. /**
  65703. * The animation array of the path cursor
  65704. */
  65705. animations: Animation[];
  65706. /**
  65707. * Initializes the path cursor
  65708. * @param path The path to track
  65709. */
  65710. constructor(path: Path2);
  65711. /**
  65712. * Gets the cursor point on the path
  65713. * @returns A point on the path cursor at the cursor location
  65714. */
  65715. getPoint(): Vector3;
  65716. /**
  65717. * Moves the cursor ahead by the step amount
  65718. * @param step The amount to move the cursor forward
  65719. * @returns This path cursor
  65720. */
  65721. moveAhead(step?: number): PathCursor;
  65722. /**
  65723. * Moves the cursor behind by the step amount
  65724. * @param step The amount to move the cursor back
  65725. * @returns This path cursor
  65726. */
  65727. moveBack(step?: number): PathCursor;
  65728. /**
  65729. * Moves the cursor by the step amount
  65730. * If the step amount is greater than one, an exception is thrown
  65731. * @param step The amount to move the cursor
  65732. * @returns This path cursor
  65733. */
  65734. move(step: number): PathCursor;
  65735. /**
  65736. * Ensures that the value is limited between zero and one
  65737. * @returns This path cursor
  65738. */
  65739. private ensureLimits;
  65740. /**
  65741. * Runs onchange callbacks on change (used by the animation engine)
  65742. * @returns This path cursor
  65743. */
  65744. private raiseOnChange;
  65745. /**
  65746. * Executes a function on change
  65747. * @param f A path cursor onchange callback
  65748. * @returns This path cursor
  65749. */
  65750. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65751. }
  65752. }
  65753. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65754. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65755. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65756. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65757. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65758. }
  65759. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65760. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65761. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65762. }
  65763. declare module "babylonjs/Engines/Processors/index" {
  65764. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65765. export * from "babylonjs/Engines/Processors/Expressions/index";
  65766. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65767. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65768. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65769. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65770. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65771. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65772. }
  65773. declare module "babylonjs/Legacy/legacy" {
  65774. import * as Babylon from "babylonjs/index";
  65775. export * from "babylonjs/index";
  65776. }
  65777. declare module "babylonjs/Shaders/blur.fragment" {
  65778. /** @hidden */
  65779. export var blurPixelShader: {
  65780. name: string;
  65781. shader: string;
  65782. };
  65783. }
  65784. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65785. /** @hidden */
  65786. export var pointCloudVertexDeclaration: {
  65787. name: string;
  65788. shader: string;
  65789. };
  65790. }
  65791. declare module "babylonjs" {
  65792. export * from "babylonjs/Legacy/legacy";
  65793. }
  65794. declare module BABYLON {
  65795. /** Alias type for value that can be null */
  65796. export type Nullable<T> = T | null;
  65797. /**
  65798. * Alias type for number that are floats
  65799. * @ignorenaming
  65800. */
  65801. export type float = number;
  65802. /**
  65803. * Alias type for number that are doubles.
  65804. * @ignorenaming
  65805. */
  65806. export type double = number;
  65807. /**
  65808. * Alias type for number that are integer
  65809. * @ignorenaming
  65810. */
  65811. export type int = number;
  65812. /** Alias type for number array or Float32Array */
  65813. export type FloatArray = number[] | Float32Array;
  65814. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65815. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65816. /**
  65817. * Alias for types that can be used by a Buffer or VertexBuffer.
  65818. */
  65819. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65820. /**
  65821. * Alias type for primitive types
  65822. * @ignorenaming
  65823. */
  65824. type Primitive = undefined | null | boolean | string | number | Function;
  65825. /**
  65826. * Type modifier to make all the properties of an object Readonly
  65827. */
  65828. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65829. /**
  65830. * Type modifier to make all the properties of an object Readonly recursively
  65831. */
  65832. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65833. /** @hidden */
  65834. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65835. }
  65836. /** @hidden */
  65837. /** @hidden */
  65838. type DeepImmutableObject<T> = {
  65839. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65840. };
  65841. }
  65842. declare module BABYLON {
  65843. /**
  65844. * A class serves as a medium between the observable and its observers
  65845. */
  65846. export class EventState {
  65847. /**
  65848. * Create a new EventState
  65849. * @param mask defines the mask associated with this state
  65850. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65851. * @param target defines the original target of the state
  65852. * @param currentTarget defines the current target of the state
  65853. */
  65854. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65855. /**
  65856. * Initialize the current event state
  65857. * @param mask defines the mask associated with this state
  65858. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65859. * @param target defines the original target of the state
  65860. * @param currentTarget defines the current target of the state
  65861. * @returns the current event state
  65862. */
  65863. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65864. /**
  65865. * An Observer can set this property to true to prevent subsequent observers of being notified
  65866. */
  65867. skipNextObservers: boolean;
  65868. /**
  65869. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65870. */
  65871. mask: number;
  65872. /**
  65873. * The object that originally notified the event
  65874. */
  65875. target?: any;
  65876. /**
  65877. * The current object in the bubbling phase
  65878. */
  65879. currentTarget?: any;
  65880. /**
  65881. * This will be populated with the return value of the last function that was executed.
  65882. * If it is the first function in the callback chain it will be the event data.
  65883. */
  65884. lastReturnValue?: any;
  65885. }
  65886. /**
  65887. * Represent an Observer registered to a given Observable object.
  65888. */
  65889. export class Observer<T> {
  65890. /**
  65891. * Defines the callback to call when the observer is notified
  65892. */
  65893. callback: (eventData: T, eventState: EventState) => void;
  65894. /**
  65895. * Defines the mask of the observer (used to filter notifications)
  65896. */
  65897. mask: number;
  65898. /**
  65899. * Defines the current scope used to restore the JS context
  65900. */
  65901. scope: any;
  65902. /** @hidden */
  65903. _willBeUnregistered: boolean;
  65904. /**
  65905. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65906. */
  65907. unregisterOnNextCall: boolean;
  65908. /**
  65909. * Creates a new observer
  65910. * @param callback defines the callback to call when the observer is notified
  65911. * @param mask defines the mask of the observer (used to filter notifications)
  65912. * @param scope defines the current scope used to restore the JS context
  65913. */
  65914. constructor(
  65915. /**
  65916. * Defines the callback to call when the observer is notified
  65917. */
  65918. callback: (eventData: T, eventState: EventState) => void,
  65919. /**
  65920. * Defines the mask of the observer (used to filter notifications)
  65921. */
  65922. mask: number,
  65923. /**
  65924. * Defines the current scope used to restore the JS context
  65925. */
  65926. scope?: any);
  65927. }
  65928. /**
  65929. * Represent a list of observers registered to multiple Observables object.
  65930. */
  65931. export class MultiObserver<T> {
  65932. private _observers;
  65933. private _observables;
  65934. /**
  65935. * Release associated resources
  65936. */
  65937. dispose(): void;
  65938. /**
  65939. * Raise a callback when one of the observable will notify
  65940. * @param observables defines a list of observables to watch
  65941. * @param callback defines the callback to call on notification
  65942. * @param mask defines the mask used to filter notifications
  65943. * @param scope defines the current scope used to restore the JS context
  65944. * @returns the new MultiObserver
  65945. */
  65946. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65947. }
  65948. /**
  65949. * The Observable class is a simple implementation of the Observable pattern.
  65950. *
  65951. * 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.
  65952. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65953. * 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).
  65954. * 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.
  65955. */
  65956. export class Observable<T> {
  65957. private _observers;
  65958. private _eventState;
  65959. private _onObserverAdded;
  65960. /**
  65961. * Gets the list of observers
  65962. */
  65963. readonly observers: Array<Observer<T>>;
  65964. /**
  65965. * Creates a new observable
  65966. * @param onObserverAdded defines a callback to call when a new observer is added
  65967. */
  65968. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65969. /**
  65970. * Create a new Observer with the specified callback
  65971. * @param callback the callback that will be executed for that Observer
  65972. * @param mask the mask used to filter observers
  65973. * @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.
  65974. * @param scope optional scope for the callback to be called from
  65975. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65976. * @returns the new observer created for the callback
  65977. */
  65978. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65979. /**
  65980. * Create a new Observer with the specified callback and unregisters after the next notification
  65981. * @param callback the callback that will be executed for that Observer
  65982. * @returns the new observer created for the callback
  65983. */
  65984. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65985. /**
  65986. * Remove an Observer from the Observable object
  65987. * @param observer the instance of the Observer to remove
  65988. * @returns false if it doesn't belong to this Observable
  65989. */
  65990. remove(observer: Nullable<Observer<T>>): boolean;
  65991. /**
  65992. * Remove a callback from the Observable object
  65993. * @param callback the callback to remove
  65994. * @param scope optional scope. If used only the callbacks with this scope will be removed
  65995. * @returns false if it doesn't belong to this Observable
  65996. */
  65997. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  65998. private _deferUnregister;
  65999. private _remove;
  66000. /**
  66001. * Moves the observable to the top of the observer list making it get called first when notified
  66002. * @param observer the observer to move
  66003. */
  66004. makeObserverTopPriority(observer: Observer<T>): void;
  66005. /**
  66006. * Moves the observable to the bottom of the observer list making it get called last when notified
  66007. * @param observer the observer to move
  66008. */
  66009. makeObserverBottomPriority(observer: Observer<T>): void;
  66010. /**
  66011. * Notify all Observers by calling their respective callback with the given data
  66012. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66013. * @param eventData defines the data to send to all observers
  66014. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66015. * @param target defines the original target of the state
  66016. * @param currentTarget defines the current target of the state
  66017. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66018. */
  66019. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66020. /**
  66021. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66022. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66023. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66024. * and it is crucial that all callbacks will be executed.
  66025. * The order of the callbacks is kept, callbacks are not executed parallel.
  66026. *
  66027. * @param eventData The data to be sent to each callback
  66028. * @param mask is used to filter observers defaults to -1
  66029. * @param target defines the callback target (see EventState)
  66030. * @param currentTarget defines he current object in the bubbling phase
  66031. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66032. */
  66033. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66034. /**
  66035. * Notify a specific observer
  66036. * @param observer defines the observer to notify
  66037. * @param eventData defines the data to be sent to each callback
  66038. * @param mask is used to filter observers defaults to -1
  66039. */
  66040. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66041. /**
  66042. * Gets a boolean indicating if the observable has at least one observer
  66043. * @returns true is the Observable has at least one Observer registered
  66044. */
  66045. hasObservers(): boolean;
  66046. /**
  66047. * Clear the list of observers
  66048. */
  66049. clear(): void;
  66050. /**
  66051. * Clone the current observable
  66052. * @returns a new observable
  66053. */
  66054. clone(): Observable<T>;
  66055. /**
  66056. * Does this observable handles observer registered with a given mask
  66057. * @param mask defines the mask to be tested
  66058. * @return whether or not one observer registered with the given mask is handeled
  66059. **/
  66060. hasSpecificMask(mask?: number): boolean;
  66061. }
  66062. }
  66063. declare module BABYLON {
  66064. /**
  66065. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66066. * Babylon.js
  66067. */
  66068. export class DomManagement {
  66069. /**
  66070. * Checks if the window object exists
  66071. * @returns true if the window object exists
  66072. */
  66073. static IsWindowObjectExist(): boolean;
  66074. /**
  66075. * Checks if the navigator object exists
  66076. * @returns true if the navigator object exists
  66077. */
  66078. static IsNavigatorAvailable(): boolean;
  66079. /**
  66080. * Extracts text content from a DOM element hierarchy
  66081. * @param element defines the root element
  66082. * @returns a string
  66083. */
  66084. static GetDOMTextContent(element: HTMLElement): string;
  66085. }
  66086. }
  66087. declare module BABYLON {
  66088. /**
  66089. * Logger used througouht the application to allow configuration of
  66090. * the log level required for the messages.
  66091. */
  66092. export class Logger {
  66093. /**
  66094. * No log
  66095. */
  66096. static readonly NoneLogLevel: number;
  66097. /**
  66098. * Only message logs
  66099. */
  66100. static readonly MessageLogLevel: number;
  66101. /**
  66102. * Only warning logs
  66103. */
  66104. static readonly WarningLogLevel: number;
  66105. /**
  66106. * Only error logs
  66107. */
  66108. static readonly ErrorLogLevel: number;
  66109. /**
  66110. * All logs
  66111. */
  66112. static readonly AllLogLevel: number;
  66113. private static _LogCache;
  66114. /**
  66115. * Gets a value indicating the number of loading errors
  66116. * @ignorenaming
  66117. */
  66118. static errorsCount: number;
  66119. /**
  66120. * Callback called when a new log is added
  66121. */
  66122. static OnNewCacheEntry: (entry: string) => void;
  66123. private static _AddLogEntry;
  66124. private static _FormatMessage;
  66125. private static _LogDisabled;
  66126. private static _LogEnabled;
  66127. private static _WarnDisabled;
  66128. private static _WarnEnabled;
  66129. private static _ErrorDisabled;
  66130. private static _ErrorEnabled;
  66131. /**
  66132. * Log a message to the console
  66133. */
  66134. static Log: (message: string) => void;
  66135. /**
  66136. * Write a warning message to the console
  66137. */
  66138. static Warn: (message: string) => void;
  66139. /**
  66140. * Write an error message to the console
  66141. */
  66142. static Error: (message: string) => void;
  66143. /**
  66144. * Gets current log cache (list of logs)
  66145. */
  66146. static readonly LogCache: string;
  66147. /**
  66148. * Clears the log cache
  66149. */
  66150. static ClearLogCache(): void;
  66151. /**
  66152. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66153. */
  66154. static LogLevels: number;
  66155. }
  66156. }
  66157. declare module BABYLON {
  66158. /** @hidden */
  66159. export class _TypeStore {
  66160. /** @hidden */
  66161. static RegisteredTypes: {
  66162. [key: string]: Object;
  66163. };
  66164. /** @hidden */
  66165. static GetClass(fqdn: string): any;
  66166. }
  66167. }
  66168. declare module BABYLON {
  66169. /**
  66170. * Class containing a set of static utilities functions for deep copy.
  66171. */
  66172. export class DeepCopier {
  66173. /**
  66174. * Tries to copy an object by duplicating every property
  66175. * @param source defines the source object
  66176. * @param destination defines the target object
  66177. * @param doNotCopyList defines a list of properties to avoid
  66178. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66179. */
  66180. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66181. }
  66182. }
  66183. declare module BABYLON {
  66184. /**
  66185. * Class containing a set of static utilities functions for precision date
  66186. */
  66187. export class PrecisionDate {
  66188. /**
  66189. * Gets either window.performance.now() if supported or Date.now() else
  66190. */
  66191. static readonly Now: number;
  66192. }
  66193. }
  66194. declare module BABYLON {
  66195. /** @hidden */
  66196. export class _DevTools {
  66197. static WarnImport(name: string): string;
  66198. }
  66199. }
  66200. declare module BABYLON {
  66201. /**
  66202. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66203. */
  66204. export class WebRequest {
  66205. private _xhr;
  66206. /**
  66207. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66208. * i.e. when loading files, where the server/service expects an Authorization header
  66209. */
  66210. static CustomRequestHeaders: {
  66211. [key: string]: string;
  66212. };
  66213. /**
  66214. * Add callback functions in this array to update all the requests before they get sent to the network
  66215. */
  66216. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66217. private _injectCustomRequestHeaders;
  66218. /**
  66219. * Gets or sets a function to be called when loading progress changes
  66220. */
  66221. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66222. /**
  66223. * Returns client's state
  66224. */
  66225. readonly readyState: number;
  66226. /**
  66227. * Returns client's status
  66228. */
  66229. readonly status: number;
  66230. /**
  66231. * Returns client's status as a text
  66232. */
  66233. readonly statusText: string;
  66234. /**
  66235. * Returns client's response
  66236. */
  66237. readonly response: any;
  66238. /**
  66239. * Returns client's response url
  66240. */
  66241. readonly responseURL: string;
  66242. /**
  66243. * Returns client's response as text
  66244. */
  66245. readonly responseText: string;
  66246. /**
  66247. * Gets or sets the expected response type
  66248. */
  66249. responseType: XMLHttpRequestResponseType;
  66250. /** @hidden */
  66251. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66252. /** @hidden */
  66253. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66254. /**
  66255. * Cancels any network activity
  66256. */
  66257. abort(): void;
  66258. /**
  66259. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66260. * @param body defines an optional request body
  66261. */
  66262. send(body?: Document | BodyInit | null): void;
  66263. /**
  66264. * Sets the request method, request URL
  66265. * @param method defines the method to use (GET, POST, etc..)
  66266. * @param url defines the url to connect with
  66267. */
  66268. open(method: string, url: string): void;
  66269. }
  66270. }
  66271. declare module BABYLON {
  66272. /**
  66273. * File request interface
  66274. */
  66275. export interface IFileRequest {
  66276. /**
  66277. * Raised when the request is complete (success or error).
  66278. */
  66279. onCompleteObservable: Observable<IFileRequest>;
  66280. /**
  66281. * Aborts the request for a file.
  66282. */
  66283. abort: () => void;
  66284. }
  66285. }
  66286. declare module BABYLON {
  66287. /**
  66288. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  66289. */
  66290. export class PerformanceMonitor {
  66291. private _enabled;
  66292. private _rollingFrameTime;
  66293. private _lastFrameTimeMs;
  66294. /**
  66295. * constructor
  66296. * @param frameSampleSize The number of samples required to saturate the sliding window
  66297. */
  66298. constructor(frameSampleSize?: number);
  66299. /**
  66300. * Samples current frame
  66301. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  66302. */
  66303. sampleFrame(timeMs?: number): void;
  66304. /**
  66305. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66306. */
  66307. readonly averageFrameTime: number;
  66308. /**
  66309. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66310. */
  66311. readonly averageFrameTimeVariance: number;
  66312. /**
  66313. * Returns the frame time of the most recent frame
  66314. */
  66315. readonly instantaneousFrameTime: number;
  66316. /**
  66317. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  66318. */
  66319. readonly averageFPS: number;
  66320. /**
  66321. * Returns the average framerate in frames per second using the most recent frame time
  66322. */
  66323. readonly instantaneousFPS: number;
  66324. /**
  66325. * Returns true if enough samples have been taken to completely fill the sliding window
  66326. */
  66327. readonly isSaturated: boolean;
  66328. /**
  66329. * Enables contributions to the sliding window sample set
  66330. */
  66331. enable(): void;
  66332. /**
  66333. * Disables contributions to the sliding window sample set
  66334. * Samples will not be interpolated over the disabled period
  66335. */
  66336. disable(): void;
  66337. /**
  66338. * Returns true if sampling is enabled
  66339. */
  66340. readonly isEnabled: boolean;
  66341. /**
  66342. * Resets performance monitor
  66343. */
  66344. reset(): void;
  66345. }
  66346. /**
  66347. * RollingAverage
  66348. *
  66349. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  66350. */
  66351. export class RollingAverage {
  66352. /**
  66353. * Current average
  66354. */
  66355. average: number;
  66356. /**
  66357. * Current variance
  66358. */
  66359. variance: number;
  66360. protected _samples: Array<number>;
  66361. protected _sampleCount: number;
  66362. protected _pos: number;
  66363. protected _m2: number;
  66364. /**
  66365. * constructor
  66366. * @param length The number of samples required to saturate the sliding window
  66367. */
  66368. constructor(length: number);
  66369. /**
  66370. * Adds a sample to the sample set
  66371. * @param v The sample value
  66372. */
  66373. add(v: number): void;
  66374. /**
  66375. * Returns previously added values or null if outside of history or outside the sliding window domain
  66376. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  66377. * @return Value previously recorded with add() or null if outside of range
  66378. */
  66379. history(i: number): number;
  66380. /**
  66381. * Returns true if enough samples have been taken to completely fill the sliding window
  66382. * @return true if sample-set saturated
  66383. */
  66384. isSaturated(): boolean;
  66385. /**
  66386. * Resets the rolling average (equivalent to 0 samples taken so far)
  66387. */
  66388. reset(): void;
  66389. /**
  66390. * Wraps a value around the sample range boundaries
  66391. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  66392. * @return Wrapped position in sample range
  66393. */
  66394. protected _wrapPosition(i: number): number;
  66395. }
  66396. }
  66397. declare module BABYLON {
  66398. /**
  66399. * This class implement a typical dictionary using a string as key and the generic type T as value.
  66400. * The underlying implementation relies on an associative array to ensure the best performances.
  66401. * The value can be anything including 'null' but except 'undefined'
  66402. */
  66403. export class StringDictionary<T> {
  66404. /**
  66405. * This will clear this dictionary and copy the content from the 'source' one.
  66406. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  66407. * @param source the dictionary to take the content from and copy to this dictionary
  66408. */
  66409. copyFrom(source: StringDictionary<T>): void;
  66410. /**
  66411. * Get a value based from its key
  66412. * @param key the given key to get the matching value from
  66413. * @return the value if found, otherwise undefined is returned
  66414. */
  66415. get(key: string): T | undefined;
  66416. /**
  66417. * Get a value from its key or add it if it doesn't exist.
  66418. * This method will ensure you that a given key/data will be present in the dictionary.
  66419. * @param key the given key to get the matching value from
  66420. * @param factory the factory that will create the value if the key is not present in the dictionary.
  66421. * The factory will only be invoked if there's no data for the given key.
  66422. * @return the value corresponding to the key.
  66423. */
  66424. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  66425. /**
  66426. * Get a value from its key if present in the dictionary otherwise add it
  66427. * @param key the key to get the value from
  66428. * @param val if there's no such key/value pair in the dictionary add it with this value
  66429. * @return the value corresponding to the key
  66430. */
  66431. getOrAdd(key: string, val: T): T;
  66432. /**
  66433. * Check if there's a given key in the dictionary
  66434. * @param key the key to check for
  66435. * @return true if the key is present, false otherwise
  66436. */
  66437. contains(key: string): boolean;
  66438. /**
  66439. * Add a new key and its corresponding value
  66440. * @param key the key to add
  66441. * @param value the value corresponding to the key
  66442. * @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
  66443. */
  66444. add(key: string, value: T): boolean;
  66445. /**
  66446. * Update a specific value associated to a key
  66447. * @param key defines the key to use
  66448. * @param value defines the value to store
  66449. * @returns true if the value was updated (or false if the key was not found)
  66450. */
  66451. set(key: string, value: T): boolean;
  66452. /**
  66453. * Get the element of the given key and remove it from the dictionary
  66454. * @param key defines the key to search
  66455. * @returns the value associated with the key or null if not found
  66456. */
  66457. getAndRemove(key: string): Nullable<T>;
  66458. /**
  66459. * Remove a key/value from the dictionary.
  66460. * @param key the key to remove
  66461. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  66462. */
  66463. remove(key: string): boolean;
  66464. /**
  66465. * Clear the whole content of the dictionary
  66466. */
  66467. clear(): void;
  66468. /**
  66469. * Gets the current count
  66470. */
  66471. readonly count: number;
  66472. /**
  66473. * Execute a callback on each key/val of the dictionary.
  66474. * Note that you can remove any element in this dictionary in the callback implementation
  66475. * @param callback the callback to execute on a given key/value pair
  66476. */
  66477. forEach(callback: (key: string, val: T) => void): void;
  66478. /**
  66479. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  66480. * If the callback returns null or undefined the method will iterate to the next key/value pair
  66481. * Note that you can remove any element in this dictionary in the callback implementation
  66482. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  66483. * @returns the first item
  66484. */
  66485. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  66486. private _count;
  66487. private _data;
  66488. }
  66489. }
  66490. declare module BABYLON {
  66491. /**
  66492. * Class used to store gfx data (like WebGLBuffer)
  66493. */
  66494. export class DataBuffer {
  66495. /**
  66496. * Gets or sets the number of objects referencing this buffer
  66497. */
  66498. references: number;
  66499. /** Gets or sets the size of the underlying buffer */
  66500. capacity: number;
  66501. /**
  66502. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66503. */
  66504. is32Bits: boolean;
  66505. /**
  66506. * Gets the underlying buffer
  66507. */
  66508. readonly underlyingResource: any;
  66509. }
  66510. }
  66511. declare module BABYLON {
  66512. /**
  66513. * Class used to store data that will be store in GPU memory
  66514. */
  66515. export class Buffer {
  66516. private _engine;
  66517. private _buffer;
  66518. /** @hidden */
  66519. _data: Nullable<DataArray>;
  66520. private _updatable;
  66521. private _instanced;
  66522. /**
  66523. * Gets the byte stride.
  66524. */
  66525. readonly byteStride: number;
  66526. /**
  66527. * Constructor
  66528. * @param engine the engine
  66529. * @param data the data to use for this buffer
  66530. * @param updatable whether the data is updatable
  66531. * @param stride the stride (optional)
  66532. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66533. * @param instanced whether the buffer is instanced (optional)
  66534. * @param useBytes set to true if the stride in in bytes (optional)
  66535. */
  66536. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66537. /**
  66538. * Create a new VertexBuffer based on the current buffer
  66539. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66540. * @param offset defines offset in the buffer (0 by default)
  66541. * @param size defines the size in floats of attributes (position is 3 for instance)
  66542. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66543. * @param instanced defines if the vertex buffer contains indexed data
  66544. * @param useBytes defines if the offset and stride are in bytes
  66545. * @returns the new vertex buffer
  66546. */
  66547. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66548. /**
  66549. * Gets a boolean indicating if the Buffer is updatable?
  66550. * @returns true if the buffer is updatable
  66551. */
  66552. isUpdatable(): boolean;
  66553. /**
  66554. * Gets current buffer's data
  66555. * @returns a DataArray or null
  66556. */
  66557. getData(): Nullable<DataArray>;
  66558. /**
  66559. * Gets underlying native buffer
  66560. * @returns underlying native buffer
  66561. */
  66562. getBuffer(): Nullable<DataBuffer>;
  66563. /**
  66564. * Gets the stride in float32 units (i.e. byte stride / 4).
  66565. * May not be an integer if the byte stride is not divisible by 4.
  66566. * DEPRECATED. Use byteStride instead.
  66567. * @returns the stride in float32 units
  66568. */
  66569. getStrideSize(): number;
  66570. /**
  66571. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66572. * @param data defines the data to store
  66573. */
  66574. create(data?: Nullable<DataArray>): void;
  66575. /** @hidden */
  66576. _rebuild(): void;
  66577. /**
  66578. * Update current buffer data
  66579. * @param data defines the data to store
  66580. */
  66581. update(data: DataArray): void;
  66582. /**
  66583. * Updates the data directly.
  66584. * @param data the new data
  66585. * @param offset the new offset
  66586. * @param vertexCount the vertex count (optional)
  66587. * @param useBytes set to true if the offset is in bytes
  66588. */
  66589. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66590. /**
  66591. * Release all resources
  66592. */
  66593. dispose(): void;
  66594. }
  66595. /**
  66596. * Specialized buffer used to store vertex data
  66597. */
  66598. export class VertexBuffer {
  66599. /** @hidden */
  66600. _buffer: Buffer;
  66601. private _kind;
  66602. private _size;
  66603. private _ownsBuffer;
  66604. private _instanced;
  66605. private _instanceDivisor;
  66606. /**
  66607. * The byte type.
  66608. */
  66609. static readonly BYTE: number;
  66610. /**
  66611. * The unsigned byte type.
  66612. */
  66613. static readonly UNSIGNED_BYTE: number;
  66614. /**
  66615. * The short type.
  66616. */
  66617. static readonly SHORT: number;
  66618. /**
  66619. * The unsigned short type.
  66620. */
  66621. static readonly UNSIGNED_SHORT: number;
  66622. /**
  66623. * The integer type.
  66624. */
  66625. static readonly INT: number;
  66626. /**
  66627. * The unsigned integer type.
  66628. */
  66629. static readonly UNSIGNED_INT: number;
  66630. /**
  66631. * The float type.
  66632. */
  66633. static readonly FLOAT: number;
  66634. /**
  66635. * Gets or sets the instance divisor when in instanced mode
  66636. */
  66637. instanceDivisor: number;
  66638. /**
  66639. * Gets the byte stride.
  66640. */
  66641. readonly byteStride: number;
  66642. /**
  66643. * Gets the byte offset.
  66644. */
  66645. readonly byteOffset: number;
  66646. /**
  66647. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66648. */
  66649. readonly normalized: boolean;
  66650. /**
  66651. * Gets the data type of each component in the array.
  66652. */
  66653. readonly type: number;
  66654. /**
  66655. * Constructor
  66656. * @param engine the engine
  66657. * @param data the data to use for this vertex buffer
  66658. * @param kind the vertex buffer kind
  66659. * @param updatable whether the data is updatable
  66660. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66661. * @param stride the stride (optional)
  66662. * @param instanced whether the buffer is instanced (optional)
  66663. * @param offset the offset of the data (optional)
  66664. * @param size the number of components (optional)
  66665. * @param type the type of the component (optional)
  66666. * @param normalized whether the data contains normalized data (optional)
  66667. * @param useBytes set to true if stride and offset are in bytes (optional)
  66668. */
  66669. 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);
  66670. /** @hidden */
  66671. _rebuild(): void;
  66672. /**
  66673. * Returns the kind of the VertexBuffer (string)
  66674. * @returns a string
  66675. */
  66676. getKind(): string;
  66677. /**
  66678. * Gets a boolean indicating if the VertexBuffer is updatable?
  66679. * @returns true if the buffer is updatable
  66680. */
  66681. isUpdatable(): boolean;
  66682. /**
  66683. * Gets current buffer's data
  66684. * @returns a DataArray or null
  66685. */
  66686. getData(): Nullable<DataArray>;
  66687. /**
  66688. * Gets underlying native buffer
  66689. * @returns underlying native buffer
  66690. */
  66691. getBuffer(): Nullable<DataBuffer>;
  66692. /**
  66693. * Gets the stride in float32 units (i.e. byte stride / 4).
  66694. * May not be an integer if the byte stride is not divisible by 4.
  66695. * DEPRECATED. Use byteStride instead.
  66696. * @returns the stride in float32 units
  66697. */
  66698. getStrideSize(): number;
  66699. /**
  66700. * Returns the offset as a multiple of the type byte length.
  66701. * DEPRECATED. Use byteOffset instead.
  66702. * @returns the offset in bytes
  66703. */
  66704. getOffset(): number;
  66705. /**
  66706. * Returns the number of components per vertex attribute (integer)
  66707. * @returns the size in float
  66708. */
  66709. getSize(): number;
  66710. /**
  66711. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66712. * @returns true if this buffer is instanced
  66713. */
  66714. getIsInstanced(): boolean;
  66715. /**
  66716. * Returns the instancing divisor, zero for non-instanced (integer).
  66717. * @returns a number
  66718. */
  66719. getInstanceDivisor(): number;
  66720. /**
  66721. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66722. * @param data defines the data to store
  66723. */
  66724. create(data?: DataArray): void;
  66725. /**
  66726. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66727. * This function will create a new buffer if the current one is not updatable
  66728. * @param data defines the data to store
  66729. */
  66730. update(data: DataArray): void;
  66731. /**
  66732. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66733. * Returns the directly updated WebGLBuffer.
  66734. * @param data the new data
  66735. * @param offset the new offset
  66736. * @param useBytes set to true if the offset is in bytes
  66737. */
  66738. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66739. /**
  66740. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66741. */
  66742. dispose(): void;
  66743. /**
  66744. * Enumerates each value of this vertex buffer as numbers.
  66745. * @param count the number of values to enumerate
  66746. * @param callback the callback function called for each value
  66747. */
  66748. forEach(count: number, callback: (value: number, index: number) => void): void;
  66749. /**
  66750. * Positions
  66751. */
  66752. static readonly PositionKind: string;
  66753. /**
  66754. * Normals
  66755. */
  66756. static readonly NormalKind: string;
  66757. /**
  66758. * Tangents
  66759. */
  66760. static readonly TangentKind: string;
  66761. /**
  66762. * Texture coordinates
  66763. */
  66764. static readonly UVKind: string;
  66765. /**
  66766. * Texture coordinates 2
  66767. */
  66768. static readonly UV2Kind: string;
  66769. /**
  66770. * Texture coordinates 3
  66771. */
  66772. static readonly UV3Kind: string;
  66773. /**
  66774. * Texture coordinates 4
  66775. */
  66776. static readonly UV4Kind: string;
  66777. /**
  66778. * Texture coordinates 5
  66779. */
  66780. static readonly UV5Kind: string;
  66781. /**
  66782. * Texture coordinates 6
  66783. */
  66784. static readonly UV6Kind: string;
  66785. /**
  66786. * Colors
  66787. */
  66788. static readonly ColorKind: string;
  66789. /**
  66790. * Matrix indices (for bones)
  66791. */
  66792. static readonly MatricesIndicesKind: string;
  66793. /**
  66794. * Matrix weights (for bones)
  66795. */
  66796. static readonly MatricesWeightsKind: string;
  66797. /**
  66798. * Additional matrix indices (for bones)
  66799. */
  66800. static readonly MatricesIndicesExtraKind: string;
  66801. /**
  66802. * Additional matrix weights (for bones)
  66803. */
  66804. static readonly MatricesWeightsExtraKind: string;
  66805. /**
  66806. * Deduces the stride given a kind.
  66807. * @param kind The kind string to deduce
  66808. * @returns The deduced stride
  66809. */
  66810. static DeduceStride(kind: string): number;
  66811. /**
  66812. * Gets the byte length of the given type.
  66813. * @param type the type
  66814. * @returns the number of bytes
  66815. */
  66816. static GetTypeByteLength(type: number): number;
  66817. /**
  66818. * Enumerates each value of the given parameters as numbers.
  66819. * @param data the data to enumerate
  66820. * @param byteOffset the byte offset of the data
  66821. * @param byteStride the byte stride of the data
  66822. * @param componentCount the number of components per element
  66823. * @param componentType the type of the component
  66824. * @param count the number of values to enumerate
  66825. * @param normalized whether the data is normalized
  66826. * @param callback the callback function called for each value
  66827. */
  66828. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66829. private static _GetFloatValue;
  66830. }
  66831. }
  66832. declare module BABYLON {
  66833. /**
  66834. * Scalar computation library
  66835. */
  66836. export class Scalar {
  66837. /**
  66838. * Two pi constants convenient for computation.
  66839. */
  66840. static TwoPi: number;
  66841. /**
  66842. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66843. * @param a number
  66844. * @param b number
  66845. * @param epsilon (default = 1.401298E-45)
  66846. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66847. */
  66848. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66849. /**
  66850. * Returns a string : the upper case translation of the number i to hexadecimal.
  66851. * @param i number
  66852. * @returns the upper case translation of the number i to hexadecimal.
  66853. */
  66854. static ToHex(i: number): string;
  66855. /**
  66856. * Returns -1 if value is negative and +1 is value is positive.
  66857. * @param value the value
  66858. * @returns the value itself if it's equal to zero.
  66859. */
  66860. static Sign(value: number): number;
  66861. /**
  66862. * Returns the value itself if it's between min and max.
  66863. * Returns min if the value is lower than min.
  66864. * Returns max if the value is greater than max.
  66865. * @param value the value to clmap
  66866. * @param min the min value to clamp to (default: 0)
  66867. * @param max the max value to clamp to (default: 1)
  66868. * @returns the clamped value
  66869. */
  66870. static Clamp(value: number, min?: number, max?: number): number;
  66871. /**
  66872. * the log2 of value.
  66873. * @param value the value to compute log2 of
  66874. * @returns the log2 of value.
  66875. */
  66876. static Log2(value: number): number;
  66877. /**
  66878. * Loops the value, so that it is never larger than length and never smaller than 0.
  66879. *
  66880. * This is similar to the modulo operator but it works with floating point numbers.
  66881. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66882. * With t = 5 and length = 2.5, the result would be 0.0.
  66883. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66884. * @param value the value
  66885. * @param length the length
  66886. * @returns the looped value
  66887. */
  66888. static Repeat(value: number, length: number): number;
  66889. /**
  66890. * Normalize the value between 0.0 and 1.0 using min and max values
  66891. * @param value value to normalize
  66892. * @param min max to normalize between
  66893. * @param max min to normalize between
  66894. * @returns the normalized value
  66895. */
  66896. static Normalize(value: number, min: number, max: number): number;
  66897. /**
  66898. * Denormalize the value from 0.0 and 1.0 using min and max values
  66899. * @param normalized value to denormalize
  66900. * @param min max to denormalize between
  66901. * @param max min to denormalize between
  66902. * @returns the denormalized value
  66903. */
  66904. static Denormalize(normalized: number, min: number, max: number): number;
  66905. /**
  66906. * Calculates the shortest difference between two given angles given in degrees.
  66907. * @param current current angle in degrees
  66908. * @param target target angle in degrees
  66909. * @returns the delta
  66910. */
  66911. static DeltaAngle(current: number, target: number): number;
  66912. /**
  66913. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66914. * @param tx value
  66915. * @param length length
  66916. * @returns The returned value will move back and forth between 0 and length
  66917. */
  66918. static PingPong(tx: number, length: number): number;
  66919. /**
  66920. * Interpolates between min and max with smoothing at the limits.
  66921. *
  66922. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66923. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66924. * @param from from
  66925. * @param to to
  66926. * @param tx value
  66927. * @returns the smooth stepped value
  66928. */
  66929. static SmoothStep(from: number, to: number, tx: number): number;
  66930. /**
  66931. * Moves a value current towards target.
  66932. *
  66933. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66934. * Negative values of maxDelta pushes the value away from target.
  66935. * @param current current value
  66936. * @param target target value
  66937. * @param maxDelta max distance to move
  66938. * @returns resulting value
  66939. */
  66940. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66941. /**
  66942. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66943. *
  66944. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66945. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66946. * @param current current value
  66947. * @param target target value
  66948. * @param maxDelta max distance to move
  66949. * @returns resulting angle
  66950. */
  66951. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66952. /**
  66953. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66954. * @param start start value
  66955. * @param end target value
  66956. * @param amount amount to lerp between
  66957. * @returns the lerped value
  66958. */
  66959. static Lerp(start: number, end: number, amount: number): number;
  66960. /**
  66961. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66962. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66963. * @param start start value
  66964. * @param end target value
  66965. * @param amount amount to lerp between
  66966. * @returns the lerped value
  66967. */
  66968. static LerpAngle(start: number, end: number, amount: number): number;
  66969. /**
  66970. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66971. * @param a start value
  66972. * @param b target value
  66973. * @param value value between a and b
  66974. * @returns the inverseLerp value
  66975. */
  66976. static InverseLerp(a: number, b: number, value: number): number;
  66977. /**
  66978. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66979. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66980. * @param value1 spline value
  66981. * @param tangent1 spline value
  66982. * @param value2 spline value
  66983. * @param tangent2 spline value
  66984. * @param amount input value
  66985. * @returns hermite result
  66986. */
  66987. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66988. /**
  66989. * Returns a random float number between and min and max values
  66990. * @param min min value of random
  66991. * @param max max value of random
  66992. * @returns random value
  66993. */
  66994. static RandomRange(min: number, max: number): number;
  66995. /**
  66996. * This function returns percentage of a number in a given range.
  66997. *
  66998. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66999. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67000. * @param number to convert to percentage
  67001. * @param min min range
  67002. * @param max max range
  67003. * @returns the percentage
  67004. */
  67005. static RangeToPercent(number: number, min: number, max: number): number;
  67006. /**
  67007. * This function returns number that corresponds to the percentage in a given range.
  67008. *
  67009. * PercentToRange(0.34,0,100) will return 34.
  67010. * @param percent to convert to number
  67011. * @param min min range
  67012. * @param max max range
  67013. * @returns the number
  67014. */
  67015. static PercentToRange(percent: number, min: number, max: number): number;
  67016. /**
  67017. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67018. * @param angle The angle to normalize in radian.
  67019. * @return The converted angle.
  67020. */
  67021. static NormalizeRadians(angle: number): number;
  67022. }
  67023. }
  67024. declare module BABYLON {
  67025. /**
  67026. * Constant used to convert a value to gamma space
  67027. * @ignorenaming
  67028. */
  67029. export const ToGammaSpace: number;
  67030. /**
  67031. * Constant used to convert a value to linear space
  67032. * @ignorenaming
  67033. */
  67034. export const ToLinearSpace = 2.2;
  67035. /**
  67036. * Constant used to define the minimal number value in Babylon.js
  67037. * @ignorenaming
  67038. */
  67039. let Epsilon: number;
  67040. }
  67041. declare module BABYLON {
  67042. /**
  67043. * Class used to represent a viewport on screen
  67044. */
  67045. export class Viewport {
  67046. /** viewport left coordinate */
  67047. x: number;
  67048. /** viewport top coordinate */
  67049. y: number;
  67050. /**viewport width */
  67051. width: number;
  67052. /** viewport height */
  67053. height: number;
  67054. /**
  67055. * Creates a Viewport object located at (x, y) and sized (width, height)
  67056. * @param x defines viewport left coordinate
  67057. * @param y defines viewport top coordinate
  67058. * @param width defines the viewport width
  67059. * @param height defines the viewport height
  67060. */
  67061. constructor(
  67062. /** viewport left coordinate */
  67063. x: number,
  67064. /** viewport top coordinate */
  67065. y: number,
  67066. /**viewport width */
  67067. width: number,
  67068. /** viewport height */
  67069. height: number);
  67070. /**
  67071. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67072. * @param renderWidth defines the rendering width
  67073. * @param renderHeight defines the rendering height
  67074. * @returns a new Viewport
  67075. */
  67076. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67077. /**
  67078. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67079. * @param renderWidth defines the rendering width
  67080. * @param renderHeight defines the rendering height
  67081. * @param ref defines the target viewport
  67082. * @returns the current viewport
  67083. */
  67084. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67085. /**
  67086. * Returns a new Viewport copied from the current one
  67087. * @returns a new Viewport
  67088. */
  67089. clone(): Viewport;
  67090. }
  67091. }
  67092. declare module BABYLON {
  67093. /**
  67094. * Class containing a set of static utilities functions for arrays.
  67095. */
  67096. export class ArrayTools {
  67097. /**
  67098. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67099. * @param size the number of element to construct and put in the array
  67100. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67101. * @returns a new array filled with new objects
  67102. */
  67103. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67104. }
  67105. }
  67106. declare module BABYLON {
  67107. /**
  67108. * @hidden
  67109. */
  67110. export interface IColor4Like {
  67111. r: float;
  67112. g: float;
  67113. b: float;
  67114. a: float;
  67115. }
  67116. /**
  67117. * @hidden
  67118. */
  67119. export interface IColor3Like {
  67120. r: float;
  67121. g: float;
  67122. b: float;
  67123. }
  67124. /**
  67125. * @hidden
  67126. */
  67127. export interface IVector4Like {
  67128. x: float;
  67129. y: float;
  67130. z: float;
  67131. w: float;
  67132. }
  67133. /**
  67134. * @hidden
  67135. */
  67136. export interface IVector3Like {
  67137. x: float;
  67138. y: float;
  67139. z: float;
  67140. }
  67141. /**
  67142. * @hidden
  67143. */
  67144. export interface IVector2Like {
  67145. x: float;
  67146. y: float;
  67147. }
  67148. /**
  67149. * @hidden
  67150. */
  67151. export interface IMatrixLike {
  67152. toArray(): DeepImmutable<Float32Array>;
  67153. updateFlag: int;
  67154. }
  67155. /**
  67156. * @hidden
  67157. */
  67158. export interface IViewportLike {
  67159. x: float;
  67160. y: float;
  67161. width: float;
  67162. height: float;
  67163. }
  67164. /**
  67165. * @hidden
  67166. */
  67167. export interface IPlaneLike {
  67168. normal: IVector3Like;
  67169. d: float;
  67170. normalize(): void;
  67171. }
  67172. }
  67173. declare module BABYLON {
  67174. /**
  67175. * Class representing a vector containing 2 coordinates
  67176. */
  67177. export class Vector2 {
  67178. /** defines the first coordinate */
  67179. x: number;
  67180. /** defines the second coordinate */
  67181. y: number;
  67182. /**
  67183. * Creates a new Vector2 from the given x and y coordinates
  67184. * @param x defines the first coordinate
  67185. * @param y defines the second coordinate
  67186. */
  67187. constructor(
  67188. /** defines the first coordinate */
  67189. x?: number,
  67190. /** defines the second coordinate */
  67191. y?: number);
  67192. /**
  67193. * Gets a string with the Vector2 coordinates
  67194. * @returns a string with the Vector2 coordinates
  67195. */
  67196. toString(): string;
  67197. /**
  67198. * Gets class name
  67199. * @returns the string "Vector2"
  67200. */
  67201. getClassName(): string;
  67202. /**
  67203. * Gets current vector hash code
  67204. * @returns the Vector2 hash code as a number
  67205. */
  67206. getHashCode(): number;
  67207. /**
  67208. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67209. * @param array defines the source array
  67210. * @param index defines the offset in source array
  67211. * @returns the current Vector2
  67212. */
  67213. toArray(array: FloatArray, index?: number): Vector2;
  67214. /**
  67215. * Copy the current vector to an array
  67216. * @returns a new array with 2 elements: the Vector2 coordinates.
  67217. */
  67218. asArray(): number[];
  67219. /**
  67220. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67221. * @param source defines the source Vector2
  67222. * @returns the current updated Vector2
  67223. */
  67224. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67225. /**
  67226. * Sets the Vector2 coordinates with the given floats
  67227. * @param x defines the first coordinate
  67228. * @param y defines the second coordinate
  67229. * @returns the current updated Vector2
  67230. */
  67231. copyFromFloats(x: number, y: number): Vector2;
  67232. /**
  67233. * Sets the Vector2 coordinates with the given floats
  67234. * @param x defines the first coordinate
  67235. * @param y defines the second coordinate
  67236. * @returns the current updated Vector2
  67237. */
  67238. set(x: number, y: number): Vector2;
  67239. /**
  67240. * Add another vector with the current one
  67241. * @param otherVector defines the other vector
  67242. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67243. */
  67244. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67245. /**
  67246. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67247. * @param otherVector defines the other vector
  67248. * @param result defines the target vector
  67249. * @returns the unmodified current Vector2
  67250. */
  67251. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67252. /**
  67253. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67254. * @param otherVector defines the other vector
  67255. * @returns the current updated Vector2
  67256. */
  67257. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67258. /**
  67259. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67260. * @param otherVector defines the other vector
  67261. * @returns a new Vector2
  67262. */
  67263. addVector3(otherVector: Vector3): Vector2;
  67264. /**
  67265. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67266. * @param otherVector defines the other vector
  67267. * @returns a new Vector2
  67268. */
  67269. subtract(otherVector: Vector2): Vector2;
  67270. /**
  67271. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67272. * @param otherVector defines the other vector
  67273. * @param result defines the target vector
  67274. * @returns the unmodified current Vector2
  67275. */
  67276. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67277. /**
  67278. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67279. * @param otherVector defines the other vector
  67280. * @returns the current updated Vector2
  67281. */
  67282. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67283. /**
  67284. * Multiplies in place the current Vector2 coordinates by the given ones
  67285. * @param otherVector defines the other vector
  67286. * @returns the current updated Vector2
  67287. */
  67288. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67289. /**
  67290. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67291. * @param otherVector defines the other vector
  67292. * @returns a new Vector2
  67293. */
  67294. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67295. /**
  67296. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67297. * @param otherVector defines the other vector
  67298. * @param result defines the target vector
  67299. * @returns the unmodified current Vector2
  67300. */
  67301. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67302. /**
  67303. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67304. * @param x defines the first coordinate
  67305. * @param y defines the second coordinate
  67306. * @returns a new Vector2
  67307. */
  67308. multiplyByFloats(x: number, y: number): Vector2;
  67309. /**
  67310. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67311. * @param otherVector defines the other vector
  67312. * @returns a new Vector2
  67313. */
  67314. divide(otherVector: Vector2): Vector2;
  67315. /**
  67316. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67317. * @param otherVector defines the other vector
  67318. * @param result defines the target vector
  67319. * @returns the unmodified current Vector2
  67320. */
  67321. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67322. /**
  67323. * Divides the current Vector2 coordinates by the given ones
  67324. * @param otherVector defines the other vector
  67325. * @returns the current updated Vector2
  67326. */
  67327. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67328. /**
  67329. * Gets a new Vector2 with current Vector2 negated coordinates
  67330. * @returns a new Vector2
  67331. */
  67332. negate(): Vector2;
  67333. /**
  67334. * Multiply the Vector2 coordinates by scale
  67335. * @param scale defines the scaling factor
  67336. * @returns the current updated Vector2
  67337. */
  67338. scaleInPlace(scale: number): Vector2;
  67339. /**
  67340. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67341. * @param scale defines the scaling factor
  67342. * @returns a new Vector2
  67343. */
  67344. scale(scale: number): Vector2;
  67345. /**
  67346. * Scale the current Vector2 values by a factor to a given Vector2
  67347. * @param scale defines the scale factor
  67348. * @param result defines the Vector2 object where to store the result
  67349. * @returns the unmodified current Vector2
  67350. */
  67351. scaleToRef(scale: number, result: Vector2): Vector2;
  67352. /**
  67353. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67354. * @param scale defines the scale factor
  67355. * @param result defines the Vector2 object where to store the result
  67356. * @returns the unmodified current Vector2
  67357. */
  67358. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67359. /**
  67360. * Gets a boolean if two vectors are equals
  67361. * @param otherVector defines the other vector
  67362. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67363. */
  67364. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67365. /**
  67366. * Gets a boolean if two vectors are equals (using an epsilon value)
  67367. * @param otherVector defines the other vector
  67368. * @param epsilon defines the minimal distance to consider equality
  67369. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67370. */
  67371. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67372. /**
  67373. * Gets a new Vector2 from current Vector2 floored values
  67374. * @returns a new Vector2
  67375. */
  67376. floor(): Vector2;
  67377. /**
  67378. * Gets a new Vector2 from current Vector2 floored values
  67379. * @returns a new Vector2
  67380. */
  67381. fract(): Vector2;
  67382. /**
  67383. * Gets the length of the vector
  67384. * @returns the vector length (float)
  67385. */
  67386. length(): number;
  67387. /**
  67388. * Gets the vector squared length
  67389. * @returns the vector squared length (float)
  67390. */
  67391. lengthSquared(): number;
  67392. /**
  67393. * Normalize the vector
  67394. * @returns the current updated Vector2
  67395. */
  67396. normalize(): Vector2;
  67397. /**
  67398. * Gets a new Vector2 copied from the Vector2
  67399. * @returns a new Vector2
  67400. */
  67401. clone(): Vector2;
  67402. /**
  67403. * Gets a new Vector2(0, 0)
  67404. * @returns a new Vector2
  67405. */
  67406. static Zero(): Vector2;
  67407. /**
  67408. * Gets a new Vector2(1, 1)
  67409. * @returns a new Vector2
  67410. */
  67411. static One(): Vector2;
  67412. /**
  67413. * Gets a new Vector2 set from the given index element of the given array
  67414. * @param array defines the data source
  67415. * @param offset defines the offset in the data source
  67416. * @returns a new Vector2
  67417. */
  67418. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67419. /**
  67420. * Sets "result" from the given index element of the given array
  67421. * @param array defines the data source
  67422. * @param offset defines the offset in the data source
  67423. * @param result defines the target vector
  67424. */
  67425. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67426. /**
  67427. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67428. * @param value1 defines 1st point of control
  67429. * @param value2 defines 2nd point of control
  67430. * @param value3 defines 3rd point of control
  67431. * @param value4 defines 4th point of control
  67432. * @param amount defines the interpolation factor
  67433. * @returns a new Vector2
  67434. */
  67435. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67436. /**
  67437. * 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".
  67438. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67439. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67440. * @param value defines the value to clamp
  67441. * @param min defines the lower limit
  67442. * @param max defines the upper limit
  67443. * @returns a new Vector2
  67444. */
  67445. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67446. /**
  67447. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67448. * @param value1 defines the 1st control point
  67449. * @param tangent1 defines the outgoing tangent
  67450. * @param value2 defines the 2nd control point
  67451. * @param tangent2 defines the incoming tangent
  67452. * @param amount defines the interpolation factor
  67453. * @returns a new Vector2
  67454. */
  67455. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67456. /**
  67457. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67458. * @param start defines the start vector
  67459. * @param end defines the end vector
  67460. * @param amount defines the interpolation factor
  67461. * @returns a new Vector2
  67462. */
  67463. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67464. /**
  67465. * Gets the dot product of the vector "left" and the vector "right"
  67466. * @param left defines first vector
  67467. * @param right defines second vector
  67468. * @returns the dot product (float)
  67469. */
  67470. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67471. /**
  67472. * Returns a new Vector2 equal to the normalized given vector
  67473. * @param vector defines the vector to normalize
  67474. * @returns a new Vector2
  67475. */
  67476. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67477. /**
  67478. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67479. * @param left defines 1st vector
  67480. * @param right defines 2nd vector
  67481. * @returns a new Vector2
  67482. */
  67483. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67484. /**
  67485. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67486. * @param left defines 1st vector
  67487. * @param right defines 2nd vector
  67488. * @returns a new Vector2
  67489. */
  67490. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67491. /**
  67492. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67493. * @param vector defines the vector to transform
  67494. * @param transformation defines the matrix to apply
  67495. * @returns a new Vector2
  67496. */
  67497. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67498. /**
  67499. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67500. * @param vector defines the vector to transform
  67501. * @param transformation defines the matrix to apply
  67502. * @param result defines the target vector
  67503. */
  67504. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67505. /**
  67506. * Determines if a given vector is included in a triangle
  67507. * @param p defines the vector to test
  67508. * @param p0 defines 1st triangle point
  67509. * @param p1 defines 2nd triangle point
  67510. * @param p2 defines 3rd triangle point
  67511. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67512. */
  67513. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67514. /**
  67515. * Gets the distance between the vectors "value1" and "value2"
  67516. * @param value1 defines first vector
  67517. * @param value2 defines second vector
  67518. * @returns the distance between vectors
  67519. */
  67520. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67521. /**
  67522. * Returns the squared distance between the vectors "value1" and "value2"
  67523. * @param value1 defines first vector
  67524. * @param value2 defines second vector
  67525. * @returns the squared distance between vectors
  67526. */
  67527. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67528. /**
  67529. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67530. * @param value1 defines first vector
  67531. * @param value2 defines second vector
  67532. * @returns a new Vector2
  67533. */
  67534. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67535. /**
  67536. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67537. * @param p defines the middle point
  67538. * @param segA defines one point of the segment
  67539. * @param segB defines the other point of the segment
  67540. * @returns the shortest distance
  67541. */
  67542. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67543. }
  67544. /**
  67545. * Classed used to store (x,y,z) vector representation
  67546. * A Vector3 is the main object used in 3D geometry
  67547. * It can represent etiher the coordinates of a point the space, either a direction
  67548. * Reminder: js uses a left handed forward facing system
  67549. */
  67550. export class Vector3 {
  67551. /**
  67552. * Defines the first coordinates (on X axis)
  67553. */
  67554. x: number;
  67555. /**
  67556. * Defines the second coordinates (on Y axis)
  67557. */
  67558. y: number;
  67559. /**
  67560. * Defines the third coordinates (on Z axis)
  67561. */
  67562. z: number;
  67563. private static _UpReadOnly;
  67564. private static _ZeroReadOnly;
  67565. /**
  67566. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67567. * @param x defines the first coordinates (on X axis)
  67568. * @param y defines the second coordinates (on Y axis)
  67569. * @param z defines the third coordinates (on Z axis)
  67570. */
  67571. constructor(
  67572. /**
  67573. * Defines the first coordinates (on X axis)
  67574. */
  67575. x?: number,
  67576. /**
  67577. * Defines the second coordinates (on Y axis)
  67578. */
  67579. y?: number,
  67580. /**
  67581. * Defines the third coordinates (on Z axis)
  67582. */
  67583. z?: number);
  67584. /**
  67585. * Creates a string representation of the Vector3
  67586. * @returns a string with the Vector3 coordinates.
  67587. */
  67588. toString(): string;
  67589. /**
  67590. * Gets the class name
  67591. * @returns the string "Vector3"
  67592. */
  67593. getClassName(): string;
  67594. /**
  67595. * Creates the Vector3 hash code
  67596. * @returns a number which tends to be unique between Vector3 instances
  67597. */
  67598. getHashCode(): number;
  67599. /**
  67600. * Creates an array containing three elements : the coordinates of the Vector3
  67601. * @returns a new array of numbers
  67602. */
  67603. asArray(): number[];
  67604. /**
  67605. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67606. * @param array defines the destination array
  67607. * @param index defines the offset in the destination array
  67608. * @returns the current Vector3
  67609. */
  67610. toArray(array: FloatArray, index?: number): Vector3;
  67611. /**
  67612. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67613. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67614. */
  67615. toQuaternion(): Quaternion;
  67616. /**
  67617. * Adds the given vector to the current Vector3
  67618. * @param otherVector defines the second operand
  67619. * @returns the current updated Vector3
  67620. */
  67621. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67622. /**
  67623. * Adds the given coordinates to the current Vector3
  67624. * @param x defines the x coordinate of the operand
  67625. * @param y defines the y coordinate of the operand
  67626. * @param z defines the z coordinate of the operand
  67627. * @returns the current updated Vector3
  67628. */
  67629. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67630. /**
  67631. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67632. * @param otherVector defines the second operand
  67633. * @returns the resulting Vector3
  67634. */
  67635. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67636. /**
  67637. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67638. * @param otherVector defines the second operand
  67639. * @param result defines the Vector3 object where to store the result
  67640. * @returns the current Vector3
  67641. */
  67642. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67643. /**
  67644. * Subtract the given vector from the current Vector3
  67645. * @param otherVector defines the second operand
  67646. * @returns the current updated Vector3
  67647. */
  67648. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67649. /**
  67650. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67651. * @param otherVector defines the second operand
  67652. * @returns the resulting Vector3
  67653. */
  67654. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67655. /**
  67656. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67657. * @param otherVector defines the second operand
  67658. * @param result defines the Vector3 object where to store the result
  67659. * @returns the current Vector3
  67660. */
  67661. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67662. /**
  67663. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67664. * @param x defines the x coordinate of the operand
  67665. * @param y defines the y coordinate of the operand
  67666. * @param z defines the z coordinate of the operand
  67667. * @returns the resulting Vector3
  67668. */
  67669. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67670. /**
  67671. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67672. * @param x defines the x coordinate of the operand
  67673. * @param y defines the y coordinate of the operand
  67674. * @param z defines the z coordinate of the operand
  67675. * @param result defines the Vector3 object where to store the result
  67676. * @returns the current Vector3
  67677. */
  67678. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67679. /**
  67680. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67681. * @returns a new Vector3
  67682. */
  67683. negate(): Vector3;
  67684. /**
  67685. * Multiplies the Vector3 coordinates by the float "scale"
  67686. * @param scale defines the multiplier factor
  67687. * @returns the current updated Vector3
  67688. */
  67689. scaleInPlace(scale: number): Vector3;
  67690. /**
  67691. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67692. * @param scale defines the multiplier factor
  67693. * @returns a new Vector3
  67694. */
  67695. scale(scale: number): Vector3;
  67696. /**
  67697. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67698. * @param scale defines the multiplier factor
  67699. * @param result defines the Vector3 object where to store the result
  67700. * @returns the current Vector3
  67701. */
  67702. scaleToRef(scale: number, result: Vector3): Vector3;
  67703. /**
  67704. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67705. * @param scale defines the scale factor
  67706. * @param result defines the Vector3 object where to store the result
  67707. * @returns the unmodified current Vector3
  67708. */
  67709. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67710. /**
  67711. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67712. * @param otherVector defines the second operand
  67713. * @returns true if both vectors are equals
  67714. */
  67715. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67716. /**
  67717. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67718. * @param otherVector defines the second operand
  67719. * @param epsilon defines the minimal distance to define values as equals
  67720. * @returns true if both vectors are distant less than epsilon
  67721. */
  67722. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67723. /**
  67724. * Returns true if the current Vector3 coordinates equals the given floats
  67725. * @param x defines the x coordinate of the operand
  67726. * @param y defines the y coordinate of the operand
  67727. * @param z defines the z coordinate of the operand
  67728. * @returns true if both vectors are equals
  67729. */
  67730. equalsToFloats(x: number, y: number, z: number): boolean;
  67731. /**
  67732. * Multiplies the current Vector3 coordinates by the given ones
  67733. * @param otherVector defines the second operand
  67734. * @returns the current updated Vector3
  67735. */
  67736. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67737. /**
  67738. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67739. * @param otherVector defines the second operand
  67740. * @returns the new Vector3
  67741. */
  67742. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67743. /**
  67744. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67745. * @param otherVector defines the second operand
  67746. * @param result defines the Vector3 object where to store the result
  67747. * @returns the current Vector3
  67748. */
  67749. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67750. /**
  67751. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67752. * @param x defines the x coordinate of the operand
  67753. * @param y defines the y coordinate of the operand
  67754. * @param z defines the z coordinate of the operand
  67755. * @returns the new Vector3
  67756. */
  67757. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67758. /**
  67759. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67760. * @param otherVector defines the second operand
  67761. * @returns the new Vector3
  67762. */
  67763. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67764. /**
  67765. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67766. * @param otherVector defines the second operand
  67767. * @param result defines the Vector3 object where to store the result
  67768. * @returns the current Vector3
  67769. */
  67770. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67771. /**
  67772. * Divides the current Vector3 coordinates by the given ones.
  67773. * @param otherVector defines the second operand
  67774. * @returns the current updated Vector3
  67775. */
  67776. divideInPlace(otherVector: Vector3): Vector3;
  67777. /**
  67778. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67779. * @param other defines the second operand
  67780. * @returns the current updated Vector3
  67781. */
  67782. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67783. /**
  67784. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67785. * @param other defines the second operand
  67786. * @returns the current updated Vector3
  67787. */
  67788. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67789. /**
  67790. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67791. * @param x defines the x coordinate of the operand
  67792. * @param y defines the y coordinate of the operand
  67793. * @param z defines the z coordinate of the operand
  67794. * @returns the current updated Vector3
  67795. */
  67796. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67797. /**
  67798. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67799. * @param x defines the x coordinate of the operand
  67800. * @param y defines the y coordinate of the operand
  67801. * @param z defines the z coordinate of the operand
  67802. * @returns the current updated Vector3
  67803. */
  67804. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67805. /**
  67806. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67807. * Check if is non uniform within a certain amount of decimal places to account for this
  67808. * @param epsilon the amount the values can differ
  67809. * @returns if the the vector is non uniform to a certain number of decimal places
  67810. */
  67811. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67812. /**
  67813. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67814. */
  67815. readonly isNonUniform: boolean;
  67816. /**
  67817. * Gets a new Vector3 from current Vector3 floored values
  67818. * @returns a new Vector3
  67819. */
  67820. floor(): Vector3;
  67821. /**
  67822. * Gets a new Vector3 from current Vector3 floored values
  67823. * @returns a new Vector3
  67824. */
  67825. fract(): Vector3;
  67826. /**
  67827. * Gets the length of the Vector3
  67828. * @returns the length of the Vector3
  67829. */
  67830. length(): number;
  67831. /**
  67832. * Gets the squared length of the Vector3
  67833. * @returns squared length of the Vector3
  67834. */
  67835. lengthSquared(): number;
  67836. /**
  67837. * Normalize the current Vector3.
  67838. * Please note that this is an in place operation.
  67839. * @returns the current updated Vector3
  67840. */
  67841. normalize(): Vector3;
  67842. /**
  67843. * Reorders the x y z properties of the vector in place
  67844. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67845. * @returns the current updated vector
  67846. */
  67847. reorderInPlace(order: string): this;
  67848. /**
  67849. * Rotates the vector around 0,0,0 by a quaternion
  67850. * @param quaternion the rotation quaternion
  67851. * @param result vector to store the result
  67852. * @returns the resulting vector
  67853. */
  67854. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67855. /**
  67856. * Rotates a vector around a given point
  67857. * @param quaternion the rotation quaternion
  67858. * @param point the point to rotate around
  67859. * @param result vector to store the result
  67860. * @returns the resulting vector
  67861. */
  67862. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67863. /**
  67864. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  67865. * The cross product is then orthogonal to both current and "other"
  67866. * @param other defines the right operand
  67867. * @returns the cross product
  67868. */
  67869. cross(other: Vector3): Vector3;
  67870. /**
  67871. * Normalize the current Vector3 with the given input length.
  67872. * Please note that this is an in place operation.
  67873. * @param len the length of the vector
  67874. * @returns the current updated Vector3
  67875. */
  67876. normalizeFromLength(len: number): Vector3;
  67877. /**
  67878. * Normalize the current Vector3 to a new vector
  67879. * @returns the new Vector3
  67880. */
  67881. normalizeToNew(): Vector3;
  67882. /**
  67883. * Normalize the current Vector3 to the reference
  67884. * @param reference define the Vector3 to update
  67885. * @returns the updated Vector3
  67886. */
  67887. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67888. /**
  67889. * Creates a new Vector3 copied from the current Vector3
  67890. * @returns the new Vector3
  67891. */
  67892. clone(): Vector3;
  67893. /**
  67894. * Copies the given vector coordinates to the current Vector3 ones
  67895. * @param source defines the source Vector3
  67896. * @returns the current updated Vector3
  67897. */
  67898. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67899. /**
  67900. * Copies the given floats to the current Vector3 coordinates
  67901. * @param x defines the x coordinate of the operand
  67902. * @param y defines the y coordinate of the operand
  67903. * @param z defines the z coordinate of the operand
  67904. * @returns the current updated Vector3
  67905. */
  67906. copyFromFloats(x: number, y: number, z: number): Vector3;
  67907. /**
  67908. * Copies the given floats to the current Vector3 coordinates
  67909. * @param x defines the x coordinate of the operand
  67910. * @param y defines the y coordinate of the operand
  67911. * @param z defines the z coordinate of the operand
  67912. * @returns the current updated Vector3
  67913. */
  67914. set(x: number, y: number, z: number): Vector3;
  67915. /**
  67916. * Copies the given float to the current Vector3 coordinates
  67917. * @param v defines the x, y and z coordinates of the operand
  67918. * @returns the current updated Vector3
  67919. */
  67920. setAll(v: number): Vector3;
  67921. /**
  67922. * Get the clip factor between two vectors
  67923. * @param vector0 defines the first operand
  67924. * @param vector1 defines the second operand
  67925. * @param axis defines the axis to use
  67926. * @param size defines the size along the axis
  67927. * @returns the clip factor
  67928. */
  67929. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67930. /**
  67931. * Get angle between two vectors
  67932. * @param vector0 angle between vector0 and vector1
  67933. * @param vector1 angle between vector0 and vector1
  67934. * @param normal direction of the normal
  67935. * @return the angle between vector0 and vector1
  67936. */
  67937. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67938. /**
  67939. * Returns a new Vector3 set from the index "offset" of the given array
  67940. * @param array defines the source array
  67941. * @param offset defines the offset in the source array
  67942. * @returns the new Vector3
  67943. */
  67944. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67945. /**
  67946. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67947. * This function is deprecated. Use FromArray instead
  67948. * @param array defines the source array
  67949. * @param offset defines the offset in the source array
  67950. * @returns the new Vector3
  67951. */
  67952. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67953. /**
  67954. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67955. * @param array defines the source array
  67956. * @param offset defines the offset in the source array
  67957. * @param result defines the Vector3 where to store the result
  67958. */
  67959. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67960. /**
  67961. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67962. * This function is deprecated. Use FromArrayToRef instead.
  67963. * @param array defines the source array
  67964. * @param offset defines the offset in the source array
  67965. * @param result defines the Vector3 where to store the result
  67966. */
  67967. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67968. /**
  67969. * Sets the given vector "result" with the given floats.
  67970. * @param x defines the x coordinate of the source
  67971. * @param y defines the y coordinate of the source
  67972. * @param z defines the z coordinate of the source
  67973. * @param result defines the Vector3 where to store the result
  67974. */
  67975. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67976. /**
  67977. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67978. * @returns a new empty Vector3
  67979. */
  67980. static Zero(): Vector3;
  67981. /**
  67982. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67983. * @returns a new unit Vector3
  67984. */
  67985. static One(): Vector3;
  67986. /**
  67987. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67988. * @returns a new up Vector3
  67989. */
  67990. static Up(): Vector3;
  67991. /**
  67992. * Gets a up Vector3 that must not be updated
  67993. */
  67994. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67995. /**
  67996. * Gets a zero Vector3 that must not be updated
  67997. */
  67998. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67999. /**
  68000. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68001. * @returns a new down Vector3
  68002. */
  68003. static Down(): Vector3;
  68004. /**
  68005. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68006. * @returns a new forward Vector3
  68007. */
  68008. static Forward(): Vector3;
  68009. /**
  68010. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68011. * @returns a new forward Vector3
  68012. */
  68013. static Backward(): Vector3;
  68014. /**
  68015. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68016. * @returns a new right Vector3
  68017. */
  68018. static Right(): Vector3;
  68019. /**
  68020. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68021. * @returns a new left Vector3
  68022. */
  68023. static Left(): Vector3;
  68024. /**
  68025. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68026. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68027. * @param vector defines the Vector3 to transform
  68028. * @param transformation defines the transformation matrix
  68029. * @returns the transformed Vector3
  68030. */
  68031. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68032. /**
  68033. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68034. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68035. * @param vector defines the Vector3 to transform
  68036. * @param transformation defines the transformation matrix
  68037. * @param result defines the Vector3 where to store the result
  68038. */
  68039. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68040. /**
  68041. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68042. * This method computes tranformed coordinates only, not transformed direction vectors
  68043. * @param x define the x coordinate of the source vector
  68044. * @param y define the y coordinate of the source vector
  68045. * @param z define the z coordinate of the source vector
  68046. * @param transformation defines the transformation matrix
  68047. * @param result defines the Vector3 where to store the result
  68048. */
  68049. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68050. /**
  68051. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68052. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68053. * @param vector defines the Vector3 to transform
  68054. * @param transformation defines the transformation matrix
  68055. * @returns the new Vector3
  68056. */
  68057. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68058. /**
  68059. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68060. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68061. * @param vector defines the Vector3 to transform
  68062. * @param transformation defines the transformation matrix
  68063. * @param result defines the Vector3 where to store the result
  68064. */
  68065. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68066. /**
  68067. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68068. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68069. * @param x define the x coordinate of the source vector
  68070. * @param y define the y coordinate of the source vector
  68071. * @param z define the z coordinate of the source vector
  68072. * @param transformation defines the transformation matrix
  68073. * @param result defines the Vector3 where to store the result
  68074. */
  68075. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68076. /**
  68077. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68078. * @param value1 defines the first control point
  68079. * @param value2 defines the second control point
  68080. * @param value3 defines the third control point
  68081. * @param value4 defines the fourth control point
  68082. * @param amount defines the amount on the spline to use
  68083. * @returns the new Vector3
  68084. */
  68085. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68086. /**
  68087. * 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"
  68088. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68089. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68090. * @param value defines the current value
  68091. * @param min defines the lower range value
  68092. * @param max defines the upper range value
  68093. * @returns the new Vector3
  68094. */
  68095. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68096. /**
  68097. * 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"
  68098. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68099. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68100. * @param value defines the current value
  68101. * @param min defines the lower range value
  68102. * @param max defines the upper range value
  68103. * @param result defines the Vector3 where to store the result
  68104. */
  68105. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68106. /**
  68107. * Checks if a given vector is inside a specific range
  68108. * @param v defines the vector to test
  68109. * @param min defines the minimum range
  68110. * @param max defines the maximum range
  68111. */
  68112. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68113. /**
  68114. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68115. * @param value1 defines the first control point
  68116. * @param tangent1 defines the first tangent vector
  68117. * @param value2 defines the second control point
  68118. * @param tangent2 defines the second tangent vector
  68119. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68120. * @returns the new Vector3
  68121. */
  68122. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68123. /**
  68124. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68125. * @param start defines the start value
  68126. * @param end defines the end value
  68127. * @param amount max defines amount between both (between 0 and 1)
  68128. * @returns the new Vector3
  68129. */
  68130. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68131. /**
  68132. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68133. * @param start defines the start value
  68134. * @param end defines the end value
  68135. * @param amount max defines amount between both (between 0 and 1)
  68136. * @param result defines the Vector3 where to store the result
  68137. */
  68138. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68139. /**
  68140. * Returns the dot product (float) between the vectors "left" and "right"
  68141. * @param left defines the left operand
  68142. * @param right defines the right operand
  68143. * @returns the dot product
  68144. */
  68145. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68146. /**
  68147. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68148. * The cross product is then orthogonal to both "left" and "right"
  68149. * @param left defines the left operand
  68150. * @param right defines the right operand
  68151. * @returns the cross product
  68152. */
  68153. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68154. /**
  68155. * Sets the given vector "result" with the cross product of "left" and "right"
  68156. * The cross product is then orthogonal to both "left" and "right"
  68157. * @param left defines the left operand
  68158. * @param right defines the right operand
  68159. * @param result defines the Vector3 where to store the result
  68160. */
  68161. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68162. /**
  68163. * Returns a new Vector3 as the normalization of the given vector
  68164. * @param vector defines the Vector3 to normalize
  68165. * @returns the new Vector3
  68166. */
  68167. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68168. /**
  68169. * Sets the given vector "result" with the normalization of the given first vector
  68170. * @param vector defines the Vector3 to normalize
  68171. * @param result defines the Vector3 where to store the result
  68172. */
  68173. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68174. /**
  68175. * Project a Vector3 onto screen space
  68176. * @param vector defines the Vector3 to project
  68177. * @param world defines the world matrix to use
  68178. * @param transform defines the transform (view x projection) matrix to use
  68179. * @param viewport defines the screen viewport to use
  68180. * @returns the new Vector3
  68181. */
  68182. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68183. /** @hidden */
  68184. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68185. /**
  68186. * Unproject from screen space to object space
  68187. * @param source defines the screen space Vector3 to use
  68188. * @param viewportWidth defines the current width of the viewport
  68189. * @param viewportHeight defines the current height of the viewport
  68190. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68191. * @param transform defines the transform (view x projection) matrix to use
  68192. * @returns the new Vector3
  68193. */
  68194. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68195. /**
  68196. * Unproject from screen space to object space
  68197. * @param source defines the screen space Vector3 to use
  68198. * @param viewportWidth defines the current width of the viewport
  68199. * @param viewportHeight defines the current height of the viewport
  68200. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68201. * @param view defines the view matrix to use
  68202. * @param projection defines the projection matrix to use
  68203. * @returns the new Vector3
  68204. */
  68205. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68206. /**
  68207. * Unproject from screen space to object space
  68208. * @param source defines the screen space Vector3 to use
  68209. * @param viewportWidth defines the current width of the viewport
  68210. * @param viewportHeight defines the current height of the viewport
  68211. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68212. * @param view defines the view matrix to use
  68213. * @param projection defines the projection matrix to use
  68214. * @param result defines the Vector3 where to store the result
  68215. */
  68216. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68217. /**
  68218. * Unproject from screen space to object space
  68219. * @param sourceX defines the screen space x coordinate to use
  68220. * @param sourceY defines the screen space y coordinate to use
  68221. * @param sourceZ defines the screen space z coordinate to use
  68222. * @param viewportWidth defines the current width of the viewport
  68223. * @param viewportHeight defines the current height of the viewport
  68224. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68225. * @param view defines the view matrix to use
  68226. * @param projection defines the projection matrix to use
  68227. * @param result defines the Vector3 where to store the result
  68228. */
  68229. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68230. /**
  68231. * Gets the minimal coordinate values between two Vector3
  68232. * @param left defines the first operand
  68233. * @param right defines the second operand
  68234. * @returns the new Vector3
  68235. */
  68236. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68237. /**
  68238. * Gets the maximal coordinate values between two Vector3
  68239. * @param left defines the first operand
  68240. * @param right defines the second operand
  68241. * @returns the new Vector3
  68242. */
  68243. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68244. /**
  68245. * Returns the distance between the vectors "value1" and "value2"
  68246. * @param value1 defines the first operand
  68247. * @param value2 defines the second operand
  68248. * @returns the distance
  68249. */
  68250. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68251. /**
  68252. * Returns the squared distance between the vectors "value1" and "value2"
  68253. * @param value1 defines the first operand
  68254. * @param value2 defines the second operand
  68255. * @returns the squared distance
  68256. */
  68257. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68258. /**
  68259. * Returns a new Vector3 located at the center between "value1" and "value2"
  68260. * @param value1 defines the first operand
  68261. * @param value2 defines the second operand
  68262. * @returns the new Vector3
  68263. */
  68264. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68265. /**
  68266. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68267. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68268. * to something in order to rotate it from its local system to the given target system
  68269. * Note: axis1, axis2 and axis3 are normalized during this operation
  68270. * @param axis1 defines the first axis
  68271. * @param axis2 defines the second axis
  68272. * @param axis3 defines the third axis
  68273. * @returns a new Vector3
  68274. */
  68275. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68276. /**
  68277. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68278. * @param axis1 defines the first axis
  68279. * @param axis2 defines the second axis
  68280. * @param axis3 defines the third axis
  68281. * @param ref defines the Vector3 where to store the result
  68282. */
  68283. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68284. }
  68285. /**
  68286. * Vector4 class created for EulerAngle class conversion to Quaternion
  68287. */
  68288. export class Vector4 {
  68289. /** x value of the vector */
  68290. x: number;
  68291. /** y value of the vector */
  68292. y: number;
  68293. /** z value of the vector */
  68294. z: number;
  68295. /** w value of the vector */
  68296. w: number;
  68297. /**
  68298. * Creates a Vector4 object from the given floats.
  68299. * @param x x value of the vector
  68300. * @param y y value of the vector
  68301. * @param z z value of the vector
  68302. * @param w w value of the vector
  68303. */
  68304. constructor(
  68305. /** x value of the vector */
  68306. x: number,
  68307. /** y value of the vector */
  68308. y: number,
  68309. /** z value of the vector */
  68310. z: number,
  68311. /** w value of the vector */
  68312. w: number);
  68313. /**
  68314. * Returns the string with the Vector4 coordinates.
  68315. * @returns a string containing all the vector values
  68316. */
  68317. toString(): string;
  68318. /**
  68319. * Returns the string "Vector4".
  68320. * @returns "Vector4"
  68321. */
  68322. getClassName(): string;
  68323. /**
  68324. * Returns the Vector4 hash code.
  68325. * @returns a unique hash code
  68326. */
  68327. getHashCode(): number;
  68328. /**
  68329. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68330. * @returns the resulting array
  68331. */
  68332. asArray(): number[];
  68333. /**
  68334. * Populates the given array from the given index with the Vector4 coordinates.
  68335. * @param array array to populate
  68336. * @param index index of the array to start at (default: 0)
  68337. * @returns the Vector4.
  68338. */
  68339. toArray(array: FloatArray, index?: number): Vector4;
  68340. /**
  68341. * Adds the given vector to the current Vector4.
  68342. * @param otherVector the vector to add
  68343. * @returns the updated Vector4.
  68344. */
  68345. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68346. /**
  68347. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68348. * @param otherVector the vector to add
  68349. * @returns the resulting vector
  68350. */
  68351. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68352. /**
  68353. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68354. * @param otherVector the vector to add
  68355. * @param result the vector to store the result
  68356. * @returns the current Vector4.
  68357. */
  68358. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68359. /**
  68360. * Subtract in place the given vector from the current Vector4.
  68361. * @param otherVector the vector to subtract
  68362. * @returns the updated Vector4.
  68363. */
  68364. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68365. /**
  68366. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68367. * @param otherVector the vector to add
  68368. * @returns the new vector with the result
  68369. */
  68370. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68371. /**
  68372. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68373. * @param otherVector the vector to subtract
  68374. * @param result the vector to store the result
  68375. * @returns the current Vector4.
  68376. */
  68377. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68378. /**
  68379. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68380. */
  68381. /**
  68382. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68383. * @param x value to subtract
  68384. * @param y value to subtract
  68385. * @param z value to subtract
  68386. * @param w value to subtract
  68387. * @returns new vector containing the result
  68388. */
  68389. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68390. /**
  68391. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68392. * @param x value to subtract
  68393. * @param y value to subtract
  68394. * @param z value to subtract
  68395. * @param w value to subtract
  68396. * @param result the vector to store the result in
  68397. * @returns the current Vector4.
  68398. */
  68399. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68400. /**
  68401. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68402. * @returns a new vector with the negated values
  68403. */
  68404. negate(): Vector4;
  68405. /**
  68406. * Multiplies the current Vector4 coordinates by scale (float).
  68407. * @param scale the number to scale with
  68408. * @returns the updated Vector4.
  68409. */
  68410. scaleInPlace(scale: number): Vector4;
  68411. /**
  68412. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68413. * @param scale the number to scale with
  68414. * @returns a new vector with the result
  68415. */
  68416. scale(scale: number): Vector4;
  68417. /**
  68418. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68419. * @param scale the number to scale with
  68420. * @param result a vector to store the result in
  68421. * @returns the current Vector4.
  68422. */
  68423. scaleToRef(scale: number, result: Vector4): Vector4;
  68424. /**
  68425. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68426. * @param scale defines the scale factor
  68427. * @param result defines the Vector4 object where to store the result
  68428. * @returns the unmodified current Vector4
  68429. */
  68430. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68431. /**
  68432. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68433. * @param otherVector the vector to compare against
  68434. * @returns true if they are equal
  68435. */
  68436. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68437. /**
  68438. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68439. * @param otherVector vector to compare against
  68440. * @param epsilon (Default: very small number)
  68441. * @returns true if they are equal
  68442. */
  68443. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68444. /**
  68445. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68446. * @param x x value to compare against
  68447. * @param y y value to compare against
  68448. * @param z z value to compare against
  68449. * @param w w value to compare against
  68450. * @returns true if equal
  68451. */
  68452. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68453. /**
  68454. * Multiplies in place the current Vector4 by the given one.
  68455. * @param otherVector vector to multiple with
  68456. * @returns the updated Vector4.
  68457. */
  68458. multiplyInPlace(otherVector: Vector4): Vector4;
  68459. /**
  68460. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68461. * @param otherVector vector to multiple with
  68462. * @returns resulting new vector
  68463. */
  68464. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68465. /**
  68466. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68467. * @param otherVector vector to multiple with
  68468. * @param result vector to store the result
  68469. * @returns the current Vector4.
  68470. */
  68471. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68472. /**
  68473. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68474. * @param x x value multiply with
  68475. * @param y y value multiply with
  68476. * @param z z value multiply with
  68477. * @param w w value multiply with
  68478. * @returns resulting new vector
  68479. */
  68480. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68481. /**
  68482. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68483. * @param otherVector vector to devide with
  68484. * @returns resulting new vector
  68485. */
  68486. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68487. /**
  68488. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68489. * @param otherVector vector to devide with
  68490. * @param result vector to store the result
  68491. * @returns the current Vector4.
  68492. */
  68493. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68494. /**
  68495. * Divides the current Vector3 coordinates by the given ones.
  68496. * @param otherVector vector to devide with
  68497. * @returns the updated Vector3.
  68498. */
  68499. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68500. /**
  68501. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68502. * @param other defines the second operand
  68503. * @returns the current updated Vector4
  68504. */
  68505. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68506. /**
  68507. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68508. * @param other defines the second operand
  68509. * @returns the current updated Vector4
  68510. */
  68511. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68512. /**
  68513. * Gets a new Vector4 from current Vector4 floored values
  68514. * @returns a new Vector4
  68515. */
  68516. floor(): Vector4;
  68517. /**
  68518. * Gets a new Vector4 from current Vector3 floored values
  68519. * @returns a new Vector4
  68520. */
  68521. fract(): Vector4;
  68522. /**
  68523. * Returns the Vector4 length (float).
  68524. * @returns the length
  68525. */
  68526. length(): number;
  68527. /**
  68528. * Returns the Vector4 squared length (float).
  68529. * @returns the length squared
  68530. */
  68531. lengthSquared(): number;
  68532. /**
  68533. * Normalizes in place the Vector4.
  68534. * @returns the updated Vector4.
  68535. */
  68536. normalize(): Vector4;
  68537. /**
  68538. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68539. * @returns this converted to a new vector3
  68540. */
  68541. toVector3(): Vector3;
  68542. /**
  68543. * Returns a new Vector4 copied from the current one.
  68544. * @returns the new cloned vector
  68545. */
  68546. clone(): Vector4;
  68547. /**
  68548. * Updates the current Vector4 with the given one coordinates.
  68549. * @param source the source vector to copy from
  68550. * @returns the updated Vector4.
  68551. */
  68552. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68553. /**
  68554. * Updates the current Vector4 coordinates with the given floats.
  68555. * @param x float to copy from
  68556. * @param y float to copy from
  68557. * @param z float to copy from
  68558. * @param w float to copy from
  68559. * @returns the updated Vector4.
  68560. */
  68561. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68562. /**
  68563. * Updates the current Vector4 coordinates with the given floats.
  68564. * @param x float to set from
  68565. * @param y float to set from
  68566. * @param z float to set from
  68567. * @param w float to set from
  68568. * @returns the updated Vector4.
  68569. */
  68570. set(x: number, y: number, z: number, w: number): Vector4;
  68571. /**
  68572. * Copies the given float to the current Vector3 coordinates
  68573. * @param v defines the x, y, z and w coordinates of the operand
  68574. * @returns the current updated Vector3
  68575. */
  68576. setAll(v: number): Vector4;
  68577. /**
  68578. * Returns a new Vector4 set from the starting index of the given array.
  68579. * @param array the array to pull values from
  68580. * @param offset the offset into the array to start at
  68581. * @returns the new vector
  68582. */
  68583. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68584. /**
  68585. * Updates the given vector "result" from the starting index of the given array.
  68586. * @param array the array to pull values from
  68587. * @param offset the offset into the array to start at
  68588. * @param result the vector to store the result in
  68589. */
  68590. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68591. /**
  68592. * Updates the given vector "result" from the starting index of the given Float32Array.
  68593. * @param array the array to pull values from
  68594. * @param offset the offset into the array to start at
  68595. * @param result the vector to store the result in
  68596. */
  68597. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68598. /**
  68599. * Updates the given vector "result" coordinates from the given floats.
  68600. * @param x float to set from
  68601. * @param y float to set from
  68602. * @param z float to set from
  68603. * @param w float to set from
  68604. * @param result the vector to the floats in
  68605. */
  68606. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68607. /**
  68608. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68609. * @returns the new vector
  68610. */
  68611. static Zero(): Vector4;
  68612. /**
  68613. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68614. * @returns the new vector
  68615. */
  68616. static One(): Vector4;
  68617. /**
  68618. * Returns a new normalized Vector4 from the given one.
  68619. * @param vector the vector to normalize
  68620. * @returns the vector
  68621. */
  68622. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68623. /**
  68624. * Updates the given vector "result" from the normalization of the given one.
  68625. * @param vector the vector to normalize
  68626. * @param result the vector to store the result in
  68627. */
  68628. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68629. /**
  68630. * Returns a vector with the minimum values from the left and right vectors
  68631. * @param left left vector to minimize
  68632. * @param right right vector to minimize
  68633. * @returns a new vector with the minimum of the left and right vector values
  68634. */
  68635. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68636. /**
  68637. * Returns a vector with the maximum values from the left and right vectors
  68638. * @param left left vector to maximize
  68639. * @param right right vector to maximize
  68640. * @returns a new vector with the maximum of the left and right vector values
  68641. */
  68642. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68643. /**
  68644. * Returns the distance (float) between the vectors "value1" and "value2".
  68645. * @param value1 value to calulate the distance between
  68646. * @param value2 value to calulate the distance between
  68647. * @return the distance between the two vectors
  68648. */
  68649. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68650. /**
  68651. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68652. * @param value1 value to calulate the distance between
  68653. * @param value2 value to calulate the distance between
  68654. * @return the distance between the two vectors squared
  68655. */
  68656. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68657. /**
  68658. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68659. * @param value1 value to calulate the center between
  68660. * @param value2 value to calulate the center between
  68661. * @return the center between the two vectors
  68662. */
  68663. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68664. /**
  68665. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68666. * This methods computes transformed normalized direction vectors only.
  68667. * @param vector the vector to transform
  68668. * @param transformation the transformation matrix to apply
  68669. * @returns the new vector
  68670. */
  68671. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68672. /**
  68673. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68674. * This methods computes transformed normalized direction vectors only.
  68675. * @param vector the vector to transform
  68676. * @param transformation the transformation matrix to apply
  68677. * @param result the vector to store the result in
  68678. */
  68679. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68680. /**
  68681. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68682. * This methods computes transformed normalized direction vectors only.
  68683. * @param x value to transform
  68684. * @param y value to transform
  68685. * @param z value to transform
  68686. * @param w value to transform
  68687. * @param transformation the transformation matrix to apply
  68688. * @param result the vector to store the results in
  68689. */
  68690. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68691. /**
  68692. * Creates a new Vector4 from a Vector3
  68693. * @param source defines the source data
  68694. * @param w defines the 4th component (default is 0)
  68695. * @returns a new Vector4
  68696. */
  68697. static FromVector3(source: Vector3, w?: number): Vector4;
  68698. }
  68699. /**
  68700. * Class used to store quaternion data
  68701. * @see https://en.wikipedia.org/wiki/Quaternion
  68702. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68703. */
  68704. export class Quaternion {
  68705. /** defines the first component (0 by default) */
  68706. x: number;
  68707. /** defines the second component (0 by default) */
  68708. y: number;
  68709. /** defines the third component (0 by default) */
  68710. z: number;
  68711. /** defines the fourth component (1.0 by default) */
  68712. w: number;
  68713. /**
  68714. * Creates a new Quaternion from the given floats
  68715. * @param x defines the first component (0 by default)
  68716. * @param y defines the second component (0 by default)
  68717. * @param z defines the third component (0 by default)
  68718. * @param w defines the fourth component (1.0 by default)
  68719. */
  68720. constructor(
  68721. /** defines the first component (0 by default) */
  68722. x?: number,
  68723. /** defines the second component (0 by default) */
  68724. y?: number,
  68725. /** defines the third component (0 by default) */
  68726. z?: number,
  68727. /** defines the fourth component (1.0 by default) */
  68728. w?: number);
  68729. /**
  68730. * Gets a string representation for the current quaternion
  68731. * @returns a string with the Quaternion coordinates
  68732. */
  68733. toString(): string;
  68734. /**
  68735. * Gets the class name of the quaternion
  68736. * @returns the string "Quaternion"
  68737. */
  68738. getClassName(): string;
  68739. /**
  68740. * Gets a hash code for this quaternion
  68741. * @returns the quaternion hash code
  68742. */
  68743. getHashCode(): number;
  68744. /**
  68745. * Copy the quaternion to an array
  68746. * @returns a new array populated with 4 elements from the quaternion coordinates
  68747. */
  68748. asArray(): number[];
  68749. /**
  68750. * Check if two quaternions are equals
  68751. * @param otherQuaternion defines the second operand
  68752. * @return true if the current quaternion and the given one coordinates are strictly equals
  68753. */
  68754. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68755. /**
  68756. * Clone the current quaternion
  68757. * @returns a new quaternion copied from the current one
  68758. */
  68759. clone(): Quaternion;
  68760. /**
  68761. * Copy a quaternion to the current one
  68762. * @param other defines the other quaternion
  68763. * @returns the updated current quaternion
  68764. */
  68765. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68766. /**
  68767. * Updates the current quaternion with the given float coordinates
  68768. * @param x defines the x coordinate
  68769. * @param y defines the y coordinate
  68770. * @param z defines the z coordinate
  68771. * @param w defines the w coordinate
  68772. * @returns the updated current quaternion
  68773. */
  68774. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68775. /**
  68776. * Updates the current quaternion from the given float coordinates
  68777. * @param x defines the x coordinate
  68778. * @param y defines the y coordinate
  68779. * @param z defines the z coordinate
  68780. * @param w defines the w coordinate
  68781. * @returns the updated current quaternion
  68782. */
  68783. set(x: number, y: number, z: number, w: number): Quaternion;
  68784. /**
  68785. * Adds two quaternions
  68786. * @param other defines the second operand
  68787. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68788. */
  68789. add(other: DeepImmutable<Quaternion>): Quaternion;
  68790. /**
  68791. * Add a quaternion to the current one
  68792. * @param other defines the quaternion to add
  68793. * @returns the current quaternion
  68794. */
  68795. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68796. /**
  68797. * Subtract two quaternions
  68798. * @param other defines the second operand
  68799. * @returns a new quaternion as the subtraction result of the given one from the current one
  68800. */
  68801. subtract(other: Quaternion): Quaternion;
  68802. /**
  68803. * Multiplies the current quaternion by a scale factor
  68804. * @param value defines the scale factor
  68805. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68806. */
  68807. scale(value: number): Quaternion;
  68808. /**
  68809. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68810. * @param scale defines the scale factor
  68811. * @param result defines the Quaternion object where to store the result
  68812. * @returns the unmodified current quaternion
  68813. */
  68814. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68815. /**
  68816. * Multiplies in place the current quaternion by a scale factor
  68817. * @param value defines the scale factor
  68818. * @returns the current modified quaternion
  68819. */
  68820. scaleInPlace(value: number): Quaternion;
  68821. /**
  68822. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68823. * @param scale defines the scale factor
  68824. * @param result defines the Quaternion object where to store the result
  68825. * @returns the unmodified current quaternion
  68826. */
  68827. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68828. /**
  68829. * Multiplies two quaternions
  68830. * @param q1 defines the second operand
  68831. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68832. */
  68833. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68834. /**
  68835. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68836. * @param q1 defines the second operand
  68837. * @param result defines the target quaternion
  68838. * @returns the current quaternion
  68839. */
  68840. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68841. /**
  68842. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68843. * @param q1 defines the second operand
  68844. * @returns the currentupdated quaternion
  68845. */
  68846. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68847. /**
  68848. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68849. * @param ref defines the target quaternion
  68850. * @returns the current quaternion
  68851. */
  68852. conjugateToRef(ref: Quaternion): Quaternion;
  68853. /**
  68854. * Conjugates in place (1-q) the current quaternion
  68855. * @returns the current updated quaternion
  68856. */
  68857. conjugateInPlace(): Quaternion;
  68858. /**
  68859. * Conjugates in place (1-q) the current quaternion
  68860. * @returns a new quaternion
  68861. */
  68862. conjugate(): Quaternion;
  68863. /**
  68864. * Gets length of current quaternion
  68865. * @returns the quaternion length (float)
  68866. */
  68867. length(): number;
  68868. /**
  68869. * Normalize in place the current quaternion
  68870. * @returns the current updated quaternion
  68871. */
  68872. normalize(): Quaternion;
  68873. /**
  68874. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68875. * @param order is a reserved parameter and is ignore for now
  68876. * @returns a new Vector3 containing the Euler angles
  68877. */
  68878. toEulerAngles(order?: string): Vector3;
  68879. /**
  68880. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68881. * @param result defines the vector which will be filled with the Euler angles
  68882. * @param order is a reserved parameter and is ignore for now
  68883. * @returns the current unchanged quaternion
  68884. */
  68885. toEulerAnglesToRef(result: Vector3): Quaternion;
  68886. /**
  68887. * Updates the given rotation matrix with the current quaternion values
  68888. * @param result defines the target matrix
  68889. * @returns the current unchanged quaternion
  68890. */
  68891. toRotationMatrix(result: Matrix): Quaternion;
  68892. /**
  68893. * Updates the current quaternion from the given rotation matrix values
  68894. * @param matrix defines the source matrix
  68895. * @returns the current updated quaternion
  68896. */
  68897. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68898. /**
  68899. * Creates a new quaternion from a rotation matrix
  68900. * @param matrix defines the source matrix
  68901. * @returns a new quaternion created from the given rotation matrix values
  68902. */
  68903. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68904. /**
  68905. * Updates the given quaternion with the given rotation matrix values
  68906. * @param matrix defines the source matrix
  68907. * @param result defines the target quaternion
  68908. */
  68909. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68910. /**
  68911. * Returns the dot product (float) between the quaternions "left" and "right"
  68912. * @param left defines the left operand
  68913. * @param right defines the right operand
  68914. * @returns the dot product
  68915. */
  68916. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68917. /**
  68918. * Checks if the two quaternions are close to each other
  68919. * @param quat0 defines the first quaternion to check
  68920. * @param quat1 defines the second quaternion to check
  68921. * @returns true if the two quaternions are close to each other
  68922. */
  68923. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68924. /**
  68925. * Creates an empty quaternion
  68926. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68927. */
  68928. static Zero(): Quaternion;
  68929. /**
  68930. * Inverse a given quaternion
  68931. * @param q defines the source quaternion
  68932. * @returns a new quaternion as the inverted current quaternion
  68933. */
  68934. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68935. /**
  68936. * Inverse a given quaternion
  68937. * @param q defines the source quaternion
  68938. * @param result the quaternion the result will be stored in
  68939. * @returns the result quaternion
  68940. */
  68941. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68942. /**
  68943. * Creates an identity quaternion
  68944. * @returns the identity quaternion
  68945. */
  68946. static Identity(): Quaternion;
  68947. /**
  68948. * Gets a boolean indicating if the given quaternion is identity
  68949. * @param quaternion defines the quaternion to check
  68950. * @returns true if the quaternion is identity
  68951. */
  68952. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68953. /**
  68954. * Creates a quaternion from a rotation around an axis
  68955. * @param axis defines the axis to use
  68956. * @param angle defines the angle to use
  68957. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68958. */
  68959. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68960. /**
  68961. * Creates a rotation around an axis and stores it into the given quaternion
  68962. * @param axis defines the axis to use
  68963. * @param angle defines the angle to use
  68964. * @param result defines the target quaternion
  68965. * @returns the target quaternion
  68966. */
  68967. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68968. /**
  68969. * Creates a new quaternion from data stored into an array
  68970. * @param array defines the data source
  68971. * @param offset defines the offset in the source array where the data starts
  68972. * @returns a new quaternion
  68973. */
  68974. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68975. /**
  68976. * Create a quaternion from Euler rotation angles
  68977. * @param x Pitch
  68978. * @param y Yaw
  68979. * @param z Roll
  68980. * @returns the new Quaternion
  68981. */
  68982. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68983. /**
  68984. * Updates a quaternion from Euler rotation angles
  68985. * @param x Pitch
  68986. * @param y Yaw
  68987. * @param z Roll
  68988. * @param result the quaternion to store the result
  68989. * @returns the updated quaternion
  68990. */
  68991. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68992. /**
  68993. * Create a quaternion from Euler rotation vector
  68994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68995. * @returns the new Quaternion
  68996. */
  68997. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68998. /**
  68999. * Updates a quaternion from Euler rotation vector
  69000. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69001. * @param result the quaternion to store the result
  69002. * @returns the updated quaternion
  69003. */
  69004. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69005. /**
  69006. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69007. * @param yaw defines the rotation around Y axis
  69008. * @param pitch defines the rotation around X axis
  69009. * @param roll defines the rotation around Z axis
  69010. * @returns the new quaternion
  69011. */
  69012. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69013. /**
  69014. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69015. * @param yaw defines the rotation around Y axis
  69016. * @param pitch defines the rotation around X axis
  69017. * @param roll defines the rotation around Z axis
  69018. * @param result defines the target quaternion
  69019. */
  69020. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69021. /**
  69022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69023. * @param alpha defines the rotation around first axis
  69024. * @param beta defines the rotation around second axis
  69025. * @param gamma defines the rotation around third axis
  69026. * @returns the new quaternion
  69027. */
  69028. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69029. /**
  69030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69031. * @param alpha defines the rotation around first axis
  69032. * @param beta defines the rotation around second axis
  69033. * @param gamma defines the rotation around third axis
  69034. * @param result defines the target quaternion
  69035. */
  69036. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69037. /**
  69038. * 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)
  69039. * @param axis1 defines the first axis
  69040. * @param axis2 defines the second axis
  69041. * @param axis3 defines the third axis
  69042. * @returns the new quaternion
  69043. */
  69044. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69045. /**
  69046. * 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
  69047. * @param axis1 defines the first axis
  69048. * @param axis2 defines the second axis
  69049. * @param axis3 defines the third axis
  69050. * @param ref defines the target quaternion
  69051. */
  69052. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69053. /**
  69054. * Interpolates between two quaternions
  69055. * @param left defines first quaternion
  69056. * @param right defines second quaternion
  69057. * @param amount defines the gradient to use
  69058. * @returns the new interpolated quaternion
  69059. */
  69060. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69061. /**
  69062. * Interpolates between two quaternions and stores it into a target quaternion
  69063. * @param left defines first quaternion
  69064. * @param right defines second quaternion
  69065. * @param amount defines the gradient to use
  69066. * @param result defines the target quaternion
  69067. */
  69068. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69069. /**
  69070. * Interpolate between two quaternions using Hermite interpolation
  69071. * @param value1 defines first quaternion
  69072. * @param tangent1 defines the incoming tangent
  69073. * @param value2 defines second quaternion
  69074. * @param tangent2 defines the outgoing tangent
  69075. * @param amount defines the target quaternion
  69076. * @returns the new interpolated quaternion
  69077. */
  69078. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69079. }
  69080. /**
  69081. * Class used to store matrix data (4x4)
  69082. */
  69083. export class Matrix {
  69084. private static _updateFlagSeed;
  69085. private static _identityReadOnly;
  69086. private _isIdentity;
  69087. private _isIdentityDirty;
  69088. private _isIdentity3x2;
  69089. private _isIdentity3x2Dirty;
  69090. /**
  69091. * Gets the update flag of the matrix which is an unique number for the matrix.
  69092. * It will be incremented every time the matrix data change.
  69093. * You can use it to speed the comparison between two versions of the same matrix.
  69094. */
  69095. updateFlag: number;
  69096. private readonly _m;
  69097. /**
  69098. * Gets the internal data of the matrix
  69099. */
  69100. readonly m: DeepImmutable<Float32Array>;
  69101. /** @hidden */
  69102. _markAsUpdated(): void;
  69103. /** @hidden */
  69104. private _updateIdentityStatus;
  69105. /**
  69106. * Creates an empty matrix (filled with zeros)
  69107. */
  69108. constructor();
  69109. /**
  69110. * Check if the current matrix is identity
  69111. * @returns true is the matrix is the identity matrix
  69112. */
  69113. isIdentity(): boolean;
  69114. /**
  69115. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69116. * @returns true is the matrix is the identity matrix
  69117. */
  69118. isIdentityAs3x2(): boolean;
  69119. /**
  69120. * Gets the determinant of the matrix
  69121. * @returns the matrix determinant
  69122. */
  69123. determinant(): number;
  69124. /**
  69125. * Returns the matrix as a Float32Array
  69126. * @returns the matrix underlying array
  69127. */
  69128. toArray(): DeepImmutable<Float32Array>;
  69129. /**
  69130. * Returns the matrix as a Float32Array
  69131. * @returns the matrix underlying array.
  69132. */
  69133. asArray(): DeepImmutable<Float32Array>;
  69134. /**
  69135. * Inverts the current matrix in place
  69136. * @returns the current inverted matrix
  69137. */
  69138. invert(): Matrix;
  69139. /**
  69140. * Sets all the matrix elements to zero
  69141. * @returns the current matrix
  69142. */
  69143. reset(): Matrix;
  69144. /**
  69145. * Adds the current matrix with a second one
  69146. * @param other defines the matrix to add
  69147. * @returns a new matrix as the addition of the current matrix and the given one
  69148. */
  69149. add(other: DeepImmutable<Matrix>): Matrix;
  69150. /**
  69151. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69152. * @param other defines the matrix to add
  69153. * @param result defines the target matrix
  69154. * @returns the current matrix
  69155. */
  69156. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69157. /**
  69158. * Adds in place the given matrix to the current matrix
  69159. * @param other defines the second operand
  69160. * @returns the current updated matrix
  69161. */
  69162. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69163. /**
  69164. * Sets the given matrix to the current inverted Matrix
  69165. * @param other defines the target matrix
  69166. * @returns the unmodified current matrix
  69167. */
  69168. invertToRef(other: Matrix): Matrix;
  69169. /**
  69170. * add a value at the specified position in the current Matrix
  69171. * @param index the index of the value within the matrix. between 0 and 15.
  69172. * @param value the value to be added
  69173. * @returns the current updated matrix
  69174. */
  69175. addAtIndex(index: number, value: number): Matrix;
  69176. /**
  69177. * mutiply the specified position in the current Matrix by a value
  69178. * @param index the index of the value within the matrix. between 0 and 15.
  69179. * @param value the value to be added
  69180. * @returns the current updated matrix
  69181. */
  69182. multiplyAtIndex(index: number, value: number): Matrix;
  69183. /**
  69184. * Inserts the translation vector (using 3 floats) in the current matrix
  69185. * @param x defines the 1st component of the translation
  69186. * @param y defines the 2nd component of the translation
  69187. * @param z defines the 3rd component of the translation
  69188. * @returns the current updated matrix
  69189. */
  69190. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69191. /**
  69192. * Adds the translation vector (using 3 floats) in the current matrix
  69193. * @param x defines the 1st component of the translation
  69194. * @param y defines the 2nd component of the translation
  69195. * @param z defines the 3rd component of the translation
  69196. * @returns the current updated matrix
  69197. */
  69198. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69199. /**
  69200. * Inserts the translation vector in the current matrix
  69201. * @param vector3 defines the translation to insert
  69202. * @returns the current updated matrix
  69203. */
  69204. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69205. /**
  69206. * Gets the translation value of the current matrix
  69207. * @returns a new Vector3 as the extracted translation from the matrix
  69208. */
  69209. getTranslation(): Vector3;
  69210. /**
  69211. * Fill a Vector3 with the extracted translation from the matrix
  69212. * @param result defines the Vector3 where to store the translation
  69213. * @returns the current matrix
  69214. */
  69215. getTranslationToRef(result: Vector3): Matrix;
  69216. /**
  69217. * Remove rotation and scaling part from the matrix
  69218. * @returns the updated matrix
  69219. */
  69220. removeRotationAndScaling(): Matrix;
  69221. /**
  69222. * Multiply two matrices
  69223. * @param other defines the second operand
  69224. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69225. */
  69226. multiply(other: DeepImmutable<Matrix>): Matrix;
  69227. /**
  69228. * Copy the current matrix from the given one
  69229. * @param other defines the source matrix
  69230. * @returns the current updated matrix
  69231. */
  69232. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69233. /**
  69234. * Populates the given array from the starting index with the current matrix values
  69235. * @param array defines the target array
  69236. * @param offset defines the offset in the target array where to start storing values
  69237. * @returns the current matrix
  69238. */
  69239. copyToArray(array: Float32Array, offset?: number): Matrix;
  69240. /**
  69241. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69242. * @param other defines the second operand
  69243. * @param result defines the matrix where to store the multiplication
  69244. * @returns the current matrix
  69245. */
  69246. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69247. /**
  69248. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69249. * @param other defines the second operand
  69250. * @param result defines the array where to store the multiplication
  69251. * @param offset defines the offset in the target array where to start storing values
  69252. * @returns the current matrix
  69253. */
  69254. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69255. /**
  69256. * Check equality between this matrix and a second one
  69257. * @param value defines the second matrix to compare
  69258. * @returns true is the current matrix and the given one values are strictly equal
  69259. */
  69260. equals(value: DeepImmutable<Matrix>): boolean;
  69261. /**
  69262. * Clone the current matrix
  69263. * @returns a new matrix from the current matrix
  69264. */
  69265. clone(): Matrix;
  69266. /**
  69267. * Returns the name of the current matrix class
  69268. * @returns the string "Matrix"
  69269. */
  69270. getClassName(): string;
  69271. /**
  69272. * Gets the hash code of the current matrix
  69273. * @returns the hash code
  69274. */
  69275. getHashCode(): number;
  69276. /**
  69277. * Decomposes the current Matrix into a translation, rotation and scaling components
  69278. * @param scale defines the scale vector3 given as a reference to update
  69279. * @param rotation defines the rotation quaternion given as a reference to update
  69280. * @param translation defines the translation vector3 given as a reference to update
  69281. * @returns true if operation was successful
  69282. */
  69283. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69284. /**
  69285. * Gets specific row of the matrix
  69286. * @param index defines the number of the row to get
  69287. * @returns the index-th row of the current matrix as a new Vector4
  69288. */
  69289. getRow(index: number): Nullable<Vector4>;
  69290. /**
  69291. * Sets the index-th row of the current matrix to the vector4 values
  69292. * @param index defines the number of the row to set
  69293. * @param row defines the target vector4
  69294. * @returns the updated current matrix
  69295. */
  69296. setRow(index: number, row: Vector4): Matrix;
  69297. /**
  69298. * Compute the transpose of the matrix
  69299. * @returns the new transposed matrix
  69300. */
  69301. transpose(): Matrix;
  69302. /**
  69303. * Compute the transpose of the matrix and store it in a given matrix
  69304. * @param result defines the target matrix
  69305. * @returns the current matrix
  69306. */
  69307. transposeToRef(result: Matrix): Matrix;
  69308. /**
  69309. * Sets the index-th row of the current matrix with the given 4 x float values
  69310. * @param index defines the row index
  69311. * @param x defines the x component to set
  69312. * @param y defines the y component to set
  69313. * @param z defines the z component to set
  69314. * @param w defines the w component to set
  69315. * @returns the updated current matrix
  69316. */
  69317. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69318. /**
  69319. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69320. * @param scale defines the scale factor
  69321. * @returns a new matrix
  69322. */
  69323. scale(scale: number): Matrix;
  69324. /**
  69325. * Scale the current matrix values by a factor to a given result matrix
  69326. * @param scale defines the scale factor
  69327. * @param result defines the matrix to store the result
  69328. * @returns the current matrix
  69329. */
  69330. scaleToRef(scale: number, result: Matrix): Matrix;
  69331. /**
  69332. * Scale the current matrix values by a factor and add the result to a given matrix
  69333. * @param scale defines the scale factor
  69334. * @param result defines the Matrix to store the result
  69335. * @returns the current matrix
  69336. */
  69337. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69338. /**
  69339. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69340. * @param ref matrix to store the result
  69341. */
  69342. toNormalMatrix(ref: Matrix): void;
  69343. /**
  69344. * Gets only rotation part of the current matrix
  69345. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69346. */
  69347. getRotationMatrix(): Matrix;
  69348. /**
  69349. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69350. * @param result defines the target matrix to store data to
  69351. * @returns the current matrix
  69352. */
  69353. getRotationMatrixToRef(result: Matrix): Matrix;
  69354. /**
  69355. * Toggles model matrix from being right handed to left handed in place and vice versa
  69356. */
  69357. toggleModelMatrixHandInPlace(): void;
  69358. /**
  69359. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69360. */
  69361. toggleProjectionMatrixHandInPlace(): void;
  69362. /**
  69363. * Creates a matrix from an array
  69364. * @param array defines the source array
  69365. * @param offset defines an offset in the source array
  69366. * @returns a new Matrix set from the starting index of the given array
  69367. */
  69368. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69369. /**
  69370. * Copy the content of an array into a given matrix
  69371. * @param array defines the source array
  69372. * @param offset defines an offset in the source array
  69373. * @param result defines the target matrix
  69374. */
  69375. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69376. /**
  69377. * Stores an array into a matrix after having multiplied each component by a given factor
  69378. * @param array defines the source array
  69379. * @param offset defines the offset in the source array
  69380. * @param scale defines the scaling factor
  69381. * @param result defines the target matrix
  69382. */
  69383. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69384. /**
  69385. * Gets an identity matrix that must not be updated
  69386. */
  69387. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69388. /**
  69389. * Stores a list of values (16) inside a given matrix
  69390. * @param initialM11 defines 1st value of 1st row
  69391. * @param initialM12 defines 2nd value of 1st row
  69392. * @param initialM13 defines 3rd value of 1st row
  69393. * @param initialM14 defines 4th value of 1st row
  69394. * @param initialM21 defines 1st value of 2nd row
  69395. * @param initialM22 defines 2nd value of 2nd row
  69396. * @param initialM23 defines 3rd value of 2nd row
  69397. * @param initialM24 defines 4th value of 2nd row
  69398. * @param initialM31 defines 1st value of 3rd row
  69399. * @param initialM32 defines 2nd value of 3rd row
  69400. * @param initialM33 defines 3rd value of 3rd row
  69401. * @param initialM34 defines 4th value of 3rd row
  69402. * @param initialM41 defines 1st value of 4th row
  69403. * @param initialM42 defines 2nd value of 4th row
  69404. * @param initialM43 defines 3rd value of 4th row
  69405. * @param initialM44 defines 4th value of 4th row
  69406. * @param result defines the target matrix
  69407. */
  69408. 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;
  69409. /**
  69410. * Creates new matrix from a list of values (16)
  69411. * @param initialM11 defines 1st value of 1st row
  69412. * @param initialM12 defines 2nd value of 1st row
  69413. * @param initialM13 defines 3rd value of 1st row
  69414. * @param initialM14 defines 4th value of 1st row
  69415. * @param initialM21 defines 1st value of 2nd row
  69416. * @param initialM22 defines 2nd value of 2nd row
  69417. * @param initialM23 defines 3rd value of 2nd row
  69418. * @param initialM24 defines 4th value of 2nd row
  69419. * @param initialM31 defines 1st value of 3rd row
  69420. * @param initialM32 defines 2nd value of 3rd row
  69421. * @param initialM33 defines 3rd value of 3rd row
  69422. * @param initialM34 defines 4th value of 3rd row
  69423. * @param initialM41 defines 1st value of 4th row
  69424. * @param initialM42 defines 2nd value of 4th row
  69425. * @param initialM43 defines 3rd value of 4th row
  69426. * @param initialM44 defines 4th value of 4th row
  69427. * @returns the new matrix
  69428. */
  69429. 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;
  69430. /**
  69431. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69432. * @param scale defines the scale vector3
  69433. * @param rotation defines the rotation quaternion
  69434. * @param translation defines the translation vector3
  69435. * @returns a new matrix
  69436. */
  69437. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69438. /**
  69439. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69440. * @param scale defines the scale vector3
  69441. * @param rotation defines the rotation quaternion
  69442. * @param translation defines the translation vector3
  69443. * @param result defines the target matrix
  69444. */
  69445. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69446. /**
  69447. * Creates a new identity matrix
  69448. * @returns a new identity matrix
  69449. */
  69450. static Identity(): Matrix;
  69451. /**
  69452. * Creates a new identity matrix and stores the result in a given matrix
  69453. * @param result defines the target matrix
  69454. */
  69455. static IdentityToRef(result: Matrix): void;
  69456. /**
  69457. * Creates a new zero matrix
  69458. * @returns a new zero matrix
  69459. */
  69460. static Zero(): Matrix;
  69461. /**
  69462. * Creates a new rotation matrix for "angle" radians around the X axis
  69463. * @param angle defines the angle (in radians) to use
  69464. * @return the new matrix
  69465. */
  69466. static RotationX(angle: number): Matrix;
  69467. /**
  69468. * Creates a new matrix as the invert of a given matrix
  69469. * @param source defines the source matrix
  69470. * @returns the new matrix
  69471. */
  69472. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69473. /**
  69474. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69475. * @param angle defines the angle (in radians) to use
  69476. * @param result defines the target matrix
  69477. */
  69478. static RotationXToRef(angle: number, result: Matrix): void;
  69479. /**
  69480. * Creates a new rotation matrix for "angle" radians around the Y axis
  69481. * @param angle defines the angle (in radians) to use
  69482. * @return the new matrix
  69483. */
  69484. static RotationY(angle: number): Matrix;
  69485. /**
  69486. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69487. * @param angle defines the angle (in radians) to use
  69488. * @param result defines the target matrix
  69489. */
  69490. static RotationYToRef(angle: number, result: Matrix): void;
  69491. /**
  69492. * Creates a new rotation matrix for "angle" radians around the Z axis
  69493. * @param angle defines the angle (in radians) to use
  69494. * @return the new matrix
  69495. */
  69496. static RotationZ(angle: number): Matrix;
  69497. /**
  69498. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69499. * @param angle defines the angle (in radians) to use
  69500. * @param result defines the target matrix
  69501. */
  69502. static RotationZToRef(angle: number, result: Matrix): void;
  69503. /**
  69504. * Creates a new rotation matrix for "angle" radians around the given axis
  69505. * @param axis defines the axis to use
  69506. * @param angle defines the angle (in radians) to use
  69507. * @return the new matrix
  69508. */
  69509. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69510. /**
  69511. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69512. * @param axis defines the axis to use
  69513. * @param angle defines the angle (in radians) to use
  69514. * @param result defines the target matrix
  69515. */
  69516. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69517. /**
  69518. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69519. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69520. * @param from defines the vector to align
  69521. * @param to defines the vector to align to
  69522. * @param result defines the target matrix
  69523. */
  69524. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69525. /**
  69526. * Creates a rotation matrix
  69527. * @param yaw defines the yaw angle in radians (Y axis)
  69528. * @param pitch defines the pitch angle in radians (X axis)
  69529. * @param roll defines the roll angle in radians (X axis)
  69530. * @returns the new rotation matrix
  69531. */
  69532. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69533. /**
  69534. * Creates a rotation matrix and stores it in a given matrix
  69535. * @param yaw defines the yaw angle in radians (Y axis)
  69536. * @param pitch defines the pitch angle in radians (X axis)
  69537. * @param roll defines the roll angle in radians (X axis)
  69538. * @param result defines the target matrix
  69539. */
  69540. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69541. /**
  69542. * Creates a scaling matrix
  69543. * @param x defines the scale factor on X axis
  69544. * @param y defines the scale factor on Y axis
  69545. * @param z defines the scale factor on Z axis
  69546. * @returns the new matrix
  69547. */
  69548. static Scaling(x: number, y: number, z: number): Matrix;
  69549. /**
  69550. * Creates a scaling matrix and stores it in a given matrix
  69551. * @param x defines the scale factor on X axis
  69552. * @param y defines the scale factor on Y axis
  69553. * @param z defines the scale factor on Z axis
  69554. * @param result defines the target matrix
  69555. */
  69556. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69557. /**
  69558. * Creates a translation matrix
  69559. * @param x defines the translation on X axis
  69560. * @param y defines the translation on Y axis
  69561. * @param z defines the translationon Z axis
  69562. * @returns the new matrix
  69563. */
  69564. static Translation(x: number, y: number, z: number): Matrix;
  69565. /**
  69566. * Creates a translation matrix and stores it in a given matrix
  69567. * @param x defines the translation on X axis
  69568. * @param y defines the translation on Y axis
  69569. * @param z defines the translationon Z axis
  69570. * @param result defines the target matrix
  69571. */
  69572. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69573. /**
  69574. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69575. * @param startValue defines the start value
  69576. * @param endValue defines the end value
  69577. * @param gradient defines the gradient factor
  69578. * @returns the new matrix
  69579. */
  69580. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69581. /**
  69582. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69583. * @param startValue defines the start value
  69584. * @param endValue defines the end value
  69585. * @param gradient defines the gradient factor
  69586. * @param result defines the Matrix object where to store data
  69587. */
  69588. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69589. /**
  69590. * Builds a new matrix whose values are computed by:
  69591. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69592. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69593. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69594. * @param startValue defines the first matrix
  69595. * @param endValue defines the second matrix
  69596. * @param gradient defines the gradient between the two matrices
  69597. * @returns the new matrix
  69598. */
  69599. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69600. /**
  69601. * Update a matrix to values which are computed by:
  69602. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69603. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69604. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69605. * @param startValue defines the first matrix
  69606. * @param endValue defines the second matrix
  69607. * @param gradient defines the gradient between the two matrices
  69608. * @param result defines the target matrix
  69609. */
  69610. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69611. /**
  69612. * 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"
  69613. * This function works in left handed mode
  69614. * @param eye defines the final position of the entity
  69615. * @param target defines where the entity should look at
  69616. * @param up defines the up vector for the entity
  69617. * @returns the new matrix
  69618. */
  69619. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69620. /**
  69621. * 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".
  69622. * This function works in left handed mode
  69623. * @param eye defines the final position of the entity
  69624. * @param target defines where the entity should look at
  69625. * @param up defines the up vector for the entity
  69626. * @param result defines the target matrix
  69627. */
  69628. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69629. /**
  69630. * 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"
  69631. * This function works in right handed mode
  69632. * @param eye defines the final position of the entity
  69633. * @param target defines where the entity should look at
  69634. * @param up defines the up vector for the entity
  69635. * @returns the new matrix
  69636. */
  69637. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69638. /**
  69639. * 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".
  69640. * This function works in right handed mode
  69641. * @param eye defines the final position of the entity
  69642. * @param target defines where the entity should look at
  69643. * @param up defines the up vector for the entity
  69644. * @param result defines the target matrix
  69645. */
  69646. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69647. /**
  69648. * Create a left-handed orthographic projection matrix
  69649. * @param width defines the viewport width
  69650. * @param height defines the viewport height
  69651. * @param znear defines the near clip plane
  69652. * @param zfar defines the far clip plane
  69653. * @returns a new matrix as a left-handed orthographic projection matrix
  69654. */
  69655. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69656. /**
  69657. * Store a left-handed orthographic projection to a given matrix
  69658. * @param width defines the viewport width
  69659. * @param height defines the viewport height
  69660. * @param znear defines the near clip plane
  69661. * @param zfar defines the far clip plane
  69662. * @param result defines the target matrix
  69663. */
  69664. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69665. /**
  69666. * Create a left-handed orthographic projection matrix
  69667. * @param left defines the viewport left coordinate
  69668. * @param right defines the viewport right coordinate
  69669. * @param bottom defines the viewport bottom coordinate
  69670. * @param top defines the viewport top coordinate
  69671. * @param znear defines the near clip plane
  69672. * @param zfar defines the far clip plane
  69673. * @returns a new matrix as a left-handed orthographic projection matrix
  69674. */
  69675. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69676. /**
  69677. * Stores a left-handed orthographic projection into a given matrix
  69678. * @param left defines the viewport left coordinate
  69679. * @param right defines the viewport right coordinate
  69680. * @param bottom defines the viewport bottom coordinate
  69681. * @param top defines the viewport top coordinate
  69682. * @param znear defines the near clip plane
  69683. * @param zfar defines the far clip plane
  69684. * @param result defines the target matrix
  69685. */
  69686. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69687. /**
  69688. * Creates a right-handed orthographic projection matrix
  69689. * @param left defines the viewport left coordinate
  69690. * @param right defines the viewport right coordinate
  69691. * @param bottom defines the viewport bottom coordinate
  69692. * @param top defines the viewport top coordinate
  69693. * @param znear defines the near clip plane
  69694. * @param zfar defines the far clip plane
  69695. * @returns a new matrix as a right-handed orthographic projection matrix
  69696. */
  69697. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69698. /**
  69699. * Stores a right-handed orthographic projection into a given matrix
  69700. * @param left defines the viewport left coordinate
  69701. * @param right defines the viewport right coordinate
  69702. * @param bottom defines the viewport bottom coordinate
  69703. * @param top defines the viewport top coordinate
  69704. * @param znear defines the near clip plane
  69705. * @param zfar defines the far clip plane
  69706. * @param result defines the target matrix
  69707. */
  69708. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69709. /**
  69710. * Creates a left-handed perspective projection matrix
  69711. * @param width defines the viewport width
  69712. * @param height defines the viewport height
  69713. * @param znear defines the near clip plane
  69714. * @param zfar defines the far clip plane
  69715. * @returns a new matrix as a left-handed perspective projection matrix
  69716. */
  69717. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69718. /**
  69719. * Creates a left-handed perspective projection matrix
  69720. * @param fov defines the horizontal field of view
  69721. * @param aspect defines the aspect ratio
  69722. * @param znear defines the near clip plane
  69723. * @param zfar defines the far clip plane
  69724. * @returns a new matrix as a left-handed perspective projection matrix
  69725. */
  69726. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69727. /**
  69728. * Stores a left-handed perspective projection into a given matrix
  69729. * @param fov defines the horizontal field of view
  69730. * @param aspect defines the aspect ratio
  69731. * @param znear defines the near clip plane
  69732. * @param zfar defines the far clip plane
  69733. * @param result defines the target matrix
  69734. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69735. */
  69736. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69737. /**
  69738. * Creates a right-handed perspective projection matrix
  69739. * @param fov defines the horizontal field of view
  69740. * @param aspect defines the aspect ratio
  69741. * @param znear defines the near clip plane
  69742. * @param zfar defines the far clip plane
  69743. * @returns a new matrix as a right-handed perspective projection matrix
  69744. */
  69745. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69746. /**
  69747. * Stores a right-handed perspective projection into a given matrix
  69748. * @param fov defines the horizontal field of view
  69749. * @param aspect defines the aspect ratio
  69750. * @param znear defines the near clip plane
  69751. * @param zfar defines the far clip plane
  69752. * @param result defines the target matrix
  69753. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69754. */
  69755. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69756. /**
  69757. * Stores a perspective projection for WebVR info a given matrix
  69758. * @param fov defines the field of view
  69759. * @param znear defines the near clip plane
  69760. * @param zfar defines the far clip plane
  69761. * @param result defines the target matrix
  69762. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69763. */
  69764. static PerspectiveFovWebVRToRef(fov: {
  69765. upDegrees: number;
  69766. downDegrees: number;
  69767. leftDegrees: number;
  69768. rightDegrees: number;
  69769. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69770. /**
  69771. * Computes a complete transformation matrix
  69772. * @param viewport defines the viewport to use
  69773. * @param world defines the world matrix
  69774. * @param view defines the view matrix
  69775. * @param projection defines the projection matrix
  69776. * @param zmin defines the near clip plane
  69777. * @param zmax defines the far clip plane
  69778. * @returns the transformation matrix
  69779. */
  69780. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69781. /**
  69782. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69783. * @param matrix defines the matrix to use
  69784. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69785. */
  69786. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69787. /**
  69788. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69789. * @param matrix defines the matrix to use
  69790. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69791. */
  69792. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69793. /**
  69794. * Compute the transpose of a given matrix
  69795. * @param matrix defines the matrix to transpose
  69796. * @returns the new matrix
  69797. */
  69798. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69799. /**
  69800. * Compute the transpose of a matrix and store it in a target matrix
  69801. * @param matrix defines the matrix to transpose
  69802. * @param result defines the target matrix
  69803. */
  69804. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69805. /**
  69806. * Computes a reflection matrix from a plane
  69807. * @param plane defines the reflection plane
  69808. * @returns a new matrix
  69809. */
  69810. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69811. /**
  69812. * Computes a reflection matrix from a plane
  69813. * @param plane defines the reflection plane
  69814. * @param result defines the target matrix
  69815. */
  69816. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69817. /**
  69818. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69819. * @param xaxis defines the value of the 1st axis
  69820. * @param yaxis defines the value of the 2nd axis
  69821. * @param zaxis defines the value of the 3rd axis
  69822. * @param result defines the target matrix
  69823. */
  69824. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69825. /**
  69826. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69827. * @param quat defines the quaternion to use
  69828. * @param result defines the target matrix
  69829. */
  69830. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69831. }
  69832. /**
  69833. * @hidden
  69834. */
  69835. export class TmpVectors {
  69836. static Vector2: Vector2[];
  69837. static Vector3: Vector3[];
  69838. static Vector4: Vector4[];
  69839. static Quaternion: Quaternion[];
  69840. static Matrix: Matrix[];
  69841. }
  69842. }
  69843. declare module BABYLON {
  69844. /** Defines the cross module used constants to avoid circular dependncies */
  69845. export class Constants {
  69846. /** Defines that alpha blending is disabled */
  69847. static readonly ALPHA_DISABLE: number;
  69848. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69849. static readonly ALPHA_ADD: number;
  69850. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69851. static readonly ALPHA_COMBINE: number;
  69852. /** Defines that alpha blending to DEST - SRC * DEST */
  69853. static readonly ALPHA_SUBTRACT: number;
  69854. /** Defines that alpha blending to SRC * DEST */
  69855. static readonly ALPHA_MULTIPLY: number;
  69856. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69857. static readonly ALPHA_MAXIMIZED: number;
  69858. /** Defines that alpha blending to SRC + DEST */
  69859. static readonly ALPHA_ONEONE: number;
  69860. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69861. static readonly ALPHA_PREMULTIPLIED: number;
  69862. /**
  69863. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69864. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69865. */
  69866. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69867. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69868. static readonly ALPHA_INTERPOLATE: number;
  69869. /**
  69870. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69871. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69872. */
  69873. static readonly ALPHA_SCREENMODE: number;
  69874. /** Defines that the ressource is not delayed*/
  69875. static readonly DELAYLOADSTATE_NONE: number;
  69876. /** Defines that the ressource was successfully delay loaded */
  69877. static readonly DELAYLOADSTATE_LOADED: number;
  69878. /** Defines that the ressource is currently delay loading */
  69879. static readonly DELAYLOADSTATE_LOADING: number;
  69880. /** Defines that the ressource is delayed and has not started loading */
  69881. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69882. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69883. static readonly NEVER: number;
  69884. /** 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 */
  69885. static readonly ALWAYS: number;
  69886. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69887. static readonly LESS: number;
  69888. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69889. static readonly EQUAL: number;
  69890. /** 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 */
  69891. static readonly LEQUAL: number;
  69892. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69893. static readonly GREATER: number;
  69894. /** 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 */
  69895. static readonly GEQUAL: number;
  69896. /** 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 */
  69897. static readonly NOTEQUAL: number;
  69898. /** Passed to stencilOperation to specify that stencil value must be kept */
  69899. static readonly KEEP: number;
  69900. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69901. static readonly REPLACE: number;
  69902. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69903. static readonly INCR: number;
  69904. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69905. static readonly DECR: number;
  69906. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69907. static readonly INVERT: number;
  69908. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69909. static readonly INCR_WRAP: number;
  69910. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69911. static readonly DECR_WRAP: number;
  69912. /** Texture is not repeating outside of 0..1 UVs */
  69913. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69914. /** Texture is repeating outside of 0..1 UVs */
  69915. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69916. /** Texture is repeating and mirrored */
  69917. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69918. /** ALPHA */
  69919. static readonly TEXTUREFORMAT_ALPHA: number;
  69920. /** LUMINANCE */
  69921. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69922. /** LUMINANCE_ALPHA */
  69923. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69924. /** RGB */
  69925. static readonly TEXTUREFORMAT_RGB: number;
  69926. /** RGBA */
  69927. static readonly TEXTUREFORMAT_RGBA: number;
  69928. /** RED */
  69929. static readonly TEXTUREFORMAT_RED: number;
  69930. /** RED (2nd reference) */
  69931. static readonly TEXTUREFORMAT_R: number;
  69932. /** RG */
  69933. static readonly TEXTUREFORMAT_RG: number;
  69934. /** RED_INTEGER */
  69935. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69936. /** RED_INTEGER (2nd reference) */
  69937. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69938. /** RG_INTEGER */
  69939. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69940. /** RGB_INTEGER */
  69941. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69942. /** RGBA_INTEGER */
  69943. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69944. /** UNSIGNED_BYTE */
  69945. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69946. /** UNSIGNED_BYTE (2nd reference) */
  69947. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69948. /** FLOAT */
  69949. static readonly TEXTURETYPE_FLOAT: number;
  69950. /** HALF_FLOAT */
  69951. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69952. /** BYTE */
  69953. static readonly TEXTURETYPE_BYTE: number;
  69954. /** SHORT */
  69955. static readonly TEXTURETYPE_SHORT: number;
  69956. /** UNSIGNED_SHORT */
  69957. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69958. /** INT */
  69959. static readonly TEXTURETYPE_INT: number;
  69960. /** UNSIGNED_INT */
  69961. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69962. /** UNSIGNED_SHORT_4_4_4_4 */
  69963. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69964. /** UNSIGNED_SHORT_5_5_5_1 */
  69965. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69966. /** UNSIGNED_SHORT_5_6_5 */
  69967. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69968. /** UNSIGNED_INT_2_10_10_10_REV */
  69969. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69970. /** UNSIGNED_INT_24_8 */
  69971. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69972. /** UNSIGNED_INT_10F_11F_11F_REV */
  69973. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69974. /** UNSIGNED_INT_5_9_9_9_REV */
  69975. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69976. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69977. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69978. /** nearest is mag = nearest and min = nearest and mip = linear */
  69979. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69980. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69981. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69982. /** Trilinear is mag = linear and min = linear and mip = linear */
  69983. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69984. /** nearest is mag = nearest and min = nearest and mip = linear */
  69985. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69986. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69987. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69988. /** Trilinear is mag = linear and min = linear and mip = linear */
  69989. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69990. /** mag = nearest and min = nearest and mip = nearest */
  69991. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69992. /** mag = nearest and min = linear and mip = nearest */
  69993. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69994. /** mag = nearest and min = linear and mip = linear */
  69995. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69996. /** mag = nearest and min = linear and mip = none */
  69997. static readonly TEXTURE_NEAREST_LINEAR: number;
  69998. /** mag = nearest and min = nearest and mip = none */
  69999. static readonly TEXTURE_NEAREST_NEAREST: number;
  70000. /** mag = linear and min = nearest and mip = nearest */
  70001. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70002. /** mag = linear and min = nearest and mip = linear */
  70003. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70004. /** mag = linear and min = linear and mip = none */
  70005. static readonly TEXTURE_LINEAR_LINEAR: number;
  70006. /** mag = linear and min = nearest and mip = none */
  70007. static readonly TEXTURE_LINEAR_NEAREST: number;
  70008. /** Explicit coordinates mode */
  70009. static readonly TEXTURE_EXPLICIT_MODE: number;
  70010. /** Spherical coordinates mode */
  70011. static readonly TEXTURE_SPHERICAL_MODE: number;
  70012. /** Planar coordinates mode */
  70013. static readonly TEXTURE_PLANAR_MODE: number;
  70014. /** Cubic coordinates mode */
  70015. static readonly TEXTURE_CUBIC_MODE: number;
  70016. /** Projection coordinates mode */
  70017. static readonly TEXTURE_PROJECTION_MODE: number;
  70018. /** Skybox coordinates mode */
  70019. static readonly TEXTURE_SKYBOX_MODE: number;
  70020. /** Inverse Cubic coordinates mode */
  70021. static readonly TEXTURE_INVCUBIC_MODE: number;
  70022. /** Equirectangular coordinates mode */
  70023. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70024. /** Equirectangular Fixed coordinates mode */
  70025. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70026. /** Equirectangular Fixed Mirrored coordinates mode */
  70027. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70028. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70029. static readonly SCALEMODE_FLOOR: number;
  70030. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70031. static readonly SCALEMODE_NEAREST: number;
  70032. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70033. static readonly SCALEMODE_CEILING: number;
  70034. /**
  70035. * The dirty texture flag value
  70036. */
  70037. static readonly MATERIAL_TextureDirtyFlag: number;
  70038. /**
  70039. * The dirty light flag value
  70040. */
  70041. static readonly MATERIAL_LightDirtyFlag: number;
  70042. /**
  70043. * The dirty fresnel flag value
  70044. */
  70045. static readonly MATERIAL_FresnelDirtyFlag: number;
  70046. /**
  70047. * The dirty attribute flag value
  70048. */
  70049. static readonly MATERIAL_AttributesDirtyFlag: number;
  70050. /**
  70051. * The dirty misc flag value
  70052. */
  70053. static readonly MATERIAL_MiscDirtyFlag: number;
  70054. /**
  70055. * The all dirty flag value
  70056. */
  70057. static readonly MATERIAL_AllDirtyFlag: number;
  70058. /**
  70059. * Returns the triangle fill mode
  70060. */
  70061. static readonly MATERIAL_TriangleFillMode: number;
  70062. /**
  70063. * Returns the wireframe mode
  70064. */
  70065. static readonly MATERIAL_WireFrameFillMode: number;
  70066. /**
  70067. * Returns the point fill mode
  70068. */
  70069. static readonly MATERIAL_PointFillMode: number;
  70070. /**
  70071. * Returns the point list draw mode
  70072. */
  70073. static readonly MATERIAL_PointListDrawMode: number;
  70074. /**
  70075. * Returns the line list draw mode
  70076. */
  70077. static readonly MATERIAL_LineListDrawMode: number;
  70078. /**
  70079. * Returns the line loop draw mode
  70080. */
  70081. static readonly MATERIAL_LineLoopDrawMode: number;
  70082. /**
  70083. * Returns the line strip draw mode
  70084. */
  70085. static readonly MATERIAL_LineStripDrawMode: number;
  70086. /**
  70087. * Returns the triangle strip draw mode
  70088. */
  70089. static readonly MATERIAL_TriangleStripDrawMode: number;
  70090. /**
  70091. * Returns the triangle fan draw mode
  70092. */
  70093. static readonly MATERIAL_TriangleFanDrawMode: number;
  70094. /**
  70095. * Stores the clock-wise side orientation
  70096. */
  70097. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70098. /**
  70099. * Stores the counter clock-wise side orientation
  70100. */
  70101. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70102. /**
  70103. * Nothing
  70104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70105. */
  70106. static readonly ACTION_NothingTrigger: number;
  70107. /**
  70108. * On pick
  70109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70110. */
  70111. static readonly ACTION_OnPickTrigger: number;
  70112. /**
  70113. * On left pick
  70114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70115. */
  70116. static readonly ACTION_OnLeftPickTrigger: number;
  70117. /**
  70118. * On right pick
  70119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70120. */
  70121. static readonly ACTION_OnRightPickTrigger: number;
  70122. /**
  70123. * On center pick
  70124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70125. */
  70126. static readonly ACTION_OnCenterPickTrigger: number;
  70127. /**
  70128. * On pick down
  70129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70130. */
  70131. static readonly ACTION_OnPickDownTrigger: number;
  70132. /**
  70133. * On double pick
  70134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70135. */
  70136. static readonly ACTION_OnDoublePickTrigger: number;
  70137. /**
  70138. * On pick up
  70139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70140. */
  70141. static readonly ACTION_OnPickUpTrigger: number;
  70142. /**
  70143. * On pick out.
  70144. * This trigger will only be raised if you also declared a OnPickDown
  70145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70146. */
  70147. static readonly ACTION_OnPickOutTrigger: number;
  70148. /**
  70149. * On long press
  70150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70151. */
  70152. static readonly ACTION_OnLongPressTrigger: number;
  70153. /**
  70154. * On pointer over
  70155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70156. */
  70157. static readonly ACTION_OnPointerOverTrigger: number;
  70158. /**
  70159. * On pointer out
  70160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70161. */
  70162. static readonly ACTION_OnPointerOutTrigger: number;
  70163. /**
  70164. * On every frame
  70165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70166. */
  70167. static readonly ACTION_OnEveryFrameTrigger: number;
  70168. /**
  70169. * On intersection enter
  70170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70171. */
  70172. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70173. /**
  70174. * On intersection exit
  70175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70176. */
  70177. static readonly ACTION_OnIntersectionExitTrigger: number;
  70178. /**
  70179. * On key down
  70180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70181. */
  70182. static readonly ACTION_OnKeyDownTrigger: number;
  70183. /**
  70184. * On key up
  70185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70186. */
  70187. static readonly ACTION_OnKeyUpTrigger: number;
  70188. /**
  70189. * Billboard mode will only apply to Y axis
  70190. */
  70191. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70192. /**
  70193. * Billboard mode will apply to all axes
  70194. */
  70195. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70196. /**
  70197. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70198. */
  70199. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70200. /**
  70201. * Gets or sets base Assets URL
  70202. */
  70203. static PARTICLES_BaseAssetsUrl: string;
  70204. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70205. * Test order :
  70206. * Is the bounding sphere outside the frustum ?
  70207. * If not, are the bounding box vertices outside the frustum ?
  70208. * It not, then the cullable object is in the frustum.
  70209. */
  70210. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70211. /** Culling strategy : Bounding Sphere Only.
  70212. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70213. * It's also less accurate than the standard because some not visible objects can still be selected.
  70214. * Test : is the bounding sphere outside the frustum ?
  70215. * If not, then the cullable object is in the frustum.
  70216. */
  70217. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70218. /** Culling strategy : Optimistic Inclusion.
  70219. * This in an inclusion test first, then the standard exclusion test.
  70220. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70221. * 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.
  70222. * Anyway, it's as accurate as the standard strategy.
  70223. * Test :
  70224. * Is the cullable object bounding sphere center in the frustum ?
  70225. * If not, apply the default culling strategy.
  70226. */
  70227. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70228. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70229. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70230. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70231. * 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.
  70232. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70233. * Test :
  70234. * Is the cullable object bounding sphere center in the frustum ?
  70235. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70236. */
  70237. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70238. /**
  70239. * No logging while loading
  70240. */
  70241. static readonly SCENELOADER_NO_LOGGING: number;
  70242. /**
  70243. * Minimal logging while loading
  70244. */
  70245. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70246. /**
  70247. * Summary logging while loading
  70248. */
  70249. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70250. /**
  70251. * Detailled logging while loading
  70252. */
  70253. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70254. }
  70255. }
  70256. declare module BABYLON {
  70257. /**
  70258. * Class used to store and describe the pipeline context associated with an effect
  70259. */
  70260. export interface IPipelineContext {
  70261. /**
  70262. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70263. */
  70264. isAsync: boolean;
  70265. /**
  70266. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70267. */
  70268. isReady: boolean;
  70269. /** @hidden */
  70270. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70271. }
  70272. }
  70273. declare module BABYLON {
  70274. /** @hidden */
  70275. export interface IShaderProcessor {
  70276. attributeProcessor?: (attribute: string) => string;
  70277. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70278. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70279. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70280. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70281. lineProcessor?: (line: string, isFragment: boolean) => string;
  70282. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70283. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70284. }
  70285. }
  70286. declare module BABYLON {
  70287. /** @hidden */
  70288. export interface ProcessingOptions {
  70289. defines: string[];
  70290. indexParameters: any;
  70291. isFragment: boolean;
  70292. shouldUseHighPrecisionShader: boolean;
  70293. supportsUniformBuffers: boolean;
  70294. shadersRepository: string;
  70295. includesShadersStore: {
  70296. [key: string]: string;
  70297. };
  70298. processor?: IShaderProcessor;
  70299. version: string;
  70300. platformName: string;
  70301. lookForClosingBracketForUniformBuffer?: boolean;
  70302. }
  70303. }
  70304. declare module BABYLON {
  70305. /**
  70306. * Helper to manipulate strings
  70307. */
  70308. export class StringTools {
  70309. /**
  70310. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70311. * @param str Source string
  70312. * @param suffix Suffix to search for in the source string
  70313. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70314. */
  70315. static EndsWith(str: string, suffix: string): boolean;
  70316. /**
  70317. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70318. * @param str Source string
  70319. * @param suffix Suffix to search for in the source string
  70320. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70321. */
  70322. static StartsWith(str: string, suffix: string): boolean;
  70323. }
  70324. }
  70325. declare module BABYLON {
  70326. /** @hidden */
  70327. export class ShaderCodeNode {
  70328. line: string;
  70329. children: ShaderCodeNode[];
  70330. additionalDefineKey?: string;
  70331. additionalDefineValue?: string;
  70332. isValid(preprocessors: {
  70333. [key: string]: string;
  70334. }): boolean;
  70335. process(preprocessors: {
  70336. [key: string]: string;
  70337. }, options: ProcessingOptions): string;
  70338. }
  70339. }
  70340. declare module BABYLON {
  70341. /** @hidden */
  70342. export class ShaderCodeCursor {
  70343. private _lines;
  70344. lineIndex: number;
  70345. readonly currentLine: string;
  70346. readonly canRead: boolean;
  70347. lines: string[];
  70348. }
  70349. }
  70350. declare module BABYLON {
  70351. /** @hidden */
  70352. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70353. process(preprocessors: {
  70354. [key: string]: string;
  70355. }, options: ProcessingOptions): string;
  70356. }
  70357. }
  70358. declare module BABYLON {
  70359. /** @hidden */
  70360. export class ShaderDefineExpression {
  70361. isTrue(preprocessors: {
  70362. [key: string]: string;
  70363. }): boolean;
  70364. }
  70365. }
  70366. declare module BABYLON {
  70367. /** @hidden */
  70368. export class ShaderCodeTestNode extends ShaderCodeNode {
  70369. testExpression: ShaderDefineExpression;
  70370. isValid(preprocessors: {
  70371. [key: string]: string;
  70372. }): boolean;
  70373. }
  70374. }
  70375. declare module BABYLON {
  70376. /** @hidden */
  70377. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70378. define: string;
  70379. not: boolean;
  70380. constructor(define: string, not?: boolean);
  70381. isTrue(preprocessors: {
  70382. [key: string]: string;
  70383. }): boolean;
  70384. }
  70385. }
  70386. declare module BABYLON {
  70387. /** @hidden */
  70388. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70389. leftOperand: ShaderDefineExpression;
  70390. rightOperand: ShaderDefineExpression;
  70391. isTrue(preprocessors: {
  70392. [key: string]: string;
  70393. }): boolean;
  70394. }
  70395. }
  70396. declare module BABYLON {
  70397. /** @hidden */
  70398. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70399. leftOperand: ShaderDefineExpression;
  70400. rightOperand: ShaderDefineExpression;
  70401. isTrue(preprocessors: {
  70402. [key: string]: string;
  70403. }): boolean;
  70404. }
  70405. }
  70406. declare module BABYLON {
  70407. /** @hidden */
  70408. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70409. define: string;
  70410. operand: string;
  70411. testValue: string;
  70412. constructor(define: string, operand: string, testValue: string);
  70413. isTrue(preprocessors: {
  70414. [key: string]: string;
  70415. }): boolean;
  70416. }
  70417. }
  70418. declare module BABYLON {
  70419. /**
  70420. * @ignore
  70421. * Application error to support additional information when loading a file
  70422. */
  70423. export class LoadFileError extends Error {
  70424. /** defines the optional web request */
  70425. request?: WebRequest | undefined;
  70426. private static _setPrototypeOf;
  70427. /**
  70428. * Creates a new LoadFileError
  70429. * @param message defines the message of the error
  70430. * @param request defines the optional web request
  70431. */
  70432. constructor(message: string,
  70433. /** defines the optional web request */
  70434. request?: WebRequest | undefined);
  70435. }
  70436. }
  70437. declare module BABYLON {
  70438. /**
  70439. * Class used to enable access to offline support
  70440. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70441. */
  70442. export interface IOfflineProvider {
  70443. /**
  70444. * Gets a boolean indicating if scene must be saved in the database
  70445. */
  70446. enableSceneOffline: boolean;
  70447. /**
  70448. * Gets a boolean indicating if textures must be saved in the database
  70449. */
  70450. enableTexturesOffline: boolean;
  70451. /**
  70452. * Open the offline support and make it available
  70453. * @param successCallback defines the callback to call on success
  70454. * @param errorCallback defines the callback to call on error
  70455. */
  70456. open(successCallback: () => void, errorCallback: () => void): void;
  70457. /**
  70458. * Loads an image from the offline support
  70459. * @param url defines the url to load from
  70460. * @param image defines the target DOM image
  70461. */
  70462. loadImage(url: string, image: HTMLImageElement): void;
  70463. /**
  70464. * Loads a file from offline support
  70465. * @param url defines the URL to load from
  70466. * @param sceneLoaded defines a callback to call on success
  70467. * @param progressCallBack defines a callback to call when progress changed
  70468. * @param errorCallback defines a callback to call on error
  70469. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70470. */
  70471. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70472. }
  70473. }
  70474. declare module BABYLON {
  70475. /**
  70476. * Class used to help managing file picking and drag'n'drop
  70477. * File Storage
  70478. */
  70479. export class FilesInputStore {
  70480. /**
  70481. * List of files ready to be loaded
  70482. */
  70483. static FilesToLoad: {
  70484. [key: string]: File;
  70485. };
  70486. }
  70487. }
  70488. declare module BABYLON {
  70489. /**
  70490. * Class used to define a retry strategy when error happens while loading assets
  70491. */
  70492. export class RetryStrategy {
  70493. /**
  70494. * Function used to defines an exponential back off strategy
  70495. * @param maxRetries defines the maximum number of retries (3 by default)
  70496. * @param baseInterval defines the interval between retries
  70497. * @returns the strategy function to use
  70498. */
  70499. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70500. }
  70501. }
  70502. declare module BABYLON {
  70503. /**
  70504. * @hidden
  70505. */
  70506. export class FileTools {
  70507. /**
  70508. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70509. */
  70510. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70511. /**
  70512. * Gets or sets the base URL to use to load assets
  70513. */
  70514. static BaseUrl: string;
  70515. /**
  70516. * Default behaviour for cors in the application.
  70517. * It can be a string if the expected behavior is identical in the entire app.
  70518. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70519. */
  70520. static CorsBehavior: string | ((url: string | string[]) => string);
  70521. /**
  70522. * Gets or sets a function used to pre-process url before using them to load assets
  70523. */
  70524. static PreprocessUrl: (url: string) => string;
  70525. /**
  70526. * Removes unwanted characters from an url
  70527. * @param url defines the url to clean
  70528. * @returns the cleaned url
  70529. */
  70530. private static _CleanUrl;
  70531. /**
  70532. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70533. * @param url define the url we are trying
  70534. * @param element define the dom element where to configure the cors policy
  70535. */
  70536. static SetCorsBehavior(url: string | string[], element: {
  70537. crossOrigin: string | null;
  70538. }): void;
  70539. /**
  70540. * Loads an image as an HTMLImageElement.
  70541. * @param input url string, ArrayBuffer, or Blob to load
  70542. * @param onLoad callback called when the image successfully loads
  70543. * @param onError callback called when the image fails to load
  70544. * @param offlineProvider offline provider for caching
  70545. * @returns the HTMLImageElement of the loaded image
  70546. */
  70547. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70548. /**
  70549. * Loads a file
  70550. * @param fileToLoad defines the file to load
  70551. * @param callback defines the callback to call when data is loaded
  70552. * @param progressCallBack defines the callback to call during loading process
  70553. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70554. * @returns a file request object
  70555. */
  70556. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70557. /**
  70558. * Loads a file
  70559. * @param url url string, ArrayBuffer, or Blob to load
  70560. * @param onSuccess callback called when the file successfully loads
  70561. * @param onProgress callback called while file is loading (if the server supports this mode)
  70562. * @param offlineProvider defines the offline provider for caching
  70563. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70564. * @param onError callback called when the file fails to load
  70565. * @returns a file request object
  70566. */
  70567. 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;
  70568. /**
  70569. * Checks if the loaded document was accessed via `file:`-Protocol.
  70570. * @returns boolean
  70571. */
  70572. static IsFileURL(): boolean;
  70573. }
  70574. }
  70575. declare module BABYLON {
  70576. /** @hidden */
  70577. export class ShaderProcessor {
  70578. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70579. private static _ProcessPrecision;
  70580. private static _ExtractOperation;
  70581. private static _BuildSubExpression;
  70582. private static _BuildExpression;
  70583. private static _MoveCursorWithinIf;
  70584. private static _MoveCursor;
  70585. private static _EvaluatePreProcessors;
  70586. private static _PreparePreProcessors;
  70587. private static _ProcessShaderConversion;
  70588. private static _ProcessIncludes;
  70589. }
  70590. }
  70591. declare module BABYLON {
  70592. /**
  70593. * Class used to hold a RBG color
  70594. */
  70595. export class Color3 {
  70596. /**
  70597. * Defines the red component (between 0 and 1, default is 0)
  70598. */
  70599. r: number;
  70600. /**
  70601. * Defines the green component (between 0 and 1, default is 0)
  70602. */
  70603. g: number;
  70604. /**
  70605. * Defines the blue component (between 0 and 1, default is 0)
  70606. */
  70607. b: number;
  70608. /**
  70609. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70610. * @param r defines the red component (between 0 and 1, default is 0)
  70611. * @param g defines the green component (between 0 and 1, default is 0)
  70612. * @param b defines the blue component (between 0 and 1, default is 0)
  70613. */
  70614. constructor(
  70615. /**
  70616. * Defines the red component (between 0 and 1, default is 0)
  70617. */
  70618. r?: number,
  70619. /**
  70620. * Defines the green component (between 0 and 1, default is 0)
  70621. */
  70622. g?: number,
  70623. /**
  70624. * Defines the blue component (between 0 and 1, default is 0)
  70625. */
  70626. b?: number);
  70627. /**
  70628. * Creates a string with the Color3 current values
  70629. * @returns the string representation of the Color3 object
  70630. */
  70631. toString(): string;
  70632. /**
  70633. * Returns the string "Color3"
  70634. * @returns "Color3"
  70635. */
  70636. getClassName(): string;
  70637. /**
  70638. * Compute the Color3 hash code
  70639. * @returns an unique number that can be used to hash Color3 objects
  70640. */
  70641. getHashCode(): number;
  70642. /**
  70643. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70644. * @param array defines the array where to store the r,g,b components
  70645. * @param index defines an optional index in the target array to define where to start storing values
  70646. * @returns the current Color3 object
  70647. */
  70648. toArray(array: FloatArray, index?: number): Color3;
  70649. /**
  70650. * Returns a new Color4 object from the current Color3 and the given alpha
  70651. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70652. * @returns a new Color4 object
  70653. */
  70654. toColor4(alpha?: number): Color4;
  70655. /**
  70656. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70657. * @returns the new array
  70658. */
  70659. asArray(): number[];
  70660. /**
  70661. * Returns the luminance value
  70662. * @returns a float value
  70663. */
  70664. toLuminance(): number;
  70665. /**
  70666. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70667. * @param otherColor defines the second operand
  70668. * @returns the new Color3 object
  70669. */
  70670. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70671. /**
  70672. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70673. * @param otherColor defines the second operand
  70674. * @param result defines the Color3 object where to store the result
  70675. * @returns the current Color3
  70676. */
  70677. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70678. /**
  70679. * Determines equality between Color3 objects
  70680. * @param otherColor defines the second operand
  70681. * @returns true if the rgb values are equal to the given ones
  70682. */
  70683. equals(otherColor: DeepImmutable<Color3>): boolean;
  70684. /**
  70685. * Determines equality between the current Color3 object and a set of r,b,g values
  70686. * @param r defines the red component to check
  70687. * @param g defines the green component to check
  70688. * @param b defines the blue component to check
  70689. * @returns true if the rgb values are equal to the given ones
  70690. */
  70691. equalsFloats(r: number, g: number, b: number): boolean;
  70692. /**
  70693. * Multiplies in place each rgb value by scale
  70694. * @param scale defines the scaling factor
  70695. * @returns the updated Color3
  70696. */
  70697. scale(scale: number): Color3;
  70698. /**
  70699. * Multiplies the rgb values by scale and stores the result into "result"
  70700. * @param scale defines the scaling factor
  70701. * @param result defines the Color3 object where to store the result
  70702. * @returns the unmodified current Color3
  70703. */
  70704. scaleToRef(scale: number, result: Color3): Color3;
  70705. /**
  70706. * Scale the current Color3 values by a factor and add the result to a given Color3
  70707. * @param scale defines the scale factor
  70708. * @param result defines color to store the result into
  70709. * @returns the unmodified current Color3
  70710. */
  70711. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70712. /**
  70713. * Clamps the rgb values by the min and max values and stores the result into "result"
  70714. * @param min defines minimum clamping value (default is 0)
  70715. * @param max defines maximum clamping value (default is 1)
  70716. * @param result defines color to store the result into
  70717. * @returns the original Color3
  70718. */
  70719. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70720. /**
  70721. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70722. * @param otherColor defines the second operand
  70723. * @returns the new Color3
  70724. */
  70725. add(otherColor: DeepImmutable<Color3>): Color3;
  70726. /**
  70727. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70728. * @param otherColor defines the second operand
  70729. * @param result defines Color3 object to store the result into
  70730. * @returns the unmodified current Color3
  70731. */
  70732. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70733. /**
  70734. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70735. * @param otherColor defines the second operand
  70736. * @returns the new Color3
  70737. */
  70738. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70739. /**
  70740. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70741. * @param otherColor defines the second operand
  70742. * @param result defines Color3 object to store the result into
  70743. * @returns the unmodified current Color3
  70744. */
  70745. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70746. /**
  70747. * Copy the current object
  70748. * @returns a new Color3 copied the current one
  70749. */
  70750. clone(): Color3;
  70751. /**
  70752. * Copies the rgb values from the source in the current Color3
  70753. * @param source defines the source Color3 object
  70754. * @returns the updated Color3 object
  70755. */
  70756. copyFrom(source: DeepImmutable<Color3>): Color3;
  70757. /**
  70758. * Updates the Color3 rgb values from the given floats
  70759. * @param r defines the red component to read from
  70760. * @param g defines the green component to read from
  70761. * @param b defines the blue component to read from
  70762. * @returns the current Color3 object
  70763. */
  70764. copyFromFloats(r: number, g: number, b: number): Color3;
  70765. /**
  70766. * Updates the Color3 rgb values from the given floats
  70767. * @param r defines the red component to read from
  70768. * @param g defines the green component to read from
  70769. * @param b defines the blue component to read from
  70770. * @returns the current Color3 object
  70771. */
  70772. set(r: number, g: number, b: number): Color3;
  70773. /**
  70774. * Compute the Color3 hexadecimal code as a string
  70775. * @returns a string containing the hexadecimal representation of the Color3 object
  70776. */
  70777. toHexString(): string;
  70778. /**
  70779. * Computes a new Color3 converted from the current one to linear space
  70780. * @returns a new Color3 object
  70781. */
  70782. toLinearSpace(): Color3;
  70783. /**
  70784. * Converts current color in rgb space to HSV values
  70785. * @returns a new color3 representing the HSV values
  70786. */
  70787. toHSV(): Color3;
  70788. /**
  70789. * Converts current color in rgb space to HSV values
  70790. * @param result defines the Color3 where to store the HSV values
  70791. */
  70792. toHSVToRef(result: Color3): void;
  70793. /**
  70794. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70795. * @param convertedColor defines the Color3 object where to store the linear space version
  70796. * @returns the unmodified Color3
  70797. */
  70798. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70799. /**
  70800. * Computes a new Color3 converted from the current one to gamma space
  70801. * @returns a new Color3 object
  70802. */
  70803. toGammaSpace(): Color3;
  70804. /**
  70805. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70806. * @param convertedColor defines the Color3 object where to store the gamma space version
  70807. * @returns the unmodified Color3
  70808. */
  70809. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70810. private static _BlackReadOnly;
  70811. /**
  70812. * Convert Hue, saturation and value to a Color3 (RGB)
  70813. * @param hue defines the hue
  70814. * @param saturation defines the saturation
  70815. * @param value defines the value
  70816. * @param result defines the Color3 where to store the RGB values
  70817. */
  70818. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70819. /**
  70820. * Creates a new Color3 from the string containing valid hexadecimal values
  70821. * @param hex defines a string containing valid hexadecimal values
  70822. * @returns a new Color3 object
  70823. */
  70824. static FromHexString(hex: string): Color3;
  70825. /**
  70826. * Creates a new Color3 from the starting index of the given array
  70827. * @param array defines the source array
  70828. * @param offset defines an offset in the source array
  70829. * @returns a new Color3 object
  70830. */
  70831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70832. /**
  70833. * Creates a new Color3 from integer values (< 256)
  70834. * @param r defines the red component to read from (value between 0 and 255)
  70835. * @param g defines the green component to read from (value between 0 and 255)
  70836. * @param b defines the blue component to read from (value between 0 and 255)
  70837. * @returns a new Color3 object
  70838. */
  70839. static FromInts(r: number, g: number, b: number): Color3;
  70840. /**
  70841. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70842. * @param start defines the start Color3 value
  70843. * @param end defines the end Color3 value
  70844. * @param amount defines the gradient value between start and end
  70845. * @returns a new Color3 object
  70846. */
  70847. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70848. /**
  70849. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70850. * @param left defines the start value
  70851. * @param right defines the end value
  70852. * @param amount defines the gradient factor
  70853. * @param result defines the Color3 object where to store the result
  70854. */
  70855. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70856. /**
  70857. * Returns a Color3 value containing a red color
  70858. * @returns a new Color3 object
  70859. */
  70860. static Red(): Color3;
  70861. /**
  70862. * Returns a Color3 value containing a green color
  70863. * @returns a new Color3 object
  70864. */
  70865. static Green(): Color3;
  70866. /**
  70867. * Returns a Color3 value containing a blue color
  70868. * @returns a new Color3 object
  70869. */
  70870. static Blue(): Color3;
  70871. /**
  70872. * Returns a Color3 value containing a black color
  70873. * @returns a new Color3 object
  70874. */
  70875. static Black(): Color3;
  70876. /**
  70877. * Gets a Color3 value containing a black color that must not be updated
  70878. */
  70879. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70880. /**
  70881. * Returns a Color3 value containing a white color
  70882. * @returns a new Color3 object
  70883. */
  70884. static White(): Color3;
  70885. /**
  70886. * Returns a Color3 value containing a purple color
  70887. * @returns a new Color3 object
  70888. */
  70889. static Purple(): Color3;
  70890. /**
  70891. * Returns a Color3 value containing a magenta color
  70892. * @returns a new Color3 object
  70893. */
  70894. static Magenta(): Color3;
  70895. /**
  70896. * Returns a Color3 value containing a yellow color
  70897. * @returns a new Color3 object
  70898. */
  70899. static Yellow(): Color3;
  70900. /**
  70901. * Returns a Color3 value containing a gray color
  70902. * @returns a new Color3 object
  70903. */
  70904. static Gray(): Color3;
  70905. /**
  70906. * Returns a Color3 value containing a teal color
  70907. * @returns a new Color3 object
  70908. */
  70909. static Teal(): Color3;
  70910. /**
  70911. * Returns a Color3 value containing a random color
  70912. * @returns a new Color3 object
  70913. */
  70914. static Random(): Color3;
  70915. }
  70916. /**
  70917. * Class used to hold a RBGA color
  70918. */
  70919. export class Color4 {
  70920. /**
  70921. * Defines the red component (between 0 and 1, default is 0)
  70922. */
  70923. r: number;
  70924. /**
  70925. * Defines the green component (between 0 and 1, default is 0)
  70926. */
  70927. g: number;
  70928. /**
  70929. * Defines the blue component (between 0 and 1, default is 0)
  70930. */
  70931. b: number;
  70932. /**
  70933. * Defines the alpha component (between 0 and 1, default is 1)
  70934. */
  70935. a: number;
  70936. /**
  70937. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70938. * @param r defines the red component (between 0 and 1, default is 0)
  70939. * @param g defines the green component (between 0 and 1, default is 0)
  70940. * @param b defines the blue component (between 0 and 1, default is 0)
  70941. * @param a defines the alpha component (between 0 and 1, default is 1)
  70942. */
  70943. constructor(
  70944. /**
  70945. * Defines the red component (between 0 and 1, default is 0)
  70946. */
  70947. r?: number,
  70948. /**
  70949. * Defines the green component (between 0 and 1, default is 0)
  70950. */
  70951. g?: number,
  70952. /**
  70953. * Defines the blue component (between 0 and 1, default is 0)
  70954. */
  70955. b?: number,
  70956. /**
  70957. * Defines the alpha component (between 0 and 1, default is 1)
  70958. */
  70959. a?: number);
  70960. /**
  70961. * Adds in place the given Color4 values to the current Color4 object
  70962. * @param right defines the second operand
  70963. * @returns the current updated Color4 object
  70964. */
  70965. addInPlace(right: DeepImmutable<Color4>): Color4;
  70966. /**
  70967. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70968. * @returns the new array
  70969. */
  70970. asArray(): number[];
  70971. /**
  70972. * Stores from the starting index in the given array the Color4 successive values
  70973. * @param array defines the array where to store the r,g,b components
  70974. * @param index defines an optional index in the target array to define where to start storing values
  70975. * @returns the current Color4 object
  70976. */
  70977. toArray(array: number[], index?: number): Color4;
  70978. /**
  70979. * Determines equality between Color4 objects
  70980. * @param otherColor defines the second operand
  70981. * @returns true if the rgba values are equal to the given ones
  70982. */
  70983. equals(otherColor: DeepImmutable<Color4>): boolean;
  70984. /**
  70985. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70986. * @param right defines the second operand
  70987. * @returns a new Color4 object
  70988. */
  70989. add(right: DeepImmutable<Color4>): Color4;
  70990. /**
  70991. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70992. * @param right defines the second operand
  70993. * @returns a new Color4 object
  70994. */
  70995. subtract(right: DeepImmutable<Color4>): Color4;
  70996. /**
  70997. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70998. * @param right defines the second operand
  70999. * @param result defines the Color4 object where to store the result
  71000. * @returns the current Color4 object
  71001. */
  71002. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  71003. /**
  71004. * Creates a new Color4 with the current Color4 values multiplied by scale
  71005. * @param scale defines the scaling factor to apply
  71006. * @returns a new Color4 object
  71007. */
  71008. scale(scale: number): Color4;
  71009. /**
  71010. * Multiplies the current Color4 values by scale and stores the result in "result"
  71011. * @param scale defines the scaling factor to apply
  71012. * @param result defines the Color4 object where to store the result
  71013. * @returns the current unmodified Color4
  71014. */
  71015. scaleToRef(scale: number, result: Color4): Color4;
  71016. /**
  71017. * Scale the current Color4 values by a factor and add the result to a given Color4
  71018. * @param scale defines the scale factor
  71019. * @param result defines the Color4 object where to store the result
  71020. * @returns the unmodified current Color4
  71021. */
  71022. scaleAndAddToRef(scale: number, result: Color4): Color4;
  71023. /**
  71024. * Clamps the rgb values by the min and max values and stores the result into "result"
  71025. * @param min defines minimum clamping value (default is 0)
  71026. * @param max defines maximum clamping value (default is 1)
  71027. * @param result defines color to store the result into.
  71028. * @returns the cuurent Color4
  71029. */
  71030. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  71031. /**
  71032. * Multipy an Color4 value by another and return a new Color4 object
  71033. * @param color defines the Color4 value to multiply by
  71034. * @returns a new Color4 object
  71035. */
  71036. multiply(color: Color4): Color4;
  71037. /**
  71038. * Multipy a Color4 value by another and push the result in a reference value
  71039. * @param color defines the Color4 value to multiply by
  71040. * @param result defines the Color4 to fill the result in
  71041. * @returns the result Color4
  71042. */
  71043. multiplyToRef(color: Color4, result: Color4): Color4;
  71044. /**
  71045. * Creates a string with the Color4 current values
  71046. * @returns the string representation of the Color4 object
  71047. */
  71048. toString(): string;
  71049. /**
  71050. * Returns the string "Color4"
  71051. * @returns "Color4"
  71052. */
  71053. getClassName(): string;
  71054. /**
  71055. * Compute the Color4 hash code
  71056. * @returns an unique number that can be used to hash Color4 objects
  71057. */
  71058. getHashCode(): number;
  71059. /**
  71060. * Creates a new Color4 copied from the current one
  71061. * @returns a new Color4 object
  71062. */
  71063. clone(): Color4;
  71064. /**
  71065. * Copies the given Color4 values into the current one
  71066. * @param source defines the source Color4 object
  71067. * @returns the current updated Color4 object
  71068. */
  71069. copyFrom(source: Color4): Color4;
  71070. /**
  71071. * Copies the given float values into the current one
  71072. * @param r defines the red component to read from
  71073. * @param g defines the green component to read from
  71074. * @param b defines the blue component to read from
  71075. * @param a defines the alpha component to read from
  71076. * @returns the current updated Color4 object
  71077. */
  71078. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  71079. /**
  71080. * Copies the given float values into the current one
  71081. * @param r defines the red component to read from
  71082. * @param g defines the green component to read from
  71083. * @param b defines the blue component to read from
  71084. * @param a defines the alpha component to read from
  71085. * @returns the current updated Color4 object
  71086. */
  71087. set(r: number, g: number, b: number, a: number): Color4;
  71088. /**
  71089. * Compute the Color4 hexadecimal code as a string
  71090. * @returns a string containing the hexadecimal representation of the Color4 object
  71091. */
  71092. toHexString(): string;
  71093. /**
  71094. * Computes a new Color4 converted from the current one to linear space
  71095. * @returns a new Color4 object
  71096. */
  71097. toLinearSpace(): Color4;
  71098. /**
  71099. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71100. * @param convertedColor defines the Color4 object where to store the linear space version
  71101. * @returns the unmodified Color4
  71102. */
  71103. toLinearSpaceToRef(convertedColor: Color4): Color4;
  71104. /**
  71105. * Computes a new Color4 converted from the current one to gamma space
  71106. * @returns a new Color4 object
  71107. */
  71108. toGammaSpace(): Color4;
  71109. /**
  71110. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71111. * @param convertedColor defines the Color4 object where to store the gamma space version
  71112. * @returns the unmodified Color4
  71113. */
  71114. toGammaSpaceToRef(convertedColor: Color4): Color4;
  71115. /**
  71116. * Creates a new Color4 from the string containing valid hexadecimal values
  71117. * @param hex defines a string containing valid hexadecimal values
  71118. * @returns a new Color4 object
  71119. */
  71120. static FromHexString(hex: string): Color4;
  71121. /**
  71122. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71123. * @param left defines the start value
  71124. * @param right defines the end value
  71125. * @param amount defines the gradient factor
  71126. * @returns a new Color4 object
  71127. */
  71128. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  71129. /**
  71130. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71131. * @param left defines the start value
  71132. * @param right defines the end value
  71133. * @param amount defines the gradient factor
  71134. * @param result defines the Color4 object where to store data
  71135. */
  71136. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  71137. /**
  71138. * Creates a new Color4 from a Color3 and an alpha value
  71139. * @param color3 defines the source Color3 to read from
  71140. * @param alpha defines the alpha component (1.0 by default)
  71141. * @returns a new Color4 object
  71142. */
  71143. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  71144. /**
  71145. * Creates a new Color4 from the starting index element of the given array
  71146. * @param array defines the source array to read from
  71147. * @param offset defines the offset in the source array
  71148. * @returns a new Color4 object
  71149. */
  71150. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  71151. /**
  71152. * Creates a new Color3 from integer values (< 256)
  71153. * @param r defines the red component to read from (value between 0 and 255)
  71154. * @param g defines the green component to read from (value between 0 and 255)
  71155. * @param b defines the blue component to read from (value between 0 and 255)
  71156. * @param a defines the alpha component to read from (value between 0 and 255)
  71157. * @returns a new Color3 object
  71158. */
  71159. static FromInts(r: number, g: number, b: number, a: number): Color4;
  71160. /**
  71161. * Check the content of a given array and convert it to an array containing RGBA data
  71162. * If the original array was already containing count * 4 values then it is returned directly
  71163. * @param colors defines the array to check
  71164. * @param count defines the number of RGBA data to expect
  71165. * @returns an array containing count * 4 values (RGBA)
  71166. */
  71167. static CheckColors4(colors: number[], count: number): number[];
  71168. }
  71169. /**
  71170. * @hidden
  71171. */
  71172. export class TmpColors {
  71173. static Color3: Color3[];
  71174. static Color4: Color4[];
  71175. }
  71176. }
  71177. declare module BABYLON {
  71178. /**
  71179. * Class representing spherical harmonics coefficients to the 3rd degree
  71180. */
  71181. export class SphericalHarmonics {
  71182. /**
  71183. * Defines whether or not the harmonics have been prescaled for rendering.
  71184. */
  71185. preScaled: boolean;
  71186. /**
  71187. * The l0,0 coefficients of the spherical harmonics
  71188. */
  71189. l00: Vector3;
  71190. /**
  71191. * The l1,-1 coefficients of the spherical harmonics
  71192. */
  71193. l1_1: Vector3;
  71194. /**
  71195. * The l1,0 coefficients of the spherical harmonics
  71196. */
  71197. l10: Vector3;
  71198. /**
  71199. * The l1,1 coefficients of the spherical harmonics
  71200. */
  71201. l11: Vector3;
  71202. /**
  71203. * The l2,-2 coefficients of the spherical harmonics
  71204. */
  71205. l2_2: Vector3;
  71206. /**
  71207. * The l2,-1 coefficients of the spherical harmonics
  71208. */
  71209. l2_1: Vector3;
  71210. /**
  71211. * The l2,0 coefficients of the spherical harmonics
  71212. */
  71213. l20: Vector3;
  71214. /**
  71215. * The l2,1 coefficients of the spherical harmonics
  71216. */
  71217. l21: Vector3;
  71218. /**
  71219. * The l2,2 coefficients of the spherical harmonics
  71220. */
  71221. l22: Vector3;
  71222. /**
  71223. * Adds a light to the spherical harmonics
  71224. * @param direction the direction of the light
  71225. * @param color the color of the light
  71226. * @param deltaSolidAngle the delta solid angle of the light
  71227. */
  71228. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  71229. /**
  71230. * Scales the spherical harmonics by the given amount
  71231. * @param scale the amount to scale
  71232. */
  71233. scaleInPlace(scale: number): void;
  71234. /**
  71235. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  71236. *
  71237. * ```
  71238. * E_lm = A_l * L_lm
  71239. * ```
  71240. *
  71241. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  71242. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  71243. * the scaling factors are given in equation 9.
  71244. */
  71245. convertIncidentRadianceToIrradiance(): void;
  71246. /**
  71247. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  71248. *
  71249. * ```
  71250. * L = (1/pi) * E * rho
  71251. * ```
  71252. *
  71253. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  71254. */
  71255. convertIrradianceToLambertianRadiance(): void;
  71256. /**
  71257. * Integrates the reconstruction coefficients directly in to the SH preventing further
  71258. * required operations at run time.
  71259. *
  71260. * This is simply done by scaling back the SH with Ylm constants parameter.
  71261. * The trigonometric part being applied by the shader at run time.
  71262. */
  71263. preScaleForRendering(): void;
  71264. /**
  71265. * Constructs a spherical harmonics from an array.
  71266. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  71267. * @returns the spherical harmonics
  71268. */
  71269. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  71270. /**
  71271. * Gets the spherical harmonics from polynomial
  71272. * @param polynomial the spherical polynomial
  71273. * @returns the spherical harmonics
  71274. */
  71275. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  71276. }
  71277. /**
  71278. * Class representing spherical polynomial coefficients to the 3rd degree
  71279. */
  71280. export class SphericalPolynomial {
  71281. private _harmonics;
  71282. /**
  71283. * The spherical harmonics used to create the polynomials.
  71284. */
  71285. readonly preScaledHarmonics: SphericalHarmonics;
  71286. /**
  71287. * The x coefficients of the spherical polynomial
  71288. */
  71289. x: Vector3;
  71290. /**
  71291. * The y coefficients of the spherical polynomial
  71292. */
  71293. y: Vector3;
  71294. /**
  71295. * The z coefficients of the spherical polynomial
  71296. */
  71297. z: Vector3;
  71298. /**
  71299. * The xx coefficients of the spherical polynomial
  71300. */
  71301. xx: Vector3;
  71302. /**
  71303. * The yy coefficients of the spherical polynomial
  71304. */
  71305. yy: Vector3;
  71306. /**
  71307. * The zz coefficients of the spherical polynomial
  71308. */
  71309. zz: Vector3;
  71310. /**
  71311. * The xy coefficients of the spherical polynomial
  71312. */
  71313. xy: Vector3;
  71314. /**
  71315. * The yz coefficients of the spherical polynomial
  71316. */
  71317. yz: Vector3;
  71318. /**
  71319. * The zx coefficients of the spherical polynomial
  71320. */
  71321. zx: Vector3;
  71322. /**
  71323. * Adds an ambient color to the spherical polynomial
  71324. * @param color the color to add
  71325. */
  71326. addAmbient(color: Color3): void;
  71327. /**
  71328. * Scales the spherical polynomial by the given amount
  71329. * @param scale the amount to scale
  71330. */
  71331. scaleInPlace(scale: number): void;
  71332. /**
  71333. * Gets the spherical polynomial from harmonics
  71334. * @param harmonics the spherical harmonics
  71335. * @returns the spherical polynomial
  71336. */
  71337. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71338. /**
  71339. * Constructs a spherical polynomial from an array.
  71340. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71341. * @returns the spherical polynomial
  71342. */
  71343. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71344. }
  71345. }
  71346. declare module BABYLON {
  71347. /**
  71348. * Define options used to create a render target texture
  71349. */
  71350. export class RenderTargetCreationOptions {
  71351. /**
  71352. * Specifies is mipmaps must be generated
  71353. */
  71354. generateMipMaps?: boolean;
  71355. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71356. generateDepthBuffer?: boolean;
  71357. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71358. generateStencilBuffer?: boolean;
  71359. /** Defines texture type (int by default) */
  71360. type?: number;
  71361. /** Defines sampling mode (trilinear by default) */
  71362. samplingMode?: number;
  71363. /** Defines format (RGBA by default) */
  71364. format?: number;
  71365. }
  71366. }
  71367. declare module BABYLON {
  71368. /**
  71369. * @hidden
  71370. **/
  71371. export class _AlphaState {
  71372. private _isAlphaBlendDirty;
  71373. private _isBlendFunctionParametersDirty;
  71374. private _isBlendEquationParametersDirty;
  71375. private _isBlendConstantsDirty;
  71376. private _alphaBlend;
  71377. private _blendFunctionParameters;
  71378. private _blendEquationParameters;
  71379. private _blendConstants;
  71380. /**
  71381. * Initializes the state.
  71382. */
  71383. constructor();
  71384. readonly isDirty: boolean;
  71385. alphaBlend: boolean;
  71386. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71387. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71388. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71389. reset(): void;
  71390. apply(gl: WebGLRenderingContext): void;
  71391. }
  71392. }
  71393. declare module BABYLON {
  71394. /**
  71395. * @hidden
  71396. **/
  71397. export class _DepthCullingState {
  71398. private _isDepthTestDirty;
  71399. private _isDepthMaskDirty;
  71400. private _isDepthFuncDirty;
  71401. private _isCullFaceDirty;
  71402. private _isCullDirty;
  71403. private _isZOffsetDirty;
  71404. private _isFrontFaceDirty;
  71405. private _depthTest;
  71406. private _depthMask;
  71407. private _depthFunc;
  71408. private _cull;
  71409. private _cullFace;
  71410. private _zOffset;
  71411. private _frontFace;
  71412. /**
  71413. * Initializes the state.
  71414. */
  71415. constructor();
  71416. readonly isDirty: boolean;
  71417. zOffset: number;
  71418. cullFace: Nullable<number>;
  71419. cull: Nullable<boolean>;
  71420. depthFunc: Nullable<number>;
  71421. depthMask: boolean;
  71422. depthTest: boolean;
  71423. frontFace: Nullable<number>;
  71424. reset(): void;
  71425. apply(gl: WebGLRenderingContext): void;
  71426. }
  71427. }
  71428. declare module BABYLON {
  71429. /**
  71430. * @hidden
  71431. **/
  71432. export class _StencilState {
  71433. /** 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 */
  71434. static readonly ALWAYS: number;
  71435. /** Passed to stencilOperation to specify that stencil value must be kept */
  71436. static readonly KEEP: number;
  71437. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71438. static readonly REPLACE: number;
  71439. private _isStencilTestDirty;
  71440. private _isStencilMaskDirty;
  71441. private _isStencilFuncDirty;
  71442. private _isStencilOpDirty;
  71443. private _stencilTest;
  71444. private _stencilMask;
  71445. private _stencilFunc;
  71446. private _stencilFuncRef;
  71447. private _stencilFuncMask;
  71448. private _stencilOpStencilFail;
  71449. private _stencilOpDepthFail;
  71450. private _stencilOpStencilDepthPass;
  71451. readonly isDirty: boolean;
  71452. stencilFunc: number;
  71453. stencilFuncRef: number;
  71454. stencilFuncMask: number;
  71455. stencilOpStencilFail: number;
  71456. stencilOpDepthFail: number;
  71457. stencilOpStencilDepthPass: number;
  71458. stencilMask: number;
  71459. stencilTest: boolean;
  71460. constructor();
  71461. reset(): void;
  71462. apply(gl: WebGLRenderingContext): void;
  71463. }
  71464. }
  71465. declare module BABYLON {
  71466. /**
  71467. * @hidden
  71468. **/
  71469. export class _TimeToken {
  71470. _startTimeQuery: Nullable<WebGLQuery>;
  71471. _endTimeQuery: Nullable<WebGLQuery>;
  71472. _timeElapsedQuery: Nullable<WebGLQuery>;
  71473. _timeElapsedQueryEnded: boolean;
  71474. }
  71475. }
  71476. declare module BABYLON {
  71477. /**
  71478. * Class used to evalaute queries containing `and` and `or` operators
  71479. */
  71480. export class AndOrNotEvaluator {
  71481. /**
  71482. * Evaluate a query
  71483. * @param query defines the query to evaluate
  71484. * @param evaluateCallback defines the callback used to filter result
  71485. * @returns true if the query matches
  71486. */
  71487. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71488. private static _HandleParenthesisContent;
  71489. private static _SimplifyNegation;
  71490. }
  71491. }
  71492. declare module BABYLON {
  71493. /**
  71494. * Class used to store custom tags
  71495. */
  71496. export class Tags {
  71497. /**
  71498. * Adds support for tags on the given object
  71499. * @param obj defines the object to use
  71500. */
  71501. static EnableFor(obj: any): void;
  71502. /**
  71503. * Removes tags support
  71504. * @param obj defines the object to use
  71505. */
  71506. static DisableFor(obj: any): void;
  71507. /**
  71508. * Gets a boolean indicating if the given object has tags
  71509. * @param obj defines the object to use
  71510. * @returns a boolean
  71511. */
  71512. static HasTags(obj: any): boolean;
  71513. /**
  71514. * Gets the tags available on a given object
  71515. * @param obj defines the object to use
  71516. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71517. * @returns the tags
  71518. */
  71519. static GetTags(obj: any, asString?: boolean): any;
  71520. /**
  71521. * Adds tags to an object
  71522. * @param obj defines the object to use
  71523. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71524. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71525. */
  71526. static AddTagsTo(obj: any, tagsString: string): void;
  71527. /**
  71528. * @hidden
  71529. */
  71530. static _AddTagTo(obj: any, tag: string): void;
  71531. /**
  71532. * Removes specific tags from a specific object
  71533. * @param obj defines the object to use
  71534. * @param tagsString defines the tags to remove
  71535. */
  71536. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71537. /**
  71538. * @hidden
  71539. */
  71540. static _RemoveTagFrom(obj: any, tag: string): void;
  71541. /**
  71542. * Defines if tags hosted on an object match a given query
  71543. * @param obj defines the object to use
  71544. * @param tagsQuery defines the tag query
  71545. * @returns a boolean
  71546. */
  71547. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71548. }
  71549. }
  71550. declare module BABYLON {
  71551. /**
  71552. * Defines potential orientation for back face culling
  71553. */
  71554. export enum Orientation {
  71555. /**
  71556. * Clockwise
  71557. */
  71558. CW = 0,
  71559. /** Counter clockwise */
  71560. CCW = 1
  71561. }
  71562. /** Class used to represent a Bezier curve */
  71563. export class BezierCurve {
  71564. /**
  71565. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71566. * @param t defines the time
  71567. * @param x1 defines the left coordinate on X axis
  71568. * @param y1 defines the left coordinate on Y axis
  71569. * @param x2 defines the right coordinate on X axis
  71570. * @param y2 defines the right coordinate on Y axis
  71571. * @returns the interpolated value
  71572. */
  71573. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71574. }
  71575. /**
  71576. * Defines angle representation
  71577. */
  71578. export class Angle {
  71579. private _radians;
  71580. /**
  71581. * Creates an Angle object of "radians" radians (float).
  71582. * @param radians the angle in radians
  71583. */
  71584. constructor(radians: number);
  71585. /**
  71586. * Get value in degrees
  71587. * @returns the Angle value in degrees (float)
  71588. */
  71589. degrees(): number;
  71590. /**
  71591. * Get value in radians
  71592. * @returns the Angle value in radians (float)
  71593. */
  71594. radians(): number;
  71595. /**
  71596. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71597. * @param a defines first vector
  71598. * @param b defines second vector
  71599. * @returns a new Angle
  71600. */
  71601. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71602. /**
  71603. * Gets a new Angle object from the given float in radians
  71604. * @param radians defines the angle value in radians
  71605. * @returns a new Angle
  71606. */
  71607. static FromRadians(radians: number): Angle;
  71608. /**
  71609. * Gets a new Angle object from the given float in degrees
  71610. * @param degrees defines the angle value in degrees
  71611. * @returns a new Angle
  71612. */
  71613. static FromDegrees(degrees: number): Angle;
  71614. }
  71615. /**
  71616. * This represents an arc in a 2d space.
  71617. */
  71618. export class Arc2 {
  71619. /** Defines the start point of the arc */
  71620. startPoint: Vector2;
  71621. /** Defines the mid point of the arc */
  71622. midPoint: Vector2;
  71623. /** Defines the end point of the arc */
  71624. endPoint: Vector2;
  71625. /**
  71626. * Defines the center point of the arc.
  71627. */
  71628. centerPoint: Vector2;
  71629. /**
  71630. * Defines the radius of the arc.
  71631. */
  71632. radius: number;
  71633. /**
  71634. * Defines the angle of the arc (from mid point to end point).
  71635. */
  71636. angle: Angle;
  71637. /**
  71638. * Defines the start angle of the arc (from start point to middle point).
  71639. */
  71640. startAngle: Angle;
  71641. /**
  71642. * Defines the orientation of the arc (clock wise/counter clock wise).
  71643. */
  71644. orientation: Orientation;
  71645. /**
  71646. * Creates an Arc object from the three given points : start, middle and end.
  71647. * @param startPoint Defines the start point of the arc
  71648. * @param midPoint Defines the midlle point of the arc
  71649. * @param endPoint Defines the end point of the arc
  71650. */
  71651. constructor(
  71652. /** Defines the start point of the arc */
  71653. startPoint: Vector2,
  71654. /** Defines the mid point of the arc */
  71655. midPoint: Vector2,
  71656. /** Defines the end point of the arc */
  71657. endPoint: Vector2);
  71658. }
  71659. /**
  71660. * Represents a 2D path made up of multiple 2D points
  71661. */
  71662. export class Path2 {
  71663. private _points;
  71664. private _length;
  71665. /**
  71666. * If the path start and end point are the same
  71667. */
  71668. closed: boolean;
  71669. /**
  71670. * Creates a Path2 object from the starting 2D coordinates x and y.
  71671. * @param x the starting points x value
  71672. * @param y the starting points y value
  71673. */
  71674. constructor(x: number, y: number);
  71675. /**
  71676. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71677. * @param x the added points x value
  71678. * @param y the added points y value
  71679. * @returns the updated Path2.
  71680. */
  71681. addLineTo(x: number, y: number): Path2;
  71682. /**
  71683. * 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.
  71684. * @param midX middle point x value
  71685. * @param midY middle point y value
  71686. * @param endX end point x value
  71687. * @param endY end point y value
  71688. * @param numberOfSegments (default: 36)
  71689. * @returns the updated Path2.
  71690. */
  71691. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71692. /**
  71693. * Closes the Path2.
  71694. * @returns the Path2.
  71695. */
  71696. close(): Path2;
  71697. /**
  71698. * Gets the sum of the distance between each sequential point in the path
  71699. * @returns the Path2 total length (float).
  71700. */
  71701. length(): number;
  71702. /**
  71703. * Gets the points which construct the path
  71704. * @returns the Path2 internal array of points.
  71705. */
  71706. getPoints(): Vector2[];
  71707. /**
  71708. * Retreives the point at the distance aways from the starting point
  71709. * @param normalizedLengthPosition the length along the path to retreive the point from
  71710. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71711. */
  71712. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71713. /**
  71714. * Creates a new path starting from an x and y position
  71715. * @param x starting x value
  71716. * @param y starting y value
  71717. * @returns a new Path2 starting at the coordinates (x, y).
  71718. */
  71719. static StartingAt(x: number, y: number): Path2;
  71720. }
  71721. /**
  71722. * Represents a 3D path made up of multiple 3D points
  71723. */
  71724. export class Path3D {
  71725. /**
  71726. * an array of Vector3, the curve axis of the Path3D
  71727. */
  71728. path: Vector3[];
  71729. private _curve;
  71730. private _distances;
  71731. private _tangents;
  71732. private _normals;
  71733. private _binormals;
  71734. private _raw;
  71735. /**
  71736. * new Path3D(path, normal, raw)
  71737. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71738. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71739. * @param path an array of Vector3, the curve axis of the Path3D
  71740. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71741. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71742. */
  71743. constructor(
  71744. /**
  71745. * an array of Vector3, the curve axis of the Path3D
  71746. */
  71747. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71748. /**
  71749. * Returns the Path3D array of successive Vector3 designing its curve.
  71750. * @returns the Path3D array of successive Vector3 designing its curve.
  71751. */
  71752. getCurve(): Vector3[];
  71753. /**
  71754. * Returns an array populated with tangent vectors on each Path3D curve point.
  71755. * @returns an array populated with tangent vectors on each Path3D curve point.
  71756. */
  71757. getTangents(): Vector3[];
  71758. /**
  71759. * Returns an array populated with normal vectors on each Path3D curve point.
  71760. * @returns an array populated with normal vectors on each Path3D curve point.
  71761. */
  71762. getNormals(): Vector3[];
  71763. /**
  71764. * Returns an array populated with binormal vectors on each Path3D curve point.
  71765. * @returns an array populated with binormal vectors on each Path3D curve point.
  71766. */
  71767. getBinormals(): Vector3[];
  71768. /**
  71769. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71770. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71771. */
  71772. getDistances(): number[];
  71773. /**
  71774. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71775. * @param path path which all values are copied into the curves points
  71776. * @param firstNormal which should be projected onto the curve
  71777. * @returns the same object updated.
  71778. */
  71779. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71780. private _compute;
  71781. private _getFirstNonNullVector;
  71782. private _getLastNonNullVector;
  71783. private _normalVector;
  71784. }
  71785. /**
  71786. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71787. * A Curve3 is designed from a series of successive Vector3.
  71788. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71789. */
  71790. export class Curve3 {
  71791. private _points;
  71792. private _length;
  71793. /**
  71794. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71795. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71796. * @param v1 (Vector3) the control point
  71797. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71798. * @param nbPoints (integer) the wanted number of points in the curve
  71799. * @returns the created Curve3
  71800. */
  71801. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71802. /**
  71803. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71804. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71805. * @param v1 (Vector3) the first control point
  71806. * @param v2 (Vector3) the second control point
  71807. * @param v3 (Vector3) the end point of the Cubic Bezier
  71808. * @param nbPoints (integer) the wanted number of points in the curve
  71809. * @returns the created Curve3
  71810. */
  71811. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71812. /**
  71813. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71814. * @param p1 (Vector3) the origin point of the Hermite Spline
  71815. * @param t1 (Vector3) the tangent vector at the origin point
  71816. * @param p2 (Vector3) the end point of the Hermite Spline
  71817. * @param t2 (Vector3) the tangent vector at the end point
  71818. * @param nbPoints (integer) the wanted number of points in the curve
  71819. * @returns the created Curve3
  71820. */
  71821. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71822. /**
  71823. * Returns a Curve3 object along a CatmullRom Spline curve :
  71824. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71825. * @param nbPoints (integer) the wanted number of points between each curve control points
  71826. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71827. * @returns the created Curve3
  71828. */
  71829. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71830. /**
  71831. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71832. * A Curve3 is designed from a series of successive Vector3.
  71833. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71834. * @param points points which make up the curve
  71835. */
  71836. constructor(points: Vector3[]);
  71837. /**
  71838. * @returns the Curve3 stored array of successive Vector3
  71839. */
  71840. getPoints(): Vector3[];
  71841. /**
  71842. * @returns the computed length (float) of the curve.
  71843. */
  71844. length(): number;
  71845. /**
  71846. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71847. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71848. * curveA and curveB keep unchanged.
  71849. * @param curve the curve to continue from this curve
  71850. * @returns the newly constructed curve
  71851. */
  71852. continue(curve: DeepImmutable<Curve3>): Curve3;
  71853. private _computeLength;
  71854. }
  71855. }
  71856. declare module BABYLON {
  71857. /**
  71858. * This represents the main contract an easing function should follow.
  71859. * Easing functions are used throughout the animation system.
  71860. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71861. */
  71862. export interface IEasingFunction {
  71863. /**
  71864. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71865. * of the easing function.
  71866. * The link below provides some of the most common examples of easing functions.
  71867. * @see https://easings.net/
  71868. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71869. * @returns the corresponding value on the curve defined by the easing function
  71870. */
  71871. ease(gradient: number): number;
  71872. }
  71873. /**
  71874. * Base class used for every default easing function.
  71875. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71876. */
  71877. export class EasingFunction implements IEasingFunction {
  71878. /**
  71879. * Interpolation follows the mathematical formula associated with the easing function.
  71880. */
  71881. static readonly EASINGMODE_EASEIN: number;
  71882. /**
  71883. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71884. */
  71885. static readonly EASINGMODE_EASEOUT: number;
  71886. /**
  71887. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71888. */
  71889. static readonly EASINGMODE_EASEINOUT: number;
  71890. private _easingMode;
  71891. /**
  71892. * Sets the easing mode of the current function.
  71893. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71894. */
  71895. setEasingMode(easingMode: number): void;
  71896. /**
  71897. * Gets the current easing mode.
  71898. * @returns the easing mode
  71899. */
  71900. getEasingMode(): number;
  71901. /**
  71902. * @hidden
  71903. */
  71904. easeInCore(gradient: number): number;
  71905. /**
  71906. * Given an input gradient between 0 and 1, this returns the corresponding value
  71907. * of the easing function.
  71908. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71909. * @returns the corresponding value on the curve defined by the easing function
  71910. */
  71911. ease(gradient: number): number;
  71912. }
  71913. /**
  71914. * Easing function with a circle shape (see link below).
  71915. * @see https://easings.net/#easeInCirc
  71916. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71917. */
  71918. export class CircleEase extends EasingFunction implements IEasingFunction {
  71919. /** @hidden */
  71920. easeInCore(gradient: number): number;
  71921. }
  71922. /**
  71923. * Easing function with a ease back shape (see link below).
  71924. * @see https://easings.net/#easeInBack
  71925. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71926. */
  71927. export class BackEase extends EasingFunction implements IEasingFunction {
  71928. /** Defines the amplitude of the function */
  71929. amplitude: number;
  71930. /**
  71931. * Instantiates a back ease easing
  71932. * @see https://easings.net/#easeInBack
  71933. * @param amplitude Defines the amplitude of the function
  71934. */
  71935. constructor(
  71936. /** Defines the amplitude of the function */
  71937. amplitude?: number);
  71938. /** @hidden */
  71939. easeInCore(gradient: number): number;
  71940. }
  71941. /**
  71942. * Easing function with a bouncing shape (see link below).
  71943. * @see https://easings.net/#easeInBounce
  71944. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71945. */
  71946. export class BounceEase extends EasingFunction implements IEasingFunction {
  71947. /** Defines the number of bounces */
  71948. bounces: number;
  71949. /** Defines the amplitude of the bounce */
  71950. bounciness: number;
  71951. /**
  71952. * Instantiates a bounce easing
  71953. * @see https://easings.net/#easeInBounce
  71954. * @param bounces Defines the number of bounces
  71955. * @param bounciness Defines the amplitude of the bounce
  71956. */
  71957. constructor(
  71958. /** Defines the number of bounces */
  71959. bounces?: number,
  71960. /** Defines the amplitude of the bounce */
  71961. bounciness?: number);
  71962. /** @hidden */
  71963. easeInCore(gradient: number): number;
  71964. }
  71965. /**
  71966. * Easing function with a power of 3 shape (see link below).
  71967. * @see https://easings.net/#easeInCubic
  71968. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71969. */
  71970. export class CubicEase extends EasingFunction implements IEasingFunction {
  71971. /** @hidden */
  71972. easeInCore(gradient: number): number;
  71973. }
  71974. /**
  71975. * Easing function with an elastic shape (see link below).
  71976. * @see https://easings.net/#easeInElastic
  71977. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71978. */
  71979. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71980. /** Defines the number of oscillations*/
  71981. oscillations: number;
  71982. /** Defines the amplitude of the oscillations*/
  71983. springiness: number;
  71984. /**
  71985. * Instantiates an elastic easing function
  71986. * @see https://easings.net/#easeInElastic
  71987. * @param oscillations Defines the number of oscillations
  71988. * @param springiness Defines the amplitude of the oscillations
  71989. */
  71990. constructor(
  71991. /** Defines the number of oscillations*/
  71992. oscillations?: number,
  71993. /** Defines the amplitude of the oscillations*/
  71994. springiness?: number);
  71995. /** @hidden */
  71996. easeInCore(gradient: number): number;
  71997. }
  71998. /**
  71999. * Easing function with an exponential shape (see link below).
  72000. * @see https://easings.net/#easeInExpo
  72001. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72002. */
  72003. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72004. /** Defines the exponent of the function */
  72005. exponent: number;
  72006. /**
  72007. * Instantiates an exponential easing function
  72008. * @see https://easings.net/#easeInExpo
  72009. * @param exponent Defines the exponent of the function
  72010. */
  72011. constructor(
  72012. /** Defines the exponent of the function */
  72013. exponent?: number);
  72014. /** @hidden */
  72015. easeInCore(gradient: number): number;
  72016. }
  72017. /**
  72018. * Easing function with a power shape (see link below).
  72019. * @see https://easings.net/#easeInQuad
  72020. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72021. */
  72022. export class PowerEase extends EasingFunction implements IEasingFunction {
  72023. /** Defines the power of the function */
  72024. power: number;
  72025. /**
  72026. * Instantiates an power base easing function
  72027. * @see https://easings.net/#easeInQuad
  72028. * @param power Defines the power of the function
  72029. */
  72030. constructor(
  72031. /** Defines the power of the function */
  72032. power?: number);
  72033. /** @hidden */
  72034. easeInCore(gradient: number): number;
  72035. }
  72036. /**
  72037. * Easing function with a power of 2 shape (see link below).
  72038. * @see https://easings.net/#easeInQuad
  72039. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72040. */
  72041. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72042. /** @hidden */
  72043. easeInCore(gradient: number): number;
  72044. }
  72045. /**
  72046. * Easing function with a power of 4 shape (see link below).
  72047. * @see https://easings.net/#easeInQuart
  72048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72049. */
  72050. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72051. /** @hidden */
  72052. easeInCore(gradient: number): number;
  72053. }
  72054. /**
  72055. * Easing function with a power of 5 shape (see link below).
  72056. * @see https://easings.net/#easeInQuint
  72057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72058. */
  72059. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72060. /** @hidden */
  72061. easeInCore(gradient: number): number;
  72062. }
  72063. /**
  72064. * Easing function with a sin shape (see link below).
  72065. * @see https://easings.net/#easeInSine
  72066. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72067. */
  72068. export class SineEase extends EasingFunction implements IEasingFunction {
  72069. /** @hidden */
  72070. easeInCore(gradient: number): number;
  72071. }
  72072. /**
  72073. * Easing function with a bezier shape (see link below).
  72074. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72075. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72076. */
  72077. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72078. /** Defines the x component of the start tangent in the bezier curve */
  72079. x1: number;
  72080. /** Defines the y component of the start tangent in the bezier curve */
  72081. y1: number;
  72082. /** Defines the x component of the end tangent in the bezier curve */
  72083. x2: number;
  72084. /** Defines the y component of the end tangent in the bezier curve */
  72085. y2: number;
  72086. /**
  72087. * Instantiates a bezier function
  72088. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72089. * @param x1 Defines the x component of the start tangent in the bezier curve
  72090. * @param y1 Defines the y component of the start tangent in the bezier curve
  72091. * @param x2 Defines the x component of the end tangent in the bezier curve
  72092. * @param y2 Defines the y component of the end tangent in the bezier curve
  72093. */
  72094. constructor(
  72095. /** Defines the x component of the start tangent in the bezier curve */
  72096. x1?: number,
  72097. /** Defines the y component of the start tangent in the bezier curve */
  72098. y1?: number,
  72099. /** Defines the x component of the end tangent in the bezier curve */
  72100. x2?: number,
  72101. /** Defines the y component of the end tangent in the bezier curve */
  72102. y2?: number);
  72103. /** @hidden */
  72104. easeInCore(gradient: number): number;
  72105. }
  72106. }
  72107. declare module BABYLON {
  72108. /**
  72109. * Defines an interface which represents an animation key frame
  72110. */
  72111. export interface IAnimationKey {
  72112. /**
  72113. * Frame of the key frame
  72114. */
  72115. frame: number;
  72116. /**
  72117. * Value at the specifies key frame
  72118. */
  72119. value: any;
  72120. /**
  72121. * The input tangent for the cubic hermite spline
  72122. */
  72123. inTangent?: any;
  72124. /**
  72125. * The output tangent for the cubic hermite spline
  72126. */
  72127. outTangent?: any;
  72128. /**
  72129. * The animation interpolation type
  72130. */
  72131. interpolation?: AnimationKeyInterpolation;
  72132. }
  72133. /**
  72134. * Enum for the animation key frame interpolation type
  72135. */
  72136. export enum AnimationKeyInterpolation {
  72137. /**
  72138. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72139. */
  72140. STEP = 1
  72141. }
  72142. }
  72143. declare module BABYLON {
  72144. /**
  72145. * Represents the range of an animation
  72146. */
  72147. export class AnimationRange {
  72148. /**The name of the animation range**/
  72149. name: string;
  72150. /**The starting frame of the animation */
  72151. from: number;
  72152. /**The ending frame of the animation*/
  72153. to: number;
  72154. /**
  72155. * Initializes the range of an animation
  72156. * @param name The name of the animation range
  72157. * @param from The starting frame of the animation
  72158. * @param to The ending frame of the animation
  72159. */
  72160. constructor(
  72161. /**The name of the animation range**/
  72162. name: string,
  72163. /**The starting frame of the animation */
  72164. from: number,
  72165. /**The ending frame of the animation*/
  72166. to: number);
  72167. /**
  72168. * Makes a copy of the animation range
  72169. * @returns A copy of the animation range
  72170. */
  72171. clone(): AnimationRange;
  72172. }
  72173. }
  72174. declare module BABYLON {
  72175. /**
  72176. * Composed of a frame, and an action function
  72177. */
  72178. export class AnimationEvent {
  72179. /** The frame for which the event is triggered **/
  72180. frame: number;
  72181. /** The event to perform when triggered **/
  72182. action: (currentFrame: number) => void;
  72183. /** Specifies if the event should be triggered only once**/
  72184. onlyOnce?: boolean | undefined;
  72185. /**
  72186. * Specifies if the animation event is done
  72187. */
  72188. isDone: boolean;
  72189. /**
  72190. * Initializes the animation event
  72191. * @param frame The frame for which the event is triggered
  72192. * @param action The event to perform when triggered
  72193. * @param onlyOnce Specifies if the event should be triggered only once
  72194. */
  72195. constructor(
  72196. /** The frame for which the event is triggered **/
  72197. frame: number,
  72198. /** The event to perform when triggered **/
  72199. action: (currentFrame: number) => void,
  72200. /** Specifies if the event should be triggered only once**/
  72201. onlyOnce?: boolean | undefined);
  72202. /** @hidden */
  72203. _clone(): AnimationEvent;
  72204. }
  72205. }
  72206. declare module BABYLON {
  72207. /**
  72208. * Interface used to define a behavior
  72209. */
  72210. export interface Behavior<T> {
  72211. /** gets or sets behavior's name */
  72212. name: string;
  72213. /**
  72214. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72215. */
  72216. init(): void;
  72217. /**
  72218. * Called when the behavior is attached to a target
  72219. * @param target defines the target where the behavior is attached to
  72220. */
  72221. attach(target: T): void;
  72222. /**
  72223. * Called when the behavior is detached from its target
  72224. */
  72225. detach(): void;
  72226. }
  72227. /**
  72228. * Interface implemented by classes supporting behaviors
  72229. */
  72230. export interface IBehaviorAware<T> {
  72231. /**
  72232. * Attach a behavior
  72233. * @param behavior defines the behavior to attach
  72234. * @returns the current host
  72235. */
  72236. addBehavior(behavior: Behavior<T>): T;
  72237. /**
  72238. * Remove a behavior from the current object
  72239. * @param behavior defines the behavior to detach
  72240. * @returns the current host
  72241. */
  72242. removeBehavior(behavior: Behavior<T>): T;
  72243. /**
  72244. * Gets a behavior using its name to search
  72245. * @param name defines the name to search
  72246. * @returns the behavior or null if not found
  72247. */
  72248. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72249. }
  72250. }
  72251. declare module BABYLON {
  72252. /**
  72253. * Defines an array and its length.
  72254. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72255. */
  72256. export interface ISmartArrayLike<T> {
  72257. /**
  72258. * The data of the array.
  72259. */
  72260. data: Array<T>;
  72261. /**
  72262. * The active length of the array.
  72263. */
  72264. length: number;
  72265. }
  72266. /**
  72267. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72268. */
  72269. export class SmartArray<T> implements ISmartArrayLike<T> {
  72270. /**
  72271. * The full set of data from the array.
  72272. */
  72273. data: Array<T>;
  72274. /**
  72275. * The active length of the array.
  72276. */
  72277. length: number;
  72278. protected _id: number;
  72279. /**
  72280. * Instantiates a Smart Array.
  72281. * @param capacity defines the default capacity of the array.
  72282. */
  72283. constructor(capacity: number);
  72284. /**
  72285. * Pushes a value at the end of the active data.
  72286. * @param value defines the object to push in the array.
  72287. */
  72288. push(value: T): void;
  72289. /**
  72290. * Iterates over the active data and apply the lambda to them.
  72291. * @param func defines the action to apply on each value.
  72292. */
  72293. forEach(func: (content: T) => void): void;
  72294. /**
  72295. * Sorts the full sets of data.
  72296. * @param compareFn defines the comparison function to apply.
  72297. */
  72298. sort(compareFn: (a: T, b: T) => number): void;
  72299. /**
  72300. * Resets the active data to an empty array.
  72301. */
  72302. reset(): void;
  72303. /**
  72304. * Releases all the data from the array as well as the array.
  72305. */
  72306. dispose(): void;
  72307. /**
  72308. * Concats the active data with a given array.
  72309. * @param array defines the data to concatenate with.
  72310. */
  72311. concat(array: any): void;
  72312. /**
  72313. * Returns the position of a value in the active data.
  72314. * @param value defines the value to find the index for
  72315. * @returns the index if found in the active data otherwise -1
  72316. */
  72317. indexOf(value: T): number;
  72318. /**
  72319. * Returns whether an element is part of the active data.
  72320. * @param value defines the value to look for
  72321. * @returns true if found in the active data otherwise false
  72322. */
  72323. contains(value: T): boolean;
  72324. private static _GlobalId;
  72325. }
  72326. /**
  72327. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72328. * The data in this array can only be present once
  72329. */
  72330. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72331. private _duplicateId;
  72332. /**
  72333. * Pushes a value at the end of the active data.
  72334. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72335. * @param value defines the object to push in the array.
  72336. */
  72337. push(value: T): void;
  72338. /**
  72339. * Pushes a value at the end of the active data.
  72340. * If the data is already present, it won t be added again
  72341. * @param value defines the object to push in the array.
  72342. * @returns true if added false if it was already present
  72343. */
  72344. pushNoDuplicate(value: T): boolean;
  72345. /**
  72346. * Resets the active data to an empty array.
  72347. */
  72348. reset(): void;
  72349. /**
  72350. * Concats the active data with a given array.
  72351. * This ensures no dupplicate will be present in the result.
  72352. * @param array defines the data to concatenate with.
  72353. */
  72354. concatWithNoDuplicate(array: any): void;
  72355. }
  72356. }
  72357. declare module BABYLON {
  72358. /**
  72359. * @ignore
  72360. * This is a list of all the different input types that are available in the application.
  72361. * Fo instance: ArcRotateCameraGamepadInput...
  72362. */
  72363. export var CameraInputTypes: {};
  72364. /**
  72365. * This is the contract to implement in order to create a new input class.
  72366. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72367. */
  72368. export interface ICameraInput<TCamera extends Camera> {
  72369. /**
  72370. * Defines the camera the input is attached to.
  72371. */
  72372. camera: Nullable<TCamera>;
  72373. /**
  72374. * Gets the class name of the current intput.
  72375. * @returns the class name
  72376. */
  72377. getClassName(): string;
  72378. /**
  72379. * Get the friendly name associated with the input class.
  72380. * @returns the input friendly name
  72381. */
  72382. getSimpleName(): string;
  72383. /**
  72384. * Attach the input controls to a specific dom element to get the input from.
  72385. * @param element Defines the element the controls should be listened from
  72386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72387. */
  72388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72389. /**
  72390. * Detach the current controls from the specified dom element.
  72391. * @param element Defines the element to stop listening the inputs from
  72392. */
  72393. detachControl(element: Nullable<HTMLElement>): void;
  72394. /**
  72395. * Update the current camera state depending on the inputs that have been used this frame.
  72396. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72397. */
  72398. checkInputs?: () => void;
  72399. }
  72400. /**
  72401. * Represents a map of input types to input instance or input index to input instance.
  72402. */
  72403. export interface CameraInputsMap<TCamera extends Camera> {
  72404. /**
  72405. * Accessor to the input by input type.
  72406. */
  72407. [name: string]: ICameraInput<TCamera>;
  72408. /**
  72409. * Accessor to the input by input index.
  72410. */
  72411. [idx: number]: ICameraInput<TCamera>;
  72412. }
  72413. /**
  72414. * This represents the input manager used within a camera.
  72415. * It helps dealing with all the different kind of input attached to a camera.
  72416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72417. */
  72418. export class CameraInputsManager<TCamera extends Camera> {
  72419. /**
  72420. * Defines the list of inputs attahed to the camera.
  72421. */
  72422. attached: CameraInputsMap<TCamera>;
  72423. /**
  72424. * Defines the dom element the camera is collecting inputs from.
  72425. * This is null if the controls have not been attached.
  72426. */
  72427. attachedElement: Nullable<HTMLElement>;
  72428. /**
  72429. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72430. */
  72431. noPreventDefault: boolean;
  72432. /**
  72433. * Defined the camera the input manager belongs to.
  72434. */
  72435. camera: TCamera;
  72436. /**
  72437. * Update the current camera state depending on the inputs that have been used this frame.
  72438. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72439. */
  72440. checkInputs: () => void;
  72441. /**
  72442. * Instantiate a new Camera Input Manager.
  72443. * @param camera Defines the camera the input manager blongs to
  72444. */
  72445. constructor(camera: TCamera);
  72446. /**
  72447. * Add an input method to a camera
  72448. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72449. * @param input camera input method
  72450. */
  72451. add(input: ICameraInput<TCamera>): void;
  72452. /**
  72453. * Remove a specific input method from a camera
  72454. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72455. * @param inputToRemove camera input method
  72456. */
  72457. remove(inputToRemove: ICameraInput<TCamera>): void;
  72458. /**
  72459. * Remove a specific input type from a camera
  72460. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72461. * @param inputType the type of the input to remove
  72462. */
  72463. removeByType(inputType: string): void;
  72464. private _addCheckInputs;
  72465. /**
  72466. * Attach the input controls to the currently attached dom element to listen the events from.
  72467. * @param input Defines the input to attach
  72468. */
  72469. attachInput(input: ICameraInput<TCamera>): void;
  72470. /**
  72471. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72472. * @param element Defines the dom element to collect the events from
  72473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72474. */
  72475. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72476. /**
  72477. * Detach the current manager inputs controls from a specific dom element.
  72478. * @param element Defines the dom element to collect the events from
  72479. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72480. */
  72481. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72482. /**
  72483. * Rebuild the dynamic inputCheck function from the current list of
  72484. * defined inputs in the manager.
  72485. */
  72486. rebuildInputCheck(): void;
  72487. /**
  72488. * Remove all attached input methods from a camera
  72489. */
  72490. clear(): void;
  72491. /**
  72492. * Serialize the current input manager attached to a camera.
  72493. * This ensures than once parsed,
  72494. * the input associated to the camera will be identical to the current ones
  72495. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72496. */
  72497. serialize(serializedCamera: any): void;
  72498. /**
  72499. * Parses an input manager serialized JSON to restore the previous list of inputs
  72500. * and states associated to a camera.
  72501. * @param parsedCamera Defines the JSON to parse
  72502. */
  72503. parse(parsedCamera: any): void;
  72504. }
  72505. }
  72506. declare module BABYLON {
  72507. /**
  72508. * @hidden
  72509. */
  72510. export class IntersectionInfo {
  72511. bu: Nullable<number>;
  72512. bv: Nullable<number>;
  72513. distance: number;
  72514. faceId: number;
  72515. subMeshId: number;
  72516. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72517. }
  72518. }
  72519. declare module BABYLON {
  72520. /**
  72521. * Represens a plane by the equation ax + by + cz + d = 0
  72522. */
  72523. export class Plane {
  72524. private static _TmpMatrix;
  72525. /**
  72526. * Normal of the plane (a,b,c)
  72527. */
  72528. normal: Vector3;
  72529. /**
  72530. * d component of the plane
  72531. */
  72532. d: number;
  72533. /**
  72534. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72535. * @param a a component of the plane
  72536. * @param b b component of the plane
  72537. * @param c c component of the plane
  72538. * @param d d component of the plane
  72539. */
  72540. constructor(a: number, b: number, c: number, d: number);
  72541. /**
  72542. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72543. */
  72544. asArray(): number[];
  72545. /**
  72546. * @returns a new plane copied from the current Plane.
  72547. */
  72548. clone(): Plane;
  72549. /**
  72550. * @returns the string "Plane".
  72551. */
  72552. getClassName(): string;
  72553. /**
  72554. * @returns the Plane hash code.
  72555. */
  72556. getHashCode(): number;
  72557. /**
  72558. * Normalize the current Plane in place.
  72559. * @returns the updated Plane.
  72560. */
  72561. normalize(): Plane;
  72562. /**
  72563. * Applies a transformation the plane and returns the result
  72564. * @param transformation the transformation matrix to be applied to the plane
  72565. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72566. */
  72567. transform(transformation: DeepImmutable<Matrix>): Plane;
  72568. /**
  72569. * Calcualtte the dot product between the point and the plane normal
  72570. * @param point point to calculate the dot product with
  72571. * @returns the dot product (float) of the point coordinates and the plane normal.
  72572. */
  72573. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72574. /**
  72575. * Updates the current Plane from the plane defined by the three given points.
  72576. * @param point1 one of the points used to contruct the plane
  72577. * @param point2 one of the points used to contruct the plane
  72578. * @param point3 one of the points used to contruct the plane
  72579. * @returns the updated Plane.
  72580. */
  72581. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72582. /**
  72583. * Checks if the plane is facing a given direction
  72584. * @param direction the direction to check if the plane is facing
  72585. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72586. * @returns True is the vector "direction" is the same side than the plane normal.
  72587. */
  72588. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72589. /**
  72590. * Calculates the distance to a point
  72591. * @param point point to calculate distance to
  72592. * @returns the signed distance (float) from the given point to the Plane.
  72593. */
  72594. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72595. /**
  72596. * Creates a plane from an array
  72597. * @param array the array to create a plane from
  72598. * @returns a new Plane from the given array.
  72599. */
  72600. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72601. /**
  72602. * Creates a plane from three points
  72603. * @param point1 point used to create the plane
  72604. * @param point2 point used to create the plane
  72605. * @param point3 point used to create the plane
  72606. * @returns a new Plane defined by the three given points.
  72607. */
  72608. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72609. /**
  72610. * Creates a plane from an origin point and a normal
  72611. * @param origin origin of the plane to be constructed
  72612. * @param normal normal of the plane to be constructed
  72613. * @returns a new Plane the normal vector to this plane at the given origin point.
  72614. * Note : the vector "normal" is updated because normalized.
  72615. */
  72616. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72617. /**
  72618. * Calculates the distance from a plane and a point
  72619. * @param origin origin of the plane to be constructed
  72620. * @param normal normal of the plane to be constructed
  72621. * @param point point to calculate distance to
  72622. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72623. */
  72624. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72625. }
  72626. }
  72627. declare module BABYLON {
  72628. /**
  72629. * Class used to store bounding sphere information
  72630. */
  72631. export class BoundingSphere {
  72632. /**
  72633. * Gets the center of the bounding sphere in local space
  72634. */
  72635. readonly center: Vector3;
  72636. /**
  72637. * Radius of the bounding sphere in local space
  72638. */
  72639. radius: number;
  72640. /**
  72641. * Gets the center of the bounding sphere in world space
  72642. */
  72643. readonly centerWorld: Vector3;
  72644. /**
  72645. * Radius of the bounding sphere in world space
  72646. */
  72647. radiusWorld: number;
  72648. /**
  72649. * Gets the minimum vector in local space
  72650. */
  72651. readonly minimum: Vector3;
  72652. /**
  72653. * Gets the maximum vector in local space
  72654. */
  72655. readonly maximum: Vector3;
  72656. private _worldMatrix;
  72657. private static readonly TmpVector3;
  72658. /**
  72659. * Creates a new bounding sphere
  72660. * @param min defines the minimum vector (in local space)
  72661. * @param max defines the maximum vector (in local space)
  72662. * @param worldMatrix defines the new world matrix
  72663. */
  72664. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72665. /**
  72666. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72667. * @param min defines the new minimum vector (in local space)
  72668. * @param max defines the new maximum vector (in local space)
  72669. * @param worldMatrix defines the new world matrix
  72670. */
  72671. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72672. /**
  72673. * Scale the current bounding sphere by applying a scale factor
  72674. * @param factor defines the scale factor to apply
  72675. * @returns the current bounding box
  72676. */
  72677. scale(factor: number): BoundingSphere;
  72678. /**
  72679. * Gets the world matrix of the bounding box
  72680. * @returns a matrix
  72681. */
  72682. getWorldMatrix(): DeepImmutable<Matrix>;
  72683. /** @hidden */
  72684. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72685. /**
  72686. * Tests if the bounding sphere is intersecting the frustum planes
  72687. * @param frustumPlanes defines the frustum planes to test
  72688. * @returns true if there is an intersection
  72689. */
  72690. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72691. /**
  72692. * Tests if the bounding sphere center is in between the frustum planes.
  72693. * Used for optimistic fast inclusion.
  72694. * @param frustumPlanes defines the frustum planes to test
  72695. * @returns true if the sphere center is in between the frustum planes
  72696. */
  72697. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72698. /**
  72699. * Tests if a point is inside the bounding sphere
  72700. * @param point defines the point to test
  72701. * @returns true if the point is inside the bounding sphere
  72702. */
  72703. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72704. /**
  72705. * Checks if two sphere intersct
  72706. * @param sphere0 sphere 0
  72707. * @param sphere1 sphere 1
  72708. * @returns true if the speres intersect
  72709. */
  72710. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72711. }
  72712. }
  72713. declare module BABYLON {
  72714. /**
  72715. * Class used to store bounding box information
  72716. */
  72717. export class BoundingBox implements ICullable {
  72718. /**
  72719. * Gets the 8 vectors representing the bounding box in local space
  72720. */
  72721. readonly vectors: Vector3[];
  72722. /**
  72723. * Gets the center of the bounding box in local space
  72724. */
  72725. readonly center: Vector3;
  72726. /**
  72727. * Gets the center of the bounding box in world space
  72728. */
  72729. readonly centerWorld: Vector3;
  72730. /**
  72731. * Gets the extend size in local space
  72732. */
  72733. readonly extendSize: Vector3;
  72734. /**
  72735. * Gets the extend size in world space
  72736. */
  72737. readonly extendSizeWorld: Vector3;
  72738. /**
  72739. * Gets the OBB (object bounding box) directions
  72740. */
  72741. readonly directions: Vector3[];
  72742. /**
  72743. * Gets the 8 vectors representing the bounding box in world space
  72744. */
  72745. readonly vectorsWorld: Vector3[];
  72746. /**
  72747. * Gets the minimum vector in world space
  72748. */
  72749. readonly minimumWorld: Vector3;
  72750. /**
  72751. * Gets the maximum vector in world space
  72752. */
  72753. readonly maximumWorld: Vector3;
  72754. /**
  72755. * Gets the minimum vector in local space
  72756. */
  72757. readonly minimum: Vector3;
  72758. /**
  72759. * Gets the maximum vector in local space
  72760. */
  72761. readonly maximum: Vector3;
  72762. private _worldMatrix;
  72763. private static readonly TmpVector3;
  72764. /**
  72765. * @hidden
  72766. */
  72767. _tag: number;
  72768. /**
  72769. * Creates a new bounding box
  72770. * @param min defines the minimum vector (in local space)
  72771. * @param max defines the maximum vector (in local space)
  72772. * @param worldMatrix defines the new world matrix
  72773. */
  72774. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72775. /**
  72776. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72777. * @param min defines the new minimum vector (in local space)
  72778. * @param max defines the new maximum vector (in local space)
  72779. * @param worldMatrix defines the new world matrix
  72780. */
  72781. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72782. /**
  72783. * Scale the current bounding box by applying a scale factor
  72784. * @param factor defines the scale factor to apply
  72785. * @returns the current bounding box
  72786. */
  72787. scale(factor: number): BoundingBox;
  72788. /**
  72789. * Gets the world matrix of the bounding box
  72790. * @returns a matrix
  72791. */
  72792. getWorldMatrix(): DeepImmutable<Matrix>;
  72793. /** @hidden */
  72794. _update(world: DeepImmutable<Matrix>): void;
  72795. /**
  72796. * Tests if the bounding box is intersecting the frustum planes
  72797. * @param frustumPlanes defines the frustum planes to test
  72798. * @returns true if there is an intersection
  72799. */
  72800. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72801. /**
  72802. * Tests if the bounding box is entirely inside the frustum planes
  72803. * @param frustumPlanes defines the frustum planes to test
  72804. * @returns true if there is an inclusion
  72805. */
  72806. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72807. /**
  72808. * Tests if a point is inside the bounding box
  72809. * @param point defines the point to test
  72810. * @returns true if the point is inside the bounding box
  72811. */
  72812. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72813. /**
  72814. * Tests if the bounding box intersects with a bounding sphere
  72815. * @param sphere defines the sphere to test
  72816. * @returns true if there is an intersection
  72817. */
  72818. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72819. /**
  72820. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72821. * @param min defines the min vector to use
  72822. * @param max defines the max vector to use
  72823. * @returns true if there is an intersection
  72824. */
  72825. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72826. /**
  72827. * Tests if two bounding boxes are intersections
  72828. * @param box0 defines the first box to test
  72829. * @param box1 defines the second box to test
  72830. * @returns true if there is an intersection
  72831. */
  72832. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72833. /**
  72834. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72835. * @param minPoint defines the minimum vector of the bounding box
  72836. * @param maxPoint defines the maximum vector of the bounding box
  72837. * @param sphereCenter defines the sphere center
  72838. * @param sphereRadius defines the sphere radius
  72839. * @returns true if there is an intersection
  72840. */
  72841. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72842. /**
  72843. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72844. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72845. * @param frustumPlanes defines the frustum planes to test
  72846. * @return true if there is an inclusion
  72847. */
  72848. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72849. /**
  72850. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72851. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72852. * @param frustumPlanes defines the frustum planes to test
  72853. * @return true if there is an intersection
  72854. */
  72855. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72856. }
  72857. }
  72858. declare module BABYLON {
  72859. /** @hidden */
  72860. export class Collider {
  72861. /** Define if a collision was found */
  72862. collisionFound: boolean;
  72863. /**
  72864. * Define last intersection point in local space
  72865. */
  72866. intersectionPoint: Vector3;
  72867. /**
  72868. * Define last collided mesh
  72869. */
  72870. collidedMesh: Nullable<AbstractMesh>;
  72871. private _collisionPoint;
  72872. private _planeIntersectionPoint;
  72873. private _tempVector;
  72874. private _tempVector2;
  72875. private _tempVector3;
  72876. private _tempVector4;
  72877. private _edge;
  72878. private _baseToVertex;
  72879. private _destinationPoint;
  72880. private _slidePlaneNormal;
  72881. private _displacementVector;
  72882. /** @hidden */
  72883. _radius: Vector3;
  72884. /** @hidden */
  72885. _retry: number;
  72886. private _velocity;
  72887. private _basePoint;
  72888. private _epsilon;
  72889. /** @hidden */
  72890. _velocityWorldLength: number;
  72891. /** @hidden */
  72892. _basePointWorld: Vector3;
  72893. private _velocityWorld;
  72894. private _normalizedVelocity;
  72895. /** @hidden */
  72896. _initialVelocity: Vector3;
  72897. /** @hidden */
  72898. _initialPosition: Vector3;
  72899. private _nearestDistance;
  72900. private _collisionMask;
  72901. collisionMask: number;
  72902. /**
  72903. * Gets the plane normal used to compute the sliding response (in local space)
  72904. */
  72905. readonly slidePlaneNormal: Vector3;
  72906. /** @hidden */
  72907. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72908. /** @hidden */
  72909. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72910. /** @hidden */
  72911. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72912. /** @hidden */
  72913. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72914. /** @hidden */
  72915. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72916. /** @hidden */
  72917. _getResponse(pos: Vector3, vel: Vector3): void;
  72918. }
  72919. }
  72920. declare module BABYLON {
  72921. /**
  72922. * Interface for cullable objects
  72923. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72924. */
  72925. export interface ICullable {
  72926. /**
  72927. * Checks if the object or part of the object is in the frustum
  72928. * @param frustumPlanes Camera near/planes
  72929. * @returns true if the object is in frustum otherwise false
  72930. */
  72931. isInFrustum(frustumPlanes: Plane[]): boolean;
  72932. /**
  72933. * Checks if a cullable object (mesh...) is in the camera frustum
  72934. * Unlike isInFrustum this cheks the full bounding box
  72935. * @param frustumPlanes Camera near/planes
  72936. * @returns true if the object is in frustum otherwise false
  72937. */
  72938. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72939. }
  72940. /**
  72941. * Info for a bounding data of a mesh
  72942. */
  72943. export class BoundingInfo implements ICullable {
  72944. /**
  72945. * Bounding box for the mesh
  72946. */
  72947. readonly boundingBox: BoundingBox;
  72948. /**
  72949. * Bounding sphere for the mesh
  72950. */
  72951. readonly boundingSphere: BoundingSphere;
  72952. private _isLocked;
  72953. private static readonly TmpVector3;
  72954. /**
  72955. * Constructs bounding info
  72956. * @param minimum min vector of the bounding box/sphere
  72957. * @param maximum max vector of the bounding box/sphere
  72958. * @param worldMatrix defines the new world matrix
  72959. */
  72960. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72961. /**
  72962. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72963. * @param min defines the new minimum vector (in local space)
  72964. * @param max defines the new maximum vector (in local space)
  72965. * @param worldMatrix defines the new world matrix
  72966. */
  72967. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72968. /**
  72969. * min vector of the bounding box/sphere
  72970. */
  72971. readonly minimum: Vector3;
  72972. /**
  72973. * max vector of the bounding box/sphere
  72974. */
  72975. readonly maximum: Vector3;
  72976. /**
  72977. * If the info is locked and won't be updated to avoid perf overhead
  72978. */
  72979. isLocked: boolean;
  72980. /**
  72981. * Updates the bounding sphere and box
  72982. * @param world world matrix to be used to update
  72983. */
  72984. update(world: DeepImmutable<Matrix>): void;
  72985. /**
  72986. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72987. * @param center New center of the bounding info
  72988. * @param extend New extend of the bounding info
  72989. * @returns the current bounding info
  72990. */
  72991. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  72992. /**
  72993. * Scale the current bounding info by applying a scale factor
  72994. * @param factor defines the scale factor to apply
  72995. * @returns the current bounding info
  72996. */
  72997. scale(factor: number): BoundingInfo;
  72998. /**
  72999. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73000. * @param frustumPlanes defines the frustum to test
  73001. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73002. * @returns true if the bounding info is in the frustum planes
  73003. */
  73004. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73005. /**
  73006. * Gets the world distance between the min and max points of the bounding box
  73007. */
  73008. readonly diagonalLength: number;
  73009. /**
  73010. * Checks if a cullable object (mesh...) is in the camera frustum
  73011. * Unlike isInFrustum this cheks the full bounding box
  73012. * @param frustumPlanes Camera near/planes
  73013. * @returns true if the object is in frustum otherwise false
  73014. */
  73015. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73016. /** @hidden */
  73017. _checkCollision(collider: Collider): boolean;
  73018. /**
  73019. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73020. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73021. * @param point the point to check intersection with
  73022. * @returns if the point intersects
  73023. */
  73024. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73025. /**
  73026. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73027. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73028. * @param boundingInfo the bounding info to check intersection with
  73029. * @param precise if the intersection should be done using OBB
  73030. * @returns if the bounding info intersects
  73031. */
  73032. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73033. }
  73034. }
  73035. declare module BABYLON {
  73036. /**
  73037. * Extracts minimum and maximum values from a list of indexed positions
  73038. * @param positions defines the positions to use
  73039. * @param indices defines the indices to the positions
  73040. * @param indexStart defines the start index
  73041. * @param indexCount defines the end index
  73042. * @param bias defines bias value to add to the result
  73043. * @return minimum and maximum values
  73044. */
  73045. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73046. minimum: Vector3;
  73047. maximum: Vector3;
  73048. };
  73049. /**
  73050. * Extracts minimum and maximum values from a list of positions
  73051. * @param positions defines the positions to use
  73052. * @param start defines the start index in the positions array
  73053. * @param count defines the number of positions to handle
  73054. * @param bias defines bias value to add to the result
  73055. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73056. * @return minimum and maximum values
  73057. */
  73058. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73059. minimum: Vector3;
  73060. maximum: Vector3;
  73061. };
  73062. }
  73063. declare module BABYLON {
  73064. /**
  73065. * Enum that determines the text-wrapping mode to use.
  73066. */
  73067. export enum InspectableType {
  73068. /**
  73069. * Checkbox for booleans
  73070. */
  73071. Checkbox = 0,
  73072. /**
  73073. * Sliders for numbers
  73074. */
  73075. Slider = 1,
  73076. /**
  73077. * Vector3
  73078. */
  73079. Vector3 = 2,
  73080. /**
  73081. * Quaternions
  73082. */
  73083. Quaternion = 3,
  73084. /**
  73085. * Color3
  73086. */
  73087. Color3 = 4,
  73088. /**
  73089. * String
  73090. */
  73091. String = 5
  73092. }
  73093. /**
  73094. * Interface used to define custom inspectable properties.
  73095. * This interface is used by the inspector to display custom property grids
  73096. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73097. */
  73098. export interface IInspectable {
  73099. /**
  73100. * Gets the label to display
  73101. */
  73102. label: string;
  73103. /**
  73104. * Gets the name of the property to edit
  73105. */
  73106. propertyName: string;
  73107. /**
  73108. * Gets the type of the editor to use
  73109. */
  73110. type: InspectableType;
  73111. /**
  73112. * Gets the minimum value of the property when using in "slider" mode
  73113. */
  73114. min?: number;
  73115. /**
  73116. * Gets the maximum value of the property when using in "slider" mode
  73117. */
  73118. max?: number;
  73119. /**
  73120. * Gets the setp to use when using in "slider" mode
  73121. */
  73122. step?: number;
  73123. }
  73124. }
  73125. declare module BABYLON {
  73126. /**
  73127. * Class used to provide helper for timing
  73128. */
  73129. export class TimingTools {
  73130. /**
  73131. * Polyfill for setImmediate
  73132. * @param action defines the action to execute after the current execution block
  73133. */
  73134. static SetImmediate(action: () => void): void;
  73135. }
  73136. }
  73137. declare module BABYLON {
  73138. /**
  73139. * Class used to enable instatition of objects by class name
  73140. */
  73141. export class InstantiationTools {
  73142. /**
  73143. * Use this object to register external classes like custom textures or material
  73144. * to allow the laoders to instantiate them
  73145. */
  73146. static RegisteredExternalClasses: {
  73147. [key: string]: Object;
  73148. };
  73149. /**
  73150. * Tries to instantiate a new object from a given class name
  73151. * @param className defines the class name to instantiate
  73152. * @returns the new object or null if the system was not able to do the instantiation
  73153. */
  73154. static Instantiate(className: string): any;
  73155. }
  73156. }
  73157. declare module BABYLON {
  73158. /**
  73159. * This represents the required contract to create a new type of texture loader.
  73160. */
  73161. export interface IInternalTextureLoader {
  73162. /**
  73163. * Defines wether the loader supports cascade loading the different faces.
  73164. */
  73165. supportCascades: boolean;
  73166. /**
  73167. * This returns if the loader support the current file information.
  73168. * @param extension defines the file extension of the file being loaded
  73169. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73170. * @param fallback defines the fallback internal texture if any
  73171. * @param isBase64 defines whether the texture is encoded as a base64
  73172. * @param isBuffer defines whether the texture data are stored as a buffer
  73173. * @returns true if the loader can load the specified file
  73174. */
  73175. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73176. /**
  73177. * Transform the url before loading if required.
  73178. * @param rootUrl the url of the texture
  73179. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73180. * @returns the transformed texture
  73181. */
  73182. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73183. /**
  73184. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73185. * @param rootUrl the url of the texture
  73186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73187. * @returns the fallback texture
  73188. */
  73189. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73190. /**
  73191. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73192. * @param data contains the texture data
  73193. * @param texture defines the BabylonJS internal texture
  73194. * @param createPolynomials will be true if polynomials have been requested
  73195. * @param onLoad defines the callback to trigger once the texture is ready
  73196. * @param onError defines the callback to trigger in case of error
  73197. */
  73198. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73199. /**
  73200. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73201. * @param data contains the texture data
  73202. * @param texture defines the BabylonJS internal texture
  73203. * @param callback defines the method to call once ready to upload
  73204. */
  73205. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73206. }
  73207. }
  73208. declare module BABYLON {
  73209. interface Engine {
  73210. /**
  73211. * Creates a depth stencil cube texture.
  73212. * This is only available in WebGL 2.
  73213. * @param size The size of face edge in the cube texture.
  73214. * @param options The options defining the cube texture.
  73215. * @returns The cube texture
  73216. */
  73217. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73218. /**
  73219. * Creates a cube texture
  73220. * @param rootUrl defines the url where the files to load is located
  73221. * @param scene defines the current scene
  73222. * @param files defines the list of files to load (1 per face)
  73223. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73224. * @param onLoad defines an optional callback raised when the texture is loaded
  73225. * @param onError defines an optional callback raised if there is an issue to load the texture
  73226. * @param format defines the format of the data
  73227. * @param forcedExtension defines the extension to use to pick the right loader
  73228. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73229. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73230. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73231. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73232. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73233. * @returns the cube texture as an InternalTexture
  73234. */
  73235. 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;
  73236. /**
  73237. * Creates a cube texture
  73238. * @param rootUrl defines the url where the files to load is located
  73239. * @param scene defines the current scene
  73240. * @param files defines the list of files to load (1 per face)
  73241. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73242. * @param onLoad defines an optional callback raised when the texture is loaded
  73243. * @param onError defines an optional callback raised if there is an issue to load the texture
  73244. * @param format defines the format of the data
  73245. * @param forcedExtension defines the extension to use to pick the right loader
  73246. * @returns the cube texture as an InternalTexture
  73247. */
  73248. 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;
  73249. /**
  73250. * Creates a cube texture
  73251. * @param rootUrl defines the url where the files to load is located
  73252. * @param scene defines the current scene
  73253. * @param files defines the list of files to load (1 per face)
  73254. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73255. * @param onLoad defines an optional callback raised when the texture is loaded
  73256. * @param onError defines an optional callback raised if there is an issue to load the texture
  73257. * @param format defines the format of the data
  73258. * @param forcedExtension defines the extension to use to pick the right loader
  73259. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73260. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73261. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73262. * @returns the cube texture as an InternalTexture
  73263. */
  73264. 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;
  73265. /** @hidden */
  73266. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73267. /** @hidden */
  73268. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73269. /** @hidden */
  73270. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73271. /** @hidden */
  73272. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73273. }
  73274. }
  73275. declare module BABYLON {
  73276. /**
  73277. * Class for creating a cube texture
  73278. */
  73279. export class CubeTexture extends BaseTexture {
  73280. private _delayedOnLoad;
  73281. /**
  73282. * The url of the texture
  73283. */
  73284. url: string;
  73285. /**
  73286. * Gets or sets the center of the bounding box associated with the cube texture.
  73287. * It must define where the camera used to render the texture was set
  73288. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73289. */
  73290. boundingBoxPosition: Vector3;
  73291. private _boundingBoxSize;
  73292. /**
  73293. * Gets or sets the size of the bounding box associated with the cube texture
  73294. * When defined, the cubemap will switch to local mode
  73295. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73296. * @example https://www.babylonjs-playground.com/#RNASML
  73297. */
  73298. /**
  73299. * Returns the bounding box size
  73300. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73301. */
  73302. boundingBoxSize: Vector3;
  73303. protected _rotationY: number;
  73304. /**
  73305. * Sets texture matrix rotation angle around Y axis in radians.
  73306. */
  73307. /**
  73308. * Gets texture matrix rotation angle around Y axis radians.
  73309. */
  73310. rotationY: number;
  73311. /**
  73312. * Are mip maps generated for this texture or not.
  73313. */
  73314. readonly noMipmap: boolean;
  73315. private _noMipmap;
  73316. private _files;
  73317. private _extensions;
  73318. private _textureMatrix;
  73319. private _format;
  73320. private _createPolynomials;
  73321. /** @hidden */
  73322. _prefiltered: boolean;
  73323. /**
  73324. * Creates a cube texture from an array of image urls
  73325. * @param files defines an array of image urls
  73326. * @param scene defines the hosting scene
  73327. * @param noMipmap specifies if mip maps are not used
  73328. * @returns a cube texture
  73329. */
  73330. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73331. /**
  73332. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73333. * @param url defines the url of the prefiltered texture
  73334. * @param scene defines the scene the texture is attached to
  73335. * @param forcedExtension defines the extension of the file if different from the url
  73336. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73337. * @return the prefiltered texture
  73338. */
  73339. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73340. /**
  73341. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73342. * as prefiltered data.
  73343. * @param rootUrl defines the url of the texture or the root name of the six images
  73344. * @param scene defines the scene the texture is attached to
  73345. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73346. * @param noMipmap defines if mipmaps should be created or not
  73347. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73348. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73349. * @param onError defines a callback triggered in case of error during load
  73350. * @param format defines the internal format to use for the texture once loaded
  73351. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73352. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73353. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73354. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73355. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73356. * @return the cube texture
  73357. */
  73358. 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);
  73359. /**
  73360. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73361. */
  73362. readonly isPrefiltered: boolean;
  73363. /**
  73364. * Get the current class name of the texture useful for serialization or dynamic coding.
  73365. * @returns "CubeTexture"
  73366. */
  73367. getClassName(): string;
  73368. /**
  73369. * Update the url (and optional buffer) of this texture if url was null during construction.
  73370. * @param url the url of the texture
  73371. * @param forcedExtension defines the extension to use
  73372. * @param onLoad callback called when the texture is loaded (defaults to null)
  73373. */
  73374. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73375. /**
  73376. * Delays loading of the cube texture
  73377. * @param forcedExtension defines the extension to use
  73378. */
  73379. delayLoad(forcedExtension?: string): void;
  73380. /**
  73381. * Returns the reflection texture matrix
  73382. * @returns the reflection texture matrix
  73383. */
  73384. getReflectionTextureMatrix(): Matrix;
  73385. /**
  73386. * Sets the reflection texture matrix
  73387. * @param value Reflection texture matrix
  73388. */
  73389. setReflectionTextureMatrix(value: Matrix): void;
  73390. /**
  73391. * Parses text to create a cube texture
  73392. * @param parsedTexture define the serialized text to read from
  73393. * @param scene defines the hosting scene
  73394. * @param rootUrl defines the root url of the cube texture
  73395. * @returns a cube texture
  73396. */
  73397. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73398. /**
  73399. * Makes a clone, or deep copy, of the cube texture
  73400. * @returns a new cube texture
  73401. */
  73402. clone(): CubeTexture;
  73403. }
  73404. }
  73405. declare module BABYLON {
  73406. /**
  73407. * Manages the defines for the Material
  73408. */
  73409. export class MaterialDefines {
  73410. /** @hidden */
  73411. protected _keys: string[];
  73412. private _isDirty;
  73413. /** @hidden */
  73414. _renderId: number;
  73415. /** @hidden */
  73416. _areLightsDirty: boolean;
  73417. /** @hidden */
  73418. _areLightsDisposed: boolean;
  73419. /** @hidden */
  73420. _areAttributesDirty: boolean;
  73421. /** @hidden */
  73422. _areTexturesDirty: boolean;
  73423. /** @hidden */
  73424. _areFresnelDirty: boolean;
  73425. /** @hidden */
  73426. _areMiscDirty: boolean;
  73427. /** @hidden */
  73428. _areImageProcessingDirty: boolean;
  73429. /** @hidden */
  73430. _normals: boolean;
  73431. /** @hidden */
  73432. _uvs: boolean;
  73433. /** @hidden */
  73434. _needNormals: boolean;
  73435. /** @hidden */
  73436. _needUVs: boolean;
  73437. [id: string]: any;
  73438. /**
  73439. * Specifies if the material needs to be re-calculated
  73440. */
  73441. readonly isDirty: boolean;
  73442. /**
  73443. * Marks the material to indicate that it has been re-calculated
  73444. */
  73445. markAsProcessed(): void;
  73446. /**
  73447. * Marks the material to indicate that it needs to be re-calculated
  73448. */
  73449. markAsUnprocessed(): void;
  73450. /**
  73451. * Marks the material to indicate all of its defines need to be re-calculated
  73452. */
  73453. markAllAsDirty(): void;
  73454. /**
  73455. * Marks the material to indicate that image processing needs to be re-calculated
  73456. */
  73457. markAsImageProcessingDirty(): void;
  73458. /**
  73459. * Marks the material to indicate the lights need to be re-calculated
  73460. * @param disposed Defines whether the light is dirty due to dispose or not
  73461. */
  73462. markAsLightDirty(disposed?: boolean): void;
  73463. /**
  73464. * Marks the attribute state as changed
  73465. */
  73466. markAsAttributesDirty(): void;
  73467. /**
  73468. * Marks the texture state as changed
  73469. */
  73470. markAsTexturesDirty(): void;
  73471. /**
  73472. * Marks the fresnel state as changed
  73473. */
  73474. markAsFresnelDirty(): void;
  73475. /**
  73476. * Marks the misc state as changed
  73477. */
  73478. markAsMiscDirty(): void;
  73479. /**
  73480. * Rebuilds the material defines
  73481. */
  73482. rebuild(): void;
  73483. /**
  73484. * Specifies if two material defines are equal
  73485. * @param other - A material define instance to compare to
  73486. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73487. */
  73488. isEqual(other: MaterialDefines): boolean;
  73489. /**
  73490. * Clones this instance's defines to another instance
  73491. * @param other - material defines to clone values to
  73492. */
  73493. cloneTo(other: MaterialDefines): void;
  73494. /**
  73495. * Resets the material define values
  73496. */
  73497. reset(): void;
  73498. /**
  73499. * Converts the material define values to a string
  73500. * @returns - String of material define information
  73501. */
  73502. toString(): string;
  73503. }
  73504. }
  73505. declare module BABYLON {
  73506. /**
  73507. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73508. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73509. * 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;
  73510. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73511. */
  73512. export class ColorCurves {
  73513. private _dirty;
  73514. private _tempColor;
  73515. private _globalCurve;
  73516. private _highlightsCurve;
  73517. private _midtonesCurve;
  73518. private _shadowsCurve;
  73519. private _positiveCurve;
  73520. private _negativeCurve;
  73521. private _globalHue;
  73522. private _globalDensity;
  73523. private _globalSaturation;
  73524. private _globalExposure;
  73525. /**
  73526. * Gets the global Hue value.
  73527. * 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).
  73528. */
  73529. /**
  73530. * Sets the global Hue value.
  73531. * 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).
  73532. */
  73533. globalHue: number;
  73534. /**
  73535. * Gets the global Density value.
  73536. * 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.
  73537. * Values less than zero provide a filter of opposite hue.
  73538. */
  73539. /**
  73540. * Sets the global Density value.
  73541. * 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.
  73542. * Values less than zero provide a filter of opposite hue.
  73543. */
  73544. globalDensity: number;
  73545. /**
  73546. * Gets the global Saturation value.
  73547. * 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.
  73548. */
  73549. /**
  73550. * Sets the global Saturation value.
  73551. * 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.
  73552. */
  73553. globalSaturation: number;
  73554. /**
  73555. * Gets the global Exposure value.
  73556. * 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.
  73557. */
  73558. /**
  73559. * Sets the global Exposure value.
  73560. * 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.
  73561. */
  73562. globalExposure: number;
  73563. private _highlightsHue;
  73564. private _highlightsDensity;
  73565. private _highlightsSaturation;
  73566. private _highlightsExposure;
  73567. /**
  73568. * Gets the highlights Hue value.
  73569. * 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).
  73570. */
  73571. /**
  73572. * Sets the highlights Hue value.
  73573. * 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).
  73574. */
  73575. highlightsHue: number;
  73576. /**
  73577. * Gets the highlights Density value.
  73578. * 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.
  73579. * Values less than zero provide a filter of opposite hue.
  73580. */
  73581. /**
  73582. * Sets the highlights Density value.
  73583. * 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.
  73584. * Values less than zero provide a filter of opposite hue.
  73585. */
  73586. highlightsDensity: number;
  73587. /**
  73588. * Gets the highlights Saturation value.
  73589. * 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.
  73590. */
  73591. /**
  73592. * Sets the highlights Saturation value.
  73593. * 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.
  73594. */
  73595. highlightsSaturation: number;
  73596. /**
  73597. * Gets the highlights Exposure value.
  73598. * 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.
  73599. */
  73600. /**
  73601. * Sets the highlights Exposure value.
  73602. * 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.
  73603. */
  73604. highlightsExposure: number;
  73605. private _midtonesHue;
  73606. private _midtonesDensity;
  73607. private _midtonesSaturation;
  73608. private _midtonesExposure;
  73609. /**
  73610. * Gets the midtones Hue value.
  73611. * 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).
  73612. */
  73613. /**
  73614. * Sets the midtones Hue value.
  73615. * 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).
  73616. */
  73617. midtonesHue: number;
  73618. /**
  73619. * Gets the midtones Density value.
  73620. * 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.
  73621. * Values less than zero provide a filter of opposite hue.
  73622. */
  73623. /**
  73624. * Sets the midtones Density value.
  73625. * 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.
  73626. * Values less than zero provide a filter of opposite hue.
  73627. */
  73628. midtonesDensity: number;
  73629. /**
  73630. * Gets the midtones Saturation value.
  73631. * 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.
  73632. */
  73633. /**
  73634. * Sets the midtones Saturation value.
  73635. * 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.
  73636. */
  73637. midtonesSaturation: number;
  73638. /**
  73639. * Gets the midtones Exposure value.
  73640. * 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.
  73641. */
  73642. /**
  73643. * Sets the midtones Exposure value.
  73644. * 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.
  73645. */
  73646. midtonesExposure: number;
  73647. private _shadowsHue;
  73648. private _shadowsDensity;
  73649. private _shadowsSaturation;
  73650. private _shadowsExposure;
  73651. /**
  73652. * Gets the shadows Hue value.
  73653. * 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).
  73654. */
  73655. /**
  73656. * Sets the shadows Hue value.
  73657. * 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).
  73658. */
  73659. shadowsHue: number;
  73660. /**
  73661. * Gets the shadows Density value.
  73662. * 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.
  73663. * Values less than zero provide a filter of opposite hue.
  73664. */
  73665. /**
  73666. * Sets the shadows Density value.
  73667. * 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.
  73668. * Values less than zero provide a filter of opposite hue.
  73669. */
  73670. shadowsDensity: number;
  73671. /**
  73672. * Gets the shadows Saturation value.
  73673. * 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.
  73674. */
  73675. /**
  73676. * Sets the shadows Saturation value.
  73677. * 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.
  73678. */
  73679. shadowsSaturation: number;
  73680. /**
  73681. * Gets the shadows Exposure value.
  73682. * 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.
  73683. */
  73684. /**
  73685. * Sets the shadows Exposure value.
  73686. * 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.
  73687. */
  73688. shadowsExposure: number;
  73689. /**
  73690. * Returns the class name
  73691. * @returns The class name
  73692. */
  73693. getClassName(): string;
  73694. /**
  73695. * Binds the color curves to the shader.
  73696. * @param colorCurves The color curve to bind
  73697. * @param effect The effect to bind to
  73698. * @param positiveUniform The positive uniform shader parameter
  73699. * @param neutralUniform The neutral uniform shader parameter
  73700. * @param negativeUniform The negative uniform shader parameter
  73701. */
  73702. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73703. /**
  73704. * Prepare the list of uniforms associated with the ColorCurves effects.
  73705. * @param uniformsList The list of uniforms used in the effect
  73706. */
  73707. static PrepareUniforms(uniformsList: string[]): void;
  73708. /**
  73709. * Returns color grading data based on a hue, density, saturation and exposure value.
  73710. * @param filterHue The hue of the color filter.
  73711. * @param filterDensity The density of the color filter.
  73712. * @param saturation The saturation.
  73713. * @param exposure The exposure.
  73714. * @param result The result data container.
  73715. */
  73716. private getColorGradingDataToRef;
  73717. /**
  73718. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73719. * @param value The input slider value in range [-100,100].
  73720. * @returns Adjusted value.
  73721. */
  73722. private static applyColorGradingSliderNonlinear;
  73723. /**
  73724. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73725. * @param hue The hue (H) input.
  73726. * @param saturation The saturation (S) input.
  73727. * @param brightness The brightness (B) input.
  73728. * @result An RGBA color represented as Vector4.
  73729. */
  73730. private static fromHSBToRef;
  73731. /**
  73732. * Returns a value clamped between min and max
  73733. * @param value The value to clamp
  73734. * @param min The minimum of value
  73735. * @param max The maximum of value
  73736. * @returns The clamped value.
  73737. */
  73738. private static clamp;
  73739. /**
  73740. * Clones the current color curve instance.
  73741. * @return The cloned curves
  73742. */
  73743. clone(): ColorCurves;
  73744. /**
  73745. * Serializes the current color curve instance to a json representation.
  73746. * @return a JSON representation
  73747. */
  73748. serialize(): any;
  73749. /**
  73750. * Parses the color curve from a json representation.
  73751. * @param source the JSON source to parse
  73752. * @return The parsed curves
  73753. */
  73754. static Parse(source: any): ColorCurves;
  73755. }
  73756. }
  73757. declare module BABYLON {
  73758. /**
  73759. * Interface to follow in your material defines to integrate easily the
  73760. * Image proccessing functions.
  73761. * @hidden
  73762. */
  73763. export interface IImageProcessingConfigurationDefines {
  73764. IMAGEPROCESSING: boolean;
  73765. VIGNETTE: boolean;
  73766. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73767. VIGNETTEBLENDMODEOPAQUE: boolean;
  73768. TONEMAPPING: boolean;
  73769. TONEMAPPING_ACES: boolean;
  73770. CONTRAST: boolean;
  73771. EXPOSURE: boolean;
  73772. COLORCURVES: boolean;
  73773. COLORGRADING: boolean;
  73774. COLORGRADING3D: boolean;
  73775. SAMPLER3DGREENDEPTH: boolean;
  73776. SAMPLER3DBGRMAP: boolean;
  73777. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73778. }
  73779. /**
  73780. * @hidden
  73781. */
  73782. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73783. IMAGEPROCESSING: boolean;
  73784. VIGNETTE: boolean;
  73785. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73786. VIGNETTEBLENDMODEOPAQUE: boolean;
  73787. TONEMAPPING: boolean;
  73788. TONEMAPPING_ACES: boolean;
  73789. CONTRAST: boolean;
  73790. COLORCURVES: boolean;
  73791. COLORGRADING: boolean;
  73792. COLORGRADING3D: boolean;
  73793. SAMPLER3DGREENDEPTH: boolean;
  73794. SAMPLER3DBGRMAP: boolean;
  73795. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73796. EXPOSURE: boolean;
  73797. constructor();
  73798. }
  73799. /**
  73800. * This groups together the common properties used for image processing either in direct forward pass
  73801. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73802. * or not.
  73803. */
  73804. export class ImageProcessingConfiguration {
  73805. /**
  73806. * Default tone mapping applied in BabylonJS.
  73807. */
  73808. static readonly TONEMAPPING_STANDARD: number;
  73809. /**
  73810. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73811. * to other engines rendering to increase portability.
  73812. */
  73813. static readonly TONEMAPPING_ACES: number;
  73814. /**
  73815. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73816. */
  73817. colorCurves: Nullable<ColorCurves>;
  73818. private _colorCurvesEnabled;
  73819. /**
  73820. * Gets wether the color curves effect is enabled.
  73821. */
  73822. /**
  73823. * Sets wether the color curves effect is enabled.
  73824. */
  73825. colorCurvesEnabled: boolean;
  73826. private _colorGradingTexture;
  73827. /**
  73828. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73829. */
  73830. /**
  73831. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73832. */
  73833. colorGradingTexture: Nullable<BaseTexture>;
  73834. private _colorGradingEnabled;
  73835. /**
  73836. * Gets wether the color grading effect is enabled.
  73837. */
  73838. /**
  73839. * Sets wether the color grading effect is enabled.
  73840. */
  73841. colorGradingEnabled: boolean;
  73842. private _colorGradingWithGreenDepth;
  73843. /**
  73844. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73845. */
  73846. /**
  73847. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73848. */
  73849. colorGradingWithGreenDepth: boolean;
  73850. private _colorGradingBGR;
  73851. /**
  73852. * Gets wether the color grading texture contains BGR values.
  73853. */
  73854. /**
  73855. * Sets wether the color grading texture contains BGR values.
  73856. */
  73857. colorGradingBGR: boolean;
  73858. /** @hidden */
  73859. _exposure: number;
  73860. /**
  73861. * Gets the Exposure used in the effect.
  73862. */
  73863. /**
  73864. * Sets the Exposure used in the effect.
  73865. */
  73866. exposure: number;
  73867. private _toneMappingEnabled;
  73868. /**
  73869. * Gets wether the tone mapping effect is enabled.
  73870. */
  73871. /**
  73872. * Sets wether the tone mapping effect is enabled.
  73873. */
  73874. toneMappingEnabled: boolean;
  73875. private _toneMappingType;
  73876. /**
  73877. * Gets the type of tone mapping effect.
  73878. */
  73879. /**
  73880. * Sets the type of tone mapping effect used in BabylonJS.
  73881. */
  73882. toneMappingType: number;
  73883. protected _contrast: number;
  73884. /**
  73885. * Gets the contrast used in the effect.
  73886. */
  73887. /**
  73888. * Sets the contrast used in the effect.
  73889. */
  73890. contrast: number;
  73891. /**
  73892. * Vignette stretch size.
  73893. */
  73894. vignetteStretch: number;
  73895. /**
  73896. * Vignette centre X Offset.
  73897. */
  73898. vignetteCentreX: number;
  73899. /**
  73900. * Vignette centre Y Offset.
  73901. */
  73902. vignetteCentreY: number;
  73903. /**
  73904. * Vignette weight or intensity of the vignette effect.
  73905. */
  73906. vignetteWeight: number;
  73907. /**
  73908. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73909. * if vignetteEnabled is set to true.
  73910. */
  73911. vignetteColor: Color4;
  73912. /**
  73913. * Camera field of view used by the Vignette effect.
  73914. */
  73915. vignetteCameraFov: number;
  73916. private _vignetteBlendMode;
  73917. /**
  73918. * Gets the vignette blend mode allowing different kind of effect.
  73919. */
  73920. /**
  73921. * Sets the vignette blend mode allowing different kind of effect.
  73922. */
  73923. vignetteBlendMode: number;
  73924. private _vignetteEnabled;
  73925. /**
  73926. * Gets wether the vignette effect is enabled.
  73927. */
  73928. /**
  73929. * Sets wether the vignette effect is enabled.
  73930. */
  73931. vignetteEnabled: boolean;
  73932. private _applyByPostProcess;
  73933. /**
  73934. * Gets wether the image processing is applied through a post process or not.
  73935. */
  73936. /**
  73937. * Sets wether the image processing is applied through a post process or not.
  73938. */
  73939. applyByPostProcess: boolean;
  73940. private _isEnabled;
  73941. /**
  73942. * Gets wether the image processing is enabled or not.
  73943. */
  73944. /**
  73945. * Sets wether the image processing is enabled or not.
  73946. */
  73947. isEnabled: boolean;
  73948. /**
  73949. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73950. */
  73951. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73952. /**
  73953. * Method called each time the image processing information changes requires to recompile the effect.
  73954. */
  73955. protected _updateParameters(): void;
  73956. /**
  73957. * Gets the current class name.
  73958. * @return "ImageProcessingConfiguration"
  73959. */
  73960. getClassName(): string;
  73961. /**
  73962. * Prepare the list of uniforms associated with the Image Processing effects.
  73963. * @param uniforms The list of uniforms used in the effect
  73964. * @param defines the list of defines currently in use
  73965. */
  73966. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73967. /**
  73968. * Prepare the list of samplers associated with the Image Processing effects.
  73969. * @param samplersList The list of uniforms used in the effect
  73970. * @param defines the list of defines currently in use
  73971. */
  73972. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73973. /**
  73974. * Prepare the list of defines associated to the shader.
  73975. * @param defines the list of defines to complete
  73976. * @param forPostProcess Define if we are currently in post process mode or not
  73977. */
  73978. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73979. /**
  73980. * Returns true if all the image processing information are ready.
  73981. * @returns True if ready, otherwise, false
  73982. */
  73983. isReady(): boolean;
  73984. /**
  73985. * Binds the image processing to the shader.
  73986. * @param effect The effect to bind to
  73987. * @param aspectRatio Define the current aspect ratio of the effect
  73988. */
  73989. bind(effect: Effect, aspectRatio?: number): void;
  73990. /**
  73991. * Clones the current image processing instance.
  73992. * @return The cloned image processing
  73993. */
  73994. clone(): ImageProcessingConfiguration;
  73995. /**
  73996. * Serializes the current image processing instance to a json representation.
  73997. * @return a JSON representation
  73998. */
  73999. serialize(): any;
  74000. /**
  74001. * Parses the image processing from a json representation.
  74002. * @param source the JSON source to parse
  74003. * @return The parsed image processing
  74004. */
  74005. static Parse(source: any): ImageProcessingConfiguration;
  74006. private static _VIGNETTEMODE_MULTIPLY;
  74007. private static _VIGNETTEMODE_OPAQUE;
  74008. /**
  74009. * Used to apply the vignette as a mix with the pixel color.
  74010. */
  74011. static readonly VIGNETTEMODE_MULTIPLY: number;
  74012. /**
  74013. * Used to apply the vignette as a replacement of the pixel color.
  74014. */
  74015. static readonly VIGNETTEMODE_OPAQUE: number;
  74016. }
  74017. }
  74018. declare module BABYLON {
  74019. /** @hidden */
  74020. export var postprocessVertexShader: {
  74021. name: string;
  74022. shader: string;
  74023. };
  74024. }
  74025. declare module BABYLON {
  74026. /** Defines supported spaces */
  74027. export enum Space {
  74028. /** Local (object) space */
  74029. LOCAL = 0,
  74030. /** World space */
  74031. WORLD = 1,
  74032. /** Bone space */
  74033. BONE = 2
  74034. }
  74035. /** Defines the 3 main axes */
  74036. export class Axis {
  74037. /** X axis */
  74038. static X: Vector3;
  74039. /** Y axis */
  74040. static Y: Vector3;
  74041. /** Z axis */
  74042. static Z: Vector3;
  74043. }
  74044. }
  74045. declare module BABYLON {
  74046. /**
  74047. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74048. * This is the base of the follow, arc rotate cameras and Free camera
  74049. * @see http://doc.babylonjs.com/features/cameras
  74050. */
  74051. export class TargetCamera extends Camera {
  74052. private static _RigCamTransformMatrix;
  74053. private static _TargetTransformMatrix;
  74054. private static _TargetFocalPoint;
  74055. /**
  74056. * Define the current direction the camera is moving to
  74057. */
  74058. cameraDirection: Vector3;
  74059. /**
  74060. * Define the current rotation the camera is rotating to
  74061. */
  74062. cameraRotation: Vector2;
  74063. /**
  74064. * When set, the up vector of the camera will be updated by the rotation of the camera
  74065. */
  74066. updateUpVectorFromRotation: boolean;
  74067. private _tmpQuaternion;
  74068. /**
  74069. * Define the current rotation of the camera
  74070. */
  74071. rotation: Vector3;
  74072. /**
  74073. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74074. */
  74075. rotationQuaternion: Quaternion;
  74076. /**
  74077. * Define the current speed of the camera
  74078. */
  74079. speed: number;
  74080. /**
  74081. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74082. * around all axis.
  74083. */
  74084. noRotationConstraint: boolean;
  74085. /**
  74086. * Define the current target of the camera as an object or a position.
  74087. */
  74088. lockedTarget: any;
  74089. /** @hidden */
  74090. _currentTarget: Vector3;
  74091. /** @hidden */
  74092. _initialFocalDistance: number;
  74093. /** @hidden */
  74094. _viewMatrix: Matrix;
  74095. /** @hidden */
  74096. _camMatrix: Matrix;
  74097. /** @hidden */
  74098. _cameraTransformMatrix: Matrix;
  74099. /** @hidden */
  74100. _cameraRotationMatrix: Matrix;
  74101. /** @hidden */
  74102. _referencePoint: Vector3;
  74103. /** @hidden */
  74104. _transformedReferencePoint: Vector3;
  74105. protected _globalCurrentTarget: Vector3;
  74106. protected _globalCurrentUpVector: Vector3;
  74107. /** @hidden */
  74108. _reset: () => void;
  74109. private _defaultUp;
  74110. /**
  74111. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74112. * This is the base of the follow, arc rotate cameras and Free camera
  74113. * @see http://doc.babylonjs.com/features/cameras
  74114. * @param name Defines the name of the camera in the scene
  74115. * @param position Defines the start position of the camera in the scene
  74116. * @param scene Defines the scene the camera belongs to
  74117. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74118. */
  74119. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74120. /**
  74121. * Gets the position in front of the camera at a given distance.
  74122. * @param distance The distance from the camera we want the position to be
  74123. * @returns the position
  74124. */
  74125. getFrontPosition(distance: number): Vector3;
  74126. /** @hidden */
  74127. _getLockedTargetPosition(): Nullable<Vector3>;
  74128. private _storedPosition;
  74129. private _storedRotation;
  74130. private _storedRotationQuaternion;
  74131. /**
  74132. * Store current camera state of the camera (fov, position, rotation, etc..)
  74133. * @returns the camera
  74134. */
  74135. storeState(): Camera;
  74136. /**
  74137. * Restored camera state. You must call storeState() first
  74138. * @returns whether it was successful or not
  74139. * @hidden
  74140. */
  74141. _restoreStateValues(): boolean;
  74142. /** @hidden */
  74143. _initCache(): void;
  74144. /** @hidden */
  74145. _updateCache(ignoreParentClass?: boolean): void;
  74146. /** @hidden */
  74147. _isSynchronizedViewMatrix(): boolean;
  74148. /** @hidden */
  74149. _computeLocalCameraSpeed(): number;
  74150. /**
  74151. * Defines the target the camera should look at.
  74152. * @param target Defines the new target as a Vector or a mesh
  74153. */
  74154. setTarget(target: Vector3): void;
  74155. /**
  74156. * Return the current target position of the camera. This value is expressed in local space.
  74157. * @returns the target position
  74158. */
  74159. getTarget(): Vector3;
  74160. /** @hidden */
  74161. _decideIfNeedsToMove(): boolean;
  74162. /** @hidden */
  74163. _updatePosition(): void;
  74164. /** @hidden */
  74165. _checkInputs(): void;
  74166. protected _updateCameraRotationMatrix(): void;
  74167. /**
  74168. * 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)
  74169. * @returns the current camera
  74170. */
  74171. private _rotateUpVectorWithCameraRotationMatrix;
  74172. private _cachedRotationZ;
  74173. private _cachedQuaternionRotationZ;
  74174. /** @hidden */
  74175. _getViewMatrix(): Matrix;
  74176. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74177. /**
  74178. * @hidden
  74179. */
  74180. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74181. /**
  74182. * @hidden
  74183. */
  74184. _updateRigCameras(): void;
  74185. private _getRigCamPositionAndTarget;
  74186. /**
  74187. * Gets the current object class name.
  74188. * @return the class name
  74189. */
  74190. getClassName(): string;
  74191. }
  74192. }
  74193. declare module BABYLON {
  74194. /**
  74195. * Gather the list of keyboard event types as constants.
  74196. */
  74197. export class KeyboardEventTypes {
  74198. /**
  74199. * The keydown event is fired when a key becomes active (pressed).
  74200. */
  74201. static readonly KEYDOWN: number;
  74202. /**
  74203. * The keyup event is fired when a key has been released.
  74204. */
  74205. static readonly KEYUP: number;
  74206. }
  74207. /**
  74208. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74209. */
  74210. export class KeyboardInfo {
  74211. /**
  74212. * Defines the type of event (KeyboardEventTypes)
  74213. */
  74214. type: number;
  74215. /**
  74216. * Defines the related dom event
  74217. */
  74218. event: KeyboardEvent;
  74219. /**
  74220. * Instantiates a new keyboard info.
  74221. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74222. * @param type Defines the type of event (KeyboardEventTypes)
  74223. * @param event Defines the related dom event
  74224. */
  74225. constructor(
  74226. /**
  74227. * Defines the type of event (KeyboardEventTypes)
  74228. */
  74229. type: number,
  74230. /**
  74231. * Defines the related dom event
  74232. */
  74233. event: KeyboardEvent);
  74234. }
  74235. /**
  74236. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74237. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74238. */
  74239. export class KeyboardInfoPre extends KeyboardInfo {
  74240. /**
  74241. * Defines the type of event (KeyboardEventTypes)
  74242. */
  74243. type: number;
  74244. /**
  74245. * Defines the related dom event
  74246. */
  74247. event: KeyboardEvent;
  74248. /**
  74249. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74250. */
  74251. skipOnPointerObservable: boolean;
  74252. /**
  74253. * Instantiates a new keyboard pre info.
  74254. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74255. * @param type Defines the type of event (KeyboardEventTypes)
  74256. * @param event Defines the related dom event
  74257. */
  74258. constructor(
  74259. /**
  74260. * Defines the type of event (KeyboardEventTypes)
  74261. */
  74262. type: number,
  74263. /**
  74264. * Defines the related dom event
  74265. */
  74266. event: KeyboardEvent);
  74267. }
  74268. }
  74269. declare module BABYLON {
  74270. /**
  74271. * Manage the keyboard inputs to control the movement of a free camera.
  74272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74273. */
  74274. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74275. /**
  74276. * Defines the camera the input is attached to.
  74277. */
  74278. camera: FreeCamera;
  74279. /**
  74280. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74281. */
  74282. keysUp: number[];
  74283. /**
  74284. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74285. */
  74286. keysDown: number[];
  74287. /**
  74288. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74289. */
  74290. keysLeft: number[];
  74291. /**
  74292. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74293. */
  74294. keysRight: number[];
  74295. private _keys;
  74296. private _onCanvasBlurObserver;
  74297. private _onKeyboardObserver;
  74298. private _engine;
  74299. private _scene;
  74300. /**
  74301. * Attach the input controls to a specific dom element to get the input from.
  74302. * @param element Defines the element the controls should be listened from
  74303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74304. */
  74305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74306. /**
  74307. * Detach the current controls from the specified dom element.
  74308. * @param element Defines the element to stop listening the inputs from
  74309. */
  74310. detachControl(element: Nullable<HTMLElement>): void;
  74311. /**
  74312. * Update the current camera state depending on the inputs that have been used this frame.
  74313. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74314. */
  74315. checkInputs(): void;
  74316. /**
  74317. * Gets the class name of the current intput.
  74318. * @returns the class name
  74319. */
  74320. getClassName(): string;
  74321. /** @hidden */
  74322. _onLostFocus(): void;
  74323. /**
  74324. * Get the friendly name associated with the input class.
  74325. * @returns the input friendly name
  74326. */
  74327. getSimpleName(): string;
  74328. }
  74329. }
  74330. declare module BABYLON {
  74331. /**
  74332. * Interface describing all the common properties and methods a shadow light needs to implement.
  74333. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74334. * as well as binding the different shadow properties to the effects.
  74335. */
  74336. export interface IShadowLight extends Light {
  74337. /**
  74338. * The light id in the scene (used in scene.findLighById for instance)
  74339. */
  74340. id: string;
  74341. /**
  74342. * The position the shdow will be casted from.
  74343. */
  74344. position: Vector3;
  74345. /**
  74346. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74347. */
  74348. direction: Vector3;
  74349. /**
  74350. * The transformed position. Position of the light in world space taking parenting in account.
  74351. */
  74352. transformedPosition: Vector3;
  74353. /**
  74354. * The transformed direction. Direction of the light in world space taking parenting in account.
  74355. */
  74356. transformedDirection: Vector3;
  74357. /**
  74358. * The friendly name of the light in the scene.
  74359. */
  74360. name: string;
  74361. /**
  74362. * Defines the shadow projection clipping minimum z value.
  74363. */
  74364. shadowMinZ: number;
  74365. /**
  74366. * Defines the shadow projection clipping maximum z value.
  74367. */
  74368. shadowMaxZ: number;
  74369. /**
  74370. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74371. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74372. */
  74373. computeTransformedInformation(): boolean;
  74374. /**
  74375. * Gets the scene the light belongs to.
  74376. * @returns The scene
  74377. */
  74378. getScene(): Scene;
  74379. /**
  74380. * Callback defining a custom Projection Matrix Builder.
  74381. * This can be used to override the default projection matrix computation.
  74382. */
  74383. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74384. /**
  74385. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74386. * @param matrix The materix to updated with the projection information
  74387. * @param viewMatrix The transform matrix of the light
  74388. * @param renderList The list of mesh to render in the map
  74389. * @returns The current light
  74390. */
  74391. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74392. /**
  74393. * Gets the current depth scale used in ESM.
  74394. * @returns The scale
  74395. */
  74396. getDepthScale(): number;
  74397. /**
  74398. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74399. * @returns true if a cube texture needs to be use
  74400. */
  74401. needCube(): boolean;
  74402. /**
  74403. * Detects if the projection matrix requires to be recomputed this frame.
  74404. * @returns true if it requires to be recomputed otherwise, false.
  74405. */
  74406. needProjectionMatrixCompute(): boolean;
  74407. /**
  74408. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74409. */
  74410. forceProjectionMatrixCompute(): void;
  74411. /**
  74412. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74413. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74414. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74415. */
  74416. getShadowDirection(faceIndex?: number): Vector3;
  74417. /**
  74418. * Gets the minZ used for shadow according to both the scene and the light.
  74419. * @param activeCamera The camera we are returning the min for
  74420. * @returns the depth min z
  74421. */
  74422. getDepthMinZ(activeCamera: Camera): number;
  74423. /**
  74424. * Gets the maxZ used for shadow according to both the scene and the light.
  74425. * @param activeCamera The camera we are returning the max for
  74426. * @returns the depth max z
  74427. */
  74428. getDepthMaxZ(activeCamera: Camera): number;
  74429. }
  74430. /**
  74431. * Base implementation IShadowLight
  74432. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74433. */
  74434. export abstract class ShadowLight extends Light implements IShadowLight {
  74435. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74436. protected _position: Vector3;
  74437. protected _setPosition(value: Vector3): void;
  74438. /**
  74439. * Sets the position the shadow will be casted from. Also use as the light position for both
  74440. * point and spot lights.
  74441. */
  74442. /**
  74443. * Sets the position the shadow will be casted from. Also use as the light position for both
  74444. * point and spot lights.
  74445. */
  74446. position: Vector3;
  74447. protected _direction: Vector3;
  74448. protected _setDirection(value: Vector3): void;
  74449. /**
  74450. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74451. * Also use as the light direction on spot and directional lights.
  74452. */
  74453. /**
  74454. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74455. * Also use as the light direction on spot and directional lights.
  74456. */
  74457. direction: Vector3;
  74458. private _shadowMinZ;
  74459. /**
  74460. * Gets the shadow projection clipping minimum z value.
  74461. */
  74462. /**
  74463. * Sets the shadow projection clipping minimum z value.
  74464. */
  74465. shadowMinZ: number;
  74466. private _shadowMaxZ;
  74467. /**
  74468. * Sets the shadow projection clipping maximum z value.
  74469. */
  74470. /**
  74471. * Gets the shadow projection clipping maximum z value.
  74472. */
  74473. shadowMaxZ: number;
  74474. /**
  74475. * Callback defining a custom Projection Matrix Builder.
  74476. * This can be used to override the default projection matrix computation.
  74477. */
  74478. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74479. /**
  74480. * The transformed position. Position of the light in world space taking parenting in account.
  74481. */
  74482. transformedPosition: Vector3;
  74483. /**
  74484. * The transformed direction. Direction of the light in world space taking parenting in account.
  74485. */
  74486. transformedDirection: Vector3;
  74487. private _needProjectionMatrixCompute;
  74488. /**
  74489. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74490. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74491. */
  74492. computeTransformedInformation(): boolean;
  74493. /**
  74494. * Return the depth scale used for the shadow map.
  74495. * @returns the depth scale.
  74496. */
  74497. getDepthScale(): number;
  74498. /**
  74499. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74500. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74501. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74502. */
  74503. getShadowDirection(faceIndex?: number): Vector3;
  74504. /**
  74505. * Returns the ShadowLight absolute position in the World.
  74506. * @returns the position vector in world space
  74507. */
  74508. getAbsolutePosition(): Vector3;
  74509. /**
  74510. * Sets the ShadowLight direction toward the passed target.
  74511. * @param target The point to target in local space
  74512. * @returns the updated ShadowLight direction
  74513. */
  74514. setDirectionToTarget(target: Vector3): Vector3;
  74515. /**
  74516. * Returns the light rotation in euler definition.
  74517. * @returns the x y z rotation in local space.
  74518. */
  74519. getRotation(): Vector3;
  74520. /**
  74521. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74522. * @returns true if a cube texture needs to be use
  74523. */
  74524. needCube(): boolean;
  74525. /**
  74526. * Detects if the projection matrix requires to be recomputed this frame.
  74527. * @returns true if it requires to be recomputed otherwise, false.
  74528. */
  74529. needProjectionMatrixCompute(): boolean;
  74530. /**
  74531. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74532. */
  74533. forceProjectionMatrixCompute(): void;
  74534. /** @hidden */
  74535. _initCache(): void;
  74536. /** @hidden */
  74537. _isSynchronized(): boolean;
  74538. /**
  74539. * Computes the world matrix of the node
  74540. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74541. * @returns the world matrix
  74542. */
  74543. computeWorldMatrix(force?: boolean): Matrix;
  74544. /**
  74545. * Gets the minZ used for shadow according to both the scene and the light.
  74546. * @param activeCamera The camera we are returning the min for
  74547. * @returns the depth min z
  74548. */
  74549. getDepthMinZ(activeCamera: Camera): number;
  74550. /**
  74551. * Gets the maxZ used for shadow according to both the scene and the light.
  74552. * @param activeCamera The camera we are returning the max for
  74553. * @returns the depth max z
  74554. */
  74555. getDepthMaxZ(activeCamera: Camera): number;
  74556. /**
  74557. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74558. * @param matrix The materix to updated with the projection information
  74559. * @param viewMatrix The transform matrix of the light
  74560. * @param renderList The list of mesh to render in the map
  74561. * @returns The current light
  74562. */
  74563. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74564. }
  74565. }
  74566. declare module BABYLON {
  74567. /**
  74568. * "Static Class" containing the most commonly used helper while dealing with material for
  74569. * rendering purpose.
  74570. *
  74571. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74572. *
  74573. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74574. */
  74575. export class MaterialHelper {
  74576. /**
  74577. * Bind the current view position to an effect.
  74578. * @param effect The effect to be bound
  74579. * @param scene The scene the eyes position is used from
  74580. */
  74581. static BindEyePosition(effect: Effect, scene: Scene): void;
  74582. /**
  74583. * Helps preparing the defines values about the UVs in used in the effect.
  74584. * UVs are shared as much as we can accross channels in the shaders.
  74585. * @param texture The texture we are preparing the UVs for
  74586. * @param defines The defines to update
  74587. * @param key The channel key "diffuse", "specular"... used in the shader
  74588. */
  74589. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74590. /**
  74591. * Binds a texture matrix value to its corrsponding uniform
  74592. * @param texture The texture to bind the matrix for
  74593. * @param uniformBuffer The uniform buffer receivin the data
  74594. * @param key The channel key "diffuse", "specular"... used in the shader
  74595. */
  74596. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74597. /**
  74598. * Gets the current status of the fog (should it be enabled?)
  74599. * @param mesh defines the mesh to evaluate for fog support
  74600. * @param scene defines the hosting scene
  74601. * @returns true if fog must be enabled
  74602. */
  74603. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74604. /**
  74605. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74606. * @param mesh defines the current mesh
  74607. * @param scene defines the current scene
  74608. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74609. * @param pointsCloud defines if point cloud rendering has to be turned on
  74610. * @param fogEnabled defines if fog has to be turned on
  74611. * @param alphaTest defines if alpha testing has to be turned on
  74612. * @param defines defines the current list of defines
  74613. */
  74614. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74615. /**
  74616. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74617. * @param scene defines the current scene
  74618. * @param engine defines the current engine
  74619. * @param defines specifies the list of active defines
  74620. * @param useInstances defines if instances have to be turned on
  74621. * @param useClipPlane defines if clip plane have to be turned on
  74622. */
  74623. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74624. /**
  74625. * Prepares the defines for bones
  74626. * @param mesh The mesh containing the geometry data we will draw
  74627. * @param defines The defines to update
  74628. */
  74629. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74630. /**
  74631. * Prepares the defines for morph targets
  74632. * @param mesh The mesh containing the geometry data we will draw
  74633. * @param defines The defines to update
  74634. */
  74635. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74636. /**
  74637. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74638. * @param mesh The mesh containing the geometry data we will draw
  74639. * @param defines The defines to update
  74640. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74641. * @param useBones Precise whether bones should be used or not (override mesh info)
  74642. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74643. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74644. * @returns false if defines are considered not dirty and have not been checked
  74645. */
  74646. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74647. /**
  74648. * Prepares the defines related to multiview
  74649. * @param scene The scene we are intending to draw
  74650. * @param defines The defines to update
  74651. */
  74652. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74653. /**
  74654. * Prepares the defines related to the light information passed in parameter
  74655. * @param scene The scene we are intending to draw
  74656. * @param mesh The mesh the effect is compiling for
  74657. * @param light The light the effect is compiling for
  74658. * @param lightIndex The index of the light
  74659. * @param defines The defines to update
  74660. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74661. * @param state Defines the current state regarding what is needed (normals, etc...)
  74662. */
  74663. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74664. needNormals: boolean;
  74665. needRebuild: boolean;
  74666. shadowEnabled: boolean;
  74667. specularEnabled: boolean;
  74668. lightmapMode: boolean;
  74669. }): void;
  74670. /**
  74671. * Prepares the defines related to the light information passed in parameter
  74672. * @param scene The scene we are intending to draw
  74673. * @param mesh The mesh the effect is compiling for
  74674. * @param defines The defines to update
  74675. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74676. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74677. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74678. * @returns true if normals will be required for the rest of the effect
  74679. */
  74680. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74681. /**
  74682. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74683. * @param lightIndex defines the light index
  74684. * @param uniformsList The uniform list
  74685. * @param samplersList The sampler list
  74686. * @param projectedLightTexture defines if projected texture must be used
  74687. * @param uniformBuffersList defines an optional list of uniform buffers
  74688. */
  74689. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74690. /**
  74691. * Prepares the uniforms and samplers list to be used in the effect
  74692. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74693. * @param samplersList The sampler list
  74694. * @param defines The defines helping in the list generation
  74695. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74696. */
  74697. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74698. /**
  74699. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74700. * @param defines The defines to update while falling back
  74701. * @param fallbacks The authorized effect fallbacks
  74702. * @param maxSimultaneousLights The maximum number of lights allowed
  74703. * @param rank the current rank of the Effect
  74704. * @returns The newly affected rank
  74705. */
  74706. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74707. private static _TmpMorphInfluencers;
  74708. /**
  74709. * Prepares the list of attributes required for morph targets according to the effect defines.
  74710. * @param attribs The current list of supported attribs
  74711. * @param mesh The mesh to prepare the morph targets attributes for
  74712. * @param influencers The number of influencers
  74713. */
  74714. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74715. /**
  74716. * Prepares the list of attributes required for morph targets according to the effect defines.
  74717. * @param attribs The current list of supported attribs
  74718. * @param mesh The mesh to prepare the morph targets attributes for
  74719. * @param defines The current Defines of the effect
  74720. */
  74721. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74722. /**
  74723. * Prepares the list of attributes required for bones according to the effect defines.
  74724. * @param attribs The current list of supported attribs
  74725. * @param mesh The mesh to prepare the bones attributes for
  74726. * @param defines The current Defines of the effect
  74727. * @param fallbacks The current efffect fallback strategy
  74728. */
  74729. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74730. /**
  74731. * Check and prepare the list of attributes required for instances according to the effect defines.
  74732. * @param attribs The current list of supported attribs
  74733. * @param defines The current MaterialDefines of the effect
  74734. */
  74735. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74736. /**
  74737. * Add the list of attributes required for instances to the attribs array.
  74738. * @param attribs The current list of supported attribs
  74739. */
  74740. static PushAttributesForInstances(attribs: string[]): void;
  74741. /**
  74742. * Binds the light shadow information to the effect for the given mesh.
  74743. * @param light The light containing the generator
  74744. * @param scene The scene the lights belongs to
  74745. * @param mesh The mesh we are binding the information to render
  74746. * @param lightIndex The light index in the effect used to render the mesh
  74747. * @param effect The effect we are binding the data to
  74748. */
  74749. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74750. /**
  74751. * Binds the light information to the effect.
  74752. * @param light The light containing the generator
  74753. * @param effect The effect we are binding the data to
  74754. * @param lightIndex The light index in the effect used to render
  74755. */
  74756. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74757. /**
  74758. * Binds the lights information from the scene to the effect for the given mesh.
  74759. * @param light Light to bind
  74760. * @param lightIndex Light index
  74761. * @param scene The scene where the light belongs to
  74762. * @param mesh The mesh we are binding the information to render
  74763. * @param effect The effect we are binding the data to
  74764. * @param useSpecular Defines if specular is supported
  74765. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74766. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74767. */
  74768. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74769. /**
  74770. * Binds the lights information from the scene to the effect for the given mesh.
  74771. * @param scene The scene the lights belongs to
  74772. * @param mesh The mesh we are binding the information to render
  74773. * @param effect The effect we are binding the data to
  74774. * @param defines The generated defines for the effect
  74775. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74776. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74777. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74778. */
  74779. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74780. private static _tempFogColor;
  74781. /**
  74782. * Binds the fog information from the scene to the effect for the given mesh.
  74783. * @param scene The scene the lights belongs to
  74784. * @param mesh The mesh we are binding the information to render
  74785. * @param effect The effect we are binding the data to
  74786. * @param linearSpace Defines if the fog effect is applied in linear space
  74787. */
  74788. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74789. /**
  74790. * Binds the bones information from the mesh to the effect.
  74791. * @param mesh The mesh we are binding the information to render
  74792. * @param effect The effect we are binding the data to
  74793. */
  74794. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74795. /**
  74796. * Binds the morph targets information from the mesh to the effect.
  74797. * @param abstractMesh The mesh we are binding the information to render
  74798. * @param effect The effect we are binding the data to
  74799. */
  74800. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74801. /**
  74802. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74803. * @param defines The generated defines used in the effect
  74804. * @param effect The effect we are binding the data to
  74805. * @param scene The scene we are willing to render with logarithmic scale for
  74806. */
  74807. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74808. /**
  74809. * Binds the clip plane information from the scene to the effect.
  74810. * @param scene The scene the clip plane information are extracted from
  74811. * @param effect The effect we are binding the data to
  74812. */
  74813. static BindClipPlane(effect: Effect, scene: Scene): void;
  74814. }
  74815. }
  74816. declare module BABYLON {
  74817. /** @hidden */
  74818. export var packingFunctions: {
  74819. name: string;
  74820. shader: string;
  74821. };
  74822. }
  74823. declare module BABYLON {
  74824. /** @hidden */
  74825. export var shadowMapPixelShader: {
  74826. name: string;
  74827. shader: string;
  74828. };
  74829. }
  74830. declare module BABYLON {
  74831. /** @hidden */
  74832. export var bonesDeclaration: {
  74833. name: string;
  74834. shader: string;
  74835. };
  74836. }
  74837. declare module BABYLON {
  74838. /** @hidden */
  74839. export var morphTargetsVertexGlobalDeclaration: {
  74840. name: string;
  74841. shader: string;
  74842. };
  74843. }
  74844. declare module BABYLON {
  74845. /** @hidden */
  74846. export var morphTargetsVertexDeclaration: {
  74847. name: string;
  74848. shader: string;
  74849. };
  74850. }
  74851. declare module BABYLON {
  74852. /** @hidden */
  74853. export var instancesDeclaration: {
  74854. name: string;
  74855. shader: string;
  74856. };
  74857. }
  74858. declare module BABYLON {
  74859. /** @hidden */
  74860. export var helperFunctions: {
  74861. name: string;
  74862. shader: string;
  74863. };
  74864. }
  74865. declare module BABYLON {
  74866. /** @hidden */
  74867. export var morphTargetsVertex: {
  74868. name: string;
  74869. shader: string;
  74870. };
  74871. }
  74872. declare module BABYLON {
  74873. /** @hidden */
  74874. export var instancesVertex: {
  74875. name: string;
  74876. shader: string;
  74877. };
  74878. }
  74879. declare module BABYLON {
  74880. /** @hidden */
  74881. export var bonesVertex: {
  74882. name: string;
  74883. shader: string;
  74884. };
  74885. }
  74886. declare module BABYLON {
  74887. /** @hidden */
  74888. export var shadowMapVertexShader: {
  74889. name: string;
  74890. shader: string;
  74891. };
  74892. }
  74893. declare module BABYLON {
  74894. /** @hidden */
  74895. export var depthBoxBlurPixelShader: {
  74896. name: string;
  74897. shader: string;
  74898. };
  74899. }
  74900. declare module BABYLON {
  74901. /**
  74902. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74903. */
  74904. export interface ICustomShaderOptions {
  74905. /**
  74906. * Gets or sets the custom shader name to use
  74907. */
  74908. shaderName: string;
  74909. /**
  74910. * The list of attribute names used in the shader
  74911. */
  74912. attributes?: string[];
  74913. /**
  74914. * The list of unifrom names used in the shader
  74915. */
  74916. uniforms?: string[];
  74917. /**
  74918. * The list of sampler names used in the shader
  74919. */
  74920. samplers?: string[];
  74921. /**
  74922. * The list of defines used in the shader
  74923. */
  74924. defines?: string[];
  74925. }
  74926. /**
  74927. * Interface to implement to create a shadow generator compatible with BJS.
  74928. */
  74929. export interface IShadowGenerator {
  74930. /**
  74931. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74932. * @returns The render target texture if present otherwise, null
  74933. */
  74934. getShadowMap(): Nullable<RenderTargetTexture>;
  74935. /**
  74936. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74937. * @returns The render target texture if the shadow map is present otherwise, null
  74938. */
  74939. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74940. /**
  74941. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74942. * @param subMesh The submesh we want to render in the shadow map
  74943. * @param useInstances Defines wether will draw in the map using instances
  74944. * @returns true if ready otherwise, false
  74945. */
  74946. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74947. /**
  74948. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74949. * @param defines Defines of the material we want to update
  74950. * @param lightIndex Index of the light in the enabled light list of the material
  74951. */
  74952. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74953. /**
  74954. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74955. * defined in the generator but impacting the effect).
  74956. * It implies the unifroms available on the materials are the standard BJS ones.
  74957. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74958. * @param effect The effect we are binfing the information for
  74959. */
  74960. bindShadowLight(lightIndex: string, effect: Effect): void;
  74961. /**
  74962. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74963. * (eq to shadow prjection matrix * light transform matrix)
  74964. * @returns The transform matrix used to create the shadow map
  74965. */
  74966. getTransformMatrix(): Matrix;
  74967. /**
  74968. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74969. * Cube and 2D textures for instance.
  74970. */
  74971. recreateShadowMap(): void;
  74972. /**
  74973. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74974. * @param onCompiled Callback triggered at the and of the effects compilation
  74975. * @param options Sets of optional options forcing the compilation with different modes
  74976. */
  74977. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74978. useInstances: boolean;
  74979. }>): void;
  74980. /**
  74981. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74982. * @param options Sets of optional options forcing the compilation with different modes
  74983. * @returns A promise that resolves when the compilation completes
  74984. */
  74985. forceCompilationAsync(options?: Partial<{
  74986. useInstances: boolean;
  74987. }>): Promise<void>;
  74988. /**
  74989. * Serializes the shadow generator setup to a json object.
  74990. * @returns The serialized JSON object
  74991. */
  74992. serialize(): any;
  74993. /**
  74994. * Disposes the Shadow map and related Textures and effects.
  74995. */
  74996. dispose(): void;
  74997. }
  74998. /**
  74999. * Default implementation IShadowGenerator.
  75000. * This is the main object responsible of generating shadows in the framework.
  75001. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  75002. */
  75003. export class ShadowGenerator implements IShadowGenerator {
  75004. /**
  75005. * Shadow generator mode None: no filtering applied.
  75006. */
  75007. static readonly FILTER_NONE: number;
  75008. /**
  75009. * Shadow generator mode ESM: Exponential Shadow Mapping.
  75010. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75011. */
  75012. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  75013. /**
  75014. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  75015. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  75016. */
  75017. static readonly FILTER_POISSONSAMPLING: number;
  75018. /**
  75019. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  75020. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75021. */
  75022. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  75023. /**
  75024. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  75025. * edge artifacts on steep falloff.
  75026. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75027. */
  75028. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  75029. /**
  75030. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75031. * edge artifacts on steep falloff.
  75032. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75033. */
  75034. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75035. /**
  75036. * Shadow generator mode PCF: Percentage Closer Filtering
  75037. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75038. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75039. */
  75040. static readonly FILTER_PCF: number;
  75041. /**
  75042. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75043. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75044. * Contact Hardening
  75045. */
  75046. static readonly FILTER_PCSS: number;
  75047. /**
  75048. * Reserved for PCF and PCSS
  75049. * Highest Quality.
  75050. *
  75051. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75052. *
  75053. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75054. */
  75055. static readonly QUALITY_HIGH: number;
  75056. /**
  75057. * Reserved for PCF and PCSS
  75058. * Good tradeoff for quality/perf cross devices
  75059. *
  75060. * Execute PCF on a 3*3 kernel.
  75061. *
  75062. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75063. */
  75064. static readonly QUALITY_MEDIUM: number;
  75065. /**
  75066. * Reserved for PCF and PCSS
  75067. * The lowest quality but the fastest.
  75068. *
  75069. * Execute PCF on a 1*1 kernel.
  75070. *
  75071. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75072. */
  75073. static readonly QUALITY_LOW: number;
  75074. /** Gets or sets the custom shader name to use */
  75075. customShaderOptions: ICustomShaderOptions;
  75076. /**
  75077. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75078. */
  75079. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75080. /**
  75081. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75082. */
  75083. onAfterShadowMapRenderObservable: Observable<Effect>;
  75084. /**
  75085. * Observable triggered before a mesh is rendered in the shadow map.
  75086. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75087. */
  75088. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75089. /**
  75090. * Observable triggered after a mesh is rendered in the shadow map.
  75091. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75092. */
  75093. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75094. private _bias;
  75095. /**
  75096. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75097. */
  75098. /**
  75099. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75100. */
  75101. bias: number;
  75102. private _normalBias;
  75103. /**
  75104. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75105. */
  75106. /**
  75107. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75108. */
  75109. normalBias: number;
  75110. private _blurBoxOffset;
  75111. /**
  75112. * Gets the blur box offset: offset applied during the blur pass.
  75113. * Only useful if useKernelBlur = false
  75114. */
  75115. /**
  75116. * Sets the blur box offset: offset applied during the blur pass.
  75117. * Only useful if useKernelBlur = false
  75118. */
  75119. blurBoxOffset: number;
  75120. private _blurScale;
  75121. /**
  75122. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75123. * 2 means half of the size.
  75124. */
  75125. /**
  75126. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75127. * 2 means half of the size.
  75128. */
  75129. blurScale: number;
  75130. private _blurKernel;
  75131. /**
  75132. * Gets the blur kernel: kernel size of the blur pass.
  75133. * Only useful if useKernelBlur = true
  75134. */
  75135. /**
  75136. * Sets the blur kernel: kernel size of the blur pass.
  75137. * Only useful if useKernelBlur = true
  75138. */
  75139. blurKernel: number;
  75140. private _useKernelBlur;
  75141. /**
  75142. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75143. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75144. */
  75145. /**
  75146. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75147. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75148. */
  75149. useKernelBlur: boolean;
  75150. private _depthScale;
  75151. /**
  75152. * Gets the depth scale used in ESM mode.
  75153. */
  75154. /**
  75155. * Sets the depth scale used in ESM mode.
  75156. * This can override the scale stored on the light.
  75157. */
  75158. depthScale: number;
  75159. private _filter;
  75160. /**
  75161. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75162. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75163. */
  75164. /**
  75165. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75166. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75167. */
  75168. filter: number;
  75169. /**
  75170. * Gets if the current filter is set to Poisson Sampling.
  75171. */
  75172. /**
  75173. * Sets the current filter to Poisson Sampling.
  75174. */
  75175. usePoissonSampling: boolean;
  75176. /**
  75177. * Gets if the current filter is set to ESM.
  75178. */
  75179. /**
  75180. * Sets the current filter is to ESM.
  75181. */
  75182. useExponentialShadowMap: boolean;
  75183. /**
  75184. * Gets if the current filter is set to filtered ESM.
  75185. */
  75186. /**
  75187. * Gets if the current filter is set to filtered ESM.
  75188. */
  75189. useBlurExponentialShadowMap: boolean;
  75190. /**
  75191. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75192. * exponential to prevent steep falloff artifacts).
  75193. */
  75194. /**
  75195. * Sets the current filter to "close ESM" (using the inverse of the
  75196. * exponential to prevent steep falloff artifacts).
  75197. */
  75198. useCloseExponentialShadowMap: boolean;
  75199. /**
  75200. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75201. * exponential to prevent steep falloff artifacts).
  75202. */
  75203. /**
  75204. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75205. * exponential to prevent steep falloff artifacts).
  75206. */
  75207. useBlurCloseExponentialShadowMap: boolean;
  75208. /**
  75209. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75210. */
  75211. /**
  75212. * Sets the current filter to "PCF" (percentage closer filtering).
  75213. */
  75214. usePercentageCloserFiltering: boolean;
  75215. private _filteringQuality;
  75216. /**
  75217. * Gets the PCF or PCSS Quality.
  75218. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75219. */
  75220. /**
  75221. * Sets the PCF or PCSS Quality.
  75222. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75223. */
  75224. filteringQuality: number;
  75225. /**
  75226. * Gets if the current filter is set to "PCSS" (contact hardening).
  75227. */
  75228. /**
  75229. * Sets the current filter to "PCSS" (contact hardening).
  75230. */
  75231. useContactHardeningShadow: boolean;
  75232. private _contactHardeningLightSizeUVRatio;
  75233. /**
  75234. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75235. * Using a ratio helps keeping shape stability independently of the map size.
  75236. *
  75237. * It does not account for the light projection as it was having too much
  75238. * instability during the light setup or during light position changes.
  75239. *
  75240. * Only valid if useContactHardeningShadow is true.
  75241. */
  75242. /**
  75243. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75244. * Using a ratio helps keeping shape stability independently of the map size.
  75245. *
  75246. * It does not account for the light projection as it was having too much
  75247. * instability during the light setup or during light position changes.
  75248. *
  75249. * Only valid if useContactHardeningShadow is true.
  75250. */
  75251. contactHardeningLightSizeUVRatio: number;
  75252. private _darkness;
  75253. /** Gets or sets the actual darkness of a shadow */
  75254. darkness: number;
  75255. /**
  75256. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75257. * 0 means strongest and 1 would means no shadow.
  75258. * @returns the darkness.
  75259. */
  75260. getDarkness(): number;
  75261. /**
  75262. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75263. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75264. * @returns the shadow generator allowing fluent coding.
  75265. */
  75266. setDarkness(darkness: number): ShadowGenerator;
  75267. private _transparencyShadow;
  75268. /** Gets or sets the ability to have transparent shadow */
  75269. transparencyShadow: boolean;
  75270. /**
  75271. * Sets the ability to have transparent shadow (boolean).
  75272. * @param transparent True if transparent else False
  75273. * @returns the shadow generator allowing fluent coding
  75274. */
  75275. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  75276. private _shadowMap;
  75277. private _shadowMap2;
  75278. /**
  75279. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75280. * @returns The render target texture if present otherwise, null
  75281. */
  75282. getShadowMap(): Nullable<RenderTargetTexture>;
  75283. /**
  75284. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75285. * @returns The render target texture if the shadow map is present otherwise, null
  75286. */
  75287. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75288. /**
  75289. * Gets the class name of that object
  75290. * @returns "ShadowGenerator"
  75291. */
  75292. getClassName(): string;
  75293. /**
  75294. * Helper function to add a mesh and its descendants to the list of shadow casters.
  75295. * @param mesh Mesh to add
  75296. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  75297. * @returns the Shadow Generator itself
  75298. */
  75299. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75300. /**
  75301. * Helper function to remove a mesh and its descendants from the list of shadow casters
  75302. * @param mesh Mesh to remove
  75303. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  75304. * @returns the Shadow Generator itself
  75305. */
  75306. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75307. /**
  75308. * Controls the extent to which the shadows fade out at the edge of the frustum
  75309. * Used only by directionals and spots
  75310. */
  75311. frustumEdgeFalloff: number;
  75312. private _light;
  75313. /**
  75314. * Returns the associated light object.
  75315. * @returns the light generating the shadow
  75316. */
  75317. getLight(): IShadowLight;
  75318. /**
  75319. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75320. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75321. * It might on the other hand introduce peter panning.
  75322. */
  75323. forceBackFacesOnly: boolean;
  75324. private _scene;
  75325. private _lightDirection;
  75326. private _effect;
  75327. private _viewMatrix;
  75328. private _projectionMatrix;
  75329. private _transformMatrix;
  75330. private _cachedPosition;
  75331. private _cachedDirection;
  75332. private _cachedDefines;
  75333. private _currentRenderID;
  75334. private _boxBlurPostprocess;
  75335. private _kernelBlurXPostprocess;
  75336. private _kernelBlurYPostprocess;
  75337. private _blurPostProcesses;
  75338. private _mapSize;
  75339. private _currentFaceIndex;
  75340. private _currentFaceIndexCache;
  75341. private _textureType;
  75342. private _defaultTextureMatrix;
  75343. /** @hidden */
  75344. static _SceneComponentInitialization: (scene: Scene) => void;
  75345. /**
  75346. * Creates a ShadowGenerator object.
  75347. * A ShadowGenerator is the required tool to use the shadows.
  75348. * Each light casting shadows needs to use its own ShadowGenerator.
  75349. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75350. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75351. * @param light The light object generating the shadows.
  75352. * @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.
  75353. */
  75354. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75355. private _initializeGenerator;
  75356. private _initializeShadowMap;
  75357. private _initializeBlurRTTAndPostProcesses;
  75358. private _renderForShadowMap;
  75359. private _renderSubMeshForShadowMap;
  75360. private _applyFilterValues;
  75361. /**
  75362. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75363. * @param onCompiled Callback triggered at the and of the effects compilation
  75364. * @param options Sets of optional options forcing the compilation with different modes
  75365. */
  75366. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75367. useInstances: boolean;
  75368. }>): void;
  75369. /**
  75370. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75371. * @param options Sets of optional options forcing the compilation with different modes
  75372. * @returns A promise that resolves when the compilation completes
  75373. */
  75374. forceCompilationAsync(options?: Partial<{
  75375. useInstances: boolean;
  75376. }>): Promise<void>;
  75377. /**
  75378. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75379. * @param subMesh The submesh we want to render in the shadow map
  75380. * @param useInstances Defines wether will draw in the map using instances
  75381. * @returns true if ready otherwise, false
  75382. */
  75383. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75384. /**
  75385. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75386. * @param defines Defines of the material we want to update
  75387. * @param lightIndex Index of the light in the enabled light list of the material
  75388. */
  75389. prepareDefines(defines: any, lightIndex: number): void;
  75390. /**
  75391. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75392. * defined in the generator but impacting the effect).
  75393. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75394. * @param effect The effect we are binfing the information for
  75395. */
  75396. bindShadowLight(lightIndex: string, effect: Effect): void;
  75397. /**
  75398. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75399. * (eq to shadow prjection matrix * light transform matrix)
  75400. * @returns The transform matrix used to create the shadow map
  75401. */
  75402. getTransformMatrix(): Matrix;
  75403. /**
  75404. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75405. * Cube and 2D textures for instance.
  75406. */
  75407. recreateShadowMap(): void;
  75408. private _disposeBlurPostProcesses;
  75409. private _disposeRTTandPostProcesses;
  75410. /**
  75411. * Disposes the ShadowGenerator.
  75412. * Returns nothing.
  75413. */
  75414. dispose(): void;
  75415. /**
  75416. * Serializes the shadow generator setup to a json object.
  75417. * @returns The serialized JSON object
  75418. */
  75419. serialize(): any;
  75420. /**
  75421. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75422. * @param parsedShadowGenerator The JSON object to parse
  75423. * @param scene The scene to create the shadow map for
  75424. * @returns The parsed shadow generator
  75425. */
  75426. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75427. }
  75428. }
  75429. declare module BABYLON {
  75430. /**
  75431. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75432. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75433. * 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.
  75434. */
  75435. export abstract class Light extends Node {
  75436. /**
  75437. * Falloff Default: light is falling off following the material specification:
  75438. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75439. */
  75440. static readonly FALLOFF_DEFAULT: number;
  75441. /**
  75442. * Falloff Physical: light is falling off following the inverse squared distance law.
  75443. */
  75444. static readonly FALLOFF_PHYSICAL: number;
  75445. /**
  75446. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75447. * to enhance interoperability with other engines.
  75448. */
  75449. static readonly FALLOFF_GLTF: number;
  75450. /**
  75451. * Falloff Standard: light is falling off like in the standard material
  75452. * to enhance interoperability with other materials.
  75453. */
  75454. static readonly FALLOFF_STANDARD: number;
  75455. /**
  75456. * If every light affecting the material is in this lightmapMode,
  75457. * material.lightmapTexture adds or multiplies
  75458. * (depends on material.useLightmapAsShadowmap)
  75459. * after every other light calculations.
  75460. */
  75461. static readonly LIGHTMAP_DEFAULT: number;
  75462. /**
  75463. * material.lightmapTexture as only diffuse lighting from this light
  75464. * adds only specular lighting from this light
  75465. * adds dynamic shadows
  75466. */
  75467. static readonly LIGHTMAP_SPECULAR: number;
  75468. /**
  75469. * material.lightmapTexture as only lighting
  75470. * no light calculation from this light
  75471. * only adds dynamic shadows from this light
  75472. */
  75473. static readonly LIGHTMAP_SHADOWSONLY: number;
  75474. /**
  75475. * Each light type uses the default quantity according to its type:
  75476. * point/spot lights use luminous intensity
  75477. * directional lights use illuminance
  75478. */
  75479. static readonly INTENSITYMODE_AUTOMATIC: number;
  75480. /**
  75481. * lumen (lm)
  75482. */
  75483. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75484. /**
  75485. * candela (lm/sr)
  75486. */
  75487. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75488. /**
  75489. * lux (lm/m^2)
  75490. */
  75491. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75492. /**
  75493. * nit (cd/m^2)
  75494. */
  75495. static readonly INTENSITYMODE_LUMINANCE: number;
  75496. /**
  75497. * Light type const id of the point light.
  75498. */
  75499. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75500. /**
  75501. * Light type const id of the directional light.
  75502. */
  75503. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75504. /**
  75505. * Light type const id of the spot light.
  75506. */
  75507. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75508. /**
  75509. * Light type const id of the hemispheric light.
  75510. */
  75511. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75512. /**
  75513. * Diffuse gives the basic color to an object.
  75514. */
  75515. diffuse: Color3;
  75516. /**
  75517. * Specular produces a highlight color on an object.
  75518. * Note: This is note affecting PBR materials.
  75519. */
  75520. specular: Color3;
  75521. /**
  75522. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75523. * falling off base on range or angle.
  75524. * This can be set to any values in Light.FALLOFF_x.
  75525. *
  75526. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75527. * other types of materials.
  75528. */
  75529. falloffType: number;
  75530. /**
  75531. * Strength of the light.
  75532. * Note: By default it is define in the framework own unit.
  75533. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75534. */
  75535. intensity: number;
  75536. private _range;
  75537. protected _inverseSquaredRange: number;
  75538. /**
  75539. * Defines how far from the source the light is impacting in scene units.
  75540. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75541. */
  75542. /**
  75543. * Defines how far from the source the light is impacting in scene units.
  75544. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75545. */
  75546. range: number;
  75547. /**
  75548. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75549. * of light.
  75550. */
  75551. private _photometricScale;
  75552. private _intensityMode;
  75553. /**
  75554. * Gets the photometric scale used to interpret the intensity.
  75555. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75556. */
  75557. /**
  75558. * Sets the photometric scale used to interpret the intensity.
  75559. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75560. */
  75561. intensityMode: number;
  75562. private _radius;
  75563. /**
  75564. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75565. */
  75566. /**
  75567. * sets the light radius used by PBR Materials to simulate soft area lights.
  75568. */
  75569. radius: number;
  75570. private _renderPriority;
  75571. /**
  75572. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75573. * exceeding the number allowed of the materials.
  75574. */
  75575. renderPriority: number;
  75576. private _shadowEnabled;
  75577. /**
  75578. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75579. * the current shadow generator.
  75580. */
  75581. /**
  75582. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75583. * the current shadow generator.
  75584. */
  75585. shadowEnabled: boolean;
  75586. private _includedOnlyMeshes;
  75587. /**
  75588. * Gets the only meshes impacted by this light.
  75589. */
  75590. /**
  75591. * Sets the only meshes impacted by this light.
  75592. */
  75593. includedOnlyMeshes: AbstractMesh[];
  75594. private _excludedMeshes;
  75595. /**
  75596. * Gets the meshes not impacted by this light.
  75597. */
  75598. /**
  75599. * Sets the meshes not impacted by this light.
  75600. */
  75601. excludedMeshes: AbstractMesh[];
  75602. private _excludeWithLayerMask;
  75603. /**
  75604. * Gets the layer id use to find what meshes are not impacted by the light.
  75605. * Inactive if 0
  75606. */
  75607. /**
  75608. * Sets the layer id use to find what meshes are not impacted by the light.
  75609. * Inactive if 0
  75610. */
  75611. excludeWithLayerMask: number;
  75612. private _includeOnlyWithLayerMask;
  75613. /**
  75614. * Gets the layer id use to find what meshes are impacted by the light.
  75615. * Inactive if 0
  75616. */
  75617. /**
  75618. * Sets the layer id use to find what meshes are impacted by the light.
  75619. * Inactive if 0
  75620. */
  75621. includeOnlyWithLayerMask: number;
  75622. private _lightmapMode;
  75623. /**
  75624. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75625. */
  75626. /**
  75627. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75628. */
  75629. lightmapMode: number;
  75630. /**
  75631. * Shadow generator associted to the light.
  75632. * @hidden Internal use only.
  75633. */
  75634. _shadowGenerator: Nullable<IShadowGenerator>;
  75635. /**
  75636. * @hidden Internal use only.
  75637. */
  75638. _excludedMeshesIds: string[];
  75639. /**
  75640. * @hidden Internal use only.
  75641. */
  75642. _includedOnlyMeshesIds: string[];
  75643. /**
  75644. * The current light unifom buffer.
  75645. * @hidden Internal use only.
  75646. */
  75647. _uniformBuffer: UniformBuffer;
  75648. /**
  75649. * Creates a Light object in the scene.
  75650. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75651. * @param name The firendly name of the light
  75652. * @param scene The scene the light belongs too
  75653. */
  75654. constructor(name: string, scene: Scene);
  75655. protected abstract _buildUniformLayout(): void;
  75656. /**
  75657. * Sets the passed Effect "effect" with the Light information.
  75658. * @param effect The effect to update
  75659. * @param lightIndex The index of the light in the effect to update
  75660. * @returns The light
  75661. */
  75662. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75663. /**
  75664. * Sets the passed Effect "effect" with the Light information.
  75665. * @param effect The effect to update
  75666. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75667. * @returns The light
  75668. */
  75669. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75670. /**
  75671. * Returns the string "Light".
  75672. * @returns the class name
  75673. */
  75674. getClassName(): string;
  75675. /** @hidden */
  75676. readonly _isLight: boolean;
  75677. /**
  75678. * Converts the light information to a readable string for debug purpose.
  75679. * @param fullDetails Supports for multiple levels of logging within scene loading
  75680. * @returns the human readable light info
  75681. */
  75682. toString(fullDetails?: boolean): string;
  75683. /** @hidden */
  75684. protected _syncParentEnabledState(): void;
  75685. /**
  75686. * Set the enabled state of this node.
  75687. * @param value - the new enabled state
  75688. */
  75689. setEnabled(value: boolean): void;
  75690. /**
  75691. * Returns the Light associated shadow generator if any.
  75692. * @return the associated shadow generator.
  75693. */
  75694. getShadowGenerator(): Nullable<IShadowGenerator>;
  75695. /**
  75696. * Returns a Vector3, the absolute light position in the World.
  75697. * @returns the world space position of the light
  75698. */
  75699. getAbsolutePosition(): Vector3;
  75700. /**
  75701. * Specifies if the light will affect the passed mesh.
  75702. * @param mesh The mesh to test against the light
  75703. * @return true the mesh is affected otherwise, false.
  75704. */
  75705. canAffectMesh(mesh: AbstractMesh): boolean;
  75706. /**
  75707. * Sort function to order lights for rendering.
  75708. * @param a First Light object to compare to second.
  75709. * @param b Second Light object to compare first.
  75710. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75711. */
  75712. static CompareLightsPriority(a: Light, b: Light): number;
  75713. /**
  75714. * Releases resources associated with this node.
  75715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75717. */
  75718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75719. /**
  75720. * Returns the light type ID (integer).
  75721. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75722. */
  75723. getTypeID(): number;
  75724. /**
  75725. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75726. * @returns the scaled intensity in intensity mode unit
  75727. */
  75728. getScaledIntensity(): number;
  75729. /**
  75730. * Returns a new Light object, named "name", from the current one.
  75731. * @param name The name of the cloned light
  75732. * @returns the new created light
  75733. */
  75734. clone(name: string): Nullable<Light>;
  75735. /**
  75736. * Serializes the current light into a Serialization object.
  75737. * @returns the serialized object.
  75738. */
  75739. serialize(): any;
  75740. /**
  75741. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75742. * This new light is named "name" and added to the passed scene.
  75743. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75744. * @param name The friendly name of the light
  75745. * @param scene The scene the new light will belong to
  75746. * @returns the constructor function
  75747. */
  75748. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75749. /**
  75750. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75751. * @param parsedLight The JSON representation of the light
  75752. * @param scene The scene to create the parsed light in
  75753. * @returns the created light after parsing
  75754. */
  75755. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75756. private _hookArrayForExcluded;
  75757. private _hookArrayForIncludedOnly;
  75758. private _resyncMeshes;
  75759. /**
  75760. * Forces the meshes to update their light related information in their rendering used effects
  75761. * @hidden Internal Use Only
  75762. */
  75763. _markMeshesAsLightDirty(): void;
  75764. /**
  75765. * Recomputes the cached photometric scale if needed.
  75766. */
  75767. private _computePhotometricScale;
  75768. /**
  75769. * Returns the Photometric Scale according to the light type and intensity mode.
  75770. */
  75771. private _getPhotometricScale;
  75772. /**
  75773. * Reorder the light in the scene according to their defined priority.
  75774. * @hidden Internal Use Only
  75775. */
  75776. _reorderLightsInScene(): void;
  75777. /**
  75778. * Prepares the list of defines specific to the light type.
  75779. * @param defines the list of defines
  75780. * @param lightIndex defines the index of the light for the effect
  75781. */
  75782. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75783. }
  75784. }
  75785. declare module BABYLON {
  75786. /**
  75787. * Interface used to define Action
  75788. */
  75789. export interface IAction {
  75790. /**
  75791. * Trigger for the action
  75792. */
  75793. trigger: number;
  75794. /** Options of the trigger */
  75795. triggerOptions: any;
  75796. /**
  75797. * Gets the trigger parameters
  75798. * @returns the trigger parameters
  75799. */
  75800. getTriggerParameter(): any;
  75801. /**
  75802. * Internal only - executes current action event
  75803. * @hidden
  75804. */
  75805. _executeCurrent(evt?: ActionEvent): void;
  75806. /**
  75807. * Serialize placeholder for child classes
  75808. * @param parent of child
  75809. * @returns the serialized object
  75810. */
  75811. serialize(parent: any): any;
  75812. /**
  75813. * Internal only
  75814. * @hidden
  75815. */
  75816. _prepare(): void;
  75817. /**
  75818. * Internal only - manager for action
  75819. * @hidden
  75820. */
  75821. _actionManager: AbstractActionManager;
  75822. /**
  75823. * Adds action to chain of actions, may be a DoNothingAction
  75824. * @param action defines the next action to execute
  75825. * @returns The action passed in
  75826. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75827. */
  75828. then(action: IAction): IAction;
  75829. }
  75830. /**
  75831. * The action to be carried out following a trigger
  75832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75833. */
  75834. export class Action implements IAction {
  75835. /** the trigger, with or without parameters, for the action */
  75836. triggerOptions: any;
  75837. /**
  75838. * Trigger for the action
  75839. */
  75840. trigger: number;
  75841. /**
  75842. * Internal only - manager for action
  75843. * @hidden
  75844. */
  75845. _actionManager: ActionManager;
  75846. private _nextActiveAction;
  75847. private _child;
  75848. private _condition?;
  75849. private _triggerParameter;
  75850. /**
  75851. * An event triggered prior to action being executed.
  75852. */
  75853. onBeforeExecuteObservable: Observable<Action>;
  75854. /**
  75855. * Creates a new Action
  75856. * @param triggerOptions the trigger, with or without parameters, for the action
  75857. * @param condition an optional determinant of action
  75858. */
  75859. constructor(
  75860. /** the trigger, with or without parameters, for the action */
  75861. triggerOptions: any, condition?: Condition);
  75862. /**
  75863. * Internal only
  75864. * @hidden
  75865. */
  75866. _prepare(): void;
  75867. /**
  75868. * Gets the trigger parameters
  75869. * @returns the trigger parameters
  75870. */
  75871. getTriggerParameter(): any;
  75872. /**
  75873. * Internal only - executes current action event
  75874. * @hidden
  75875. */
  75876. _executeCurrent(evt?: ActionEvent): void;
  75877. /**
  75878. * Execute placeholder for child classes
  75879. * @param evt optional action event
  75880. */
  75881. execute(evt?: ActionEvent): void;
  75882. /**
  75883. * Skips to next active action
  75884. */
  75885. skipToNextActiveAction(): void;
  75886. /**
  75887. * Adds action to chain of actions, may be a DoNothingAction
  75888. * @param action defines the next action to execute
  75889. * @returns The action passed in
  75890. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75891. */
  75892. then(action: Action): Action;
  75893. /**
  75894. * Internal only
  75895. * @hidden
  75896. */
  75897. _getProperty(propertyPath: string): string;
  75898. /**
  75899. * Internal only
  75900. * @hidden
  75901. */
  75902. _getEffectiveTarget(target: any, propertyPath: string): any;
  75903. /**
  75904. * Serialize placeholder for child classes
  75905. * @param parent of child
  75906. * @returns the serialized object
  75907. */
  75908. serialize(parent: any): any;
  75909. /**
  75910. * Internal only called by serialize
  75911. * @hidden
  75912. */
  75913. protected _serialize(serializedAction: any, parent?: any): any;
  75914. /**
  75915. * Internal only
  75916. * @hidden
  75917. */
  75918. static _SerializeValueAsString: (value: any) => string;
  75919. /**
  75920. * Internal only
  75921. * @hidden
  75922. */
  75923. static _GetTargetProperty: (target: Node | Scene) => {
  75924. name: string;
  75925. targetType: string;
  75926. value: string;
  75927. };
  75928. }
  75929. }
  75930. declare module BABYLON {
  75931. /**
  75932. * A Condition applied to an Action
  75933. */
  75934. export class Condition {
  75935. /**
  75936. * Internal only - manager for action
  75937. * @hidden
  75938. */
  75939. _actionManager: ActionManager;
  75940. /**
  75941. * Internal only
  75942. * @hidden
  75943. */
  75944. _evaluationId: number;
  75945. /**
  75946. * Internal only
  75947. * @hidden
  75948. */
  75949. _currentResult: boolean;
  75950. /**
  75951. * Creates a new Condition
  75952. * @param actionManager the manager of the action the condition is applied to
  75953. */
  75954. constructor(actionManager: ActionManager);
  75955. /**
  75956. * Check if the current condition is valid
  75957. * @returns a boolean
  75958. */
  75959. isValid(): boolean;
  75960. /**
  75961. * Internal only
  75962. * @hidden
  75963. */
  75964. _getProperty(propertyPath: string): string;
  75965. /**
  75966. * Internal only
  75967. * @hidden
  75968. */
  75969. _getEffectiveTarget(target: any, propertyPath: string): any;
  75970. /**
  75971. * Serialize placeholder for child classes
  75972. * @returns the serialized object
  75973. */
  75974. serialize(): any;
  75975. /**
  75976. * Internal only
  75977. * @hidden
  75978. */
  75979. protected _serialize(serializedCondition: any): any;
  75980. }
  75981. /**
  75982. * Defines specific conditional operators as extensions of Condition
  75983. */
  75984. export class ValueCondition extends Condition {
  75985. /** path to specify the property of the target the conditional operator uses */
  75986. propertyPath: string;
  75987. /** the value compared by the conditional operator against the current value of the property */
  75988. value: any;
  75989. /** the conditional operator, default ValueCondition.IsEqual */
  75990. operator: number;
  75991. /**
  75992. * Internal only
  75993. * @hidden
  75994. */
  75995. private static _IsEqual;
  75996. /**
  75997. * Internal only
  75998. * @hidden
  75999. */
  76000. private static _IsDifferent;
  76001. /**
  76002. * Internal only
  76003. * @hidden
  76004. */
  76005. private static _IsGreater;
  76006. /**
  76007. * Internal only
  76008. * @hidden
  76009. */
  76010. private static _IsLesser;
  76011. /**
  76012. * returns the number for IsEqual
  76013. */
  76014. static readonly IsEqual: number;
  76015. /**
  76016. * Returns the number for IsDifferent
  76017. */
  76018. static readonly IsDifferent: number;
  76019. /**
  76020. * Returns the number for IsGreater
  76021. */
  76022. static readonly IsGreater: number;
  76023. /**
  76024. * Returns the number for IsLesser
  76025. */
  76026. static readonly IsLesser: number;
  76027. /**
  76028. * Internal only The action manager for the condition
  76029. * @hidden
  76030. */
  76031. _actionManager: ActionManager;
  76032. /**
  76033. * Internal only
  76034. * @hidden
  76035. */
  76036. private _target;
  76037. /**
  76038. * Internal only
  76039. * @hidden
  76040. */
  76041. private _effectiveTarget;
  76042. /**
  76043. * Internal only
  76044. * @hidden
  76045. */
  76046. private _property;
  76047. /**
  76048. * Creates a new ValueCondition
  76049. * @param actionManager manager for the action the condition applies to
  76050. * @param target for the action
  76051. * @param propertyPath path to specify the property of the target the conditional operator uses
  76052. * @param value the value compared by the conditional operator against the current value of the property
  76053. * @param operator the conditional operator, default ValueCondition.IsEqual
  76054. */
  76055. constructor(actionManager: ActionManager, target: any,
  76056. /** path to specify the property of the target the conditional operator uses */
  76057. propertyPath: string,
  76058. /** the value compared by the conditional operator against the current value of the property */
  76059. value: any,
  76060. /** the conditional operator, default ValueCondition.IsEqual */
  76061. operator?: number);
  76062. /**
  76063. * Compares the given value with the property value for the specified conditional operator
  76064. * @returns the result of the comparison
  76065. */
  76066. isValid(): boolean;
  76067. /**
  76068. * Serialize the ValueCondition into a JSON compatible object
  76069. * @returns serialization object
  76070. */
  76071. serialize(): any;
  76072. /**
  76073. * Gets the name of the conditional operator for the ValueCondition
  76074. * @param operator the conditional operator
  76075. * @returns the name
  76076. */
  76077. static GetOperatorName(operator: number): string;
  76078. }
  76079. /**
  76080. * Defines a predicate condition as an extension of Condition
  76081. */
  76082. export class PredicateCondition extends Condition {
  76083. /** defines the predicate function used to validate the condition */
  76084. predicate: () => boolean;
  76085. /**
  76086. * Internal only - manager for action
  76087. * @hidden
  76088. */
  76089. _actionManager: ActionManager;
  76090. /**
  76091. * Creates a new PredicateCondition
  76092. * @param actionManager manager for the action the condition applies to
  76093. * @param predicate defines the predicate function used to validate the condition
  76094. */
  76095. constructor(actionManager: ActionManager,
  76096. /** defines the predicate function used to validate the condition */
  76097. predicate: () => boolean);
  76098. /**
  76099. * @returns the validity of the predicate condition
  76100. */
  76101. isValid(): boolean;
  76102. }
  76103. /**
  76104. * Defines a state condition as an extension of Condition
  76105. */
  76106. export class StateCondition extends Condition {
  76107. /** Value to compare with target state */
  76108. value: string;
  76109. /**
  76110. * Internal only - manager for action
  76111. * @hidden
  76112. */
  76113. _actionManager: ActionManager;
  76114. /**
  76115. * Internal only
  76116. * @hidden
  76117. */
  76118. private _target;
  76119. /**
  76120. * Creates a new StateCondition
  76121. * @param actionManager manager for the action the condition applies to
  76122. * @param target of the condition
  76123. * @param value to compare with target state
  76124. */
  76125. constructor(actionManager: ActionManager, target: any,
  76126. /** Value to compare with target state */
  76127. value: string);
  76128. /**
  76129. * Gets a boolean indicating if the current condition is met
  76130. * @returns the validity of the state
  76131. */
  76132. isValid(): boolean;
  76133. /**
  76134. * Serialize the StateCondition into a JSON compatible object
  76135. * @returns serialization object
  76136. */
  76137. serialize(): any;
  76138. }
  76139. }
  76140. declare module BABYLON {
  76141. /**
  76142. * This defines an action responsible to toggle a boolean once triggered.
  76143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76144. */
  76145. export class SwitchBooleanAction extends Action {
  76146. /**
  76147. * The path to the boolean property in the target object
  76148. */
  76149. propertyPath: string;
  76150. private _target;
  76151. private _effectiveTarget;
  76152. private _property;
  76153. /**
  76154. * Instantiate the action
  76155. * @param triggerOptions defines the trigger options
  76156. * @param target defines the object containing the boolean
  76157. * @param propertyPath defines the path to the boolean property in the target object
  76158. * @param condition defines the trigger related conditions
  76159. */
  76160. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76161. /** @hidden */
  76162. _prepare(): void;
  76163. /**
  76164. * Execute the action toggle the boolean value.
  76165. */
  76166. execute(): void;
  76167. /**
  76168. * Serializes the actions and its related information.
  76169. * @param parent defines the object to serialize in
  76170. * @returns the serialized object
  76171. */
  76172. serialize(parent: any): any;
  76173. }
  76174. /**
  76175. * This defines an action responsible to set a the state field of the target
  76176. * to a desired value once triggered.
  76177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76178. */
  76179. export class SetStateAction extends Action {
  76180. /**
  76181. * The value to store in the state field.
  76182. */
  76183. value: string;
  76184. private _target;
  76185. /**
  76186. * Instantiate the action
  76187. * @param triggerOptions defines the trigger options
  76188. * @param target defines the object containing the state property
  76189. * @param value defines the value to store in the state field
  76190. * @param condition defines the trigger related conditions
  76191. */
  76192. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76193. /**
  76194. * Execute the action and store the value on the target state property.
  76195. */
  76196. execute(): void;
  76197. /**
  76198. * Serializes the actions and its related information.
  76199. * @param parent defines the object to serialize in
  76200. * @returns the serialized object
  76201. */
  76202. serialize(parent: any): any;
  76203. }
  76204. /**
  76205. * This defines an action responsible to set a property of the target
  76206. * to a desired value once triggered.
  76207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76208. */
  76209. export class SetValueAction extends Action {
  76210. /**
  76211. * The path of the property to set in the target.
  76212. */
  76213. propertyPath: string;
  76214. /**
  76215. * The value to set in the property
  76216. */
  76217. value: any;
  76218. private _target;
  76219. private _effectiveTarget;
  76220. private _property;
  76221. /**
  76222. * Instantiate the action
  76223. * @param triggerOptions defines the trigger options
  76224. * @param target defines the object containing the property
  76225. * @param propertyPath defines the path of the property to set in the target
  76226. * @param value defines the value to set in the property
  76227. * @param condition defines the trigger related conditions
  76228. */
  76229. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76230. /** @hidden */
  76231. _prepare(): void;
  76232. /**
  76233. * Execute the action and set the targetted property to the desired value.
  76234. */
  76235. execute(): void;
  76236. /**
  76237. * Serializes the actions and its related information.
  76238. * @param parent defines the object to serialize in
  76239. * @returns the serialized object
  76240. */
  76241. serialize(parent: any): any;
  76242. }
  76243. /**
  76244. * This defines an action responsible to increment the target value
  76245. * to a desired value once triggered.
  76246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76247. */
  76248. export class IncrementValueAction extends Action {
  76249. /**
  76250. * The path of the property to increment in the target.
  76251. */
  76252. propertyPath: string;
  76253. /**
  76254. * The value we should increment the property by.
  76255. */
  76256. value: any;
  76257. private _target;
  76258. private _effectiveTarget;
  76259. private _property;
  76260. /**
  76261. * Instantiate the action
  76262. * @param triggerOptions defines the trigger options
  76263. * @param target defines the object containing the property
  76264. * @param propertyPath defines the path of the property to increment in the target
  76265. * @param value defines the value value we should increment the property by
  76266. * @param condition defines the trigger related conditions
  76267. */
  76268. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76269. /** @hidden */
  76270. _prepare(): void;
  76271. /**
  76272. * Execute the action and increment the target of the value amount.
  76273. */
  76274. execute(): void;
  76275. /**
  76276. * Serializes the actions and its related information.
  76277. * @param parent defines the object to serialize in
  76278. * @returns the serialized object
  76279. */
  76280. serialize(parent: any): any;
  76281. }
  76282. /**
  76283. * This defines an action responsible to start an animation once triggered.
  76284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76285. */
  76286. export class PlayAnimationAction extends Action {
  76287. /**
  76288. * Where the animation should start (animation frame)
  76289. */
  76290. from: number;
  76291. /**
  76292. * Where the animation should stop (animation frame)
  76293. */
  76294. to: number;
  76295. /**
  76296. * Define if the animation should loop or stop after the first play.
  76297. */
  76298. loop?: boolean;
  76299. private _target;
  76300. /**
  76301. * Instantiate the action
  76302. * @param triggerOptions defines the trigger options
  76303. * @param target defines the target animation or animation name
  76304. * @param from defines from where the animation should start (animation frame)
  76305. * @param end defines where the animation should stop (animation frame)
  76306. * @param loop defines if the animation should loop or stop after the first play
  76307. * @param condition defines the trigger related conditions
  76308. */
  76309. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76310. /** @hidden */
  76311. _prepare(): void;
  76312. /**
  76313. * Execute the action and play the animation.
  76314. */
  76315. execute(): void;
  76316. /**
  76317. * Serializes the actions and its related information.
  76318. * @param parent defines the object to serialize in
  76319. * @returns the serialized object
  76320. */
  76321. serialize(parent: any): any;
  76322. }
  76323. /**
  76324. * This defines an action responsible to stop an animation once triggered.
  76325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76326. */
  76327. export class StopAnimationAction extends Action {
  76328. private _target;
  76329. /**
  76330. * Instantiate the action
  76331. * @param triggerOptions defines the trigger options
  76332. * @param target defines the target animation or animation name
  76333. * @param condition defines the trigger related conditions
  76334. */
  76335. constructor(triggerOptions: any, target: any, condition?: Condition);
  76336. /** @hidden */
  76337. _prepare(): void;
  76338. /**
  76339. * Execute the action and stop the animation.
  76340. */
  76341. execute(): void;
  76342. /**
  76343. * Serializes the actions and its related information.
  76344. * @param parent defines the object to serialize in
  76345. * @returns the serialized object
  76346. */
  76347. serialize(parent: any): any;
  76348. }
  76349. /**
  76350. * This defines an action responsible that does nothing once triggered.
  76351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76352. */
  76353. export class DoNothingAction extends Action {
  76354. /**
  76355. * Instantiate the action
  76356. * @param triggerOptions defines the trigger options
  76357. * @param condition defines the trigger related conditions
  76358. */
  76359. constructor(triggerOptions?: any, condition?: Condition);
  76360. /**
  76361. * Execute the action and do nothing.
  76362. */
  76363. execute(): void;
  76364. /**
  76365. * Serializes the actions and its related information.
  76366. * @param parent defines the object to serialize in
  76367. * @returns the serialized object
  76368. */
  76369. serialize(parent: any): any;
  76370. }
  76371. /**
  76372. * This defines an action responsible to trigger several actions once triggered.
  76373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76374. */
  76375. export class CombineAction extends Action {
  76376. /**
  76377. * The list of aggregated animations to run.
  76378. */
  76379. children: Action[];
  76380. /**
  76381. * Instantiate the action
  76382. * @param triggerOptions defines the trigger options
  76383. * @param children defines the list of aggregated animations to run
  76384. * @param condition defines the trigger related conditions
  76385. */
  76386. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76387. /** @hidden */
  76388. _prepare(): void;
  76389. /**
  76390. * Execute the action and executes all the aggregated actions.
  76391. */
  76392. execute(evt: ActionEvent): void;
  76393. /**
  76394. * Serializes the actions and its related information.
  76395. * @param parent defines the object to serialize in
  76396. * @returns the serialized object
  76397. */
  76398. serialize(parent: any): any;
  76399. }
  76400. /**
  76401. * This defines an action responsible to run code (external event) once triggered.
  76402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76403. */
  76404. export class ExecuteCodeAction extends Action {
  76405. /**
  76406. * The callback function to run.
  76407. */
  76408. func: (evt: ActionEvent) => void;
  76409. /**
  76410. * Instantiate the action
  76411. * @param triggerOptions defines the trigger options
  76412. * @param func defines the callback function to run
  76413. * @param condition defines the trigger related conditions
  76414. */
  76415. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76416. /**
  76417. * Execute the action and run the attached code.
  76418. */
  76419. execute(evt: ActionEvent): void;
  76420. }
  76421. /**
  76422. * This defines an action responsible to set the parent property of the target once triggered.
  76423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76424. */
  76425. export class SetParentAction extends Action {
  76426. private _parent;
  76427. private _target;
  76428. /**
  76429. * Instantiate the action
  76430. * @param triggerOptions defines the trigger options
  76431. * @param target defines the target containing the parent property
  76432. * @param parent defines from where the animation should start (animation frame)
  76433. * @param condition defines the trigger related conditions
  76434. */
  76435. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76436. /** @hidden */
  76437. _prepare(): void;
  76438. /**
  76439. * Execute the action and set the parent property.
  76440. */
  76441. execute(): void;
  76442. /**
  76443. * Serializes the actions and its related information.
  76444. * @param parent defines the object to serialize in
  76445. * @returns the serialized object
  76446. */
  76447. serialize(parent: any): any;
  76448. }
  76449. }
  76450. declare module BABYLON {
  76451. /**
  76452. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76453. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76455. */
  76456. export class ActionManager extends AbstractActionManager {
  76457. /**
  76458. * Nothing
  76459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76460. */
  76461. static readonly NothingTrigger: number;
  76462. /**
  76463. * On pick
  76464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76465. */
  76466. static readonly OnPickTrigger: number;
  76467. /**
  76468. * On left pick
  76469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76470. */
  76471. static readonly OnLeftPickTrigger: number;
  76472. /**
  76473. * On right pick
  76474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76475. */
  76476. static readonly OnRightPickTrigger: number;
  76477. /**
  76478. * On center pick
  76479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76480. */
  76481. static readonly OnCenterPickTrigger: number;
  76482. /**
  76483. * On pick down
  76484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76485. */
  76486. static readonly OnPickDownTrigger: number;
  76487. /**
  76488. * On double pick
  76489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76490. */
  76491. static readonly OnDoublePickTrigger: number;
  76492. /**
  76493. * On pick up
  76494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76495. */
  76496. static readonly OnPickUpTrigger: number;
  76497. /**
  76498. * On pick out.
  76499. * This trigger will only be raised if you also declared a OnPickDown
  76500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76501. */
  76502. static readonly OnPickOutTrigger: number;
  76503. /**
  76504. * On long press
  76505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76506. */
  76507. static readonly OnLongPressTrigger: number;
  76508. /**
  76509. * On pointer over
  76510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76511. */
  76512. static readonly OnPointerOverTrigger: number;
  76513. /**
  76514. * On pointer out
  76515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76516. */
  76517. static readonly OnPointerOutTrigger: number;
  76518. /**
  76519. * On every frame
  76520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76521. */
  76522. static readonly OnEveryFrameTrigger: number;
  76523. /**
  76524. * On intersection enter
  76525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76526. */
  76527. static readonly OnIntersectionEnterTrigger: number;
  76528. /**
  76529. * On intersection exit
  76530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76531. */
  76532. static readonly OnIntersectionExitTrigger: number;
  76533. /**
  76534. * On key down
  76535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76536. */
  76537. static readonly OnKeyDownTrigger: number;
  76538. /**
  76539. * On key up
  76540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76541. */
  76542. static readonly OnKeyUpTrigger: number;
  76543. private _scene;
  76544. /**
  76545. * Creates a new action manager
  76546. * @param scene defines the hosting scene
  76547. */
  76548. constructor(scene: Scene);
  76549. /**
  76550. * Releases all associated resources
  76551. */
  76552. dispose(): void;
  76553. /**
  76554. * Gets hosting scene
  76555. * @returns the hosting scene
  76556. */
  76557. getScene(): Scene;
  76558. /**
  76559. * Does this action manager handles actions of any of the given triggers
  76560. * @param triggers defines the triggers to be tested
  76561. * @return a boolean indicating whether one (or more) of the triggers is handled
  76562. */
  76563. hasSpecificTriggers(triggers: number[]): boolean;
  76564. /**
  76565. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76566. * speed.
  76567. * @param triggerA defines the trigger to be tested
  76568. * @param triggerB defines the trigger to be tested
  76569. * @return a boolean indicating whether one (or more) of the triggers is handled
  76570. */
  76571. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76572. /**
  76573. * Does this action manager handles actions of a given trigger
  76574. * @param trigger defines the trigger to be tested
  76575. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76576. * @return whether the trigger is handled
  76577. */
  76578. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76579. /**
  76580. * Does this action manager has pointer triggers
  76581. */
  76582. readonly hasPointerTriggers: boolean;
  76583. /**
  76584. * Does this action manager has pick triggers
  76585. */
  76586. readonly hasPickTriggers: boolean;
  76587. /**
  76588. * Registers an action to this action manager
  76589. * @param action defines the action to be registered
  76590. * @return the action amended (prepared) after registration
  76591. */
  76592. registerAction(action: IAction): Nullable<IAction>;
  76593. /**
  76594. * Unregisters an action to this action manager
  76595. * @param action defines the action to be unregistered
  76596. * @return a boolean indicating whether the action has been unregistered
  76597. */
  76598. unregisterAction(action: IAction): Boolean;
  76599. /**
  76600. * Process a specific trigger
  76601. * @param trigger defines the trigger to process
  76602. * @param evt defines the event details to be processed
  76603. */
  76604. processTrigger(trigger: number, evt?: IActionEvent): void;
  76605. /** @hidden */
  76606. _getEffectiveTarget(target: any, propertyPath: string): any;
  76607. /** @hidden */
  76608. _getProperty(propertyPath: string): string;
  76609. /**
  76610. * Serialize this manager to a JSON object
  76611. * @param name defines the property name to store this manager
  76612. * @returns a JSON representation of this manager
  76613. */
  76614. serialize(name: string): any;
  76615. /**
  76616. * Creates a new ActionManager from a JSON data
  76617. * @param parsedActions defines the JSON data to read from
  76618. * @param object defines the hosting mesh
  76619. * @param scene defines the hosting scene
  76620. */
  76621. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76622. /**
  76623. * Get a trigger name by index
  76624. * @param trigger defines the trigger index
  76625. * @returns a trigger name
  76626. */
  76627. static GetTriggerName(trigger: number): string;
  76628. }
  76629. }
  76630. declare module BABYLON {
  76631. /**
  76632. * Class representing a ray with position and direction
  76633. */
  76634. export class Ray {
  76635. /** origin point */
  76636. origin: Vector3;
  76637. /** direction */
  76638. direction: Vector3;
  76639. /** length of the ray */
  76640. length: number;
  76641. private static readonly TmpVector3;
  76642. private _tmpRay;
  76643. /**
  76644. * Creates a new ray
  76645. * @param origin origin point
  76646. * @param direction direction
  76647. * @param length length of the ray
  76648. */
  76649. constructor(
  76650. /** origin point */
  76651. origin: Vector3,
  76652. /** direction */
  76653. direction: Vector3,
  76654. /** length of the ray */
  76655. length?: number);
  76656. /**
  76657. * Checks if the ray intersects a box
  76658. * @param minimum bound of the box
  76659. * @param maximum bound of the box
  76660. * @param intersectionTreshold extra extend to be added to the box in all direction
  76661. * @returns if the box was hit
  76662. */
  76663. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76664. /**
  76665. * Checks if the ray intersects a box
  76666. * @param box the bounding box to check
  76667. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76668. * @returns if the box was hit
  76669. */
  76670. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76671. /**
  76672. * If the ray hits a sphere
  76673. * @param sphere the bounding sphere to check
  76674. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76675. * @returns true if it hits the sphere
  76676. */
  76677. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76678. /**
  76679. * If the ray hits a triange
  76680. * @param vertex0 triangle vertex
  76681. * @param vertex1 triangle vertex
  76682. * @param vertex2 triangle vertex
  76683. * @returns intersection information if hit
  76684. */
  76685. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76686. /**
  76687. * Checks if ray intersects a plane
  76688. * @param plane the plane to check
  76689. * @returns the distance away it was hit
  76690. */
  76691. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76692. /**
  76693. * Calculate the intercept of a ray on a given axis
  76694. * @param axis to check 'x' | 'y' | 'z'
  76695. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76696. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76697. */
  76698. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76699. /**
  76700. * Checks if ray intersects a mesh
  76701. * @param mesh the mesh to check
  76702. * @param fastCheck if only the bounding box should checked
  76703. * @returns picking info of the intersecton
  76704. */
  76705. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76706. /**
  76707. * Checks if ray intersects a mesh
  76708. * @param meshes the meshes to check
  76709. * @param fastCheck if only the bounding box should checked
  76710. * @param results array to store result in
  76711. * @returns Array of picking infos
  76712. */
  76713. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76714. private _comparePickingInfo;
  76715. private static smallnum;
  76716. private static rayl;
  76717. /**
  76718. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76719. * @param sega the first point of the segment to test the intersection against
  76720. * @param segb the second point of the segment to test the intersection against
  76721. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76722. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76723. */
  76724. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76725. /**
  76726. * Update the ray from viewport position
  76727. * @param x position
  76728. * @param y y position
  76729. * @param viewportWidth viewport width
  76730. * @param viewportHeight viewport height
  76731. * @param world world matrix
  76732. * @param view view matrix
  76733. * @param projection projection matrix
  76734. * @returns this ray updated
  76735. */
  76736. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76737. /**
  76738. * Creates a ray with origin and direction of 0,0,0
  76739. * @returns the new ray
  76740. */
  76741. static Zero(): Ray;
  76742. /**
  76743. * Creates a new ray from screen space and viewport
  76744. * @param x position
  76745. * @param y y position
  76746. * @param viewportWidth viewport width
  76747. * @param viewportHeight viewport height
  76748. * @param world world matrix
  76749. * @param view view matrix
  76750. * @param projection projection matrix
  76751. * @returns new ray
  76752. */
  76753. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76754. /**
  76755. * 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
  76756. * transformed to the given world matrix.
  76757. * @param origin The origin point
  76758. * @param end The end point
  76759. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76760. * @returns the new ray
  76761. */
  76762. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76763. /**
  76764. * Transforms a ray by a matrix
  76765. * @param ray ray to transform
  76766. * @param matrix matrix to apply
  76767. * @returns the resulting new ray
  76768. */
  76769. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76770. /**
  76771. * Transforms a ray by a matrix
  76772. * @param ray ray to transform
  76773. * @param matrix matrix to apply
  76774. * @param result ray to store result in
  76775. */
  76776. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76777. /**
  76778. * Unproject a ray from screen space to object space
  76779. * @param sourceX defines the screen space x coordinate to use
  76780. * @param sourceY defines the screen space y coordinate to use
  76781. * @param viewportWidth defines the current width of the viewport
  76782. * @param viewportHeight defines the current height of the viewport
  76783. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76784. * @param view defines the view matrix to use
  76785. * @param projection defines the projection matrix to use
  76786. */
  76787. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76788. }
  76789. /**
  76790. * Type used to define predicate used to select faces when a mesh intersection is detected
  76791. */
  76792. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76793. interface Scene {
  76794. /** @hidden */
  76795. _tempPickingRay: Nullable<Ray>;
  76796. /** @hidden */
  76797. _cachedRayForTransform: Ray;
  76798. /** @hidden */
  76799. _pickWithRayInverseMatrix: Matrix;
  76800. /** @hidden */
  76801. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76802. /** @hidden */
  76803. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76804. }
  76805. }
  76806. declare module BABYLON {
  76807. /**
  76808. * Groups all the scene component constants in one place to ease maintenance.
  76809. * @hidden
  76810. */
  76811. export class SceneComponentConstants {
  76812. static readonly NAME_EFFECTLAYER: string;
  76813. static readonly NAME_LAYER: string;
  76814. static readonly NAME_LENSFLARESYSTEM: string;
  76815. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76816. static readonly NAME_PARTICLESYSTEM: string;
  76817. static readonly NAME_GAMEPAD: string;
  76818. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76819. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76820. static readonly NAME_DEPTHRENDERER: string;
  76821. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76822. static readonly NAME_SPRITE: string;
  76823. static readonly NAME_OUTLINERENDERER: string;
  76824. static readonly NAME_PROCEDURALTEXTURE: string;
  76825. static readonly NAME_SHADOWGENERATOR: string;
  76826. static readonly NAME_OCTREE: string;
  76827. static readonly NAME_PHYSICSENGINE: string;
  76828. static readonly NAME_AUDIO: string;
  76829. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76830. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76831. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76832. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76833. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76834. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76835. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76836. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76837. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76838. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76839. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76840. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76841. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76842. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76843. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76844. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76845. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76846. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76847. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76848. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76849. static readonly STEP_AFTERRENDER_AUDIO: number;
  76850. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76851. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76852. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76853. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76854. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76855. static readonly STEP_POINTERMOVE_SPRITE: number;
  76856. static readonly STEP_POINTERDOWN_SPRITE: number;
  76857. static readonly STEP_POINTERUP_SPRITE: number;
  76858. }
  76859. /**
  76860. * This represents a scene component.
  76861. *
  76862. * This is used to decouple the dependency the scene is having on the different workloads like
  76863. * layers, post processes...
  76864. */
  76865. export interface ISceneComponent {
  76866. /**
  76867. * The name of the component. Each component must have a unique name.
  76868. */
  76869. name: string;
  76870. /**
  76871. * The scene the component belongs to.
  76872. */
  76873. scene: Scene;
  76874. /**
  76875. * Register the component to one instance of a scene.
  76876. */
  76877. register(): void;
  76878. /**
  76879. * Rebuilds the elements related to this component in case of
  76880. * context lost for instance.
  76881. */
  76882. rebuild(): void;
  76883. /**
  76884. * Disposes the component and the associated ressources.
  76885. */
  76886. dispose(): void;
  76887. }
  76888. /**
  76889. * This represents a SERIALIZABLE scene component.
  76890. *
  76891. * This extends Scene Component to add Serialization methods on top.
  76892. */
  76893. export interface ISceneSerializableComponent extends ISceneComponent {
  76894. /**
  76895. * Adds all the elements from the container to the scene
  76896. * @param container the container holding the elements
  76897. */
  76898. addFromContainer(container: AbstractScene): void;
  76899. /**
  76900. * Removes all the elements in the container from the scene
  76901. * @param container contains the elements to remove
  76902. * @param dispose if the removed element should be disposed (default: false)
  76903. */
  76904. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76905. /**
  76906. * Serializes the component data to the specified json object
  76907. * @param serializationObject The object to serialize to
  76908. */
  76909. serialize(serializationObject: any): void;
  76910. }
  76911. /**
  76912. * Strong typing of a Mesh related stage step action
  76913. */
  76914. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76915. /**
  76916. * Strong typing of a Evaluate Sub Mesh related stage step action
  76917. */
  76918. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76919. /**
  76920. * Strong typing of a Active Mesh related stage step action
  76921. */
  76922. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76923. /**
  76924. * Strong typing of a Camera related stage step action
  76925. */
  76926. export type CameraStageAction = (camera: Camera) => void;
  76927. /**
  76928. * Strong typing of a Camera Frame buffer related stage step action
  76929. */
  76930. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76931. /**
  76932. * Strong typing of a Render Target related stage step action
  76933. */
  76934. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76935. /**
  76936. * Strong typing of a RenderingGroup related stage step action
  76937. */
  76938. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76939. /**
  76940. * Strong typing of a Mesh Render related stage step action
  76941. */
  76942. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76943. /**
  76944. * Strong typing of a simple stage step action
  76945. */
  76946. export type SimpleStageAction = () => void;
  76947. /**
  76948. * Strong typing of a render target action.
  76949. */
  76950. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76951. /**
  76952. * Strong typing of a pointer move action.
  76953. */
  76954. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76955. /**
  76956. * Strong typing of a pointer up/down action.
  76957. */
  76958. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76959. /**
  76960. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76961. * @hidden
  76962. */
  76963. export class Stage<T extends Function> extends Array<{
  76964. index: number;
  76965. component: ISceneComponent;
  76966. action: T;
  76967. }> {
  76968. /**
  76969. * Hide ctor from the rest of the world.
  76970. * @param items The items to add.
  76971. */
  76972. private constructor();
  76973. /**
  76974. * Creates a new Stage.
  76975. * @returns A new instance of a Stage
  76976. */
  76977. static Create<T extends Function>(): Stage<T>;
  76978. /**
  76979. * Registers a step in an ordered way in the targeted stage.
  76980. * @param index Defines the position to register the step in
  76981. * @param component Defines the component attached to the step
  76982. * @param action Defines the action to launch during the step
  76983. */
  76984. registerStep(index: number, component: ISceneComponent, action: T): void;
  76985. /**
  76986. * Clears all the steps from the stage.
  76987. */
  76988. clear(): void;
  76989. }
  76990. }
  76991. declare module BABYLON {
  76992. interface Scene {
  76993. /** @hidden */
  76994. _pointerOverSprite: Nullable<Sprite>;
  76995. /** @hidden */
  76996. _pickedDownSprite: Nullable<Sprite>;
  76997. /** @hidden */
  76998. _tempSpritePickingRay: Nullable<Ray>;
  76999. /**
  77000. * All of the sprite managers added to this scene
  77001. * @see http://doc.babylonjs.com/babylon101/sprites
  77002. */
  77003. spriteManagers: Array<ISpriteManager>;
  77004. /**
  77005. * An event triggered when sprites rendering is about to start
  77006. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77007. */
  77008. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77009. /**
  77010. * An event triggered when sprites rendering is done
  77011. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77012. */
  77013. onAfterSpritesRenderingObservable: Observable<Scene>;
  77014. /** @hidden */
  77015. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77016. /** Launch a ray to try to pick a sprite in the scene
  77017. * @param x position on screen
  77018. * @param y position on screen
  77019. * @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
  77020. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77021. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77022. * @returns a PickingInfo
  77023. */
  77024. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77025. /** Use the given ray to pick a sprite in the scene
  77026. * @param ray The ray (in world space) to use to pick meshes
  77027. * @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
  77028. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77029. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77030. * @returns a PickingInfo
  77031. */
  77032. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77033. /** @hidden */
  77034. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77035. /** Launch a ray to try to pick sprites in the scene
  77036. * @param x position on screen
  77037. * @param y position on screen
  77038. * @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
  77039. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77040. * @returns a PickingInfo array
  77041. */
  77042. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77043. /** Use the given ray to pick sprites in the scene
  77044. * @param ray The ray (in world space) to use to pick meshes
  77045. * @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
  77046. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77047. * @returns a PickingInfo array
  77048. */
  77049. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77050. /**
  77051. * Force the sprite under the pointer
  77052. * @param sprite defines the sprite to use
  77053. */
  77054. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77055. /**
  77056. * Gets the sprite under the pointer
  77057. * @returns a Sprite or null if no sprite is under the pointer
  77058. */
  77059. getPointerOverSprite(): Nullable<Sprite>;
  77060. }
  77061. /**
  77062. * Defines the sprite scene component responsible to manage sprites
  77063. * in a given scene.
  77064. */
  77065. export class SpriteSceneComponent implements ISceneComponent {
  77066. /**
  77067. * The component name helpfull to identify the component in the list of scene components.
  77068. */
  77069. readonly name: string;
  77070. /**
  77071. * The scene the component belongs to.
  77072. */
  77073. scene: Scene;
  77074. /** @hidden */
  77075. private _spritePredicate;
  77076. /**
  77077. * Creates a new instance of the component for the given scene
  77078. * @param scene Defines the scene to register the component in
  77079. */
  77080. constructor(scene: Scene);
  77081. /**
  77082. * Registers the component in a given scene
  77083. */
  77084. register(): void;
  77085. /**
  77086. * Rebuilds the elements related to this component in case of
  77087. * context lost for instance.
  77088. */
  77089. rebuild(): void;
  77090. /**
  77091. * Disposes the component and the associated ressources.
  77092. */
  77093. dispose(): void;
  77094. private _pickSpriteButKeepRay;
  77095. private _pointerMove;
  77096. private _pointerDown;
  77097. private _pointerUp;
  77098. }
  77099. }
  77100. declare module BABYLON {
  77101. /** @hidden */
  77102. export var fogFragmentDeclaration: {
  77103. name: string;
  77104. shader: string;
  77105. };
  77106. }
  77107. declare module BABYLON {
  77108. /** @hidden */
  77109. export var fogFragment: {
  77110. name: string;
  77111. shader: string;
  77112. };
  77113. }
  77114. declare module BABYLON {
  77115. /** @hidden */
  77116. export var spritesPixelShader: {
  77117. name: string;
  77118. shader: string;
  77119. };
  77120. }
  77121. declare module BABYLON {
  77122. /** @hidden */
  77123. export var fogVertexDeclaration: {
  77124. name: string;
  77125. shader: string;
  77126. };
  77127. }
  77128. declare module BABYLON {
  77129. /** @hidden */
  77130. export var spritesVertexShader: {
  77131. name: string;
  77132. shader: string;
  77133. };
  77134. }
  77135. declare module BABYLON {
  77136. /**
  77137. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77138. */
  77139. export interface ISpriteManager extends IDisposable {
  77140. /**
  77141. * Restricts the camera to viewing objects with the same layerMask.
  77142. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77143. */
  77144. layerMask: number;
  77145. /**
  77146. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77147. */
  77148. isPickable: boolean;
  77149. /**
  77150. * Specifies the rendering group id for this mesh (0 by default)
  77151. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77152. */
  77153. renderingGroupId: number;
  77154. /**
  77155. * Defines the list of sprites managed by the manager.
  77156. */
  77157. sprites: Array<Sprite>;
  77158. /**
  77159. * Tests the intersection of a sprite with a specific ray.
  77160. * @param ray The ray we are sending to test the collision
  77161. * @param camera The camera space we are sending rays in
  77162. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77163. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77164. * @returns picking info or null.
  77165. */
  77166. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77167. /**
  77168. * Intersects the sprites with a ray
  77169. * @param ray defines the ray to intersect with
  77170. * @param camera defines the current active camera
  77171. * @param predicate defines a predicate used to select candidate sprites
  77172. * @returns null if no hit or a PickingInfo array
  77173. */
  77174. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77175. /**
  77176. * Renders the list of sprites on screen.
  77177. */
  77178. render(): void;
  77179. }
  77180. /**
  77181. * Class used to manage multiple sprites on the same spritesheet
  77182. * @see http://doc.babylonjs.com/babylon101/sprites
  77183. */
  77184. export class SpriteManager implements ISpriteManager {
  77185. /** defines the manager's name */
  77186. name: string;
  77187. /** Gets the list of sprites */
  77188. sprites: Sprite[];
  77189. /** Gets or sets the rendering group id (0 by default) */
  77190. renderingGroupId: number;
  77191. /** Gets or sets camera layer mask */
  77192. layerMask: number;
  77193. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77194. fogEnabled: boolean;
  77195. /** Gets or sets a boolean indicating if the sprites are pickable */
  77196. isPickable: boolean;
  77197. /** Defines the default width of a cell in the spritesheet */
  77198. cellWidth: number;
  77199. /** Defines the default height of a cell in the spritesheet */
  77200. cellHeight: number;
  77201. /** Associative array from JSON sprite data file */
  77202. private _cellData;
  77203. /** Array of sprite names from JSON sprite data file */
  77204. private _spriteMap;
  77205. /** True when packed cell data from JSON file is ready*/
  77206. private _packedAndReady;
  77207. /**
  77208. * An event triggered when the manager is disposed.
  77209. */
  77210. onDisposeObservable: Observable<SpriteManager>;
  77211. private _onDisposeObserver;
  77212. /**
  77213. * Callback called when the manager is disposed
  77214. */
  77215. onDispose: () => void;
  77216. private _capacity;
  77217. private _fromPacked;
  77218. private _spriteTexture;
  77219. private _epsilon;
  77220. private _scene;
  77221. private _vertexData;
  77222. private _buffer;
  77223. private _vertexBuffers;
  77224. private _indexBuffer;
  77225. private _effectBase;
  77226. private _effectFog;
  77227. /**
  77228. * Gets or sets the spritesheet texture
  77229. */
  77230. texture: Texture;
  77231. /**
  77232. * Creates a new sprite manager
  77233. * @param name defines the manager's name
  77234. * @param imgUrl defines the sprite sheet url
  77235. * @param capacity defines the maximum allowed number of sprites
  77236. * @param cellSize defines the size of a sprite cell
  77237. * @param scene defines the hosting scene
  77238. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77239. * @param samplingMode defines the smapling mode to use with spritesheet
  77240. * @param fromPacked set to false; do not alter
  77241. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77242. */
  77243. constructor(
  77244. /** defines the manager's name */
  77245. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77246. private _makePacked;
  77247. private _appendSpriteVertex;
  77248. /**
  77249. * Intersects the sprites with a ray
  77250. * @param ray defines the ray to intersect with
  77251. * @param camera defines the current active camera
  77252. * @param predicate defines a predicate used to select candidate sprites
  77253. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77254. * @returns null if no hit or a PickingInfo
  77255. */
  77256. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77257. /**
  77258. * Intersects the sprites with a ray
  77259. * @param ray defines the ray to intersect with
  77260. * @param camera defines the current active camera
  77261. * @param predicate defines a predicate used to select candidate sprites
  77262. * @returns null if no hit or a PickingInfo array
  77263. */
  77264. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77265. /**
  77266. * Render all child sprites
  77267. */
  77268. render(): void;
  77269. /**
  77270. * Release associated resources
  77271. */
  77272. dispose(): void;
  77273. }
  77274. }
  77275. declare module BABYLON {
  77276. /**
  77277. * Class used to represent a sprite
  77278. * @see http://doc.babylonjs.com/babylon101/sprites
  77279. */
  77280. export class Sprite {
  77281. /** defines the name */
  77282. name: string;
  77283. /** Gets or sets the current world position */
  77284. position: Vector3;
  77285. /** Gets or sets the main color */
  77286. color: Color4;
  77287. /** Gets or sets the width */
  77288. width: number;
  77289. /** Gets or sets the height */
  77290. height: number;
  77291. /** Gets or sets rotation angle */
  77292. angle: number;
  77293. /** Gets or sets the cell index in the sprite sheet */
  77294. cellIndex: number;
  77295. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  77296. cellRef: string;
  77297. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77298. invertU: number;
  77299. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77300. invertV: number;
  77301. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77302. disposeWhenFinishedAnimating: boolean;
  77303. /** Gets the list of attached animations */
  77304. animations: Animation[];
  77305. /** Gets or sets a boolean indicating if the sprite can be picked */
  77306. isPickable: boolean;
  77307. /**
  77308. * Gets or sets the associated action manager
  77309. */
  77310. actionManager: Nullable<ActionManager>;
  77311. private _animationStarted;
  77312. private _loopAnimation;
  77313. private _fromIndex;
  77314. private _toIndex;
  77315. private _delay;
  77316. private _direction;
  77317. private _manager;
  77318. private _time;
  77319. private _onAnimationEnd;
  77320. /**
  77321. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77322. */
  77323. isVisible: boolean;
  77324. /**
  77325. * Gets or sets the sprite size
  77326. */
  77327. size: number;
  77328. /**
  77329. * Creates a new Sprite
  77330. * @param name defines the name
  77331. * @param manager defines the manager
  77332. */
  77333. constructor(
  77334. /** defines the name */
  77335. name: string, manager: ISpriteManager);
  77336. /**
  77337. * Starts an animation
  77338. * @param from defines the initial key
  77339. * @param to defines the end key
  77340. * @param loop defines if the animation must loop
  77341. * @param delay defines the start delay (in ms)
  77342. * @param onAnimationEnd defines a callback to call when animation ends
  77343. */
  77344. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77345. /** Stops current animation (if any) */
  77346. stopAnimation(): void;
  77347. /** @hidden */
  77348. _animate(deltaTime: number): void;
  77349. /** Release associated resources */
  77350. dispose(): void;
  77351. }
  77352. }
  77353. declare module BABYLON {
  77354. /**
  77355. * Information about the result of picking within a scene
  77356. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77357. */
  77358. export class PickingInfo {
  77359. /** @hidden */
  77360. _pickingUnavailable: boolean;
  77361. /**
  77362. * If the pick collided with an object
  77363. */
  77364. hit: boolean;
  77365. /**
  77366. * Distance away where the pick collided
  77367. */
  77368. distance: number;
  77369. /**
  77370. * The location of pick collision
  77371. */
  77372. pickedPoint: Nullable<Vector3>;
  77373. /**
  77374. * The mesh corresponding the the pick collision
  77375. */
  77376. pickedMesh: Nullable<AbstractMesh>;
  77377. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77378. bu: number;
  77379. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77380. bv: number;
  77381. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77382. faceId: number;
  77383. /** Id of the the submesh that was picked */
  77384. subMeshId: number;
  77385. /** If a sprite was picked, this will be the sprite the pick collided with */
  77386. pickedSprite: Nullable<Sprite>;
  77387. /**
  77388. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77389. */
  77390. originMesh: Nullable<AbstractMesh>;
  77391. /**
  77392. * The ray that was used to perform the picking.
  77393. */
  77394. ray: Nullable<Ray>;
  77395. /**
  77396. * Gets the normal correspodning to the face the pick collided with
  77397. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77398. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77399. * @returns The normal correspodning to the face the pick collided with
  77400. */
  77401. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77402. /**
  77403. * Gets the texture coordinates of where the pick occured
  77404. * @returns the vector containing the coordnates of the texture
  77405. */
  77406. getTextureCoordinates(): Nullable<Vector2>;
  77407. }
  77408. }
  77409. declare module BABYLON {
  77410. /**
  77411. * Gather the list of pointer event types as constants.
  77412. */
  77413. export class PointerEventTypes {
  77414. /**
  77415. * 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.
  77416. */
  77417. static readonly POINTERDOWN: number;
  77418. /**
  77419. * The pointerup event is fired when a pointer is no longer active.
  77420. */
  77421. static readonly POINTERUP: number;
  77422. /**
  77423. * The pointermove event is fired when a pointer changes coordinates.
  77424. */
  77425. static readonly POINTERMOVE: number;
  77426. /**
  77427. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77428. */
  77429. static readonly POINTERWHEEL: number;
  77430. /**
  77431. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77432. */
  77433. static readonly POINTERPICK: number;
  77434. /**
  77435. * The pointertap event is fired when a the object has been touched and released without drag.
  77436. */
  77437. static readonly POINTERTAP: number;
  77438. /**
  77439. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77440. */
  77441. static readonly POINTERDOUBLETAP: number;
  77442. }
  77443. /**
  77444. * Base class of pointer info types.
  77445. */
  77446. export class PointerInfoBase {
  77447. /**
  77448. * Defines the type of event (PointerEventTypes)
  77449. */
  77450. type: number;
  77451. /**
  77452. * Defines the related dom event
  77453. */
  77454. event: PointerEvent | MouseWheelEvent;
  77455. /**
  77456. * Instantiates the base class of pointers info.
  77457. * @param type Defines the type of event (PointerEventTypes)
  77458. * @param event Defines the related dom event
  77459. */
  77460. constructor(
  77461. /**
  77462. * Defines the type of event (PointerEventTypes)
  77463. */
  77464. type: number,
  77465. /**
  77466. * Defines the related dom event
  77467. */
  77468. event: PointerEvent | MouseWheelEvent);
  77469. }
  77470. /**
  77471. * This class is used to store pointer related info for the onPrePointerObservable event.
  77472. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77473. */
  77474. export class PointerInfoPre extends PointerInfoBase {
  77475. /**
  77476. * Ray from a pointer if availible (eg. 6dof controller)
  77477. */
  77478. ray: Nullable<Ray>;
  77479. /**
  77480. * Defines the local position of the pointer on the canvas.
  77481. */
  77482. localPosition: Vector2;
  77483. /**
  77484. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77485. */
  77486. skipOnPointerObservable: boolean;
  77487. /**
  77488. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77489. * @param type Defines the type of event (PointerEventTypes)
  77490. * @param event Defines the related dom event
  77491. * @param localX Defines the local x coordinates of the pointer when the event occured
  77492. * @param localY Defines the local y coordinates of the pointer when the event occured
  77493. */
  77494. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77495. }
  77496. /**
  77497. * This type contains all the data related to a pointer event in Babylon.js.
  77498. * 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.
  77499. */
  77500. export class PointerInfo extends PointerInfoBase {
  77501. /**
  77502. * Defines the picking info associated to the info (if any)\
  77503. */
  77504. pickInfo: Nullable<PickingInfo>;
  77505. /**
  77506. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77507. * @param type Defines the type of event (PointerEventTypes)
  77508. * @param event Defines the related dom event
  77509. * @param pickInfo Defines the picking info associated to the info (if any)\
  77510. */
  77511. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77512. /**
  77513. * Defines the picking info associated to the info (if any)\
  77514. */
  77515. pickInfo: Nullable<PickingInfo>);
  77516. }
  77517. /**
  77518. * Data relating to a touch event on the screen.
  77519. */
  77520. export interface PointerTouch {
  77521. /**
  77522. * X coordinate of touch.
  77523. */
  77524. x: number;
  77525. /**
  77526. * Y coordinate of touch.
  77527. */
  77528. y: number;
  77529. /**
  77530. * Id of touch. Unique for each finger.
  77531. */
  77532. pointerId: number;
  77533. /**
  77534. * Event type passed from DOM.
  77535. */
  77536. type: any;
  77537. }
  77538. }
  77539. declare module BABYLON {
  77540. /**
  77541. * Manage the mouse inputs to control the movement of a free camera.
  77542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77543. */
  77544. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77545. /**
  77546. * Define if touch is enabled in the mouse input
  77547. */
  77548. touchEnabled: boolean;
  77549. /**
  77550. * Defines the camera the input is attached to.
  77551. */
  77552. camera: FreeCamera;
  77553. /**
  77554. * Defines the buttons associated with the input to handle camera move.
  77555. */
  77556. buttons: number[];
  77557. /**
  77558. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77559. */
  77560. angularSensibility: number;
  77561. private _pointerInput;
  77562. private _onMouseMove;
  77563. private _observer;
  77564. private previousPosition;
  77565. /**
  77566. * Observable for when a pointer move event occurs containing the move offset
  77567. */
  77568. onPointerMovedObservable: Observable<{
  77569. offsetX: number;
  77570. offsetY: number;
  77571. }>;
  77572. /**
  77573. * @hidden
  77574. * If the camera should be rotated automatically based on pointer movement
  77575. */
  77576. _allowCameraRotation: boolean;
  77577. /**
  77578. * Manage the mouse inputs to control the movement of a free camera.
  77579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77580. * @param touchEnabled Defines if touch is enabled or not
  77581. */
  77582. constructor(
  77583. /**
  77584. * Define if touch is enabled in the mouse input
  77585. */
  77586. touchEnabled?: boolean);
  77587. /**
  77588. * Attach the input controls to a specific dom element to get the input from.
  77589. * @param element Defines the element the controls should be listened from
  77590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77591. */
  77592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77593. /**
  77594. * Called on JS contextmenu event.
  77595. * Override this method to provide functionality.
  77596. */
  77597. protected onContextMenu(evt: PointerEvent): void;
  77598. /**
  77599. * Detach the current controls from the specified dom element.
  77600. * @param element Defines the element to stop listening the inputs from
  77601. */
  77602. detachControl(element: Nullable<HTMLElement>): void;
  77603. /**
  77604. * Gets the class name of the current intput.
  77605. * @returns the class name
  77606. */
  77607. getClassName(): string;
  77608. /**
  77609. * Get the friendly name associated with the input class.
  77610. * @returns the input friendly name
  77611. */
  77612. getSimpleName(): string;
  77613. }
  77614. }
  77615. declare module BABYLON {
  77616. /**
  77617. * Manage the touch inputs to control the movement of a free camera.
  77618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77619. */
  77620. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77621. /**
  77622. * Defines the camera the input is attached to.
  77623. */
  77624. camera: FreeCamera;
  77625. /**
  77626. * Defines the touch sensibility for rotation.
  77627. * The higher the faster.
  77628. */
  77629. touchAngularSensibility: number;
  77630. /**
  77631. * Defines the touch sensibility for move.
  77632. * The higher the faster.
  77633. */
  77634. touchMoveSensibility: number;
  77635. private _offsetX;
  77636. private _offsetY;
  77637. private _pointerPressed;
  77638. private _pointerInput;
  77639. private _observer;
  77640. private _onLostFocus;
  77641. /**
  77642. * Attach the input controls to a specific dom element to get the input from.
  77643. * @param element Defines the element the controls should be listened from
  77644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77645. */
  77646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77647. /**
  77648. * Detach the current controls from the specified dom element.
  77649. * @param element Defines the element to stop listening the inputs from
  77650. */
  77651. detachControl(element: Nullable<HTMLElement>): void;
  77652. /**
  77653. * Update the current camera state depending on the inputs that have been used this frame.
  77654. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77655. */
  77656. checkInputs(): void;
  77657. /**
  77658. * Gets the class name of the current intput.
  77659. * @returns the class name
  77660. */
  77661. getClassName(): string;
  77662. /**
  77663. * Get the friendly name associated with the input class.
  77664. * @returns the input friendly name
  77665. */
  77666. getSimpleName(): string;
  77667. }
  77668. }
  77669. declare module BABYLON {
  77670. /**
  77671. * Default Inputs manager for the FreeCamera.
  77672. * It groups all the default supported inputs for ease of use.
  77673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77674. */
  77675. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77676. /**
  77677. * @hidden
  77678. */
  77679. _mouseInput: Nullable<FreeCameraMouseInput>;
  77680. /**
  77681. * Instantiates a new FreeCameraInputsManager.
  77682. * @param camera Defines the camera the inputs belong to
  77683. */
  77684. constructor(camera: FreeCamera);
  77685. /**
  77686. * Add keyboard input support to the input manager.
  77687. * @returns the current input manager
  77688. */
  77689. addKeyboard(): FreeCameraInputsManager;
  77690. /**
  77691. * Add mouse input support to the input manager.
  77692. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77693. * @returns the current input manager
  77694. */
  77695. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77696. /**
  77697. * Removes the mouse input support from the manager
  77698. * @returns the current input manager
  77699. */
  77700. removeMouse(): FreeCameraInputsManager;
  77701. /**
  77702. * Add touch input support to the input manager.
  77703. * @returns the current input manager
  77704. */
  77705. addTouch(): FreeCameraInputsManager;
  77706. /**
  77707. * Remove all attached input methods from a camera
  77708. */
  77709. clear(): void;
  77710. }
  77711. }
  77712. declare module BABYLON {
  77713. /**
  77714. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77715. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77716. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77717. */
  77718. export class FreeCamera extends TargetCamera {
  77719. /**
  77720. * Define the collision ellipsoid of the camera.
  77721. * This is helpful to simulate a camera body like the player body around the camera
  77722. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77723. */
  77724. ellipsoid: Vector3;
  77725. /**
  77726. * Define an offset for the position of the ellipsoid around the camera.
  77727. * This can be helpful to determine the center of the body near the gravity center of the body
  77728. * instead of its head.
  77729. */
  77730. ellipsoidOffset: Vector3;
  77731. /**
  77732. * Enable or disable collisions of the camera with the rest of the scene objects.
  77733. */
  77734. checkCollisions: boolean;
  77735. /**
  77736. * Enable or disable gravity on the camera.
  77737. */
  77738. applyGravity: boolean;
  77739. /**
  77740. * Define the input manager associated to the camera.
  77741. */
  77742. inputs: FreeCameraInputsManager;
  77743. /**
  77744. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77745. * Higher values reduce sensitivity.
  77746. */
  77747. /**
  77748. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77749. * Higher values reduce sensitivity.
  77750. */
  77751. angularSensibility: number;
  77752. /**
  77753. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77754. */
  77755. keysUp: number[];
  77756. /**
  77757. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77758. */
  77759. keysDown: number[];
  77760. /**
  77761. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77762. */
  77763. keysLeft: number[];
  77764. /**
  77765. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77766. */
  77767. keysRight: number[];
  77768. /**
  77769. * Event raised when the camera collide with a mesh in the scene.
  77770. */
  77771. onCollide: (collidedMesh: AbstractMesh) => void;
  77772. private _collider;
  77773. private _needMoveForGravity;
  77774. private _oldPosition;
  77775. private _diffPosition;
  77776. private _newPosition;
  77777. /** @hidden */
  77778. _localDirection: Vector3;
  77779. /** @hidden */
  77780. _transformedDirection: Vector3;
  77781. /**
  77782. * Instantiates a Free Camera.
  77783. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77784. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77785. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77786. * @param name Define the name of the camera in the scene
  77787. * @param position Define the start position of the camera in the scene
  77788. * @param scene Define the scene the camera belongs to
  77789. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77790. */
  77791. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77792. /**
  77793. * Attached controls to the current camera.
  77794. * @param element Defines the element the controls should be listened from
  77795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77796. */
  77797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77798. /**
  77799. * Detach the current controls from the camera.
  77800. * The camera will stop reacting to inputs.
  77801. * @param element Defines the element to stop listening the inputs from
  77802. */
  77803. detachControl(element: HTMLElement): void;
  77804. private _collisionMask;
  77805. /**
  77806. * Define a collision mask to limit the list of object the camera can collide with
  77807. */
  77808. collisionMask: number;
  77809. /** @hidden */
  77810. _collideWithWorld(displacement: Vector3): void;
  77811. private _onCollisionPositionChange;
  77812. /** @hidden */
  77813. _checkInputs(): void;
  77814. /** @hidden */
  77815. _decideIfNeedsToMove(): boolean;
  77816. /** @hidden */
  77817. _updatePosition(): void;
  77818. /**
  77819. * Destroy the camera and release the current resources hold by it.
  77820. */
  77821. dispose(): void;
  77822. /**
  77823. * Gets the current object class name.
  77824. * @return the class name
  77825. */
  77826. getClassName(): string;
  77827. }
  77828. }
  77829. declare module BABYLON {
  77830. /**
  77831. * Represents a gamepad control stick position
  77832. */
  77833. export class StickValues {
  77834. /**
  77835. * The x component of the control stick
  77836. */
  77837. x: number;
  77838. /**
  77839. * The y component of the control stick
  77840. */
  77841. y: number;
  77842. /**
  77843. * Initializes the gamepad x and y control stick values
  77844. * @param x The x component of the gamepad control stick value
  77845. * @param y The y component of the gamepad control stick value
  77846. */
  77847. constructor(
  77848. /**
  77849. * The x component of the control stick
  77850. */
  77851. x: number,
  77852. /**
  77853. * The y component of the control stick
  77854. */
  77855. y: number);
  77856. }
  77857. /**
  77858. * An interface which manages callbacks for gamepad button changes
  77859. */
  77860. export interface GamepadButtonChanges {
  77861. /**
  77862. * Called when a gamepad has been changed
  77863. */
  77864. changed: boolean;
  77865. /**
  77866. * Called when a gamepad press event has been triggered
  77867. */
  77868. pressChanged: boolean;
  77869. /**
  77870. * Called when a touch event has been triggered
  77871. */
  77872. touchChanged: boolean;
  77873. /**
  77874. * Called when a value has changed
  77875. */
  77876. valueChanged: boolean;
  77877. }
  77878. /**
  77879. * Represents a gamepad
  77880. */
  77881. export class Gamepad {
  77882. /**
  77883. * The id of the gamepad
  77884. */
  77885. id: string;
  77886. /**
  77887. * The index of the gamepad
  77888. */
  77889. index: number;
  77890. /**
  77891. * The browser gamepad
  77892. */
  77893. browserGamepad: any;
  77894. /**
  77895. * Specifies what type of gamepad this represents
  77896. */
  77897. type: number;
  77898. private _leftStick;
  77899. private _rightStick;
  77900. /** @hidden */
  77901. _isConnected: boolean;
  77902. private _leftStickAxisX;
  77903. private _leftStickAxisY;
  77904. private _rightStickAxisX;
  77905. private _rightStickAxisY;
  77906. /**
  77907. * Triggered when the left control stick has been changed
  77908. */
  77909. private _onleftstickchanged;
  77910. /**
  77911. * Triggered when the right control stick has been changed
  77912. */
  77913. private _onrightstickchanged;
  77914. /**
  77915. * Represents a gamepad controller
  77916. */
  77917. static GAMEPAD: number;
  77918. /**
  77919. * Represents a generic controller
  77920. */
  77921. static GENERIC: number;
  77922. /**
  77923. * Represents an XBox controller
  77924. */
  77925. static XBOX: number;
  77926. /**
  77927. * Represents a pose-enabled controller
  77928. */
  77929. static POSE_ENABLED: number;
  77930. /**
  77931. * Represents an Dual Shock controller
  77932. */
  77933. static DUALSHOCK: number;
  77934. /**
  77935. * Specifies whether the left control stick should be Y-inverted
  77936. */
  77937. protected _invertLeftStickY: boolean;
  77938. /**
  77939. * Specifies if the gamepad has been connected
  77940. */
  77941. readonly isConnected: boolean;
  77942. /**
  77943. * Initializes the gamepad
  77944. * @param id The id of the gamepad
  77945. * @param index The index of the gamepad
  77946. * @param browserGamepad The browser gamepad
  77947. * @param leftStickX The x component of the left joystick
  77948. * @param leftStickY The y component of the left joystick
  77949. * @param rightStickX The x component of the right joystick
  77950. * @param rightStickY The y component of the right joystick
  77951. */
  77952. constructor(
  77953. /**
  77954. * The id of the gamepad
  77955. */
  77956. id: string,
  77957. /**
  77958. * The index of the gamepad
  77959. */
  77960. index: number,
  77961. /**
  77962. * The browser gamepad
  77963. */
  77964. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77965. /**
  77966. * Callback triggered when the left joystick has changed
  77967. * @param callback
  77968. */
  77969. onleftstickchanged(callback: (values: StickValues) => void): void;
  77970. /**
  77971. * Callback triggered when the right joystick has changed
  77972. * @param callback
  77973. */
  77974. onrightstickchanged(callback: (values: StickValues) => void): void;
  77975. /**
  77976. * Gets the left joystick
  77977. */
  77978. /**
  77979. * Sets the left joystick values
  77980. */
  77981. leftStick: StickValues;
  77982. /**
  77983. * Gets the right joystick
  77984. */
  77985. /**
  77986. * Sets the right joystick value
  77987. */
  77988. rightStick: StickValues;
  77989. /**
  77990. * Updates the gamepad joystick positions
  77991. */
  77992. update(): void;
  77993. /**
  77994. * Disposes the gamepad
  77995. */
  77996. dispose(): void;
  77997. }
  77998. /**
  77999. * Represents a generic gamepad
  78000. */
  78001. export class GenericPad extends Gamepad {
  78002. private _buttons;
  78003. private _onbuttondown;
  78004. private _onbuttonup;
  78005. /**
  78006. * Observable triggered when a button has been pressed
  78007. */
  78008. onButtonDownObservable: Observable<number>;
  78009. /**
  78010. * Observable triggered when a button has been released
  78011. */
  78012. onButtonUpObservable: Observable<number>;
  78013. /**
  78014. * Callback triggered when a button has been pressed
  78015. * @param callback Called when a button has been pressed
  78016. */
  78017. onbuttondown(callback: (buttonPressed: number) => void): void;
  78018. /**
  78019. * Callback triggered when a button has been released
  78020. * @param callback Called when a button has been released
  78021. */
  78022. onbuttonup(callback: (buttonReleased: number) => void): void;
  78023. /**
  78024. * Initializes the generic gamepad
  78025. * @param id The id of the generic gamepad
  78026. * @param index The index of the generic gamepad
  78027. * @param browserGamepad The browser gamepad
  78028. */
  78029. constructor(id: string, index: number, browserGamepad: any);
  78030. private _setButtonValue;
  78031. /**
  78032. * Updates the generic gamepad
  78033. */
  78034. update(): void;
  78035. /**
  78036. * Disposes the generic gamepad
  78037. */
  78038. dispose(): void;
  78039. }
  78040. }
  78041. declare module BABYLON {
  78042. interface Engine {
  78043. /**
  78044. * Creates a raw texture
  78045. * @param data defines the data to store in the texture
  78046. * @param width defines the width of the texture
  78047. * @param height defines the height of the texture
  78048. * @param format defines the format of the data
  78049. * @param generateMipMaps defines if the engine should generate the mip levels
  78050. * @param invertY defines if data must be stored with Y axis inverted
  78051. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78052. * @param compression defines the compression used (null by default)
  78053. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78054. * @returns the raw texture inside an InternalTexture
  78055. */
  78056. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78057. /**
  78058. * Update a raw texture
  78059. * @param texture defines the texture to update
  78060. * @param data defines the data to store in the texture
  78061. * @param format defines the format of the data
  78062. * @param invertY defines if data must be stored with Y axis inverted
  78063. */
  78064. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78065. /**
  78066. * Update a raw texture
  78067. * @param texture defines the texture to update
  78068. * @param data defines the data to store in the texture
  78069. * @param format defines the format of the data
  78070. * @param invertY defines if data must be stored with Y axis inverted
  78071. * @param compression defines the compression used (null by default)
  78072. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78073. */
  78074. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78075. /**
  78076. * Creates a new raw cube texture
  78077. * @param data defines the array of data to use to create each face
  78078. * @param size defines the size of the textures
  78079. * @param format defines the format of the data
  78080. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78081. * @param generateMipMaps defines if the engine should generate the mip levels
  78082. * @param invertY defines if data must be stored with Y axis inverted
  78083. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78084. * @param compression defines the compression used (null by default)
  78085. * @returns the cube texture as an InternalTexture
  78086. */
  78087. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78088. /**
  78089. * Update a raw cube texture
  78090. * @param texture defines the texture to udpdate
  78091. * @param data defines the data to store
  78092. * @param format defines the data format
  78093. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78094. * @param invertY defines if data must be stored with Y axis inverted
  78095. */
  78096. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78097. /**
  78098. * Update a raw cube texture
  78099. * @param texture defines the texture to udpdate
  78100. * @param data defines the data to store
  78101. * @param format defines the data format
  78102. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78103. * @param invertY defines if data must be stored with Y axis inverted
  78104. * @param compression defines the compression used (null by default)
  78105. */
  78106. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78107. /**
  78108. * Update a raw cube texture
  78109. * @param texture defines the texture to udpdate
  78110. * @param data defines the data to store
  78111. * @param format defines the data format
  78112. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78113. * @param invertY defines if data must be stored with Y axis inverted
  78114. * @param compression defines the compression used (null by default)
  78115. * @param level defines which level of the texture to update
  78116. */
  78117. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78118. /**
  78119. * Creates a new raw cube texture from a specified url
  78120. * @param url defines the url where the data is located
  78121. * @param scene defines the current scene
  78122. * @param size defines the size of the textures
  78123. * @param format defines the format of the data
  78124. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78125. * @param noMipmap defines if the engine should avoid generating the mip levels
  78126. * @param callback defines a callback used to extract texture data from loaded data
  78127. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78128. * @param onLoad defines a callback called when texture is loaded
  78129. * @param onError defines a callback called if there is an error
  78130. * @returns the cube texture as an InternalTexture
  78131. */
  78132. 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;
  78133. /**
  78134. * Creates a new raw cube texture from a specified url
  78135. * @param url defines the url where the data is located
  78136. * @param scene defines the current scene
  78137. * @param size defines the size of the textures
  78138. * @param format defines the format of the data
  78139. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78140. * @param noMipmap defines if the engine should avoid generating the mip levels
  78141. * @param callback defines a callback used to extract texture data from loaded data
  78142. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78143. * @param onLoad defines a callback called when texture is loaded
  78144. * @param onError defines a callback called if there is an error
  78145. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78146. * @param invertY defines if data must be stored with Y axis inverted
  78147. * @returns the cube texture as an InternalTexture
  78148. */
  78149. 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;
  78150. /**
  78151. * Creates a new raw 3D texture
  78152. * @param data defines the data used to create the texture
  78153. * @param width defines the width of the texture
  78154. * @param height defines the height of the texture
  78155. * @param depth defines the depth of the texture
  78156. * @param format defines the format of the texture
  78157. * @param generateMipMaps defines if the engine must generate mip levels
  78158. * @param invertY defines if data must be stored with Y axis inverted
  78159. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78160. * @param compression defines the compressed used (can be null)
  78161. * @param textureType defines the compressed used (can be null)
  78162. * @returns a new raw 3D texture (stored in an InternalTexture)
  78163. */
  78164. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78165. /**
  78166. * Update a raw 3D texture
  78167. * @param texture defines the texture to update
  78168. * @param data defines the data to store
  78169. * @param format defines the data format
  78170. * @param invertY defines if data must be stored with Y axis inverted
  78171. */
  78172. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78173. /**
  78174. * Update a raw 3D texture
  78175. * @param texture defines the texture to update
  78176. * @param data defines the data to store
  78177. * @param format defines the data format
  78178. * @param invertY defines if data must be stored with Y axis inverted
  78179. * @param compression defines the used compression (can be null)
  78180. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78181. */
  78182. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78183. }
  78184. }
  78185. declare module BABYLON {
  78186. /**
  78187. * Raw texture can help creating a texture directly from an array of data.
  78188. * This can be super useful if you either get the data from an uncompressed source or
  78189. * if you wish to create your texture pixel by pixel.
  78190. */
  78191. export class RawTexture extends Texture {
  78192. /**
  78193. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78194. */
  78195. format: number;
  78196. private _engine;
  78197. /**
  78198. * Instantiates a new RawTexture.
  78199. * Raw texture can help creating a texture directly from an array of data.
  78200. * This can be super useful if you either get the data from an uncompressed source or
  78201. * if you wish to create your texture pixel by pixel.
  78202. * @param data define the array of data to use to create the texture
  78203. * @param width define the width of the texture
  78204. * @param height define the height of the texture
  78205. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78206. * @param scene define the scene the texture belongs to
  78207. * @param generateMipMaps define whether mip maps should be generated or not
  78208. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78209. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78210. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78211. */
  78212. constructor(data: ArrayBufferView, width: number, height: number,
  78213. /**
  78214. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78215. */
  78216. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78217. /**
  78218. * Updates the texture underlying data.
  78219. * @param data Define the new data of the texture
  78220. */
  78221. update(data: ArrayBufferView): void;
  78222. /**
  78223. * Creates a luminance texture from some data.
  78224. * @param data Define the texture data
  78225. * @param width Define the width of the texture
  78226. * @param height Define the height of the texture
  78227. * @param scene Define the scene the texture belongs to
  78228. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78229. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78230. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78231. * @returns the luminance texture
  78232. */
  78233. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78234. /**
  78235. * Creates a luminance alpha texture from some data.
  78236. * @param data Define the texture data
  78237. * @param width Define the width of the texture
  78238. * @param height Define the height of the texture
  78239. * @param scene Define the scene the texture belongs to
  78240. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78241. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78242. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78243. * @returns the luminance alpha texture
  78244. */
  78245. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78246. /**
  78247. * Creates an alpha texture from some data.
  78248. * @param data Define the texture data
  78249. * @param width Define the width of the texture
  78250. * @param height Define the height of the texture
  78251. * @param scene Define the scene the texture belongs to
  78252. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78253. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78254. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78255. * @returns the alpha texture
  78256. */
  78257. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78258. /**
  78259. * Creates a RGB texture from some data.
  78260. * @param data Define the texture data
  78261. * @param width Define the width of the texture
  78262. * @param height Define the height of the texture
  78263. * @param scene Define the scene the texture belongs to
  78264. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78265. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78266. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78267. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78268. * @returns the RGB alpha texture
  78269. */
  78270. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78271. /**
  78272. * Creates a RGBA texture from some data.
  78273. * @param data Define the texture data
  78274. * @param width Define the width of the texture
  78275. * @param height Define the height of the texture
  78276. * @param scene Define the scene the texture belongs to
  78277. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78278. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78279. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78280. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78281. * @returns the RGBA texture
  78282. */
  78283. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78284. /**
  78285. * Creates a R texture from some data.
  78286. * @param data Define the texture data
  78287. * @param width Define the width of the texture
  78288. * @param height Define the height of the texture
  78289. * @param scene Define the scene the texture belongs to
  78290. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78291. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78292. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78293. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78294. * @returns the R texture
  78295. */
  78296. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78297. }
  78298. }
  78299. declare module BABYLON {
  78300. /**
  78301. * Interface for the size containing width and height
  78302. */
  78303. export interface ISize {
  78304. /**
  78305. * Width
  78306. */
  78307. width: number;
  78308. /**
  78309. * Heighht
  78310. */
  78311. height: number;
  78312. }
  78313. /**
  78314. * Size containing widht and height
  78315. */
  78316. export class Size implements ISize {
  78317. /**
  78318. * Width
  78319. */
  78320. width: number;
  78321. /**
  78322. * Height
  78323. */
  78324. height: number;
  78325. /**
  78326. * Creates a Size object from the given width and height (floats).
  78327. * @param width width of the new size
  78328. * @param height height of the new size
  78329. */
  78330. constructor(width: number, height: number);
  78331. /**
  78332. * Returns a string with the Size width and height
  78333. * @returns a string with the Size width and height
  78334. */
  78335. toString(): string;
  78336. /**
  78337. * "Size"
  78338. * @returns the string "Size"
  78339. */
  78340. getClassName(): string;
  78341. /**
  78342. * Returns the Size hash code.
  78343. * @returns a hash code for a unique width and height
  78344. */
  78345. getHashCode(): number;
  78346. /**
  78347. * Updates the current size from the given one.
  78348. * @param src the given size
  78349. */
  78350. copyFrom(src: Size): void;
  78351. /**
  78352. * Updates in place the current Size from the given floats.
  78353. * @param width width of the new size
  78354. * @param height height of the new size
  78355. * @returns the updated Size.
  78356. */
  78357. copyFromFloats(width: number, height: number): Size;
  78358. /**
  78359. * Updates in place the current Size from the given floats.
  78360. * @param width width to set
  78361. * @param height height to set
  78362. * @returns the updated Size.
  78363. */
  78364. set(width: number, height: number): Size;
  78365. /**
  78366. * Multiplies the width and height by numbers
  78367. * @param w factor to multiple the width by
  78368. * @param h factor to multiple the height by
  78369. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78370. */
  78371. multiplyByFloats(w: number, h: number): Size;
  78372. /**
  78373. * Clones the size
  78374. * @returns a new Size copied from the given one.
  78375. */
  78376. clone(): Size;
  78377. /**
  78378. * True if the current Size and the given one width and height are strictly equal.
  78379. * @param other the other size to compare against
  78380. * @returns True if the current Size and the given one width and height are strictly equal.
  78381. */
  78382. equals(other: Size): boolean;
  78383. /**
  78384. * The surface of the Size : width * height (float).
  78385. */
  78386. readonly surface: number;
  78387. /**
  78388. * Create a new size of zero
  78389. * @returns a new Size set to (0.0, 0.0)
  78390. */
  78391. static Zero(): Size;
  78392. /**
  78393. * Sums the width and height of two sizes
  78394. * @param otherSize size to add to this size
  78395. * @returns a new Size set as the addition result of the current Size and the given one.
  78396. */
  78397. add(otherSize: Size): Size;
  78398. /**
  78399. * Subtracts the width and height of two
  78400. * @param otherSize size to subtract to this size
  78401. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78402. */
  78403. subtract(otherSize: Size): Size;
  78404. /**
  78405. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78406. * @param start starting size to lerp between
  78407. * @param end end size to lerp between
  78408. * @param amount amount to lerp between the start and end values
  78409. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78410. */
  78411. static Lerp(start: Size, end: Size, amount: number): Size;
  78412. }
  78413. }
  78414. declare module BABYLON {
  78415. /**
  78416. * Defines a runtime animation
  78417. */
  78418. export class RuntimeAnimation {
  78419. private _events;
  78420. /**
  78421. * The current frame of the runtime animation
  78422. */
  78423. private _currentFrame;
  78424. /**
  78425. * The animation used by the runtime animation
  78426. */
  78427. private _animation;
  78428. /**
  78429. * The target of the runtime animation
  78430. */
  78431. private _target;
  78432. /**
  78433. * The initiating animatable
  78434. */
  78435. private _host;
  78436. /**
  78437. * The original value of the runtime animation
  78438. */
  78439. private _originalValue;
  78440. /**
  78441. * The original blend value of the runtime animation
  78442. */
  78443. private _originalBlendValue;
  78444. /**
  78445. * The offsets cache of the runtime animation
  78446. */
  78447. private _offsetsCache;
  78448. /**
  78449. * The high limits cache of the runtime animation
  78450. */
  78451. private _highLimitsCache;
  78452. /**
  78453. * Specifies if the runtime animation has been stopped
  78454. */
  78455. private _stopped;
  78456. /**
  78457. * The blending factor of the runtime animation
  78458. */
  78459. private _blendingFactor;
  78460. /**
  78461. * The BabylonJS scene
  78462. */
  78463. private _scene;
  78464. /**
  78465. * The current value of the runtime animation
  78466. */
  78467. private _currentValue;
  78468. /** @hidden */
  78469. _animationState: _IAnimationState;
  78470. /**
  78471. * The active target of the runtime animation
  78472. */
  78473. private _activeTargets;
  78474. private _currentActiveTarget;
  78475. private _directTarget;
  78476. /**
  78477. * The target path of the runtime animation
  78478. */
  78479. private _targetPath;
  78480. /**
  78481. * The weight of the runtime animation
  78482. */
  78483. private _weight;
  78484. /**
  78485. * The ratio offset of the runtime animation
  78486. */
  78487. private _ratioOffset;
  78488. /**
  78489. * The previous delay of the runtime animation
  78490. */
  78491. private _previousDelay;
  78492. /**
  78493. * The previous ratio of the runtime animation
  78494. */
  78495. private _previousRatio;
  78496. private _enableBlending;
  78497. private _keys;
  78498. private _minFrame;
  78499. private _maxFrame;
  78500. private _minValue;
  78501. private _maxValue;
  78502. private _targetIsArray;
  78503. /**
  78504. * Gets the current frame of the runtime animation
  78505. */
  78506. readonly currentFrame: number;
  78507. /**
  78508. * Gets the weight of the runtime animation
  78509. */
  78510. readonly weight: number;
  78511. /**
  78512. * Gets the current value of the runtime animation
  78513. */
  78514. readonly currentValue: any;
  78515. /**
  78516. * Gets the target path of the runtime animation
  78517. */
  78518. readonly targetPath: string;
  78519. /**
  78520. * Gets the actual target of the runtime animation
  78521. */
  78522. readonly target: any;
  78523. /** @hidden */
  78524. _onLoop: () => void;
  78525. /**
  78526. * Create a new RuntimeAnimation object
  78527. * @param target defines the target of the animation
  78528. * @param animation defines the source animation object
  78529. * @param scene defines the hosting scene
  78530. * @param host defines the initiating Animatable
  78531. */
  78532. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78533. private _preparePath;
  78534. /**
  78535. * Gets the animation from the runtime animation
  78536. */
  78537. readonly animation: Animation;
  78538. /**
  78539. * Resets the runtime animation to the beginning
  78540. * @param restoreOriginal defines whether to restore the target property to the original value
  78541. */
  78542. reset(restoreOriginal?: boolean): void;
  78543. /**
  78544. * Specifies if the runtime animation is stopped
  78545. * @returns Boolean specifying if the runtime animation is stopped
  78546. */
  78547. isStopped(): boolean;
  78548. /**
  78549. * Disposes of the runtime animation
  78550. */
  78551. dispose(): void;
  78552. /**
  78553. * Apply the interpolated value to the target
  78554. * @param currentValue defines the value computed by the animation
  78555. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78556. */
  78557. setValue(currentValue: any, weight: number): void;
  78558. private _getOriginalValues;
  78559. private _setValue;
  78560. /**
  78561. * Gets the loop pmode of the runtime animation
  78562. * @returns Loop Mode
  78563. */
  78564. private _getCorrectLoopMode;
  78565. /**
  78566. * Move the current animation to a given frame
  78567. * @param frame defines the frame to move to
  78568. */
  78569. goToFrame(frame: number): void;
  78570. /**
  78571. * @hidden Internal use only
  78572. */
  78573. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78574. /**
  78575. * Execute the current animation
  78576. * @param delay defines the delay to add to the current frame
  78577. * @param from defines the lower bound of the animation range
  78578. * @param to defines the upper bound of the animation range
  78579. * @param loop defines if the current animation must loop
  78580. * @param speedRatio defines the current speed ratio
  78581. * @param weight defines the weight of the animation (default is -1 so no weight)
  78582. * @param onLoop optional callback called when animation loops
  78583. * @returns a boolean indicating if the animation is running
  78584. */
  78585. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78586. }
  78587. }
  78588. declare module BABYLON {
  78589. /**
  78590. * Class used to store an actual running animation
  78591. */
  78592. export class Animatable {
  78593. /** defines the target object */
  78594. target: any;
  78595. /** defines the starting frame number (default is 0) */
  78596. fromFrame: number;
  78597. /** defines the ending frame number (default is 100) */
  78598. toFrame: number;
  78599. /** defines if the animation must loop (default is false) */
  78600. loopAnimation: boolean;
  78601. /** defines a callback to call when animation ends if it is not looping */
  78602. onAnimationEnd?: (() => void) | null | undefined;
  78603. /** defines a callback to call when animation loops */
  78604. onAnimationLoop?: (() => void) | null | undefined;
  78605. private _localDelayOffset;
  78606. private _pausedDelay;
  78607. private _runtimeAnimations;
  78608. private _paused;
  78609. private _scene;
  78610. private _speedRatio;
  78611. private _weight;
  78612. private _syncRoot;
  78613. /**
  78614. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78615. * This will only apply for non looping animation (default is true)
  78616. */
  78617. disposeOnEnd: boolean;
  78618. /**
  78619. * Gets a boolean indicating if the animation has started
  78620. */
  78621. animationStarted: boolean;
  78622. /**
  78623. * Observer raised when the animation ends
  78624. */
  78625. onAnimationEndObservable: Observable<Animatable>;
  78626. /**
  78627. * Observer raised when the animation loops
  78628. */
  78629. onAnimationLoopObservable: Observable<Animatable>;
  78630. /**
  78631. * Gets the root Animatable used to synchronize and normalize animations
  78632. */
  78633. readonly syncRoot: Nullable<Animatable>;
  78634. /**
  78635. * Gets the current frame of the first RuntimeAnimation
  78636. * Used to synchronize Animatables
  78637. */
  78638. readonly masterFrame: number;
  78639. /**
  78640. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78641. */
  78642. weight: number;
  78643. /**
  78644. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78645. */
  78646. speedRatio: number;
  78647. /**
  78648. * Creates a new Animatable
  78649. * @param scene defines the hosting scene
  78650. * @param target defines the target object
  78651. * @param fromFrame defines the starting frame number (default is 0)
  78652. * @param toFrame defines the ending frame number (default is 100)
  78653. * @param loopAnimation defines if the animation must loop (default is false)
  78654. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78655. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78656. * @param animations defines a group of animation to add to the new Animatable
  78657. * @param onAnimationLoop defines a callback to call when animation loops
  78658. */
  78659. constructor(scene: Scene,
  78660. /** defines the target object */
  78661. target: any,
  78662. /** defines the starting frame number (default is 0) */
  78663. fromFrame?: number,
  78664. /** defines the ending frame number (default is 100) */
  78665. toFrame?: number,
  78666. /** defines if the animation must loop (default is false) */
  78667. loopAnimation?: boolean, speedRatio?: number,
  78668. /** defines a callback to call when animation ends if it is not looping */
  78669. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78670. /** defines a callback to call when animation loops */
  78671. onAnimationLoop?: (() => void) | null | undefined);
  78672. /**
  78673. * Synchronize and normalize current Animatable with a source Animatable
  78674. * This is useful when using animation weights and when animations are not of the same length
  78675. * @param root defines the root Animatable to synchronize with
  78676. * @returns the current Animatable
  78677. */
  78678. syncWith(root: Animatable): Animatable;
  78679. /**
  78680. * Gets the list of runtime animations
  78681. * @returns an array of RuntimeAnimation
  78682. */
  78683. getAnimations(): RuntimeAnimation[];
  78684. /**
  78685. * Adds more animations to the current animatable
  78686. * @param target defines the target of the animations
  78687. * @param animations defines the new animations to add
  78688. */
  78689. appendAnimations(target: any, animations: Animation[]): void;
  78690. /**
  78691. * Gets the source animation for a specific property
  78692. * @param property defines the propertyu to look for
  78693. * @returns null or the source animation for the given property
  78694. */
  78695. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78696. /**
  78697. * Gets the runtime animation for a specific property
  78698. * @param property defines the propertyu to look for
  78699. * @returns null or the runtime animation for the given property
  78700. */
  78701. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78702. /**
  78703. * Resets the animatable to its original state
  78704. */
  78705. reset(): void;
  78706. /**
  78707. * Allows the animatable to blend with current running animations
  78708. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78709. * @param blendingSpeed defines the blending speed to use
  78710. */
  78711. enableBlending(blendingSpeed: number): void;
  78712. /**
  78713. * Disable animation blending
  78714. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78715. */
  78716. disableBlending(): void;
  78717. /**
  78718. * Jump directly to a given frame
  78719. * @param frame defines the frame to jump to
  78720. */
  78721. goToFrame(frame: number): void;
  78722. /**
  78723. * Pause the animation
  78724. */
  78725. pause(): void;
  78726. /**
  78727. * Restart the animation
  78728. */
  78729. restart(): void;
  78730. private _raiseOnAnimationEnd;
  78731. /**
  78732. * Stop and delete the current animation
  78733. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78734. * @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)
  78735. */
  78736. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78737. /**
  78738. * Wait asynchronously for the animation to end
  78739. * @returns a promise which will be fullfilled when the animation ends
  78740. */
  78741. waitAsync(): Promise<Animatable>;
  78742. /** @hidden */
  78743. _animate(delay: number): boolean;
  78744. }
  78745. interface Scene {
  78746. /** @hidden */
  78747. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78748. /** @hidden */
  78749. _processLateAnimationBindingsForMatrices(holder: {
  78750. totalWeight: number;
  78751. animations: RuntimeAnimation[];
  78752. originalValue: Matrix;
  78753. }): any;
  78754. /** @hidden */
  78755. _processLateAnimationBindingsForQuaternions(holder: {
  78756. totalWeight: number;
  78757. animations: RuntimeAnimation[];
  78758. originalValue: Quaternion;
  78759. }, refQuaternion: Quaternion): Quaternion;
  78760. /** @hidden */
  78761. _processLateAnimationBindings(): void;
  78762. /**
  78763. * Will start the animation sequence of a given target
  78764. * @param target defines the target
  78765. * @param from defines from which frame should animation start
  78766. * @param to defines until which frame should animation run.
  78767. * @param weight defines the weight to apply to the animation (1.0 by default)
  78768. * @param loop defines if the animation loops
  78769. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78770. * @param onAnimationEnd defines the function to be executed when the animation ends
  78771. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78772. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78773. * @param onAnimationLoop defines the callback to call when an animation loops
  78774. * @returns the animatable object created for this animation
  78775. */
  78776. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78777. /**
  78778. * Will start the animation sequence of a given target
  78779. * @param target defines the target
  78780. * @param from defines from which frame should animation start
  78781. * @param to defines until which frame should animation run.
  78782. * @param loop defines if the animation loops
  78783. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78784. * @param onAnimationEnd defines the function to be executed when the animation ends
  78785. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78786. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78787. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78788. * @param onAnimationLoop defines the callback to call when an animation loops
  78789. * @returns the animatable object created for this animation
  78790. */
  78791. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78792. /**
  78793. * Will start the animation sequence of a given target and its hierarchy
  78794. * @param target defines the target
  78795. * @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.
  78796. * @param from defines from which frame should animation start
  78797. * @param to defines until which frame should animation run.
  78798. * @param loop defines if the animation loops
  78799. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78800. * @param onAnimationEnd defines the function to be executed when the animation ends
  78801. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78802. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78803. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78804. * @param onAnimationLoop defines the callback to call when an animation loops
  78805. * @returns the list of created animatables
  78806. */
  78807. 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[];
  78808. /**
  78809. * Begin a new animation on a given node
  78810. * @param target defines the target where the animation will take place
  78811. * @param animations defines the list of animations to start
  78812. * @param from defines the initial value
  78813. * @param to defines the final value
  78814. * @param loop defines if you want animation to loop (off by default)
  78815. * @param speedRatio defines the speed ratio to apply to all animations
  78816. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78817. * @param onAnimationLoop defines the callback to call when an animation loops
  78818. * @returns the list of created animatables
  78819. */
  78820. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78821. /**
  78822. * Begin a new animation on a given node and its hierarchy
  78823. * @param target defines the root node where the animation will take place
  78824. * @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.
  78825. * @param animations defines the list of animations to start
  78826. * @param from defines the initial value
  78827. * @param to defines the final value
  78828. * @param loop defines if you want animation to loop (off by default)
  78829. * @param speedRatio defines the speed ratio to apply to all animations
  78830. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78831. * @param onAnimationLoop defines the callback to call when an animation loops
  78832. * @returns the list of animatables created for all nodes
  78833. */
  78834. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78835. /**
  78836. * Gets the animatable associated with a specific target
  78837. * @param target defines the target of the animatable
  78838. * @returns the required animatable if found
  78839. */
  78840. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78841. /**
  78842. * Gets all animatables associated with a given target
  78843. * @param target defines the target to look animatables for
  78844. * @returns an array of Animatables
  78845. */
  78846. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78847. /**
  78848. * Stops and removes all animations that have been applied to the scene
  78849. */
  78850. stopAllAnimations(): void;
  78851. }
  78852. interface Bone {
  78853. /**
  78854. * Copy an animation range from another bone
  78855. * @param source defines the source bone
  78856. * @param rangeName defines the range name to copy
  78857. * @param frameOffset defines the frame offset
  78858. * @param rescaleAsRequired defines if rescaling must be applied if required
  78859. * @param skelDimensionsRatio defines the scaling ratio
  78860. * @returns true if operation was successful
  78861. */
  78862. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78863. }
  78864. }
  78865. declare module BABYLON {
  78866. /**
  78867. * Class used to override all child animations of a given target
  78868. */
  78869. export class AnimationPropertiesOverride {
  78870. /**
  78871. * Gets or sets a value indicating if animation blending must be used
  78872. */
  78873. enableBlending: boolean;
  78874. /**
  78875. * Gets or sets the blending speed to use when enableBlending is true
  78876. */
  78877. blendingSpeed: number;
  78878. /**
  78879. * Gets or sets the default loop mode to use
  78880. */
  78881. loopMode: number;
  78882. }
  78883. }
  78884. declare module BABYLON {
  78885. /**
  78886. * Class used to handle skinning animations
  78887. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78888. */
  78889. export class Skeleton implements IAnimatable {
  78890. /** defines the skeleton name */
  78891. name: string;
  78892. /** defines the skeleton Id */
  78893. id: string;
  78894. /**
  78895. * Defines the list of child bones
  78896. */
  78897. bones: Bone[];
  78898. /**
  78899. * Defines an estimate of the dimension of the skeleton at rest
  78900. */
  78901. dimensionsAtRest: Vector3;
  78902. /**
  78903. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78904. */
  78905. needInitialSkinMatrix: boolean;
  78906. /**
  78907. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78908. */
  78909. overrideMesh: Nullable<AbstractMesh>;
  78910. /**
  78911. * Gets the list of animations attached to this skeleton
  78912. */
  78913. animations: Array<Animation>;
  78914. private _scene;
  78915. private _isDirty;
  78916. private _transformMatrices;
  78917. private _transformMatrixTexture;
  78918. private _meshesWithPoseMatrix;
  78919. private _animatables;
  78920. private _identity;
  78921. private _synchronizedWithMesh;
  78922. private _ranges;
  78923. private _lastAbsoluteTransformsUpdateId;
  78924. private _canUseTextureForBones;
  78925. private _uniqueId;
  78926. /** @hidden */
  78927. _numBonesWithLinkedTransformNode: number;
  78928. /** @hidden */
  78929. _hasWaitingData: Nullable<boolean>;
  78930. /**
  78931. * Specifies if the skeleton should be serialized
  78932. */
  78933. doNotSerialize: boolean;
  78934. private _useTextureToStoreBoneMatrices;
  78935. /**
  78936. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78937. * Please note that this option is not available if the hardware does not support it
  78938. */
  78939. useTextureToStoreBoneMatrices: boolean;
  78940. private _animationPropertiesOverride;
  78941. /**
  78942. * Gets or sets the animation properties override
  78943. */
  78944. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78945. /**
  78946. * List of inspectable custom properties (used by the Inspector)
  78947. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78948. */
  78949. inspectableCustomProperties: IInspectable[];
  78950. /**
  78951. * An observable triggered before computing the skeleton's matrices
  78952. */
  78953. onBeforeComputeObservable: Observable<Skeleton>;
  78954. /**
  78955. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78956. */
  78957. readonly isUsingTextureForMatrices: boolean;
  78958. /**
  78959. * Gets the unique ID of this skeleton
  78960. */
  78961. readonly uniqueId: number;
  78962. /**
  78963. * Creates a new skeleton
  78964. * @param name defines the skeleton name
  78965. * @param id defines the skeleton Id
  78966. * @param scene defines the hosting scene
  78967. */
  78968. constructor(
  78969. /** defines the skeleton name */
  78970. name: string,
  78971. /** defines the skeleton Id */
  78972. id: string, scene: Scene);
  78973. /**
  78974. * Gets the current object class name.
  78975. * @return the class name
  78976. */
  78977. getClassName(): string;
  78978. /**
  78979. * Returns an array containing the root bones
  78980. * @returns an array containing the root bones
  78981. */
  78982. getChildren(): Array<Bone>;
  78983. /**
  78984. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78985. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78986. * @returns a Float32Array containing matrices data
  78987. */
  78988. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78989. /**
  78990. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78991. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78992. * @returns a raw texture containing the data
  78993. */
  78994. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  78995. /**
  78996. * Gets the current hosting scene
  78997. * @returns a scene object
  78998. */
  78999. getScene(): Scene;
  79000. /**
  79001. * Gets a string representing the current skeleton data
  79002. * @param fullDetails defines a boolean indicating if we want a verbose version
  79003. * @returns a string representing the current skeleton data
  79004. */
  79005. toString(fullDetails?: boolean): string;
  79006. /**
  79007. * Get bone's index searching by name
  79008. * @param name defines bone's name to search for
  79009. * @return the indice of the bone. Returns -1 if not found
  79010. */
  79011. getBoneIndexByName(name: string): number;
  79012. /**
  79013. * Creater a new animation range
  79014. * @param name defines the name of the range
  79015. * @param from defines the start key
  79016. * @param to defines the end key
  79017. */
  79018. createAnimationRange(name: string, from: number, to: number): void;
  79019. /**
  79020. * Delete a specific animation range
  79021. * @param name defines the name of the range
  79022. * @param deleteFrames defines if frames must be removed as well
  79023. */
  79024. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79025. /**
  79026. * Gets a specific animation range
  79027. * @param name defines the name of the range to look for
  79028. * @returns the requested animation range or null if not found
  79029. */
  79030. getAnimationRange(name: string): Nullable<AnimationRange>;
  79031. /**
  79032. * Gets the list of all animation ranges defined on this skeleton
  79033. * @returns an array
  79034. */
  79035. getAnimationRanges(): Nullable<AnimationRange>[];
  79036. /**
  79037. * Copy animation range from a source skeleton.
  79038. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79039. * @param source defines the source skeleton
  79040. * @param name defines the name of the range to copy
  79041. * @param rescaleAsRequired defines if rescaling must be applied if required
  79042. * @returns true if operation was successful
  79043. */
  79044. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79045. /**
  79046. * Forces the skeleton to go to rest pose
  79047. */
  79048. returnToRest(): void;
  79049. private _getHighestAnimationFrame;
  79050. /**
  79051. * Begin a specific animation range
  79052. * @param name defines the name of the range to start
  79053. * @param loop defines if looping must be turned on (false by default)
  79054. * @param speedRatio defines the speed ratio to apply (1 by default)
  79055. * @param onAnimationEnd defines a callback which will be called when animation will end
  79056. * @returns a new animatable
  79057. */
  79058. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79059. /** @hidden */
  79060. _markAsDirty(): void;
  79061. /** @hidden */
  79062. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79063. /** @hidden */
  79064. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79065. private _computeTransformMatrices;
  79066. /**
  79067. * Build all resources required to render a skeleton
  79068. */
  79069. prepare(): void;
  79070. /**
  79071. * Gets the list of animatables currently running for this skeleton
  79072. * @returns an array of animatables
  79073. */
  79074. getAnimatables(): IAnimatable[];
  79075. /**
  79076. * Clone the current skeleton
  79077. * @param name defines the name of the new skeleton
  79078. * @param id defines the id of the new skeleton
  79079. * @returns the new skeleton
  79080. */
  79081. clone(name: string, id: string): Skeleton;
  79082. /**
  79083. * Enable animation blending for this skeleton
  79084. * @param blendingSpeed defines the blending speed to apply
  79085. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79086. */
  79087. enableBlending(blendingSpeed?: number): void;
  79088. /**
  79089. * Releases all resources associated with the current skeleton
  79090. */
  79091. dispose(): void;
  79092. /**
  79093. * Serialize the skeleton in a JSON object
  79094. * @returns a JSON object
  79095. */
  79096. serialize(): any;
  79097. /**
  79098. * Creates a new skeleton from serialized data
  79099. * @param parsedSkeleton defines the serialized data
  79100. * @param scene defines the hosting scene
  79101. * @returns a new skeleton
  79102. */
  79103. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79104. /**
  79105. * Compute all node absolute transforms
  79106. * @param forceUpdate defines if computation must be done even if cache is up to date
  79107. */
  79108. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79109. /**
  79110. * Gets the root pose matrix
  79111. * @returns a matrix
  79112. */
  79113. getPoseMatrix(): Nullable<Matrix>;
  79114. /**
  79115. * Sorts bones per internal index
  79116. */
  79117. sortBones(): void;
  79118. private _sortBones;
  79119. }
  79120. }
  79121. declare module BABYLON {
  79122. /**
  79123. * Class used to store bone information
  79124. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79125. */
  79126. export class Bone extends Node {
  79127. /**
  79128. * defines the bone name
  79129. */
  79130. name: string;
  79131. private static _tmpVecs;
  79132. private static _tmpQuat;
  79133. private static _tmpMats;
  79134. /**
  79135. * Gets the list of child bones
  79136. */
  79137. children: Bone[];
  79138. /** Gets the animations associated with this bone */
  79139. animations: Animation[];
  79140. /**
  79141. * Gets or sets bone length
  79142. */
  79143. length: number;
  79144. /**
  79145. * @hidden Internal only
  79146. * Set this value to map this bone to a different index in the transform matrices
  79147. * Set this value to -1 to exclude the bone from the transform matrices
  79148. */
  79149. _index: Nullable<number>;
  79150. private _skeleton;
  79151. private _localMatrix;
  79152. private _restPose;
  79153. private _baseMatrix;
  79154. private _absoluteTransform;
  79155. private _invertedAbsoluteTransform;
  79156. private _parent;
  79157. private _scalingDeterminant;
  79158. private _worldTransform;
  79159. private _localScaling;
  79160. private _localRotation;
  79161. private _localPosition;
  79162. private _needToDecompose;
  79163. private _needToCompose;
  79164. /** @hidden */
  79165. _linkedTransformNode: Nullable<TransformNode>;
  79166. /** @hidden */
  79167. _waitingTransformNodeId: Nullable<string>;
  79168. /** @hidden */
  79169. /** @hidden */
  79170. _matrix: Matrix;
  79171. /**
  79172. * Create a new bone
  79173. * @param name defines the bone name
  79174. * @param skeleton defines the parent skeleton
  79175. * @param parentBone defines the parent (can be null if the bone is the root)
  79176. * @param localMatrix defines the local matrix
  79177. * @param restPose defines the rest pose matrix
  79178. * @param baseMatrix defines the base matrix
  79179. * @param index defines index of the bone in the hiearchy
  79180. */
  79181. constructor(
  79182. /**
  79183. * defines the bone name
  79184. */
  79185. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79186. /**
  79187. * Gets the current object class name.
  79188. * @return the class name
  79189. */
  79190. getClassName(): string;
  79191. /**
  79192. * Gets the parent skeleton
  79193. * @returns a skeleton
  79194. */
  79195. getSkeleton(): Skeleton;
  79196. /**
  79197. * Gets parent bone
  79198. * @returns a bone or null if the bone is the root of the bone hierarchy
  79199. */
  79200. getParent(): Nullable<Bone>;
  79201. /**
  79202. * Returns an array containing the root bones
  79203. * @returns an array containing the root bones
  79204. */
  79205. getChildren(): Array<Bone>;
  79206. /**
  79207. * Sets the parent bone
  79208. * @param parent defines the parent (can be null if the bone is the root)
  79209. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79210. */
  79211. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79212. /**
  79213. * Gets the local matrix
  79214. * @returns a matrix
  79215. */
  79216. getLocalMatrix(): Matrix;
  79217. /**
  79218. * Gets the base matrix (initial matrix which remains unchanged)
  79219. * @returns a matrix
  79220. */
  79221. getBaseMatrix(): Matrix;
  79222. /**
  79223. * Gets the rest pose matrix
  79224. * @returns a matrix
  79225. */
  79226. getRestPose(): Matrix;
  79227. /**
  79228. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79229. */
  79230. getWorldMatrix(): Matrix;
  79231. /**
  79232. * Sets the local matrix to rest pose matrix
  79233. */
  79234. returnToRest(): void;
  79235. /**
  79236. * Gets the inverse of the absolute transform matrix.
  79237. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79238. * @returns a matrix
  79239. */
  79240. getInvertedAbsoluteTransform(): Matrix;
  79241. /**
  79242. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79243. * @returns a matrix
  79244. */
  79245. getAbsoluteTransform(): Matrix;
  79246. /**
  79247. * Links with the given transform node.
  79248. * The local matrix of this bone is copied from the transform node every frame.
  79249. * @param transformNode defines the transform node to link to
  79250. */
  79251. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79252. /**
  79253. * Gets the node used to drive the bone's transformation
  79254. * @returns a transform node or null
  79255. */
  79256. getTransformNode(): Nullable<TransformNode>;
  79257. /** Gets or sets current position (in local space) */
  79258. position: Vector3;
  79259. /** Gets or sets current rotation (in local space) */
  79260. rotation: Vector3;
  79261. /** Gets or sets current rotation quaternion (in local space) */
  79262. rotationQuaternion: Quaternion;
  79263. /** Gets or sets current scaling (in local space) */
  79264. scaling: Vector3;
  79265. /**
  79266. * Gets the animation properties override
  79267. */
  79268. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79269. private _decompose;
  79270. private _compose;
  79271. /**
  79272. * Update the base and local matrices
  79273. * @param matrix defines the new base or local matrix
  79274. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79275. * @param updateLocalMatrix defines if the local matrix should be updated
  79276. */
  79277. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79278. /** @hidden */
  79279. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79280. /**
  79281. * Flag the bone as dirty (Forcing it to update everything)
  79282. */
  79283. markAsDirty(): void;
  79284. /** @hidden */
  79285. _markAsDirtyAndCompose(): void;
  79286. private _markAsDirtyAndDecompose;
  79287. /**
  79288. * Translate the bone in local or world space
  79289. * @param vec The amount to translate the bone
  79290. * @param space The space that the translation is in
  79291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79292. */
  79293. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79294. /**
  79295. * Set the postion of the bone in local or world space
  79296. * @param position The position to set the bone
  79297. * @param space The space that the position is in
  79298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79299. */
  79300. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79301. /**
  79302. * Set the absolute position of the bone (world space)
  79303. * @param position The position to set the bone
  79304. * @param mesh The mesh that this bone is attached to
  79305. */
  79306. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79307. /**
  79308. * Scale the bone on the x, y and z axes (in local space)
  79309. * @param x The amount to scale the bone on the x axis
  79310. * @param y The amount to scale the bone on the y axis
  79311. * @param z The amount to scale the bone on the z axis
  79312. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79313. */
  79314. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79315. /**
  79316. * Set the bone scaling in local space
  79317. * @param scale defines the scaling vector
  79318. */
  79319. setScale(scale: Vector3): void;
  79320. /**
  79321. * Gets the current scaling in local space
  79322. * @returns the current scaling vector
  79323. */
  79324. getScale(): Vector3;
  79325. /**
  79326. * Gets the current scaling in local space and stores it in a target vector
  79327. * @param result defines the target vector
  79328. */
  79329. getScaleToRef(result: Vector3): void;
  79330. /**
  79331. * Set the yaw, pitch, and roll of the bone in local or world space
  79332. * @param yaw The rotation of the bone on the y axis
  79333. * @param pitch The rotation of the bone on the x axis
  79334. * @param roll The rotation of the bone on the z axis
  79335. * @param space The space that the axes of rotation are in
  79336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79337. */
  79338. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79339. /**
  79340. * Add a rotation to the bone on an axis in local or world space
  79341. * @param axis The axis to rotate the bone on
  79342. * @param amount The amount to rotate the bone
  79343. * @param space The space that the axis is in
  79344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79345. */
  79346. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79347. /**
  79348. * Set the rotation of the bone to a particular axis angle in local or world space
  79349. * @param axis The axis to rotate the bone on
  79350. * @param angle The angle that the bone should be rotated to
  79351. * @param space The space that the axis is in
  79352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79353. */
  79354. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79355. /**
  79356. * Set the euler rotation of the bone in local of world space
  79357. * @param rotation The euler rotation that the bone should be set to
  79358. * @param space The space that the rotation is in
  79359. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79360. */
  79361. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79362. /**
  79363. * Set the quaternion rotation of the bone in local of world space
  79364. * @param quat The quaternion rotation that the bone should be set to
  79365. * @param space The space that the rotation is in
  79366. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79367. */
  79368. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79369. /**
  79370. * Set the rotation matrix of the bone in local of world space
  79371. * @param rotMat The rotation matrix that the bone should be set to
  79372. * @param space The space that the rotation is in
  79373. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79374. */
  79375. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79376. private _rotateWithMatrix;
  79377. private _getNegativeRotationToRef;
  79378. /**
  79379. * Get the position of the bone in local or world space
  79380. * @param space The space that the returned position is in
  79381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79382. * @returns The position of the bone
  79383. */
  79384. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79385. /**
  79386. * Copy the position of the bone to a vector3 in local or world space
  79387. * @param space The space that the returned position is in
  79388. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79389. * @param result The vector3 to copy the position to
  79390. */
  79391. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79392. /**
  79393. * Get the absolute position of the bone (world space)
  79394. * @param mesh The mesh that this bone is attached to
  79395. * @returns The absolute position of the bone
  79396. */
  79397. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79398. /**
  79399. * Copy the absolute position of the bone (world space) to the result param
  79400. * @param mesh The mesh that this bone is attached to
  79401. * @param result The vector3 to copy the absolute position to
  79402. */
  79403. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79404. /**
  79405. * Compute the absolute transforms of this bone and its children
  79406. */
  79407. computeAbsoluteTransforms(): void;
  79408. /**
  79409. * Get the world direction from an axis that is in the local space of the bone
  79410. * @param localAxis The local direction that is used to compute the world direction
  79411. * @param mesh The mesh that this bone is attached to
  79412. * @returns The world direction
  79413. */
  79414. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79415. /**
  79416. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79417. * @param localAxis The local direction that is used to compute the world direction
  79418. * @param mesh The mesh that this bone is attached to
  79419. * @param result The vector3 that the world direction will be copied to
  79420. */
  79421. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79422. /**
  79423. * Get the euler rotation of the bone in local or world space
  79424. * @param space The space that the rotation should be in
  79425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79426. * @returns The euler rotation
  79427. */
  79428. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79429. /**
  79430. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79431. * @param space The space that the rotation should be in
  79432. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79433. * @param result The vector3 that the rotation should be copied to
  79434. */
  79435. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79436. /**
  79437. * Get the quaternion rotation of the bone in either local or world space
  79438. * @param space The space that the rotation should be in
  79439. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79440. * @returns The quaternion rotation
  79441. */
  79442. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79443. /**
  79444. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79445. * @param space The space that the rotation should be in
  79446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79447. * @param result The quaternion that the rotation should be copied to
  79448. */
  79449. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79450. /**
  79451. * Get the rotation matrix of the bone in local or world space
  79452. * @param space The space that the rotation should be in
  79453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79454. * @returns The rotation matrix
  79455. */
  79456. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79457. /**
  79458. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79459. * @param space The space that the rotation should be in
  79460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79461. * @param result The quaternion that the rotation should be copied to
  79462. */
  79463. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79464. /**
  79465. * Get the world position of a point that is in the local space of the bone
  79466. * @param position The local position
  79467. * @param mesh The mesh that this bone is attached to
  79468. * @returns The world position
  79469. */
  79470. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79471. /**
  79472. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79473. * @param position The local position
  79474. * @param mesh The mesh that this bone is attached to
  79475. * @param result The vector3 that the world position should be copied to
  79476. */
  79477. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79478. /**
  79479. * Get the local position of a point that is in world space
  79480. * @param position The world position
  79481. * @param mesh The mesh that this bone is attached to
  79482. * @returns The local position
  79483. */
  79484. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79485. /**
  79486. * Get the local position of a point that is in world space and copy it to the result param
  79487. * @param position The world position
  79488. * @param mesh The mesh that this bone is attached to
  79489. * @param result The vector3 that the local position should be copied to
  79490. */
  79491. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79492. }
  79493. }
  79494. declare module BABYLON {
  79495. /**
  79496. * 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.
  79497. * @see https://doc.babylonjs.com/how_to/transformnode
  79498. */
  79499. export class TransformNode extends Node {
  79500. /**
  79501. * Object will not rotate to face the camera
  79502. */
  79503. static BILLBOARDMODE_NONE: number;
  79504. /**
  79505. * Object will rotate to face the camera but only on the x axis
  79506. */
  79507. static BILLBOARDMODE_X: number;
  79508. /**
  79509. * Object will rotate to face the camera but only on the y axis
  79510. */
  79511. static BILLBOARDMODE_Y: number;
  79512. /**
  79513. * Object will rotate to face the camera but only on the z axis
  79514. */
  79515. static BILLBOARDMODE_Z: number;
  79516. /**
  79517. * Object will rotate to face the camera
  79518. */
  79519. static BILLBOARDMODE_ALL: number;
  79520. /**
  79521. * Object will rotate to face the camera's position instead of orientation
  79522. */
  79523. static BILLBOARDMODE_USE_POSITION: number;
  79524. private _forward;
  79525. private _forwardInverted;
  79526. private _up;
  79527. private _right;
  79528. private _rightInverted;
  79529. private _position;
  79530. private _rotation;
  79531. private _rotationQuaternion;
  79532. protected _scaling: Vector3;
  79533. protected _isDirty: boolean;
  79534. private _transformToBoneReferal;
  79535. private _isAbsoluteSynced;
  79536. private _billboardMode;
  79537. /**
  79538. * Gets or sets the billboard mode. Default is 0.
  79539. *
  79540. * | Value | Type | Description |
  79541. * | --- | --- | --- |
  79542. * | 0 | BILLBOARDMODE_NONE | |
  79543. * | 1 | BILLBOARDMODE_X | |
  79544. * | 2 | BILLBOARDMODE_Y | |
  79545. * | 4 | BILLBOARDMODE_Z | |
  79546. * | 7 | BILLBOARDMODE_ALL | |
  79547. *
  79548. */
  79549. billboardMode: number;
  79550. private _preserveParentRotationForBillboard;
  79551. /**
  79552. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79553. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79554. */
  79555. preserveParentRotationForBillboard: boolean;
  79556. /**
  79557. * 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
  79558. */
  79559. scalingDeterminant: number;
  79560. private _infiniteDistance;
  79561. /**
  79562. * Gets or sets the distance of the object to max, often used by skybox
  79563. */
  79564. infiniteDistance: boolean;
  79565. /**
  79566. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79567. * By default the system will update normals to compensate
  79568. */
  79569. ignoreNonUniformScaling: boolean;
  79570. /**
  79571. * 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
  79572. */
  79573. reIntegrateRotationIntoRotationQuaternion: boolean;
  79574. /** @hidden */
  79575. _poseMatrix: Nullable<Matrix>;
  79576. /** @hidden */
  79577. _localMatrix: Matrix;
  79578. private _usePivotMatrix;
  79579. private _absolutePosition;
  79580. private _absoluteScaling;
  79581. private _absoluteRotationQuaternion;
  79582. private _pivotMatrix;
  79583. private _pivotMatrixInverse;
  79584. protected _postMultiplyPivotMatrix: boolean;
  79585. protected _isWorldMatrixFrozen: boolean;
  79586. /** @hidden */
  79587. _indexInSceneTransformNodesArray: number;
  79588. /**
  79589. * An event triggered after the world matrix is updated
  79590. */
  79591. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79592. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79593. /**
  79594. * Gets a string identifying the name of the class
  79595. * @returns "TransformNode" string
  79596. */
  79597. getClassName(): string;
  79598. /**
  79599. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79600. */
  79601. position: Vector3;
  79602. /**
  79603. * 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)).
  79604. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79605. */
  79606. rotation: Vector3;
  79607. /**
  79608. * 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)).
  79609. */
  79610. scaling: Vector3;
  79611. /**
  79612. * 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).
  79613. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79614. */
  79615. rotationQuaternion: Nullable<Quaternion>;
  79616. /**
  79617. * The forward direction of that transform in world space.
  79618. */
  79619. readonly forward: Vector3;
  79620. /**
  79621. * The up direction of that transform in world space.
  79622. */
  79623. readonly up: Vector3;
  79624. /**
  79625. * The right direction of that transform in world space.
  79626. */
  79627. readonly right: Vector3;
  79628. /**
  79629. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79630. * @param matrix the matrix to copy the pose from
  79631. * @returns this TransformNode.
  79632. */
  79633. updatePoseMatrix(matrix: Matrix): TransformNode;
  79634. /**
  79635. * Returns the mesh Pose matrix.
  79636. * @returns the pose matrix
  79637. */
  79638. getPoseMatrix(): Matrix;
  79639. /** @hidden */
  79640. _isSynchronized(): boolean;
  79641. /** @hidden */
  79642. _initCache(): void;
  79643. /**
  79644. * Flag the transform node as dirty (Forcing it to update everything)
  79645. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79646. * @returns this transform node
  79647. */
  79648. markAsDirty(property: string): TransformNode;
  79649. /**
  79650. * Returns the current mesh absolute position.
  79651. * Returns a Vector3.
  79652. */
  79653. readonly absolutePosition: Vector3;
  79654. /**
  79655. * Returns the current mesh absolute scaling.
  79656. * Returns a Vector3.
  79657. */
  79658. readonly absoluteScaling: Vector3;
  79659. /**
  79660. * Returns the current mesh absolute rotation.
  79661. * Returns a Quaternion.
  79662. */
  79663. readonly absoluteRotationQuaternion: Quaternion;
  79664. /**
  79665. * Sets a new matrix to apply before all other transformation
  79666. * @param matrix defines the transform matrix
  79667. * @returns the current TransformNode
  79668. */
  79669. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79670. /**
  79671. * Sets a new pivot matrix to the current node
  79672. * @param matrix defines the new pivot matrix to use
  79673. * @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
  79674. * @returns the current TransformNode
  79675. */
  79676. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79677. /**
  79678. * Returns the mesh pivot matrix.
  79679. * Default : Identity.
  79680. * @returns the matrix
  79681. */
  79682. getPivotMatrix(): Matrix;
  79683. /**
  79684. * Instantiate (when possible) or clone that node with its hierarchy
  79685. * @param newParent defines the new parent to use for the instance (or clone)
  79686. * @returns an instance (or a clone) of the current node with its hiearchy
  79687. */
  79688. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79689. /**
  79690. * Prevents the World matrix to be computed any longer
  79691. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79692. * @returns the TransformNode.
  79693. */
  79694. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79695. /**
  79696. * Allows back the World matrix computation.
  79697. * @returns the TransformNode.
  79698. */
  79699. unfreezeWorldMatrix(): this;
  79700. /**
  79701. * True if the World matrix has been frozen.
  79702. */
  79703. readonly isWorldMatrixFrozen: boolean;
  79704. /**
  79705. * Retuns the mesh absolute position in the World.
  79706. * @returns a Vector3.
  79707. */
  79708. getAbsolutePosition(): Vector3;
  79709. /**
  79710. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79711. * @param absolutePosition the absolute position to set
  79712. * @returns the TransformNode.
  79713. */
  79714. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79715. /**
  79716. * Sets the mesh position in its local space.
  79717. * @param vector3 the position to set in localspace
  79718. * @returns the TransformNode.
  79719. */
  79720. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79721. /**
  79722. * Returns the mesh position in the local space from the current World matrix values.
  79723. * @returns a new Vector3.
  79724. */
  79725. getPositionExpressedInLocalSpace(): Vector3;
  79726. /**
  79727. * Translates the mesh along the passed Vector3 in its local space.
  79728. * @param vector3 the distance to translate in localspace
  79729. * @returns the TransformNode.
  79730. */
  79731. locallyTranslate(vector3: Vector3): TransformNode;
  79732. private static _lookAtVectorCache;
  79733. /**
  79734. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79735. * @param targetPoint the position (must be in same space as current mesh) to look at
  79736. * @param yawCor optional yaw (y-axis) correction in radians
  79737. * @param pitchCor optional pitch (x-axis) correction in radians
  79738. * @param rollCor optional roll (z-axis) correction in radians
  79739. * @param space the choosen space of the target
  79740. * @returns the TransformNode.
  79741. */
  79742. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79743. /**
  79744. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79745. * This Vector3 is expressed in the World space.
  79746. * @param localAxis axis to rotate
  79747. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79748. */
  79749. getDirection(localAxis: Vector3): Vector3;
  79750. /**
  79751. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79752. * localAxis is expressed in the mesh local space.
  79753. * result is computed in the Wordl space from the mesh World matrix.
  79754. * @param localAxis axis to rotate
  79755. * @param result the resulting transformnode
  79756. * @returns this TransformNode.
  79757. */
  79758. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79759. /**
  79760. * Sets this transform node rotation to the given local axis.
  79761. * @param localAxis the axis in local space
  79762. * @param yawCor optional yaw (y-axis) correction in radians
  79763. * @param pitchCor optional pitch (x-axis) correction in radians
  79764. * @param rollCor optional roll (z-axis) correction in radians
  79765. * @returns this TransformNode
  79766. */
  79767. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79768. /**
  79769. * Sets a new pivot point to the current node
  79770. * @param point defines the new pivot point to use
  79771. * @param space defines if the point is in world or local space (local by default)
  79772. * @returns the current TransformNode
  79773. */
  79774. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79775. /**
  79776. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79777. * @returns the pivot point
  79778. */
  79779. getPivotPoint(): Vector3;
  79780. /**
  79781. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79782. * @param result the vector3 to store the result
  79783. * @returns this TransformNode.
  79784. */
  79785. getPivotPointToRef(result: Vector3): TransformNode;
  79786. /**
  79787. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79788. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79789. */
  79790. getAbsolutePivotPoint(): Vector3;
  79791. /**
  79792. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79793. * @param result vector3 to store the result
  79794. * @returns this TransformNode.
  79795. */
  79796. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79797. /**
  79798. * Defines the passed node as the parent of the current node.
  79799. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79800. * @see https://doc.babylonjs.com/how_to/parenting
  79801. * @param node the node ot set as the parent
  79802. * @returns this TransformNode.
  79803. */
  79804. setParent(node: Nullable<Node>): TransformNode;
  79805. private _nonUniformScaling;
  79806. /**
  79807. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79808. */
  79809. readonly nonUniformScaling: boolean;
  79810. /** @hidden */
  79811. _updateNonUniformScalingState(value: boolean): boolean;
  79812. /**
  79813. * Attach the current TransformNode to another TransformNode associated with a bone
  79814. * @param bone Bone affecting the TransformNode
  79815. * @param affectedTransformNode TransformNode associated with the bone
  79816. * @returns this object
  79817. */
  79818. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79819. /**
  79820. * Detach the transform node if its associated with a bone
  79821. * @returns this object
  79822. */
  79823. detachFromBone(): TransformNode;
  79824. private static _rotationAxisCache;
  79825. /**
  79826. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79827. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79828. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79829. * The passed axis is also normalized.
  79830. * @param axis the axis to rotate around
  79831. * @param amount the amount to rotate in radians
  79832. * @param space Space to rotate in (Default: local)
  79833. * @returns the TransformNode.
  79834. */
  79835. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79836. /**
  79837. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79838. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79839. * The passed axis is also normalized. .
  79840. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79841. * @param point the point to rotate around
  79842. * @param axis the axis to rotate around
  79843. * @param amount the amount to rotate in radians
  79844. * @returns the TransformNode
  79845. */
  79846. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79847. /**
  79848. * Translates the mesh along the axis vector for the passed distance in the given space.
  79849. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79850. * @param axis the axis to translate in
  79851. * @param distance the distance to translate
  79852. * @param space Space to rotate in (Default: local)
  79853. * @returns the TransformNode.
  79854. */
  79855. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79856. /**
  79857. * Adds a rotation step to the mesh current rotation.
  79858. * x, y, z are Euler angles expressed in radians.
  79859. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79860. * This means this rotation is made in the mesh local space only.
  79861. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79862. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79863. * ```javascript
  79864. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79865. * ```
  79866. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79867. * 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.
  79868. * @param x Rotation to add
  79869. * @param y Rotation to add
  79870. * @param z Rotation to add
  79871. * @returns the TransformNode.
  79872. */
  79873. addRotation(x: number, y: number, z: number): TransformNode;
  79874. /**
  79875. * @hidden
  79876. */
  79877. protected _getEffectiveParent(): Nullable<Node>;
  79878. /**
  79879. * Computes the world matrix of the node
  79880. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79881. * @returns the world matrix
  79882. */
  79883. computeWorldMatrix(force?: boolean): Matrix;
  79884. protected _afterComputeWorldMatrix(): void;
  79885. /**
  79886. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79887. * @param func callback function to add
  79888. *
  79889. * @returns the TransformNode.
  79890. */
  79891. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79892. /**
  79893. * Removes a registered callback function.
  79894. * @param func callback function to remove
  79895. * @returns the TransformNode.
  79896. */
  79897. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79898. /**
  79899. * Gets the position of the current mesh in camera space
  79900. * @param camera defines the camera to use
  79901. * @returns a position
  79902. */
  79903. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79904. /**
  79905. * Returns the distance from the mesh to the active camera
  79906. * @param camera defines the camera to use
  79907. * @returns the distance
  79908. */
  79909. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79910. /**
  79911. * Clone the current transform node
  79912. * @param name Name of the new clone
  79913. * @param newParent New parent for the clone
  79914. * @param doNotCloneChildren Do not clone children hierarchy
  79915. * @returns the new transform node
  79916. */
  79917. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79918. /**
  79919. * Serializes the objects information.
  79920. * @param currentSerializationObject defines the object to serialize in
  79921. * @returns the serialized object
  79922. */
  79923. serialize(currentSerializationObject?: any): any;
  79924. /**
  79925. * Returns a new TransformNode object parsed from the source provided.
  79926. * @param parsedTransformNode is the source.
  79927. * @param scene the scne the object belongs to
  79928. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79929. * @returns a new TransformNode object parsed from the source provided.
  79930. */
  79931. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79932. /**
  79933. * Get all child-transformNodes of this node
  79934. * @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
  79935. * @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
  79936. * @returns an array of TransformNode
  79937. */
  79938. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79939. /**
  79940. * Releases resources associated with this transform node.
  79941. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79942. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79943. */
  79944. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79945. /**
  79946. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79947. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79948. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79949. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79950. * @returns the current mesh
  79951. */
  79952. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79953. private _syncAbsoluteScalingAndRotation;
  79954. }
  79955. }
  79956. declare module BABYLON {
  79957. /**
  79958. * Defines the types of pose enabled controllers that are supported
  79959. */
  79960. export enum PoseEnabledControllerType {
  79961. /**
  79962. * HTC Vive
  79963. */
  79964. VIVE = 0,
  79965. /**
  79966. * Oculus Rift
  79967. */
  79968. OCULUS = 1,
  79969. /**
  79970. * Windows mixed reality
  79971. */
  79972. WINDOWS = 2,
  79973. /**
  79974. * Samsung gear VR
  79975. */
  79976. GEAR_VR = 3,
  79977. /**
  79978. * Google Daydream
  79979. */
  79980. DAYDREAM = 4,
  79981. /**
  79982. * Generic
  79983. */
  79984. GENERIC = 5
  79985. }
  79986. /**
  79987. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79988. */
  79989. export interface MutableGamepadButton {
  79990. /**
  79991. * Value of the button/trigger
  79992. */
  79993. value: number;
  79994. /**
  79995. * If the button/trigger is currently touched
  79996. */
  79997. touched: boolean;
  79998. /**
  79999. * If the button/trigger is currently pressed
  80000. */
  80001. pressed: boolean;
  80002. }
  80003. /**
  80004. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80005. * @hidden
  80006. */
  80007. export interface ExtendedGamepadButton extends GamepadButton {
  80008. /**
  80009. * If the button/trigger is currently pressed
  80010. */
  80011. readonly pressed: boolean;
  80012. /**
  80013. * If the button/trigger is currently touched
  80014. */
  80015. readonly touched: boolean;
  80016. /**
  80017. * Value of the button/trigger
  80018. */
  80019. readonly value: number;
  80020. }
  80021. /** @hidden */
  80022. export interface _GamePadFactory {
  80023. /**
  80024. * Returns wether or not the current gamepad can be created for this type of controller.
  80025. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80026. * @returns true if it can be created, otherwise false
  80027. */
  80028. canCreate(gamepadInfo: any): boolean;
  80029. /**
  80030. * Creates a new instance of the Gamepad.
  80031. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80032. * @returns the new gamepad instance
  80033. */
  80034. create(gamepadInfo: any): Gamepad;
  80035. }
  80036. /**
  80037. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80038. */
  80039. export class PoseEnabledControllerHelper {
  80040. /** @hidden */
  80041. static _ControllerFactories: _GamePadFactory[];
  80042. /** @hidden */
  80043. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80044. /**
  80045. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80046. * @param vrGamepad the gamepad to initialized
  80047. * @returns a vr controller of the type the gamepad identified as
  80048. */
  80049. static InitiateController(vrGamepad: any): Gamepad;
  80050. }
  80051. /**
  80052. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80053. */
  80054. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80055. /**
  80056. * If the controller is used in a webXR session
  80057. */
  80058. isXR: boolean;
  80059. private _deviceRoomPosition;
  80060. private _deviceRoomRotationQuaternion;
  80061. /**
  80062. * The device position in babylon space
  80063. */
  80064. devicePosition: Vector3;
  80065. /**
  80066. * The device rotation in babylon space
  80067. */
  80068. deviceRotationQuaternion: Quaternion;
  80069. /**
  80070. * The scale factor of the device in babylon space
  80071. */
  80072. deviceScaleFactor: number;
  80073. /**
  80074. * (Likely devicePosition should be used instead) The device position in its room space
  80075. */
  80076. position: Vector3;
  80077. /**
  80078. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80079. */
  80080. rotationQuaternion: Quaternion;
  80081. /**
  80082. * The type of controller (Eg. Windows mixed reality)
  80083. */
  80084. controllerType: PoseEnabledControllerType;
  80085. protected _calculatedPosition: Vector3;
  80086. private _calculatedRotation;
  80087. /**
  80088. * The raw pose from the device
  80089. */
  80090. rawPose: DevicePose;
  80091. private _trackPosition;
  80092. private _maxRotationDistFromHeadset;
  80093. private _draggedRoomRotation;
  80094. /**
  80095. * @hidden
  80096. */
  80097. _disableTrackPosition(fixedPosition: Vector3): void;
  80098. /**
  80099. * Internal, the mesh attached to the controller
  80100. * @hidden
  80101. */
  80102. _mesh: Nullable<AbstractMesh>;
  80103. private _poseControlledCamera;
  80104. private _leftHandSystemQuaternion;
  80105. /**
  80106. * Internal, matrix used to convert room space to babylon space
  80107. * @hidden
  80108. */
  80109. _deviceToWorld: Matrix;
  80110. /**
  80111. * Node to be used when casting a ray from the controller
  80112. * @hidden
  80113. */
  80114. _pointingPoseNode: Nullable<TransformNode>;
  80115. /**
  80116. * Name of the child mesh that can be used to cast a ray from the controller
  80117. */
  80118. static readonly POINTING_POSE: string;
  80119. /**
  80120. * Creates a new PoseEnabledController from a gamepad
  80121. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80122. */
  80123. constructor(browserGamepad: any);
  80124. private _workingMatrix;
  80125. /**
  80126. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80127. */
  80128. update(): void;
  80129. /**
  80130. * Updates only the pose device and mesh without doing any button event checking
  80131. */
  80132. protected _updatePoseAndMesh(): void;
  80133. /**
  80134. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80135. * @param poseData raw pose fromthe device
  80136. */
  80137. updateFromDevice(poseData: DevicePose): void;
  80138. /**
  80139. * @hidden
  80140. */
  80141. _meshAttachedObservable: Observable<AbstractMesh>;
  80142. /**
  80143. * Attaches a mesh to the controller
  80144. * @param mesh the mesh to be attached
  80145. */
  80146. attachToMesh(mesh: AbstractMesh): void;
  80147. /**
  80148. * Attaches the controllers mesh to a camera
  80149. * @param camera the camera the mesh should be attached to
  80150. */
  80151. attachToPoseControlledCamera(camera: TargetCamera): void;
  80152. /**
  80153. * Disposes of the controller
  80154. */
  80155. dispose(): void;
  80156. /**
  80157. * The mesh that is attached to the controller
  80158. */
  80159. readonly mesh: Nullable<AbstractMesh>;
  80160. /**
  80161. * Gets the ray of the controller in the direction the controller is pointing
  80162. * @param length the length the resulting ray should be
  80163. * @returns a ray in the direction the controller is pointing
  80164. */
  80165. getForwardRay(length?: number): Ray;
  80166. }
  80167. }
  80168. declare module BABYLON {
  80169. /**
  80170. * Defines the WebVRController object that represents controllers tracked in 3D space
  80171. */
  80172. export abstract class WebVRController extends PoseEnabledController {
  80173. /**
  80174. * Internal, the default controller model for the controller
  80175. */
  80176. protected _defaultModel: AbstractMesh;
  80177. /**
  80178. * Fired when the trigger state has changed
  80179. */
  80180. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80181. /**
  80182. * Fired when the main button state has changed
  80183. */
  80184. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80185. /**
  80186. * Fired when the secondary button state has changed
  80187. */
  80188. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80189. /**
  80190. * Fired when the pad state has changed
  80191. */
  80192. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80193. /**
  80194. * Fired when controllers stick values have changed
  80195. */
  80196. onPadValuesChangedObservable: Observable<StickValues>;
  80197. /**
  80198. * Array of button availible on the controller
  80199. */
  80200. protected _buttons: Array<MutableGamepadButton>;
  80201. private _onButtonStateChange;
  80202. /**
  80203. * Fired when a controller button's state has changed
  80204. * @param callback the callback containing the button that was modified
  80205. */
  80206. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80207. /**
  80208. * X and Y axis corresponding to the controllers joystick
  80209. */
  80210. pad: StickValues;
  80211. /**
  80212. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80213. */
  80214. hand: string;
  80215. /**
  80216. * The default controller model for the controller
  80217. */
  80218. readonly defaultModel: AbstractMesh;
  80219. /**
  80220. * Creates a new WebVRController from a gamepad
  80221. * @param vrGamepad the gamepad that the WebVRController should be created from
  80222. */
  80223. constructor(vrGamepad: any);
  80224. /**
  80225. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80226. */
  80227. update(): void;
  80228. /**
  80229. * Function to be called when a button is modified
  80230. */
  80231. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80232. /**
  80233. * Loads a mesh and attaches it to the controller
  80234. * @param scene the scene the mesh should be added to
  80235. * @param meshLoaded callback for when the mesh has been loaded
  80236. */
  80237. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80238. private _setButtonValue;
  80239. private _changes;
  80240. private _checkChanges;
  80241. /**
  80242. * Disposes of th webVRCOntroller
  80243. */
  80244. dispose(): void;
  80245. }
  80246. }
  80247. declare module BABYLON {
  80248. /**
  80249. * The HemisphericLight simulates the ambient environment light,
  80250. * so the passed direction is the light reflection direction, not the incoming direction.
  80251. */
  80252. export class HemisphericLight extends Light {
  80253. /**
  80254. * The groundColor is the light in the opposite direction to the one specified during creation.
  80255. * 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.
  80256. */
  80257. groundColor: Color3;
  80258. /**
  80259. * The light reflection direction, not the incoming direction.
  80260. */
  80261. direction: Vector3;
  80262. /**
  80263. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80264. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80265. * The HemisphericLight can't cast shadows.
  80266. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80267. * @param name The friendly name of the light
  80268. * @param direction The direction of the light reflection
  80269. * @param scene The scene the light belongs to
  80270. */
  80271. constructor(name: string, direction: Vector3, scene: Scene);
  80272. protected _buildUniformLayout(): void;
  80273. /**
  80274. * Returns the string "HemisphericLight".
  80275. * @return The class name
  80276. */
  80277. getClassName(): string;
  80278. /**
  80279. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80280. * Returns the updated direction.
  80281. * @param target The target the direction should point to
  80282. * @return The computed direction
  80283. */
  80284. setDirectionToTarget(target: Vector3): Vector3;
  80285. /**
  80286. * Returns the shadow generator associated to the light.
  80287. * @returns Always null for hemispheric lights because it does not support shadows.
  80288. */
  80289. getShadowGenerator(): Nullable<IShadowGenerator>;
  80290. /**
  80291. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80292. * @param effect The effect to update
  80293. * @param lightIndex The index of the light in the effect to update
  80294. * @returns The hemispheric light
  80295. */
  80296. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80297. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  80298. /**
  80299. * Computes the world matrix of the node
  80300. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80301. * @param useWasUpdatedFlag defines a reserved property
  80302. * @returns the world matrix
  80303. */
  80304. computeWorldMatrix(): Matrix;
  80305. /**
  80306. * Returns the integer 3.
  80307. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80308. */
  80309. getTypeID(): number;
  80310. /**
  80311. * Prepares the list of defines specific to the light type.
  80312. * @param defines the list of defines
  80313. * @param lightIndex defines the index of the light for the effect
  80314. */
  80315. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80316. }
  80317. }
  80318. declare module BABYLON {
  80319. /** @hidden */
  80320. export var vrMultiviewToSingleviewPixelShader: {
  80321. name: string;
  80322. shader: string;
  80323. };
  80324. }
  80325. declare module BABYLON {
  80326. /**
  80327. * Renders to multiple views with a single draw call
  80328. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80329. */
  80330. export class MultiviewRenderTarget extends RenderTargetTexture {
  80331. /**
  80332. * Creates a multiview render target
  80333. * @param scene scene used with the render target
  80334. * @param size the size of the render target (used for each view)
  80335. */
  80336. constructor(scene: Scene, size?: number | {
  80337. width: number;
  80338. height: number;
  80339. } | {
  80340. ratio: number;
  80341. });
  80342. /**
  80343. * @hidden
  80344. * @param faceIndex the face index, if its a cube texture
  80345. */
  80346. _bindFrameBuffer(faceIndex?: number): void;
  80347. /**
  80348. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80349. * @returns the view count
  80350. */
  80351. getViewCount(): number;
  80352. }
  80353. }
  80354. declare module BABYLON {
  80355. /**
  80356. * Represents a camera frustum
  80357. */
  80358. export class Frustum {
  80359. /**
  80360. * Gets the planes representing the frustum
  80361. * @param transform matrix to be applied to the returned planes
  80362. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80363. */
  80364. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80365. /**
  80366. * Gets the near frustum plane transformed by the transform matrix
  80367. * @param transform transformation matrix to be applied to the resulting frustum plane
  80368. * @param frustumPlane the resuling frustum plane
  80369. */
  80370. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80371. /**
  80372. * Gets the far frustum plane transformed by the transform matrix
  80373. * @param transform transformation matrix to be applied to the resulting frustum plane
  80374. * @param frustumPlane the resuling frustum plane
  80375. */
  80376. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80377. /**
  80378. * Gets the left frustum plane transformed by the transform matrix
  80379. * @param transform transformation matrix to be applied to the resulting frustum plane
  80380. * @param frustumPlane the resuling frustum plane
  80381. */
  80382. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80383. /**
  80384. * Gets the right frustum plane transformed by the transform matrix
  80385. * @param transform transformation matrix to be applied to the resulting frustum plane
  80386. * @param frustumPlane the resuling frustum plane
  80387. */
  80388. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80389. /**
  80390. * Gets the top frustum plane transformed by the transform matrix
  80391. * @param transform transformation matrix to be applied to the resulting frustum plane
  80392. * @param frustumPlane the resuling frustum plane
  80393. */
  80394. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80395. /**
  80396. * Gets the bottom frustum plane transformed by the transform matrix
  80397. * @param transform transformation matrix to be applied to the resulting frustum plane
  80398. * @param frustumPlane the resuling frustum plane
  80399. */
  80400. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80401. /**
  80402. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80403. * @param transform transformation matrix to be applied to the resulting frustum planes
  80404. * @param frustumPlanes the resuling frustum planes
  80405. */
  80406. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80407. }
  80408. }
  80409. declare module BABYLON {
  80410. interface Engine {
  80411. /**
  80412. * Creates a new multiview render target
  80413. * @param width defines the width of the texture
  80414. * @param height defines the height of the texture
  80415. * @returns the created multiview texture
  80416. */
  80417. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80418. /**
  80419. * Binds a multiview framebuffer to be drawn to
  80420. * @param multiviewTexture texture to bind
  80421. */
  80422. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80423. }
  80424. interface Camera {
  80425. /**
  80426. * @hidden
  80427. * 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)
  80428. */
  80429. _useMultiviewToSingleView: boolean;
  80430. /**
  80431. * @hidden
  80432. * 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)
  80433. */
  80434. _multiviewTexture: Nullable<RenderTargetTexture>;
  80435. /**
  80436. * @hidden
  80437. * ensures the multiview texture of the camera exists and has the specified width/height
  80438. * @param width height to set on the multiview texture
  80439. * @param height width to set on the multiview texture
  80440. */
  80441. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80442. }
  80443. interface Scene {
  80444. /** @hidden */
  80445. _transformMatrixR: Matrix;
  80446. /** @hidden */
  80447. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80448. /** @hidden */
  80449. _createMultiviewUbo(): void;
  80450. /** @hidden */
  80451. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80452. /** @hidden */
  80453. _renderMultiviewToSingleView(camera: Camera): void;
  80454. }
  80455. }
  80456. declare module BABYLON {
  80457. /**
  80458. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80459. * This will not be used for webXR as it supports displaying texture arrays directly
  80460. */
  80461. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80462. /**
  80463. * Initializes a VRMultiviewToSingleview
  80464. * @param name name of the post process
  80465. * @param camera camera to be applied to
  80466. * @param scaleFactor scaling factor to the size of the output texture
  80467. */
  80468. constructor(name: string, camera: Camera, scaleFactor: number);
  80469. }
  80470. }
  80471. declare module BABYLON {
  80472. interface Engine {
  80473. /** @hidden */
  80474. _vrDisplay: any;
  80475. /** @hidden */
  80476. _vrSupported: boolean;
  80477. /** @hidden */
  80478. _oldSize: Size;
  80479. /** @hidden */
  80480. _oldHardwareScaleFactor: number;
  80481. /** @hidden */
  80482. _vrExclusivePointerMode: boolean;
  80483. /** @hidden */
  80484. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80485. /** @hidden */
  80486. _onVRDisplayPointerRestricted: () => void;
  80487. /** @hidden */
  80488. _onVRDisplayPointerUnrestricted: () => void;
  80489. /** @hidden */
  80490. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80491. /** @hidden */
  80492. _onVrDisplayDisconnect: Nullable<() => void>;
  80493. /** @hidden */
  80494. _onVrDisplayPresentChange: Nullable<() => void>;
  80495. /**
  80496. * Observable signaled when VR display mode changes
  80497. */
  80498. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80499. /**
  80500. * Observable signaled when VR request present is complete
  80501. */
  80502. onVRRequestPresentComplete: Observable<boolean>;
  80503. /**
  80504. * Observable signaled when VR request present starts
  80505. */
  80506. onVRRequestPresentStart: Observable<Engine>;
  80507. /**
  80508. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80509. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80510. */
  80511. isInVRExclusivePointerMode: boolean;
  80512. /**
  80513. * Gets a boolean indicating if a webVR device was detected
  80514. * @returns true if a webVR device was detected
  80515. */
  80516. isVRDevicePresent(): boolean;
  80517. /**
  80518. * Gets the current webVR device
  80519. * @returns the current webVR device (or null)
  80520. */
  80521. getVRDevice(): any;
  80522. /**
  80523. * Initializes a webVR display and starts listening to display change events
  80524. * The onVRDisplayChangedObservable will be notified upon these changes
  80525. * @returns A promise containing a VRDisplay and if vr is supported
  80526. */
  80527. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80528. /** @hidden */
  80529. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80530. /**
  80531. * Call this function to switch to webVR mode
  80532. * Will do nothing if webVR is not supported or if there is no webVR device
  80533. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80534. */
  80535. enableVR(): void;
  80536. /** @hidden */
  80537. _onVRFullScreenTriggered(): void;
  80538. }
  80539. }
  80540. declare module BABYLON {
  80541. /**
  80542. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80543. * IMPORTANT!! The data is right-hand data.
  80544. * @export
  80545. * @interface DevicePose
  80546. */
  80547. export interface DevicePose {
  80548. /**
  80549. * The position of the device, values in array are [x,y,z].
  80550. */
  80551. readonly position: Nullable<Float32Array>;
  80552. /**
  80553. * The linearVelocity of the device, values in array are [x,y,z].
  80554. */
  80555. readonly linearVelocity: Nullable<Float32Array>;
  80556. /**
  80557. * The linearAcceleration of the device, values in array are [x,y,z].
  80558. */
  80559. readonly linearAcceleration: Nullable<Float32Array>;
  80560. /**
  80561. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80562. */
  80563. readonly orientation: Nullable<Float32Array>;
  80564. /**
  80565. * The angularVelocity of the device, values in array are [x,y,z].
  80566. */
  80567. readonly angularVelocity: Nullable<Float32Array>;
  80568. /**
  80569. * The angularAcceleration of the device, values in array are [x,y,z].
  80570. */
  80571. readonly angularAcceleration: Nullable<Float32Array>;
  80572. }
  80573. /**
  80574. * Interface representing a pose controlled object in Babylon.
  80575. * A pose controlled object has both regular pose values as well as pose values
  80576. * from an external device such as a VR head mounted display
  80577. */
  80578. export interface PoseControlled {
  80579. /**
  80580. * The position of the object in babylon space.
  80581. */
  80582. position: Vector3;
  80583. /**
  80584. * The rotation quaternion of the object in babylon space.
  80585. */
  80586. rotationQuaternion: Quaternion;
  80587. /**
  80588. * The position of the device in babylon space.
  80589. */
  80590. devicePosition?: Vector3;
  80591. /**
  80592. * The rotation quaternion of the device in babylon space.
  80593. */
  80594. deviceRotationQuaternion: Quaternion;
  80595. /**
  80596. * The raw pose coming from the device.
  80597. */
  80598. rawPose: Nullable<DevicePose>;
  80599. /**
  80600. * The scale of the device to be used when translating from device space to babylon space.
  80601. */
  80602. deviceScaleFactor: number;
  80603. /**
  80604. * Updates the poseControlled values based on the input device pose.
  80605. * @param poseData the pose data to update the object with
  80606. */
  80607. updateFromDevice(poseData: DevicePose): void;
  80608. }
  80609. /**
  80610. * Set of options to customize the webVRCamera
  80611. */
  80612. export interface WebVROptions {
  80613. /**
  80614. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80615. */
  80616. trackPosition?: boolean;
  80617. /**
  80618. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80619. */
  80620. positionScale?: number;
  80621. /**
  80622. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80623. */
  80624. displayName?: string;
  80625. /**
  80626. * Should the native controller meshes be initialized. (default: true)
  80627. */
  80628. controllerMeshes?: boolean;
  80629. /**
  80630. * Creating a default HemiLight only on controllers. (default: true)
  80631. */
  80632. defaultLightingOnControllers?: boolean;
  80633. /**
  80634. * If you don't want to use the default VR button of the helper. (default: false)
  80635. */
  80636. useCustomVRButton?: boolean;
  80637. /**
  80638. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80639. */
  80640. customVRButton?: HTMLButtonElement;
  80641. /**
  80642. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80643. */
  80644. rayLength?: number;
  80645. /**
  80646. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80647. */
  80648. defaultHeight?: number;
  80649. /**
  80650. * If multiview should be used if availible (default: false)
  80651. */
  80652. useMultiview?: boolean;
  80653. }
  80654. /**
  80655. * This represents a WebVR camera.
  80656. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80657. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80658. */
  80659. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80660. private webVROptions;
  80661. /**
  80662. * @hidden
  80663. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80664. */
  80665. _vrDevice: any;
  80666. /**
  80667. * The rawPose of the vrDevice.
  80668. */
  80669. rawPose: Nullable<DevicePose>;
  80670. private _onVREnabled;
  80671. private _specsVersion;
  80672. private _attached;
  80673. private _frameData;
  80674. protected _descendants: Array<Node>;
  80675. private _deviceRoomPosition;
  80676. /** @hidden */
  80677. _deviceRoomRotationQuaternion: Quaternion;
  80678. private _standingMatrix;
  80679. /**
  80680. * Represents device position in babylon space.
  80681. */
  80682. devicePosition: Vector3;
  80683. /**
  80684. * Represents device rotation in babylon space.
  80685. */
  80686. deviceRotationQuaternion: Quaternion;
  80687. /**
  80688. * The scale of the device to be used when translating from device space to babylon space.
  80689. */
  80690. deviceScaleFactor: number;
  80691. private _deviceToWorld;
  80692. private _worldToDevice;
  80693. /**
  80694. * References to the webVR controllers for the vrDevice.
  80695. */
  80696. controllers: Array<WebVRController>;
  80697. /**
  80698. * Emits an event when a controller is attached.
  80699. */
  80700. onControllersAttachedObservable: Observable<WebVRController[]>;
  80701. /**
  80702. * Emits an event when a controller's mesh has been loaded;
  80703. */
  80704. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80705. /**
  80706. * Emits an event when the HMD's pose has been updated.
  80707. */
  80708. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80709. private _poseSet;
  80710. /**
  80711. * If the rig cameras be used as parent instead of this camera.
  80712. */
  80713. rigParenting: boolean;
  80714. private _lightOnControllers;
  80715. private _defaultHeight?;
  80716. /**
  80717. * Instantiates a WebVRFreeCamera.
  80718. * @param name The name of the WebVRFreeCamera
  80719. * @param position The starting anchor position for the camera
  80720. * @param scene The scene the camera belongs to
  80721. * @param webVROptions a set of customizable options for the webVRCamera
  80722. */
  80723. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80724. /**
  80725. * Gets the device distance from the ground in meters.
  80726. * @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.
  80727. */
  80728. deviceDistanceToRoomGround(): number;
  80729. /**
  80730. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80731. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80732. */
  80733. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80734. /**
  80735. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80736. * @returns A promise with a boolean set to if the standing matrix is supported.
  80737. */
  80738. useStandingMatrixAsync(): Promise<boolean>;
  80739. /**
  80740. * Disposes the camera
  80741. */
  80742. dispose(): void;
  80743. /**
  80744. * Gets a vrController by name.
  80745. * @param name The name of the controller to retreive
  80746. * @returns the controller matching the name specified or null if not found
  80747. */
  80748. getControllerByName(name: string): Nullable<WebVRController>;
  80749. private _leftController;
  80750. /**
  80751. * The controller corresponding to the users left hand.
  80752. */
  80753. readonly leftController: Nullable<WebVRController>;
  80754. private _rightController;
  80755. /**
  80756. * The controller corresponding to the users right hand.
  80757. */
  80758. readonly rightController: Nullable<WebVRController>;
  80759. /**
  80760. * Casts a ray forward from the vrCamera's gaze.
  80761. * @param length Length of the ray (default: 100)
  80762. * @returns the ray corresponding to the gaze
  80763. */
  80764. getForwardRay(length?: number): Ray;
  80765. /**
  80766. * @hidden
  80767. * Updates the camera based on device's frame data
  80768. */
  80769. _checkInputs(): void;
  80770. /**
  80771. * Updates the poseControlled values based on the input device pose.
  80772. * @param poseData Pose coming from the device
  80773. */
  80774. updateFromDevice(poseData: DevicePose): void;
  80775. private _htmlElementAttached;
  80776. private _detachIfAttached;
  80777. /**
  80778. * WebVR's attach control will start broadcasting frames to the device.
  80779. * Note that in certain browsers (chrome for example) this function must be called
  80780. * within a user-interaction callback. Example:
  80781. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80782. *
  80783. * @param element html element to attach the vrDevice to
  80784. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80785. */
  80786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80787. /**
  80788. * Detaches the camera from the html element and disables VR
  80789. *
  80790. * @param element html element to detach from
  80791. */
  80792. detachControl(element: HTMLElement): void;
  80793. /**
  80794. * @returns the name of this class
  80795. */
  80796. getClassName(): string;
  80797. /**
  80798. * Calls resetPose on the vrDisplay
  80799. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80800. */
  80801. resetToCurrentRotation(): void;
  80802. /**
  80803. * @hidden
  80804. * Updates the rig cameras (left and right eye)
  80805. */
  80806. _updateRigCameras(): void;
  80807. private _workingVector;
  80808. private _oneVector;
  80809. private _workingMatrix;
  80810. private updateCacheCalled;
  80811. private _correctPositionIfNotTrackPosition;
  80812. /**
  80813. * @hidden
  80814. * Updates the cached values of the camera
  80815. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80816. */
  80817. _updateCache(ignoreParentClass?: boolean): void;
  80818. /**
  80819. * @hidden
  80820. * Get current device position in babylon world
  80821. */
  80822. _computeDevicePosition(): void;
  80823. /**
  80824. * Updates the current device position and rotation in the babylon world
  80825. */
  80826. update(): void;
  80827. /**
  80828. * @hidden
  80829. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80830. * @returns an identity matrix
  80831. */
  80832. _getViewMatrix(): Matrix;
  80833. private _tmpMatrix;
  80834. /**
  80835. * This function is called by the two RIG cameras.
  80836. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80837. * @hidden
  80838. */
  80839. _getWebVRViewMatrix(): Matrix;
  80840. /** @hidden */
  80841. _getWebVRProjectionMatrix(): Matrix;
  80842. private _onGamepadConnectedObserver;
  80843. private _onGamepadDisconnectedObserver;
  80844. private _updateCacheWhenTrackingDisabledObserver;
  80845. /**
  80846. * Initializes the controllers and their meshes
  80847. */
  80848. initControllers(): void;
  80849. }
  80850. }
  80851. declare module BABYLON {
  80852. /**
  80853. * Size options for a post process
  80854. */
  80855. export type PostProcessOptions = {
  80856. width: number;
  80857. height: number;
  80858. };
  80859. /**
  80860. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80861. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80862. */
  80863. export class PostProcess {
  80864. /** Name of the PostProcess. */
  80865. name: string;
  80866. /**
  80867. * Gets or sets the unique id of the post process
  80868. */
  80869. uniqueId: number;
  80870. /**
  80871. * Width of the texture to apply the post process on
  80872. */
  80873. width: number;
  80874. /**
  80875. * Height of the texture to apply the post process on
  80876. */
  80877. height: number;
  80878. /**
  80879. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80880. * @hidden
  80881. */
  80882. _outputTexture: Nullable<InternalTexture>;
  80883. /**
  80884. * Sampling mode used by the shader
  80885. * See https://doc.babylonjs.com/classes/3.1/texture
  80886. */
  80887. renderTargetSamplingMode: number;
  80888. /**
  80889. * Clear color to use when screen clearing
  80890. */
  80891. clearColor: Color4;
  80892. /**
  80893. * If the buffer needs to be cleared before applying the post process. (default: true)
  80894. * Should be set to false if shader will overwrite all previous pixels.
  80895. */
  80896. autoClear: boolean;
  80897. /**
  80898. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80899. */
  80900. alphaMode: number;
  80901. /**
  80902. * Sets the setAlphaBlendConstants of the babylon engine
  80903. */
  80904. alphaConstants: Color4;
  80905. /**
  80906. * Animations to be used for the post processing
  80907. */
  80908. animations: Animation[];
  80909. /**
  80910. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80911. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80912. */
  80913. enablePixelPerfectMode: boolean;
  80914. /**
  80915. * Force the postprocess to be applied without taking in account viewport
  80916. */
  80917. forceFullscreenViewport: boolean;
  80918. /**
  80919. * List of inspectable custom properties (used by the Inspector)
  80920. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80921. */
  80922. inspectableCustomProperties: IInspectable[];
  80923. /**
  80924. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80925. *
  80926. * | Value | Type | Description |
  80927. * | ----- | ----------------------------------- | ----------- |
  80928. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80929. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80930. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80931. *
  80932. */
  80933. scaleMode: number;
  80934. /**
  80935. * Force textures to be a power of two (default: false)
  80936. */
  80937. alwaysForcePOT: boolean;
  80938. private _samples;
  80939. /**
  80940. * Number of sample textures (default: 1)
  80941. */
  80942. samples: number;
  80943. /**
  80944. * Modify the scale of the post process to be the same as the viewport (default: false)
  80945. */
  80946. adaptScaleToCurrentViewport: boolean;
  80947. private _camera;
  80948. private _scene;
  80949. private _engine;
  80950. private _options;
  80951. private _reusable;
  80952. private _textureType;
  80953. /**
  80954. * Smart array of input and output textures for the post process.
  80955. * @hidden
  80956. */
  80957. _textures: SmartArray<InternalTexture>;
  80958. /**
  80959. * The index in _textures that corresponds to the output texture.
  80960. * @hidden
  80961. */
  80962. _currentRenderTextureInd: number;
  80963. private _effect;
  80964. private _samplers;
  80965. private _fragmentUrl;
  80966. private _vertexUrl;
  80967. private _parameters;
  80968. private _scaleRatio;
  80969. protected _indexParameters: any;
  80970. private _shareOutputWithPostProcess;
  80971. private _texelSize;
  80972. private _forcedOutputTexture;
  80973. /**
  80974. * Returns the fragment url or shader name used in the post process.
  80975. * @returns the fragment url or name in the shader store.
  80976. */
  80977. getEffectName(): string;
  80978. /**
  80979. * An event triggered when the postprocess is activated.
  80980. */
  80981. onActivateObservable: Observable<Camera>;
  80982. private _onActivateObserver;
  80983. /**
  80984. * A function that is added to the onActivateObservable
  80985. */
  80986. onActivate: Nullable<(camera: Camera) => void>;
  80987. /**
  80988. * An event triggered when the postprocess changes its size.
  80989. */
  80990. onSizeChangedObservable: Observable<PostProcess>;
  80991. private _onSizeChangedObserver;
  80992. /**
  80993. * A function that is added to the onSizeChangedObservable
  80994. */
  80995. onSizeChanged: (postProcess: PostProcess) => void;
  80996. /**
  80997. * An event triggered when the postprocess applies its effect.
  80998. */
  80999. onApplyObservable: Observable<Effect>;
  81000. private _onApplyObserver;
  81001. /**
  81002. * A function that is added to the onApplyObservable
  81003. */
  81004. onApply: (effect: Effect) => void;
  81005. /**
  81006. * An event triggered before rendering the postprocess
  81007. */
  81008. onBeforeRenderObservable: Observable<Effect>;
  81009. private _onBeforeRenderObserver;
  81010. /**
  81011. * A function that is added to the onBeforeRenderObservable
  81012. */
  81013. onBeforeRender: (effect: Effect) => void;
  81014. /**
  81015. * An event triggered after rendering the postprocess
  81016. */
  81017. onAfterRenderObservable: Observable<Effect>;
  81018. private _onAfterRenderObserver;
  81019. /**
  81020. * A function that is added to the onAfterRenderObservable
  81021. */
  81022. onAfterRender: (efect: Effect) => void;
  81023. /**
  81024. * 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
  81025. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81026. */
  81027. inputTexture: InternalTexture;
  81028. /**
  81029. * Gets the camera which post process is applied to.
  81030. * @returns The camera the post process is applied to.
  81031. */
  81032. getCamera(): Camera;
  81033. /**
  81034. * Gets the texel size of the postprocess.
  81035. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81036. */
  81037. readonly texelSize: Vector2;
  81038. /**
  81039. * Creates a new instance PostProcess
  81040. * @param name The name of the PostProcess.
  81041. * @param fragmentUrl The url of the fragment shader to be used.
  81042. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81043. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81044. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81045. * @param camera The camera to apply the render pass to.
  81046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81047. * @param engine The engine which the post process will be applied. (default: current engine)
  81048. * @param reusable If the post process can be reused on the same frame. (default: false)
  81049. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81050. * @param textureType Type of textures used when performing the post process. (default: 0)
  81051. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81052. * @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
  81053. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81054. */
  81055. constructor(
  81056. /** Name of the PostProcess. */
  81057. 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);
  81058. /**
  81059. * Gets a string idenfifying the name of the class
  81060. * @returns "PostProcess" string
  81061. */
  81062. getClassName(): string;
  81063. /**
  81064. * Gets the engine which this post process belongs to.
  81065. * @returns The engine the post process was enabled with.
  81066. */
  81067. getEngine(): Engine;
  81068. /**
  81069. * The effect that is created when initializing the post process.
  81070. * @returns The created effect corresponding the the postprocess.
  81071. */
  81072. getEffect(): Effect;
  81073. /**
  81074. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81075. * @param postProcess The post process to share the output with.
  81076. * @returns This post process.
  81077. */
  81078. shareOutputWith(postProcess: PostProcess): PostProcess;
  81079. /**
  81080. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81081. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81082. */
  81083. useOwnOutput(): void;
  81084. /**
  81085. * Updates the effect with the current post process compile time values and recompiles the shader.
  81086. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81087. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81088. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81089. * @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
  81090. * @param onCompiled Called when the shader has been compiled.
  81091. * @param onError Called if there is an error when compiling a shader.
  81092. */
  81093. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81094. /**
  81095. * The post process is reusable if it can be used multiple times within one frame.
  81096. * @returns If the post process is reusable
  81097. */
  81098. isReusable(): boolean;
  81099. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81100. markTextureDirty(): void;
  81101. /**
  81102. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81103. * 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.
  81104. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81105. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81106. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81107. * @returns The target texture that was bound to be written to.
  81108. */
  81109. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81110. /**
  81111. * If the post process is supported.
  81112. */
  81113. readonly isSupported: boolean;
  81114. /**
  81115. * The aspect ratio of the output texture.
  81116. */
  81117. readonly aspectRatio: number;
  81118. /**
  81119. * Get a value indicating if the post-process is ready to be used
  81120. * @returns true if the post-process is ready (shader is compiled)
  81121. */
  81122. isReady(): boolean;
  81123. /**
  81124. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81125. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81126. */
  81127. apply(): Nullable<Effect>;
  81128. private _disposeTextures;
  81129. /**
  81130. * Disposes the post process.
  81131. * @param camera The camera to dispose the post process on.
  81132. */
  81133. dispose(camera?: Camera): void;
  81134. }
  81135. }
  81136. declare module BABYLON {
  81137. /** @hidden */
  81138. export var kernelBlurVaryingDeclaration: {
  81139. name: string;
  81140. shader: string;
  81141. };
  81142. }
  81143. declare module BABYLON {
  81144. /** @hidden */
  81145. export var kernelBlurFragment: {
  81146. name: string;
  81147. shader: string;
  81148. };
  81149. }
  81150. declare module BABYLON {
  81151. /** @hidden */
  81152. export var kernelBlurFragment2: {
  81153. name: string;
  81154. shader: string;
  81155. };
  81156. }
  81157. declare module BABYLON {
  81158. /** @hidden */
  81159. export var kernelBlurPixelShader: {
  81160. name: string;
  81161. shader: string;
  81162. };
  81163. }
  81164. declare module BABYLON {
  81165. /** @hidden */
  81166. export var kernelBlurVertex: {
  81167. name: string;
  81168. shader: string;
  81169. };
  81170. }
  81171. declare module BABYLON {
  81172. /** @hidden */
  81173. export var kernelBlurVertexShader: {
  81174. name: string;
  81175. shader: string;
  81176. };
  81177. }
  81178. declare module BABYLON {
  81179. /**
  81180. * The Blur Post Process which blurs an image based on a kernel and direction.
  81181. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81182. */
  81183. export class BlurPostProcess extends PostProcess {
  81184. /** The direction in which to blur the image. */
  81185. direction: Vector2;
  81186. private blockCompilation;
  81187. protected _kernel: number;
  81188. protected _idealKernel: number;
  81189. protected _packedFloat: boolean;
  81190. private _staticDefines;
  81191. /**
  81192. * Sets the length in pixels of the blur sample region
  81193. */
  81194. /**
  81195. * Gets the length in pixels of the blur sample region
  81196. */
  81197. kernel: number;
  81198. /**
  81199. * Sets wether or not the blur needs to unpack/repack floats
  81200. */
  81201. /**
  81202. * Gets wether or not the blur is unpacking/repacking floats
  81203. */
  81204. packedFloat: boolean;
  81205. /**
  81206. * Creates a new instance BlurPostProcess
  81207. * @param name The name of the effect.
  81208. * @param direction The direction in which to blur the image.
  81209. * @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.
  81210. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81211. * @param camera The camera to apply the render pass to.
  81212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81213. * @param engine The engine which the post process will be applied. (default: current engine)
  81214. * @param reusable If the post process can be reused on the same frame. (default: false)
  81215. * @param textureType Type of textures used when performing the post process. (default: 0)
  81216. * @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)
  81217. */
  81218. constructor(name: string,
  81219. /** The direction in which to blur the image. */
  81220. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81221. /**
  81222. * Updates the effect with the current post process compile time values and recompiles the shader.
  81223. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81224. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81225. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81226. * @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
  81227. * @param onCompiled Called when the shader has been compiled.
  81228. * @param onError Called if there is an error when compiling a shader.
  81229. */
  81230. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81231. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81232. /**
  81233. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81234. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81235. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81236. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81237. * The gaps between physical kernels are compensated for in the weighting of the samples
  81238. * @param idealKernel Ideal blur kernel.
  81239. * @return Nearest best kernel.
  81240. */
  81241. protected _nearestBestKernel(idealKernel: number): number;
  81242. /**
  81243. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81244. * @param x The point on the Gaussian distribution to sample.
  81245. * @return the value of the Gaussian function at x.
  81246. */
  81247. protected _gaussianWeight(x: number): number;
  81248. /**
  81249. * Generates a string that can be used as a floating point number in GLSL.
  81250. * @param x Value to print.
  81251. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81252. * @return GLSL float string.
  81253. */
  81254. protected _glslFloat(x: number, decimalFigures?: number): string;
  81255. }
  81256. }
  81257. declare module BABYLON {
  81258. /**
  81259. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81260. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81261. * You can then easily use it as a reflectionTexture on a flat surface.
  81262. * In case the surface is not a plane, please consider relying on reflection probes.
  81263. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81264. */
  81265. export class MirrorTexture extends RenderTargetTexture {
  81266. private scene;
  81267. /**
  81268. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81269. * 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.
  81270. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81271. */
  81272. mirrorPlane: Plane;
  81273. /**
  81274. * Define the blur ratio used to blur the reflection if needed.
  81275. */
  81276. blurRatio: number;
  81277. /**
  81278. * Define the adaptive blur kernel used to blur the reflection if needed.
  81279. * This will autocompute the closest best match for the `blurKernel`
  81280. */
  81281. adaptiveBlurKernel: number;
  81282. /**
  81283. * Define the blur kernel used to blur the reflection if needed.
  81284. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81285. */
  81286. blurKernel: number;
  81287. /**
  81288. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81289. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81290. */
  81291. blurKernelX: number;
  81292. /**
  81293. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81294. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81295. */
  81296. blurKernelY: number;
  81297. private _autoComputeBlurKernel;
  81298. protected _onRatioRescale(): void;
  81299. private _updateGammaSpace;
  81300. private _imageProcessingConfigChangeObserver;
  81301. private _transformMatrix;
  81302. private _mirrorMatrix;
  81303. private _savedViewMatrix;
  81304. private _blurX;
  81305. private _blurY;
  81306. private _adaptiveBlurKernel;
  81307. private _blurKernelX;
  81308. private _blurKernelY;
  81309. private _blurRatio;
  81310. /**
  81311. * Instantiates a Mirror Texture.
  81312. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81313. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81314. * You can then easily use it as a reflectionTexture on a flat surface.
  81315. * In case the surface is not a plane, please consider relying on reflection probes.
  81316. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81317. * @param name
  81318. * @param size
  81319. * @param scene
  81320. * @param generateMipMaps
  81321. * @param type
  81322. * @param samplingMode
  81323. * @param generateDepthBuffer
  81324. */
  81325. constructor(name: string, size: number | {
  81326. width: number;
  81327. height: number;
  81328. } | {
  81329. ratio: number;
  81330. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81331. private _preparePostProcesses;
  81332. /**
  81333. * Clone the mirror texture.
  81334. * @returns the cloned texture
  81335. */
  81336. clone(): MirrorTexture;
  81337. /**
  81338. * Serialize the texture to a JSON representation you could use in Parse later on
  81339. * @returns the serialized JSON representation
  81340. */
  81341. serialize(): any;
  81342. /**
  81343. * Dispose the texture and release its associated resources.
  81344. */
  81345. dispose(): void;
  81346. }
  81347. }
  81348. declare module BABYLON {
  81349. /**
  81350. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81351. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81352. */
  81353. export class Texture extends BaseTexture {
  81354. /**
  81355. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  81356. */
  81357. static SerializeBuffers: boolean;
  81358. /** @hidden */
  81359. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81360. /** @hidden */
  81361. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81362. /** @hidden */
  81363. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81364. /** nearest is mag = nearest and min = nearest and mip = linear */
  81365. static readonly NEAREST_SAMPLINGMODE: number;
  81366. /** nearest is mag = nearest and min = nearest and mip = linear */
  81367. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81368. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81369. static readonly BILINEAR_SAMPLINGMODE: number;
  81370. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81371. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81372. /** Trilinear is mag = linear and min = linear and mip = linear */
  81373. static readonly TRILINEAR_SAMPLINGMODE: number;
  81374. /** Trilinear is mag = linear and min = linear and mip = linear */
  81375. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81376. /** mag = nearest and min = nearest and mip = nearest */
  81377. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81378. /** mag = nearest and min = linear and mip = nearest */
  81379. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81380. /** mag = nearest and min = linear and mip = linear */
  81381. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81382. /** mag = nearest and min = linear and mip = none */
  81383. static readonly NEAREST_LINEAR: number;
  81384. /** mag = nearest and min = nearest and mip = none */
  81385. static readonly NEAREST_NEAREST: number;
  81386. /** mag = linear and min = nearest and mip = nearest */
  81387. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81388. /** mag = linear and min = nearest and mip = linear */
  81389. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81390. /** mag = linear and min = linear and mip = none */
  81391. static readonly LINEAR_LINEAR: number;
  81392. /** mag = linear and min = nearest and mip = none */
  81393. static readonly LINEAR_NEAREST: number;
  81394. /** Explicit coordinates mode */
  81395. static readonly EXPLICIT_MODE: number;
  81396. /** Spherical coordinates mode */
  81397. static readonly SPHERICAL_MODE: number;
  81398. /** Planar coordinates mode */
  81399. static readonly PLANAR_MODE: number;
  81400. /** Cubic coordinates mode */
  81401. static readonly CUBIC_MODE: number;
  81402. /** Projection coordinates mode */
  81403. static readonly PROJECTION_MODE: number;
  81404. /** Inverse Cubic coordinates mode */
  81405. static readonly SKYBOX_MODE: number;
  81406. /** Inverse Cubic coordinates mode */
  81407. static readonly INVCUBIC_MODE: number;
  81408. /** Equirectangular coordinates mode */
  81409. static readonly EQUIRECTANGULAR_MODE: number;
  81410. /** Equirectangular Fixed coordinates mode */
  81411. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81412. /** Equirectangular Fixed Mirrored coordinates mode */
  81413. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81414. /** Texture is not repeating outside of 0..1 UVs */
  81415. static readonly CLAMP_ADDRESSMODE: number;
  81416. /** Texture is repeating outside of 0..1 UVs */
  81417. static readonly WRAP_ADDRESSMODE: number;
  81418. /** Texture is repeating and mirrored */
  81419. static readonly MIRROR_ADDRESSMODE: number;
  81420. /**
  81421. * 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
  81422. */
  81423. static UseSerializedUrlIfAny: boolean;
  81424. /**
  81425. * Define the url of the texture.
  81426. */
  81427. url: Nullable<string>;
  81428. /**
  81429. * Define an offset on the texture to offset the u coordinates of the UVs
  81430. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81431. */
  81432. uOffset: number;
  81433. /**
  81434. * Define an offset on the texture to offset the v coordinates of the UVs
  81435. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81436. */
  81437. vOffset: number;
  81438. /**
  81439. * Define an offset on the texture to scale the u coordinates of the UVs
  81440. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81441. */
  81442. uScale: number;
  81443. /**
  81444. * Define an offset on the texture to scale the v coordinates of the UVs
  81445. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81446. */
  81447. vScale: number;
  81448. /**
  81449. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81450. * @see http://doc.babylonjs.com/how_to/more_materials
  81451. */
  81452. uAng: number;
  81453. /**
  81454. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81455. * @see http://doc.babylonjs.com/how_to/more_materials
  81456. */
  81457. vAng: number;
  81458. /**
  81459. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81460. * @see http://doc.babylonjs.com/how_to/more_materials
  81461. */
  81462. wAng: number;
  81463. /**
  81464. * Defines the center of rotation (U)
  81465. */
  81466. uRotationCenter: number;
  81467. /**
  81468. * Defines the center of rotation (V)
  81469. */
  81470. vRotationCenter: number;
  81471. /**
  81472. * Defines the center of rotation (W)
  81473. */
  81474. wRotationCenter: number;
  81475. /**
  81476. * Are mip maps generated for this texture or not.
  81477. */
  81478. readonly noMipmap: boolean;
  81479. /**
  81480. * List of inspectable custom properties (used by the Inspector)
  81481. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81482. */
  81483. inspectableCustomProperties: Nullable<IInspectable[]>;
  81484. private _noMipmap;
  81485. /** @hidden */
  81486. _invertY: boolean;
  81487. private _rowGenerationMatrix;
  81488. private _cachedTextureMatrix;
  81489. private _projectionModeMatrix;
  81490. private _t0;
  81491. private _t1;
  81492. private _t2;
  81493. private _cachedUOffset;
  81494. private _cachedVOffset;
  81495. private _cachedUScale;
  81496. private _cachedVScale;
  81497. private _cachedUAng;
  81498. private _cachedVAng;
  81499. private _cachedWAng;
  81500. private _cachedProjectionMatrixId;
  81501. private _cachedCoordinatesMode;
  81502. /** @hidden */
  81503. protected _initialSamplingMode: number;
  81504. /** @hidden */
  81505. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81506. private _deleteBuffer;
  81507. protected _format: Nullable<number>;
  81508. private _delayedOnLoad;
  81509. private _delayedOnError;
  81510. /**
  81511. * Observable triggered once the texture has been loaded.
  81512. */
  81513. onLoadObservable: Observable<Texture>;
  81514. protected _isBlocking: boolean;
  81515. /**
  81516. * Is the texture preventing material to render while loading.
  81517. * If false, a default texture will be used instead of the loading one during the preparation step.
  81518. */
  81519. isBlocking: boolean;
  81520. /**
  81521. * Get the current sampling mode associated with the texture.
  81522. */
  81523. readonly samplingMode: number;
  81524. /**
  81525. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81526. */
  81527. readonly invertY: boolean;
  81528. /**
  81529. * Instantiates a new texture.
  81530. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81531. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81532. * @param url define the url of the picture to load as a texture
  81533. * @param scene define the scene or engine the texture will belong to
  81534. * @param noMipmap define if the texture will require mip maps or not
  81535. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81536. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81537. * @param onLoad define a callback triggered when the texture has been loaded
  81538. * @param onError define a callback triggered when an error occurred during the loading session
  81539. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81540. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81541. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81542. */
  81543. 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);
  81544. /**
  81545. * Update the url (and optional buffer) of this texture if url was null during construction.
  81546. * @param url the url of the texture
  81547. * @param buffer the buffer of the texture (defaults to null)
  81548. * @param onLoad callback called when the texture is loaded (defaults to null)
  81549. */
  81550. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81551. /**
  81552. * Finish the loading sequence of a texture flagged as delayed load.
  81553. * @hidden
  81554. */
  81555. delayLoad(): void;
  81556. private _prepareRowForTextureGeneration;
  81557. /**
  81558. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81559. * @returns the transform matrix of the texture.
  81560. */
  81561. getTextureMatrix(): Matrix;
  81562. /**
  81563. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81564. * @returns The reflection texture transform
  81565. */
  81566. getReflectionTextureMatrix(): Matrix;
  81567. /**
  81568. * Clones the texture.
  81569. * @returns the cloned texture
  81570. */
  81571. clone(): Texture;
  81572. /**
  81573. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81574. * @returns The JSON representation of the texture
  81575. */
  81576. serialize(): any;
  81577. /**
  81578. * Get the current class name of the texture useful for serialization or dynamic coding.
  81579. * @returns "Texture"
  81580. */
  81581. getClassName(): string;
  81582. /**
  81583. * Dispose the texture and release its associated resources.
  81584. */
  81585. dispose(): void;
  81586. /**
  81587. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81588. * @param parsedTexture Define the JSON representation of the texture
  81589. * @param scene Define the scene the parsed texture should be instantiated in
  81590. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81591. * @returns The parsed texture if successful
  81592. */
  81593. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81594. /**
  81595. * Creates a texture from its base 64 representation.
  81596. * @param data Define the base64 payload without the data: prefix
  81597. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81598. * @param scene Define the scene the texture should belong to
  81599. * @param noMipmap Forces the texture to not create mip map information if true
  81600. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81601. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81602. * @param onLoad define a callback triggered when the texture has been loaded
  81603. * @param onError define a callback triggered when an error occurred during the loading session
  81604. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81605. * @returns the created texture
  81606. */
  81607. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81608. /**
  81609. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81610. * @param data Define the base64 payload without the data: prefix
  81611. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81612. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81613. * @param scene Define the scene the texture should belong to
  81614. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81615. * @param noMipmap Forces the texture to not create mip map information if true
  81616. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81617. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81618. * @param onLoad define a callback triggered when the texture has been loaded
  81619. * @param onError define a callback triggered when an error occurred during the loading session
  81620. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81621. * @returns the created texture
  81622. */
  81623. 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;
  81624. }
  81625. }
  81626. declare module BABYLON {
  81627. /**
  81628. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81629. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81630. */
  81631. export class PostProcessManager {
  81632. private _scene;
  81633. private _indexBuffer;
  81634. private _vertexBuffers;
  81635. /**
  81636. * Creates a new instance PostProcess
  81637. * @param scene The scene that the post process is associated with.
  81638. */
  81639. constructor(scene: Scene);
  81640. private _prepareBuffers;
  81641. private _buildIndexBuffer;
  81642. /**
  81643. * Rebuilds the vertex buffers of the manager.
  81644. * @hidden
  81645. */
  81646. _rebuild(): void;
  81647. /**
  81648. * Prepares a frame to be run through a post process.
  81649. * @param sourceTexture The input texture to the post procesess. (default: null)
  81650. * @param postProcesses An array of post processes to be run. (default: null)
  81651. * @returns True if the post processes were able to be run.
  81652. * @hidden
  81653. */
  81654. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81655. /**
  81656. * Manually render a set of post processes to a texture.
  81657. * @param postProcesses An array of post processes to be run.
  81658. * @param targetTexture The target texture to render to.
  81659. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81660. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81661. * @param lodLevel defines which lod of the texture to render to
  81662. */
  81663. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81664. /**
  81665. * Finalize the result of the output of the postprocesses.
  81666. * @param doNotPresent If true the result will not be displayed to the screen.
  81667. * @param targetTexture The target texture to render to.
  81668. * @param faceIndex The index of the face to bind the target texture to.
  81669. * @param postProcesses The array of post processes to render.
  81670. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81671. * @hidden
  81672. */
  81673. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81674. /**
  81675. * Disposes of the post process manager.
  81676. */
  81677. dispose(): void;
  81678. }
  81679. }
  81680. declare module BABYLON {
  81681. /** Interface used by value gradients (color, factor, ...) */
  81682. export interface IValueGradient {
  81683. /**
  81684. * Gets or sets the gradient value (between 0 and 1)
  81685. */
  81686. gradient: number;
  81687. }
  81688. /** Class used to store color4 gradient */
  81689. export class ColorGradient implements IValueGradient {
  81690. /**
  81691. * Gets or sets the gradient value (between 0 and 1)
  81692. */
  81693. gradient: number;
  81694. /**
  81695. * Gets or sets first associated color
  81696. */
  81697. color1: Color4;
  81698. /**
  81699. * Gets or sets second associated color
  81700. */
  81701. color2?: Color4;
  81702. /**
  81703. * Will get a color picked randomly between color1 and color2.
  81704. * If color2 is undefined then color1 will be used
  81705. * @param result defines the target Color4 to store the result in
  81706. */
  81707. getColorToRef(result: Color4): void;
  81708. }
  81709. /** Class used to store color 3 gradient */
  81710. export class Color3Gradient implements IValueGradient {
  81711. /**
  81712. * Gets or sets the gradient value (between 0 and 1)
  81713. */
  81714. gradient: number;
  81715. /**
  81716. * Gets or sets the associated color
  81717. */
  81718. color: Color3;
  81719. }
  81720. /** Class used to store factor gradient */
  81721. export class FactorGradient implements IValueGradient {
  81722. /**
  81723. * Gets or sets the gradient value (between 0 and 1)
  81724. */
  81725. gradient: number;
  81726. /**
  81727. * Gets or sets first associated factor
  81728. */
  81729. factor1: number;
  81730. /**
  81731. * Gets or sets second associated factor
  81732. */
  81733. factor2?: number;
  81734. /**
  81735. * Will get a number picked randomly between factor1 and factor2.
  81736. * If factor2 is undefined then factor1 will be used
  81737. * @returns the picked number
  81738. */
  81739. getFactor(): number;
  81740. }
  81741. /**
  81742. * Helper used to simplify some generic gradient tasks
  81743. */
  81744. export class GradientHelper {
  81745. /**
  81746. * Gets the current gradient from an array of IValueGradient
  81747. * @param ratio defines the current ratio to get
  81748. * @param gradients defines the array of IValueGradient
  81749. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81750. */
  81751. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81752. }
  81753. }
  81754. declare module BABYLON {
  81755. /**
  81756. * A class extending Texture allowing drawing on a texture
  81757. * @see http://doc.babylonjs.com/how_to/dynamictexture
  81758. */
  81759. export class DynamicTexture extends Texture {
  81760. private _generateMipMaps;
  81761. private _canvas;
  81762. private _context;
  81763. private _engine;
  81764. /**
  81765. * Creates a DynamicTexture
  81766. * @param name defines the name of the texture
  81767. * @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
  81768. * @param scene defines the scene where you want the texture
  81769. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  81770. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81771. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  81772. */
  81773. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  81774. /**
  81775. * Get the current class name of the texture useful for serialization or dynamic coding.
  81776. * @returns "DynamicTexture"
  81777. */
  81778. getClassName(): string;
  81779. /**
  81780. * Gets the current state of canRescale
  81781. */
  81782. readonly canRescale: boolean;
  81783. private _recreate;
  81784. /**
  81785. * Scales the texture
  81786. * @param ratio the scale factor to apply to both width and height
  81787. */
  81788. scale(ratio: number): void;
  81789. /**
  81790. * Resizes the texture
  81791. * @param width the new width
  81792. * @param height the new height
  81793. */
  81794. scaleTo(width: number, height: number): void;
  81795. /**
  81796. * Gets the context of the canvas used by the texture
  81797. * @returns the canvas context of the dynamic texture
  81798. */
  81799. getContext(): CanvasRenderingContext2D;
  81800. /**
  81801. * Clears the texture
  81802. */
  81803. clear(): void;
  81804. /**
  81805. * Updates the texture
  81806. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81807. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  81808. */
  81809. update(invertY?: boolean, premulAlpha?: boolean): void;
  81810. /**
  81811. * Draws text onto the texture
  81812. * @param text defines the text to be drawn
  81813. * @param x defines the placement of the text from the left
  81814. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  81815. * @param font defines the font to be used with font-style, font-size, font-name
  81816. * @param color defines the color used for the text
  81817. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  81818. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81819. * @param update defines whether texture is immediately update (default is true)
  81820. */
  81821. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  81822. /**
  81823. * Clones the texture
  81824. * @returns the clone of the texture.
  81825. */
  81826. clone(): DynamicTexture;
  81827. /**
  81828. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  81829. * @returns a serialized dynamic texture object
  81830. */
  81831. serialize(): any;
  81832. /** @hidden */
  81833. _rebuild(): void;
  81834. }
  81835. }
  81836. declare module BABYLON {
  81837. interface AbstractScene {
  81838. /**
  81839. * The list of procedural textures added to the scene
  81840. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81841. */
  81842. proceduralTextures: Array<ProceduralTexture>;
  81843. }
  81844. /**
  81845. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81846. * in a given scene.
  81847. */
  81848. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81849. /**
  81850. * The component name helpfull to identify the component in the list of scene components.
  81851. */
  81852. readonly name: string;
  81853. /**
  81854. * The scene the component belongs to.
  81855. */
  81856. scene: Scene;
  81857. /**
  81858. * Creates a new instance of the component for the given scene
  81859. * @param scene Defines the scene to register the component in
  81860. */
  81861. constructor(scene: Scene);
  81862. /**
  81863. * Registers the component in a given scene
  81864. */
  81865. register(): void;
  81866. /**
  81867. * Rebuilds the elements related to this component in case of
  81868. * context lost for instance.
  81869. */
  81870. rebuild(): void;
  81871. /**
  81872. * Disposes the component and the associated ressources.
  81873. */
  81874. dispose(): void;
  81875. private _beforeClear;
  81876. }
  81877. }
  81878. declare module BABYLON {
  81879. interface Engine {
  81880. /**
  81881. * Creates a new render target cube texture
  81882. * @param size defines the size of the texture
  81883. * @param options defines the options used to create the texture
  81884. * @returns a new render target cube texture stored in an InternalTexture
  81885. */
  81886. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81887. }
  81888. }
  81889. declare module BABYLON {
  81890. /** @hidden */
  81891. export var proceduralVertexShader: {
  81892. name: string;
  81893. shader: string;
  81894. };
  81895. }
  81896. declare module BABYLON {
  81897. /**
  81898. * 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.
  81899. * This is the base class of any Procedural texture and contains most of the shareable code.
  81900. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81901. */
  81902. export class ProceduralTexture extends Texture {
  81903. isCube: boolean;
  81904. /**
  81905. * Define if the texture is enabled or not (disabled texture will not render)
  81906. */
  81907. isEnabled: boolean;
  81908. /**
  81909. * Define if the texture must be cleared before rendering (default is true)
  81910. */
  81911. autoClear: boolean;
  81912. /**
  81913. * Callback called when the texture is generated
  81914. */
  81915. onGenerated: () => void;
  81916. /**
  81917. * Event raised when the texture is generated
  81918. */
  81919. onGeneratedObservable: Observable<ProceduralTexture>;
  81920. /** @hidden */
  81921. _generateMipMaps: boolean;
  81922. /** @hidden **/
  81923. _effect: Effect;
  81924. /** @hidden */
  81925. _textures: {
  81926. [key: string]: Texture;
  81927. };
  81928. private _size;
  81929. private _currentRefreshId;
  81930. private _refreshRate;
  81931. private _vertexBuffers;
  81932. private _indexBuffer;
  81933. private _uniforms;
  81934. private _samplers;
  81935. private _fragment;
  81936. private _floats;
  81937. private _ints;
  81938. private _floatsArrays;
  81939. private _colors3;
  81940. private _colors4;
  81941. private _vectors2;
  81942. private _vectors3;
  81943. private _matrices;
  81944. private _fallbackTexture;
  81945. private _fallbackTextureUsed;
  81946. private _engine;
  81947. private _cachedDefines;
  81948. private _contentUpdateId;
  81949. private _contentData;
  81950. /**
  81951. * Instantiates a new procedural texture.
  81952. * 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.
  81953. * This is the base class of any Procedural texture and contains most of the shareable code.
  81954. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81955. * @param name Define the name of the texture
  81956. * @param size Define the size of the texture to create
  81957. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81958. * @param scene Define the scene the texture belongs to
  81959. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81960. * @param generateMipMaps Define if the texture should creates mip maps or not
  81961. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81962. */
  81963. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81964. /**
  81965. * The effect that is created when initializing the post process.
  81966. * @returns The created effect corresponding the the postprocess.
  81967. */
  81968. getEffect(): Effect;
  81969. /**
  81970. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81971. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81972. */
  81973. getContent(): Nullable<ArrayBufferView>;
  81974. private _createIndexBuffer;
  81975. /** @hidden */
  81976. _rebuild(): void;
  81977. /**
  81978. * Resets the texture in order to recreate its associated resources.
  81979. * This can be called in case of context loss
  81980. */
  81981. reset(): void;
  81982. protected _getDefines(): string;
  81983. /**
  81984. * Is the texture ready to be used ? (rendered at least once)
  81985. * @returns true if ready, otherwise, false.
  81986. */
  81987. isReady(): boolean;
  81988. /**
  81989. * Resets the refresh counter of the texture and start bak from scratch.
  81990. * Could be useful to regenerate the texture if it is setup to render only once.
  81991. */
  81992. resetRefreshCounter(): void;
  81993. /**
  81994. * Set the fragment shader to use in order to render the texture.
  81995. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81996. */
  81997. setFragment(fragment: any): void;
  81998. /**
  81999. * Define the refresh rate of the texture or the rendering frequency.
  82000. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  82001. */
  82002. refreshRate: number;
  82003. /** @hidden */
  82004. _shouldRender(): boolean;
  82005. /**
  82006. * Get the size the texture is rendering at.
  82007. * @returns the size (texture is always squared)
  82008. */
  82009. getRenderSize(): number;
  82010. /**
  82011. * Resize the texture to new value.
  82012. * @param size Define the new size the texture should have
  82013. * @param generateMipMaps Define whether the new texture should create mip maps
  82014. */
  82015. resize(size: number, generateMipMaps: boolean): void;
  82016. private _checkUniform;
  82017. /**
  82018. * Set a texture in the shader program used to render.
  82019. * @param name Define the name of the uniform samplers as defined in the shader
  82020. * @param texture Define the texture to bind to this sampler
  82021. * @return the texture itself allowing "fluent" like uniform updates
  82022. */
  82023. setTexture(name: string, texture: Texture): ProceduralTexture;
  82024. /**
  82025. * Set a float in the shader.
  82026. * @param name Define the name of the uniform as defined in the shader
  82027. * @param value Define the value to give to the uniform
  82028. * @return the texture itself allowing "fluent" like uniform updates
  82029. */
  82030. setFloat(name: string, value: number): ProceduralTexture;
  82031. /**
  82032. * Set a int in the shader.
  82033. * @param name Define the name of the uniform as defined in the shader
  82034. * @param value Define the value to give to the uniform
  82035. * @return the texture itself allowing "fluent" like uniform updates
  82036. */
  82037. setInt(name: string, value: number): ProceduralTexture;
  82038. /**
  82039. * Set an array of floats in the shader.
  82040. * @param name Define the name of the uniform as defined in the shader
  82041. * @param value Define the value to give to the uniform
  82042. * @return the texture itself allowing "fluent" like uniform updates
  82043. */
  82044. setFloats(name: string, value: number[]): ProceduralTexture;
  82045. /**
  82046. * Set a vec3 in the shader from a Color3.
  82047. * @param name Define the name of the uniform as defined in the shader
  82048. * @param value Define the value to give to the uniform
  82049. * @return the texture itself allowing "fluent" like uniform updates
  82050. */
  82051. setColor3(name: string, value: Color3): ProceduralTexture;
  82052. /**
  82053. * Set a vec4 in the shader from a Color4.
  82054. * @param name Define the name of the uniform as defined in the shader
  82055. * @param value Define the value to give to the uniform
  82056. * @return the texture itself allowing "fluent" like uniform updates
  82057. */
  82058. setColor4(name: string, value: Color4): ProceduralTexture;
  82059. /**
  82060. * Set a vec2 in the shader from a Vector2.
  82061. * @param name Define the name of the uniform as defined in the shader
  82062. * @param value Define the value to give to the uniform
  82063. * @return the texture itself allowing "fluent" like uniform updates
  82064. */
  82065. setVector2(name: string, value: Vector2): ProceduralTexture;
  82066. /**
  82067. * Set a vec3 in the shader from a Vector3.
  82068. * @param name Define the name of the uniform as defined in the shader
  82069. * @param value Define the value to give to the uniform
  82070. * @return the texture itself allowing "fluent" like uniform updates
  82071. */
  82072. setVector3(name: string, value: Vector3): ProceduralTexture;
  82073. /**
  82074. * Set a mat4 in the shader from a MAtrix.
  82075. * @param name Define the name of the uniform as defined in the shader
  82076. * @param value Define the value to give to the uniform
  82077. * @return the texture itself allowing "fluent" like uniform updates
  82078. */
  82079. setMatrix(name: string, value: Matrix): ProceduralTexture;
  82080. /**
  82081. * Render the texture to its associated render target.
  82082. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  82083. */
  82084. render(useCameraPostProcess?: boolean): void;
  82085. /**
  82086. * Clone the texture.
  82087. * @returns the cloned texture
  82088. */
  82089. clone(): ProceduralTexture;
  82090. /**
  82091. * Dispose the texture and release its asoociated resources.
  82092. */
  82093. dispose(): void;
  82094. }
  82095. }
  82096. declare module BABYLON {
  82097. /**
  82098. * This represents the base class for particle system in Babylon.
  82099. * 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.
  82100. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82101. * @example https://doc.babylonjs.com/babylon101/particles
  82102. */
  82103. export class BaseParticleSystem {
  82104. /**
  82105. * Source color is added to the destination color without alpha affecting the result
  82106. */
  82107. static BLENDMODE_ONEONE: number;
  82108. /**
  82109. * Blend current color and particle color using particle’s alpha
  82110. */
  82111. static BLENDMODE_STANDARD: number;
  82112. /**
  82113. * Add current color and particle color multiplied by particle’s alpha
  82114. */
  82115. static BLENDMODE_ADD: number;
  82116. /**
  82117. * Multiply current color with particle color
  82118. */
  82119. static BLENDMODE_MULTIPLY: number;
  82120. /**
  82121. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82122. */
  82123. static BLENDMODE_MULTIPLYADD: number;
  82124. /**
  82125. * List of animations used by the particle system.
  82126. */
  82127. animations: Animation[];
  82128. /**
  82129. * The id of the Particle system.
  82130. */
  82131. id: string;
  82132. /**
  82133. * The friendly name of the Particle system.
  82134. */
  82135. name: string;
  82136. /**
  82137. * The rendering group used by the Particle system to chose when to render.
  82138. */
  82139. renderingGroupId: number;
  82140. /**
  82141. * The emitter represents the Mesh or position we are attaching the particle system to.
  82142. */
  82143. emitter: Nullable<AbstractMesh | Vector3>;
  82144. /**
  82145. * The maximum number of particles to emit per frame
  82146. */
  82147. emitRate: number;
  82148. /**
  82149. * If you want to launch only a few particles at once, that can be done, as well.
  82150. */
  82151. manualEmitCount: number;
  82152. /**
  82153. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82154. */
  82155. updateSpeed: number;
  82156. /**
  82157. * The amount of time the particle system is running (depends of the overall update speed).
  82158. */
  82159. targetStopDuration: number;
  82160. /**
  82161. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82162. */
  82163. disposeOnStop: boolean;
  82164. /**
  82165. * Minimum power of emitting particles.
  82166. */
  82167. minEmitPower: number;
  82168. /**
  82169. * Maximum power of emitting particles.
  82170. */
  82171. maxEmitPower: number;
  82172. /**
  82173. * Minimum life time of emitting particles.
  82174. */
  82175. minLifeTime: number;
  82176. /**
  82177. * Maximum life time of emitting particles.
  82178. */
  82179. maxLifeTime: number;
  82180. /**
  82181. * Minimum Size of emitting particles.
  82182. */
  82183. minSize: number;
  82184. /**
  82185. * Maximum Size of emitting particles.
  82186. */
  82187. maxSize: number;
  82188. /**
  82189. * Minimum scale of emitting particles on X axis.
  82190. */
  82191. minScaleX: number;
  82192. /**
  82193. * Maximum scale of emitting particles on X axis.
  82194. */
  82195. maxScaleX: number;
  82196. /**
  82197. * Minimum scale of emitting particles on Y axis.
  82198. */
  82199. minScaleY: number;
  82200. /**
  82201. * Maximum scale of emitting particles on Y axis.
  82202. */
  82203. maxScaleY: number;
  82204. /**
  82205. * Gets or sets the minimal initial rotation in radians.
  82206. */
  82207. minInitialRotation: number;
  82208. /**
  82209. * Gets or sets the maximal initial rotation in radians.
  82210. */
  82211. maxInitialRotation: number;
  82212. /**
  82213. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82214. */
  82215. minAngularSpeed: number;
  82216. /**
  82217. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82218. */
  82219. maxAngularSpeed: number;
  82220. /**
  82221. * The texture used to render each particle. (this can be a spritesheet)
  82222. */
  82223. particleTexture: Nullable<Texture>;
  82224. /**
  82225. * The layer mask we are rendering the particles through.
  82226. */
  82227. layerMask: number;
  82228. /**
  82229. * This can help using your own shader to render the particle system.
  82230. * The according effect will be created
  82231. */
  82232. customShader: any;
  82233. /**
  82234. * By default particle system starts as soon as they are created. This prevents the
  82235. * automatic start to happen and let you decide when to start emitting particles.
  82236. */
  82237. preventAutoStart: boolean;
  82238. private _noiseTexture;
  82239. /**
  82240. * Gets or sets a texture used to add random noise to particle positions
  82241. */
  82242. noiseTexture: Nullable<ProceduralTexture>;
  82243. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82244. noiseStrength: Vector3;
  82245. /**
  82246. * Callback triggered when the particle animation is ending.
  82247. */
  82248. onAnimationEnd: Nullable<() => void>;
  82249. /**
  82250. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82251. */
  82252. blendMode: number;
  82253. /**
  82254. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82255. * to override the particles.
  82256. */
  82257. forceDepthWrite: boolean;
  82258. /** 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 */
  82259. preWarmCycles: number;
  82260. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82261. preWarmStepOffset: number;
  82262. /**
  82263. * 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)
  82264. */
  82265. spriteCellChangeSpeed: number;
  82266. /**
  82267. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82268. */
  82269. startSpriteCellID: number;
  82270. /**
  82271. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82272. */
  82273. endSpriteCellID: number;
  82274. /**
  82275. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82276. */
  82277. spriteCellWidth: number;
  82278. /**
  82279. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82280. */
  82281. spriteCellHeight: number;
  82282. /**
  82283. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82284. */
  82285. spriteRandomStartCell: boolean;
  82286. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82287. translationPivot: Vector2;
  82288. /** @hidden */
  82289. protected _isAnimationSheetEnabled: boolean;
  82290. /**
  82291. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82292. */
  82293. beginAnimationOnStart: boolean;
  82294. /**
  82295. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82296. */
  82297. beginAnimationFrom: number;
  82298. /**
  82299. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82300. */
  82301. beginAnimationTo: number;
  82302. /**
  82303. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82304. */
  82305. beginAnimationLoop: boolean;
  82306. /**
  82307. * Gets or sets a world offset applied to all particles
  82308. */
  82309. worldOffset: Vector3;
  82310. /**
  82311. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82312. */
  82313. isAnimationSheetEnabled: boolean;
  82314. /**
  82315. * Get hosting scene
  82316. * @returns the scene
  82317. */
  82318. getScene(): Scene;
  82319. /**
  82320. * You can use gravity if you want to give an orientation to your particles.
  82321. */
  82322. gravity: Vector3;
  82323. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82324. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82325. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82326. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82327. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82328. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82329. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82330. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82331. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82332. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82333. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82334. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82335. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82336. /**
  82337. * Defines the delay in milliseconds before starting the system (0 by default)
  82338. */
  82339. startDelay: number;
  82340. /**
  82341. * Gets the current list of drag gradients.
  82342. * You must use addDragGradient and removeDragGradient to udpate this list
  82343. * @returns the list of drag gradients
  82344. */
  82345. getDragGradients(): Nullable<Array<FactorGradient>>;
  82346. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82347. limitVelocityDamping: number;
  82348. /**
  82349. * Gets the current list of limit velocity gradients.
  82350. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82351. * @returns the list of limit velocity gradients
  82352. */
  82353. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82354. /**
  82355. * Gets the current list of color gradients.
  82356. * You must use addColorGradient and removeColorGradient to udpate this list
  82357. * @returns the list of color gradients
  82358. */
  82359. getColorGradients(): Nullable<Array<ColorGradient>>;
  82360. /**
  82361. * Gets the current list of size gradients.
  82362. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82363. * @returns the list of size gradients
  82364. */
  82365. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82366. /**
  82367. * Gets the current list of color remap gradients.
  82368. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82369. * @returns the list of color remap gradients
  82370. */
  82371. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82372. /**
  82373. * Gets the current list of alpha remap gradients.
  82374. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82375. * @returns the list of alpha remap gradients
  82376. */
  82377. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82378. /**
  82379. * Gets the current list of life time gradients.
  82380. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82381. * @returns the list of life time gradients
  82382. */
  82383. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82384. /**
  82385. * Gets the current list of angular speed gradients.
  82386. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82387. * @returns the list of angular speed gradients
  82388. */
  82389. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82390. /**
  82391. * Gets the current list of velocity gradients.
  82392. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82393. * @returns the list of velocity gradients
  82394. */
  82395. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82396. /**
  82397. * Gets the current list of start size gradients.
  82398. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82399. * @returns the list of start size gradients
  82400. */
  82401. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82402. /**
  82403. * Gets the current list of emit rate gradients.
  82404. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82405. * @returns the list of emit rate gradients
  82406. */
  82407. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82408. /**
  82409. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82410. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82411. */
  82412. direction1: Vector3;
  82413. /**
  82414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82415. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82416. */
  82417. direction2: Vector3;
  82418. /**
  82419. * 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.
  82420. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82421. */
  82422. minEmitBox: Vector3;
  82423. /**
  82424. * 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.
  82425. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82426. */
  82427. maxEmitBox: Vector3;
  82428. /**
  82429. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82430. */
  82431. color1: Color4;
  82432. /**
  82433. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82434. */
  82435. color2: Color4;
  82436. /**
  82437. * Color the particle will have at the end of its lifetime
  82438. */
  82439. colorDead: Color4;
  82440. /**
  82441. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82442. */
  82443. textureMask: Color4;
  82444. /**
  82445. * The particle emitter type defines the emitter used by the particle system.
  82446. * It can be for example box, sphere, or cone...
  82447. */
  82448. particleEmitterType: IParticleEmitterType;
  82449. /** @hidden */
  82450. _isSubEmitter: boolean;
  82451. /**
  82452. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82453. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82454. */
  82455. billboardMode: number;
  82456. protected _isBillboardBased: boolean;
  82457. /**
  82458. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82459. */
  82460. isBillboardBased: boolean;
  82461. /**
  82462. * The scene the particle system belongs to.
  82463. */
  82464. protected _scene: Scene;
  82465. /**
  82466. * Local cache of defines for image processing.
  82467. */
  82468. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82469. /**
  82470. * Default configuration related to image processing available in the standard Material.
  82471. */
  82472. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82473. /**
  82474. * Gets the image processing configuration used either in this material.
  82475. */
  82476. /**
  82477. * Sets the Default image processing configuration used either in the this material.
  82478. *
  82479. * If sets to null, the scene one is in use.
  82480. */
  82481. imageProcessingConfiguration: ImageProcessingConfiguration;
  82482. /**
  82483. * Attaches a new image processing configuration to the Standard Material.
  82484. * @param configuration
  82485. */
  82486. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82487. /** @hidden */
  82488. protected _reset(): void;
  82489. /** @hidden */
  82490. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82491. /**
  82492. * Instantiates a particle system.
  82493. * 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.
  82494. * @param name The name of the particle system
  82495. */
  82496. constructor(name: string);
  82497. /**
  82498. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82499. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82500. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82501. * @returns the emitter
  82502. */
  82503. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82504. /**
  82505. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82506. * @param radius The radius of the hemisphere to emit from
  82507. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82508. * @returns the emitter
  82509. */
  82510. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82511. /**
  82512. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82513. * @param radius The radius of the sphere to emit from
  82514. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82515. * @returns the emitter
  82516. */
  82517. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82518. /**
  82519. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82520. * @param radius The radius of the sphere to emit from
  82521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82523. * @returns the emitter
  82524. */
  82525. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82526. /**
  82527. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82528. * @param radius The radius of the emission cylinder
  82529. * @param height The height of the emission cylinder
  82530. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82531. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82532. * @returns the emitter
  82533. */
  82534. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82535. /**
  82536. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82537. * @param radius The radius of the cylinder to emit from
  82538. * @param height The height of the emission cylinder
  82539. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82540. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82541. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82542. * @returns the emitter
  82543. */
  82544. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82545. /**
  82546. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82547. * @param radius The radius of the cone to emit from
  82548. * @param angle The base angle of the cone
  82549. * @returns the emitter
  82550. */
  82551. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82552. /**
  82553. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82554. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82555. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82556. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82557. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82558. * @returns the emitter
  82559. */
  82560. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82561. }
  82562. }
  82563. declare module BABYLON {
  82564. /**
  82565. * Type of sub emitter
  82566. */
  82567. export enum SubEmitterType {
  82568. /**
  82569. * Attached to the particle over it's lifetime
  82570. */
  82571. ATTACHED = 0,
  82572. /**
  82573. * Created when the particle dies
  82574. */
  82575. END = 1
  82576. }
  82577. /**
  82578. * Sub emitter class used to emit particles from an existing particle
  82579. */
  82580. export class SubEmitter {
  82581. /**
  82582. * the particle system to be used by the sub emitter
  82583. */
  82584. particleSystem: ParticleSystem;
  82585. /**
  82586. * Type of the submitter (Default: END)
  82587. */
  82588. type: SubEmitterType;
  82589. /**
  82590. * 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)
  82591. * Note: This only is supported when using an emitter of type Mesh
  82592. */
  82593. inheritDirection: boolean;
  82594. /**
  82595. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82596. */
  82597. inheritedVelocityAmount: number;
  82598. /**
  82599. * Creates a sub emitter
  82600. * @param particleSystem the particle system to be used by the sub emitter
  82601. */
  82602. constructor(
  82603. /**
  82604. * the particle system to be used by the sub emitter
  82605. */
  82606. particleSystem: ParticleSystem);
  82607. /**
  82608. * Clones the sub emitter
  82609. * @returns the cloned sub emitter
  82610. */
  82611. clone(): SubEmitter;
  82612. /**
  82613. * Serialize current object to a JSON object
  82614. * @returns the serialized object
  82615. */
  82616. serialize(): any;
  82617. /** @hidden */
  82618. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82619. /**
  82620. * Creates a new SubEmitter from a serialized JSON version
  82621. * @param serializationObject defines the JSON object to read from
  82622. * @param scene defines the hosting scene
  82623. * @param rootUrl defines the rootUrl for data loading
  82624. * @returns a new SubEmitter
  82625. */
  82626. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82627. /** Release associated resources */
  82628. dispose(): void;
  82629. }
  82630. }
  82631. declare module BABYLON {
  82632. /** @hidden */
  82633. export var clipPlaneFragmentDeclaration: {
  82634. name: string;
  82635. shader: string;
  82636. };
  82637. }
  82638. declare module BABYLON {
  82639. /** @hidden */
  82640. export var imageProcessingDeclaration: {
  82641. name: string;
  82642. shader: string;
  82643. };
  82644. }
  82645. declare module BABYLON {
  82646. /** @hidden */
  82647. export var imageProcessingFunctions: {
  82648. name: string;
  82649. shader: string;
  82650. };
  82651. }
  82652. declare module BABYLON {
  82653. /** @hidden */
  82654. export var clipPlaneFragment: {
  82655. name: string;
  82656. shader: string;
  82657. };
  82658. }
  82659. declare module BABYLON {
  82660. /** @hidden */
  82661. export var particlesPixelShader: {
  82662. name: string;
  82663. shader: string;
  82664. };
  82665. }
  82666. declare module BABYLON {
  82667. /** @hidden */
  82668. export var clipPlaneVertexDeclaration: {
  82669. name: string;
  82670. shader: string;
  82671. };
  82672. }
  82673. declare module BABYLON {
  82674. /** @hidden */
  82675. export var clipPlaneVertex: {
  82676. name: string;
  82677. shader: string;
  82678. };
  82679. }
  82680. declare module BABYLON {
  82681. /** @hidden */
  82682. export var particlesVertexShader: {
  82683. name: string;
  82684. shader: string;
  82685. };
  82686. }
  82687. declare module BABYLON {
  82688. /**
  82689. * This represents a particle system in Babylon.
  82690. * 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.
  82691. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82692. * @example https://doc.babylonjs.com/babylon101/particles
  82693. */
  82694. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82695. /**
  82696. * Billboard mode will only apply to Y axis
  82697. */
  82698. static readonly BILLBOARDMODE_Y: number;
  82699. /**
  82700. * Billboard mode will apply to all axes
  82701. */
  82702. static readonly BILLBOARDMODE_ALL: number;
  82703. /**
  82704. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82705. */
  82706. static readonly BILLBOARDMODE_STRETCHED: number;
  82707. /**
  82708. * This function can be defined to provide custom update for active particles.
  82709. * This function will be called instead of regular update (age, position, color, etc.).
  82710. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82711. */
  82712. updateFunction: (particles: Particle[]) => void;
  82713. private _emitterWorldMatrix;
  82714. /**
  82715. * This function can be defined to specify initial direction for every new particle.
  82716. * It by default use the emitterType defined function
  82717. */
  82718. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82719. /**
  82720. * This function can be defined to specify initial position for every new particle.
  82721. * It by default use the emitterType defined function
  82722. */
  82723. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82724. /**
  82725. * @hidden
  82726. */
  82727. _inheritedVelocityOffset: Vector3;
  82728. /**
  82729. * An event triggered when the system is disposed
  82730. */
  82731. onDisposeObservable: Observable<ParticleSystem>;
  82732. private _onDisposeObserver;
  82733. /**
  82734. * Sets a callback that will be triggered when the system is disposed
  82735. */
  82736. onDispose: () => void;
  82737. private _particles;
  82738. private _epsilon;
  82739. private _capacity;
  82740. private _stockParticles;
  82741. private _newPartsExcess;
  82742. private _vertexData;
  82743. private _vertexBuffer;
  82744. private _vertexBuffers;
  82745. private _spriteBuffer;
  82746. private _indexBuffer;
  82747. private _effect;
  82748. private _customEffect;
  82749. private _cachedDefines;
  82750. private _scaledColorStep;
  82751. private _colorDiff;
  82752. private _scaledDirection;
  82753. private _scaledGravity;
  82754. private _currentRenderId;
  82755. private _alive;
  82756. private _useInstancing;
  82757. private _started;
  82758. private _stopped;
  82759. private _actualFrame;
  82760. private _scaledUpdateSpeed;
  82761. private _vertexBufferSize;
  82762. /** @hidden */
  82763. _currentEmitRateGradient: Nullable<FactorGradient>;
  82764. /** @hidden */
  82765. _currentEmitRate1: number;
  82766. /** @hidden */
  82767. _currentEmitRate2: number;
  82768. /** @hidden */
  82769. _currentStartSizeGradient: Nullable<FactorGradient>;
  82770. /** @hidden */
  82771. _currentStartSize1: number;
  82772. /** @hidden */
  82773. _currentStartSize2: number;
  82774. private readonly _rawTextureWidth;
  82775. private _rampGradientsTexture;
  82776. private _useRampGradients;
  82777. /** Gets or sets a boolean indicating that ramp gradients must be used
  82778. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82779. */
  82780. useRampGradients: boolean;
  82781. /**
  82782. * 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.
  82783. * 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: [])
  82784. */
  82785. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82786. private _subEmitters;
  82787. /**
  82788. * @hidden
  82789. * If the particle systems emitter should be disposed when the particle system is disposed
  82790. */
  82791. _disposeEmitterOnDispose: boolean;
  82792. /**
  82793. * The current active Sub-systems, this property is used by the root particle system only.
  82794. */
  82795. activeSubSystems: Array<ParticleSystem>;
  82796. private _rootParticleSystem;
  82797. /**
  82798. * Gets the current list of active particles
  82799. */
  82800. readonly particles: Particle[];
  82801. /**
  82802. * Returns the string "ParticleSystem"
  82803. * @returns a string containing the class name
  82804. */
  82805. getClassName(): string;
  82806. /**
  82807. * Instantiates a particle system.
  82808. * 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.
  82809. * @param name The name of the particle system
  82810. * @param capacity The max number of particles alive at the same time
  82811. * @param scene The scene the particle system belongs to
  82812. * @param customEffect a custom effect used to change the way particles are rendered by default
  82813. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82814. * @param epsilon Offset used to render the particles
  82815. */
  82816. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82817. private _addFactorGradient;
  82818. private _removeFactorGradient;
  82819. /**
  82820. * Adds a new life time gradient
  82821. * @param gradient defines the gradient to use (between 0 and 1)
  82822. * @param factor defines the life time factor to affect to the specified gradient
  82823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82824. * @returns the current particle system
  82825. */
  82826. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82827. /**
  82828. * Remove a specific life time gradient
  82829. * @param gradient defines the gradient to remove
  82830. * @returns the current particle system
  82831. */
  82832. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82833. /**
  82834. * Adds a new size gradient
  82835. * @param gradient defines the gradient to use (between 0 and 1)
  82836. * @param factor defines the size factor to affect to the specified gradient
  82837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82838. * @returns the current particle system
  82839. */
  82840. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82841. /**
  82842. * Remove a specific size gradient
  82843. * @param gradient defines the gradient to remove
  82844. * @returns the current particle system
  82845. */
  82846. removeSizeGradient(gradient: number): IParticleSystem;
  82847. /**
  82848. * Adds a new color remap gradient
  82849. * @param gradient defines the gradient to use (between 0 and 1)
  82850. * @param min defines the color remap minimal range
  82851. * @param max defines the color remap maximal range
  82852. * @returns the current particle system
  82853. */
  82854. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82855. /**
  82856. * Remove a specific color remap gradient
  82857. * @param gradient defines the gradient to remove
  82858. * @returns the current particle system
  82859. */
  82860. removeColorRemapGradient(gradient: number): IParticleSystem;
  82861. /**
  82862. * Adds a new alpha remap gradient
  82863. * @param gradient defines the gradient to use (between 0 and 1)
  82864. * @param min defines the alpha remap minimal range
  82865. * @param max defines the alpha remap maximal range
  82866. * @returns the current particle system
  82867. */
  82868. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82869. /**
  82870. * Remove a specific alpha remap gradient
  82871. * @param gradient defines the gradient to remove
  82872. * @returns the current particle system
  82873. */
  82874. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82875. /**
  82876. * Adds a new angular speed gradient
  82877. * @param gradient defines the gradient to use (between 0 and 1)
  82878. * @param factor defines the angular speed to affect to the specified gradient
  82879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82880. * @returns the current particle system
  82881. */
  82882. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82883. /**
  82884. * Remove a specific angular speed gradient
  82885. * @param gradient defines the gradient to remove
  82886. * @returns the current particle system
  82887. */
  82888. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82889. /**
  82890. * Adds a new velocity gradient
  82891. * @param gradient defines the gradient to use (between 0 and 1)
  82892. * @param factor defines the velocity to affect to the specified gradient
  82893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82894. * @returns the current particle system
  82895. */
  82896. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82897. /**
  82898. * Remove a specific velocity gradient
  82899. * @param gradient defines the gradient to remove
  82900. * @returns the current particle system
  82901. */
  82902. removeVelocityGradient(gradient: number): IParticleSystem;
  82903. /**
  82904. * Adds a new limit velocity gradient
  82905. * @param gradient defines the gradient to use (between 0 and 1)
  82906. * @param factor defines the limit velocity value to affect to the specified gradient
  82907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82908. * @returns the current particle system
  82909. */
  82910. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82911. /**
  82912. * Remove a specific limit velocity gradient
  82913. * @param gradient defines the gradient to remove
  82914. * @returns the current particle system
  82915. */
  82916. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82917. /**
  82918. * Adds a new drag gradient
  82919. * @param gradient defines the gradient to use (between 0 and 1)
  82920. * @param factor defines the drag value to affect to the specified gradient
  82921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82922. * @returns the current particle system
  82923. */
  82924. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82925. /**
  82926. * Remove a specific drag gradient
  82927. * @param gradient defines the gradient to remove
  82928. * @returns the current particle system
  82929. */
  82930. removeDragGradient(gradient: number): IParticleSystem;
  82931. /**
  82932. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82933. * @param gradient defines the gradient to use (between 0 and 1)
  82934. * @param factor defines the emit rate value to affect to the specified gradient
  82935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82936. * @returns the current particle system
  82937. */
  82938. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82939. /**
  82940. * Remove a specific emit rate gradient
  82941. * @param gradient defines the gradient to remove
  82942. * @returns the current particle system
  82943. */
  82944. removeEmitRateGradient(gradient: number): IParticleSystem;
  82945. /**
  82946. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82947. * @param gradient defines the gradient to use (between 0 and 1)
  82948. * @param factor defines the start size value to affect to the specified gradient
  82949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82950. * @returns the current particle system
  82951. */
  82952. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82953. /**
  82954. * Remove a specific start size gradient
  82955. * @param gradient defines the gradient to remove
  82956. * @returns the current particle system
  82957. */
  82958. removeStartSizeGradient(gradient: number): IParticleSystem;
  82959. private _createRampGradientTexture;
  82960. /**
  82961. * Gets the current list of ramp gradients.
  82962. * You must use addRampGradient and removeRampGradient to udpate this list
  82963. * @returns the list of ramp gradients
  82964. */
  82965. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82966. /**
  82967. * Adds a new ramp gradient used to remap particle colors
  82968. * @param gradient defines the gradient to use (between 0 and 1)
  82969. * @param color defines the color to affect to the specified gradient
  82970. * @returns the current particle system
  82971. */
  82972. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82973. /**
  82974. * Remove a specific ramp gradient
  82975. * @param gradient defines the gradient to remove
  82976. * @returns the current particle system
  82977. */
  82978. removeRampGradient(gradient: number): ParticleSystem;
  82979. /**
  82980. * Adds a new color gradient
  82981. * @param gradient defines the gradient to use (between 0 and 1)
  82982. * @param color1 defines the color to affect to the specified gradient
  82983. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82984. * @returns this particle system
  82985. */
  82986. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82987. /**
  82988. * Remove a specific color gradient
  82989. * @param gradient defines the gradient to remove
  82990. * @returns this particle system
  82991. */
  82992. removeColorGradient(gradient: number): IParticleSystem;
  82993. private _fetchR;
  82994. protected _reset(): void;
  82995. private _resetEffect;
  82996. private _createVertexBuffers;
  82997. private _createIndexBuffer;
  82998. /**
  82999. * Gets the maximum number of particles active at the same time.
  83000. * @returns The max number of active particles.
  83001. */
  83002. getCapacity(): number;
  83003. /**
  83004. * Gets whether there are still active particles in the system.
  83005. * @returns True if it is alive, otherwise false.
  83006. */
  83007. isAlive(): boolean;
  83008. /**
  83009. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83010. * @returns True if it has been started, otherwise false.
  83011. */
  83012. isStarted(): boolean;
  83013. private _prepareSubEmitterInternalArray;
  83014. /**
  83015. * Starts the particle system and begins to emit
  83016. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  83017. */
  83018. start(delay?: number): void;
  83019. /**
  83020. * Stops the particle system.
  83021. * @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.
  83022. */
  83023. stop(stopSubEmitters?: boolean): void;
  83024. /**
  83025. * Remove all active particles
  83026. */
  83027. reset(): void;
  83028. /**
  83029. * @hidden (for internal use only)
  83030. */
  83031. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  83032. /**
  83033. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  83034. * Its lifetime will start back at 0.
  83035. */
  83036. recycleParticle: (particle: Particle) => void;
  83037. private _stopSubEmitters;
  83038. private _createParticle;
  83039. private _removeFromRoot;
  83040. private _emitFromParticle;
  83041. private _update;
  83042. /** @hidden */
  83043. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  83044. /** @hidden */
  83045. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  83046. /** @hidden */
  83047. private _getEffect;
  83048. /**
  83049. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  83050. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  83051. */
  83052. animate(preWarmOnly?: boolean): void;
  83053. private _appendParticleVertices;
  83054. /**
  83055. * Rebuilds the particle system.
  83056. */
  83057. rebuild(): void;
  83058. /**
  83059. * Is this system ready to be used/rendered
  83060. * @return true if the system is ready
  83061. */
  83062. isReady(): boolean;
  83063. private _render;
  83064. /**
  83065. * Renders the particle system in its current state.
  83066. * @returns the current number of particles
  83067. */
  83068. render(): number;
  83069. /**
  83070. * Disposes the particle system and free the associated resources
  83071. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83072. */
  83073. dispose(disposeTexture?: boolean): void;
  83074. /**
  83075. * Clones the particle system.
  83076. * @param name The name of the cloned object
  83077. * @param newEmitter The new emitter to use
  83078. * @returns the cloned particle system
  83079. */
  83080. clone(name: string, newEmitter: any): ParticleSystem;
  83081. /**
  83082. * Serializes the particle system to a JSON object.
  83083. * @returns the JSON object
  83084. */
  83085. serialize(): any;
  83086. /** @hidden */
  83087. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  83088. /** @hidden */
  83089. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  83090. /**
  83091. * Parses a JSON object to create a particle system.
  83092. * @param parsedParticleSystem The JSON object to parse
  83093. * @param scene The scene to create the particle system in
  83094. * @param rootUrl The root url to use to load external dependencies like texture
  83095. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  83096. * @returns the Parsed particle system
  83097. */
  83098. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  83099. }
  83100. }
  83101. declare module BABYLON {
  83102. /**
  83103. * A particle represents one of the element emitted by a particle system.
  83104. * This is mainly define by its coordinates, direction, velocity and age.
  83105. */
  83106. export class Particle {
  83107. /**
  83108. * The particle system the particle belongs to.
  83109. */
  83110. particleSystem: ParticleSystem;
  83111. private static _Count;
  83112. /**
  83113. * Unique ID of the particle
  83114. */
  83115. id: number;
  83116. /**
  83117. * The world position of the particle in the scene.
  83118. */
  83119. position: Vector3;
  83120. /**
  83121. * The world direction of the particle in the scene.
  83122. */
  83123. direction: Vector3;
  83124. /**
  83125. * The color of the particle.
  83126. */
  83127. color: Color4;
  83128. /**
  83129. * The color change of the particle per step.
  83130. */
  83131. colorStep: Color4;
  83132. /**
  83133. * Defines how long will the life of the particle be.
  83134. */
  83135. lifeTime: number;
  83136. /**
  83137. * The current age of the particle.
  83138. */
  83139. age: number;
  83140. /**
  83141. * The current size of the particle.
  83142. */
  83143. size: number;
  83144. /**
  83145. * The current scale of the particle.
  83146. */
  83147. scale: Vector2;
  83148. /**
  83149. * The current angle of the particle.
  83150. */
  83151. angle: number;
  83152. /**
  83153. * Defines how fast is the angle changing.
  83154. */
  83155. angularSpeed: number;
  83156. /**
  83157. * Defines the cell index used by the particle to be rendered from a sprite.
  83158. */
  83159. cellIndex: number;
  83160. /**
  83161. * The information required to support color remapping
  83162. */
  83163. remapData: Vector4;
  83164. /** @hidden */
  83165. _randomCellOffset?: number;
  83166. /** @hidden */
  83167. _initialDirection: Nullable<Vector3>;
  83168. /** @hidden */
  83169. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83170. /** @hidden */
  83171. _initialStartSpriteCellID: number;
  83172. /** @hidden */
  83173. _initialEndSpriteCellID: number;
  83174. /** @hidden */
  83175. _currentColorGradient: Nullable<ColorGradient>;
  83176. /** @hidden */
  83177. _currentColor1: Color4;
  83178. /** @hidden */
  83179. _currentColor2: Color4;
  83180. /** @hidden */
  83181. _currentSizeGradient: Nullable<FactorGradient>;
  83182. /** @hidden */
  83183. _currentSize1: number;
  83184. /** @hidden */
  83185. _currentSize2: number;
  83186. /** @hidden */
  83187. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83188. /** @hidden */
  83189. _currentAngularSpeed1: number;
  83190. /** @hidden */
  83191. _currentAngularSpeed2: number;
  83192. /** @hidden */
  83193. _currentVelocityGradient: Nullable<FactorGradient>;
  83194. /** @hidden */
  83195. _currentVelocity1: number;
  83196. /** @hidden */
  83197. _currentVelocity2: number;
  83198. /** @hidden */
  83199. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83200. /** @hidden */
  83201. _currentLimitVelocity1: number;
  83202. /** @hidden */
  83203. _currentLimitVelocity2: number;
  83204. /** @hidden */
  83205. _currentDragGradient: Nullable<FactorGradient>;
  83206. /** @hidden */
  83207. _currentDrag1: number;
  83208. /** @hidden */
  83209. _currentDrag2: number;
  83210. /** @hidden */
  83211. _randomNoiseCoordinates1: Vector3;
  83212. /** @hidden */
  83213. _randomNoiseCoordinates2: Vector3;
  83214. /**
  83215. * Creates a new instance Particle
  83216. * @param particleSystem the particle system the particle belongs to
  83217. */
  83218. constructor(
  83219. /**
  83220. * The particle system the particle belongs to.
  83221. */
  83222. particleSystem: ParticleSystem);
  83223. private updateCellInfoFromSystem;
  83224. /**
  83225. * Defines how the sprite cell index is updated for the particle
  83226. */
  83227. updateCellIndex(): void;
  83228. /** @hidden */
  83229. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83230. /** @hidden */
  83231. _inheritParticleInfoToSubEmitters(): void;
  83232. /** @hidden */
  83233. _reset(): void;
  83234. /**
  83235. * Copy the properties of particle to another one.
  83236. * @param other the particle to copy the information to.
  83237. */
  83238. copyTo(other: Particle): void;
  83239. }
  83240. }
  83241. declare module BABYLON {
  83242. /**
  83243. * Particle emitter represents a volume emitting particles.
  83244. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83245. */
  83246. export interface IParticleEmitterType {
  83247. /**
  83248. * Called by the particle System when the direction is computed for the created particle.
  83249. * @param worldMatrix is the world matrix of the particle system
  83250. * @param directionToUpdate is the direction vector to update with the result
  83251. * @param particle is the particle we are computed the direction for
  83252. */
  83253. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83254. /**
  83255. * Called by the particle System when the position is computed for the created particle.
  83256. * @param worldMatrix is the world matrix of the particle system
  83257. * @param positionToUpdate is the position vector to update with the result
  83258. * @param particle is the particle we are computed the position for
  83259. */
  83260. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83261. /**
  83262. * Clones the current emitter and returns a copy of it
  83263. * @returns the new emitter
  83264. */
  83265. clone(): IParticleEmitterType;
  83266. /**
  83267. * Called by the GPUParticleSystem to setup the update shader
  83268. * @param effect defines the update shader
  83269. */
  83270. applyToShader(effect: Effect): void;
  83271. /**
  83272. * Returns a string to use to update the GPU particles update shader
  83273. * @returns the effect defines string
  83274. */
  83275. getEffectDefines(): string;
  83276. /**
  83277. * Returns a string representing the class name
  83278. * @returns a string containing the class name
  83279. */
  83280. getClassName(): string;
  83281. /**
  83282. * Serializes the particle system to a JSON object.
  83283. * @returns the JSON object
  83284. */
  83285. serialize(): any;
  83286. /**
  83287. * Parse properties from a JSON object
  83288. * @param serializationObject defines the JSON object
  83289. */
  83290. parse(serializationObject: any): void;
  83291. }
  83292. }
  83293. declare module BABYLON {
  83294. /**
  83295. * Particle emitter emitting particles from the inside of a box.
  83296. * It emits the particles randomly between 2 given directions.
  83297. */
  83298. export class BoxParticleEmitter implements IParticleEmitterType {
  83299. /**
  83300. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83301. */
  83302. direction1: Vector3;
  83303. /**
  83304. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83305. */
  83306. direction2: Vector3;
  83307. /**
  83308. * 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.
  83309. */
  83310. minEmitBox: Vector3;
  83311. /**
  83312. * 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.
  83313. */
  83314. maxEmitBox: Vector3;
  83315. /**
  83316. * Creates a new instance BoxParticleEmitter
  83317. */
  83318. constructor();
  83319. /**
  83320. * Called by the particle System when the direction is computed for the created particle.
  83321. * @param worldMatrix is the world matrix of the particle system
  83322. * @param directionToUpdate is the direction vector to update with the result
  83323. * @param particle is the particle we are computed the direction for
  83324. */
  83325. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83326. /**
  83327. * Called by the particle System when the position is computed for the created particle.
  83328. * @param worldMatrix is the world matrix of the particle system
  83329. * @param positionToUpdate is the position vector to update with the result
  83330. * @param particle is the particle we are computed the position for
  83331. */
  83332. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83333. /**
  83334. * Clones the current emitter and returns a copy of it
  83335. * @returns the new emitter
  83336. */
  83337. clone(): BoxParticleEmitter;
  83338. /**
  83339. * Called by the GPUParticleSystem to setup the update shader
  83340. * @param effect defines the update shader
  83341. */
  83342. applyToShader(effect: Effect): void;
  83343. /**
  83344. * Returns a string to use to update the GPU particles update shader
  83345. * @returns a string containng the defines string
  83346. */
  83347. getEffectDefines(): string;
  83348. /**
  83349. * Returns the string "BoxParticleEmitter"
  83350. * @returns a string containing the class name
  83351. */
  83352. getClassName(): string;
  83353. /**
  83354. * Serializes the particle system to a JSON object.
  83355. * @returns the JSON object
  83356. */
  83357. serialize(): any;
  83358. /**
  83359. * Parse properties from a JSON object
  83360. * @param serializationObject defines the JSON object
  83361. */
  83362. parse(serializationObject: any): void;
  83363. }
  83364. }
  83365. declare module BABYLON {
  83366. /**
  83367. * Particle emitter emitting particles from the inside of a cone.
  83368. * It emits the particles alongside the cone volume from the base to the particle.
  83369. * The emission direction might be randomized.
  83370. */
  83371. export class ConeParticleEmitter implements IParticleEmitterType {
  83372. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83373. directionRandomizer: number;
  83374. private _radius;
  83375. private _angle;
  83376. private _height;
  83377. /**
  83378. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83379. */
  83380. radiusRange: number;
  83381. /**
  83382. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83383. */
  83384. heightRange: number;
  83385. /**
  83386. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83387. */
  83388. emitFromSpawnPointOnly: boolean;
  83389. /**
  83390. * Gets or sets the radius of the emission cone
  83391. */
  83392. radius: number;
  83393. /**
  83394. * Gets or sets the angle of the emission cone
  83395. */
  83396. angle: number;
  83397. private _buildHeight;
  83398. /**
  83399. * Creates a new instance ConeParticleEmitter
  83400. * @param radius the radius of the emission cone (1 by default)
  83401. * @param angle the cone base angle (PI by default)
  83402. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83403. */
  83404. constructor(radius?: number, angle?: number,
  83405. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83406. directionRandomizer?: number);
  83407. /**
  83408. * Called by the particle System when the direction is computed for the created particle.
  83409. * @param worldMatrix is the world matrix of the particle system
  83410. * @param directionToUpdate is the direction vector to update with the result
  83411. * @param particle is the particle we are computed the direction for
  83412. */
  83413. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83414. /**
  83415. * Called by the particle System when the position is computed for the created particle.
  83416. * @param worldMatrix is the world matrix of the particle system
  83417. * @param positionToUpdate is the position vector to update with the result
  83418. * @param particle is the particle we are computed the position for
  83419. */
  83420. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83421. /**
  83422. * Clones the current emitter and returns a copy of it
  83423. * @returns the new emitter
  83424. */
  83425. clone(): ConeParticleEmitter;
  83426. /**
  83427. * Called by the GPUParticleSystem to setup the update shader
  83428. * @param effect defines the update shader
  83429. */
  83430. applyToShader(effect: Effect): void;
  83431. /**
  83432. * Returns a string to use to update the GPU particles update shader
  83433. * @returns a string containng the defines string
  83434. */
  83435. getEffectDefines(): string;
  83436. /**
  83437. * Returns the string "ConeParticleEmitter"
  83438. * @returns a string containing the class name
  83439. */
  83440. getClassName(): string;
  83441. /**
  83442. * Serializes the particle system to a JSON object.
  83443. * @returns the JSON object
  83444. */
  83445. serialize(): any;
  83446. /**
  83447. * Parse properties from a JSON object
  83448. * @param serializationObject defines the JSON object
  83449. */
  83450. parse(serializationObject: any): void;
  83451. }
  83452. }
  83453. declare module BABYLON {
  83454. /**
  83455. * Particle emitter emitting particles from the inside of a cylinder.
  83456. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83457. */
  83458. export class CylinderParticleEmitter implements IParticleEmitterType {
  83459. /**
  83460. * The radius of the emission cylinder.
  83461. */
  83462. radius: number;
  83463. /**
  83464. * The height of the emission cylinder.
  83465. */
  83466. height: number;
  83467. /**
  83468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83469. */
  83470. radiusRange: number;
  83471. /**
  83472. * How much to randomize the particle direction [0-1].
  83473. */
  83474. directionRandomizer: number;
  83475. /**
  83476. * Creates a new instance CylinderParticleEmitter
  83477. * @param radius the radius of the emission cylinder (1 by default)
  83478. * @param height the height of the emission cylinder (1 by default)
  83479. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83480. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83481. */
  83482. constructor(
  83483. /**
  83484. * The radius of the emission cylinder.
  83485. */
  83486. radius?: number,
  83487. /**
  83488. * The height of the emission cylinder.
  83489. */
  83490. height?: number,
  83491. /**
  83492. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83493. */
  83494. radiusRange?: number,
  83495. /**
  83496. * How much to randomize the particle direction [0-1].
  83497. */
  83498. directionRandomizer?: number);
  83499. /**
  83500. * Called by the particle System when the direction is computed for the created particle.
  83501. * @param worldMatrix is the world matrix of the particle system
  83502. * @param directionToUpdate is the direction vector to update with the result
  83503. * @param particle is the particle we are computed the direction for
  83504. */
  83505. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83506. /**
  83507. * Called by the particle System when the position is computed for the created particle.
  83508. * @param worldMatrix is the world matrix of the particle system
  83509. * @param positionToUpdate is the position vector to update with the result
  83510. * @param particle is the particle we are computed the position for
  83511. */
  83512. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83513. /**
  83514. * Clones the current emitter and returns a copy of it
  83515. * @returns the new emitter
  83516. */
  83517. clone(): CylinderParticleEmitter;
  83518. /**
  83519. * Called by the GPUParticleSystem to setup the update shader
  83520. * @param effect defines the update shader
  83521. */
  83522. applyToShader(effect: Effect): void;
  83523. /**
  83524. * Returns a string to use to update the GPU particles update shader
  83525. * @returns a string containng the defines string
  83526. */
  83527. getEffectDefines(): string;
  83528. /**
  83529. * Returns the string "CylinderParticleEmitter"
  83530. * @returns a string containing the class name
  83531. */
  83532. getClassName(): string;
  83533. /**
  83534. * Serializes the particle system to a JSON object.
  83535. * @returns the JSON object
  83536. */
  83537. serialize(): any;
  83538. /**
  83539. * Parse properties from a JSON object
  83540. * @param serializationObject defines the JSON object
  83541. */
  83542. parse(serializationObject: any): void;
  83543. }
  83544. /**
  83545. * Particle emitter emitting particles from the inside of a cylinder.
  83546. * It emits the particles randomly between two vectors.
  83547. */
  83548. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83549. /**
  83550. * The min limit of the emission direction.
  83551. */
  83552. direction1: Vector3;
  83553. /**
  83554. * The max limit of the emission direction.
  83555. */
  83556. direction2: Vector3;
  83557. /**
  83558. * Creates a new instance CylinderDirectedParticleEmitter
  83559. * @param radius the radius of the emission cylinder (1 by default)
  83560. * @param height the height of the emission cylinder (1 by default)
  83561. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83562. * @param direction1 the min limit of the emission direction (up vector by default)
  83563. * @param direction2 the max limit of the emission direction (up vector by default)
  83564. */
  83565. constructor(radius?: number, height?: number, radiusRange?: number,
  83566. /**
  83567. * The min limit of the emission direction.
  83568. */
  83569. direction1?: Vector3,
  83570. /**
  83571. * The max limit of the emission direction.
  83572. */
  83573. direction2?: Vector3);
  83574. /**
  83575. * Called by the particle System when the direction is computed for the created particle.
  83576. * @param worldMatrix is the world matrix of the particle system
  83577. * @param directionToUpdate is the direction vector to update with the result
  83578. * @param particle is the particle we are computed the direction for
  83579. */
  83580. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83581. /**
  83582. * Clones the current emitter and returns a copy of it
  83583. * @returns the new emitter
  83584. */
  83585. clone(): CylinderDirectedParticleEmitter;
  83586. /**
  83587. * Called by the GPUParticleSystem to setup the update shader
  83588. * @param effect defines the update shader
  83589. */
  83590. applyToShader(effect: Effect): void;
  83591. /**
  83592. * Returns a string to use to update the GPU particles update shader
  83593. * @returns a string containng the defines string
  83594. */
  83595. getEffectDefines(): string;
  83596. /**
  83597. * Returns the string "CylinderDirectedParticleEmitter"
  83598. * @returns a string containing the class name
  83599. */
  83600. getClassName(): string;
  83601. /**
  83602. * Serializes the particle system to a JSON object.
  83603. * @returns the JSON object
  83604. */
  83605. serialize(): any;
  83606. /**
  83607. * Parse properties from a JSON object
  83608. * @param serializationObject defines the JSON object
  83609. */
  83610. parse(serializationObject: any): void;
  83611. }
  83612. }
  83613. declare module BABYLON {
  83614. /**
  83615. * Particle emitter emitting particles from the inside of a hemisphere.
  83616. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83617. */
  83618. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83619. /**
  83620. * The radius of the emission hemisphere.
  83621. */
  83622. radius: number;
  83623. /**
  83624. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83625. */
  83626. radiusRange: number;
  83627. /**
  83628. * How much to randomize the particle direction [0-1].
  83629. */
  83630. directionRandomizer: number;
  83631. /**
  83632. * Creates a new instance HemisphericParticleEmitter
  83633. * @param radius the radius of the emission hemisphere (1 by default)
  83634. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83635. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83636. */
  83637. constructor(
  83638. /**
  83639. * The radius of the emission hemisphere.
  83640. */
  83641. radius?: number,
  83642. /**
  83643. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83644. */
  83645. radiusRange?: number,
  83646. /**
  83647. * How much to randomize the particle direction [0-1].
  83648. */
  83649. directionRandomizer?: number);
  83650. /**
  83651. * Called by the particle System when the direction is computed for the created particle.
  83652. * @param worldMatrix is the world matrix of the particle system
  83653. * @param directionToUpdate is the direction vector to update with the result
  83654. * @param particle is the particle we are computed the direction for
  83655. */
  83656. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83657. /**
  83658. * Called by the particle System when the position is computed for the created particle.
  83659. * @param worldMatrix is the world matrix of the particle system
  83660. * @param positionToUpdate is the position vector to update with the result
  83661. * @param particle is the particle we are computed the position for
  83662. */
  83663. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83664. /**
  83665. * Clones the current emitter and returns a copy of it
  83666. * @returns the new emitter
  83667. */
  83668. clone(): HemisphericParticleEmitter;
  83669. /**
  83670. * Called by the GPUParticleSystem to setup the update shader
  83671. * @param effect defines the update shader
  83672. */
  83673. applyToShader(effect: Effect): void;
  83674. /**
  83675. * Returns a string to use to update the GPU particles update shader
  83676. * @returns a string containng the defines string
  83677. */
  83678. getEffectDefines(): string;
  83679. /**
  83680. * Returns the string "HemisphericParticleEmitter"
  83681. * @returns a string containing the class name
  83682. */
  83683. getClassName(): string;
  83684. /**
  83685. * Serializes the particle system to a JSON object.
  83686. * @returns the JSON object
  83687. */
  83688. serialize(): any;
  83689. /**
  83690. * Parse properties from a JSON object
  83691. * @param serializationObject defines the JSON object
  83692. */
  83693. parse(serializationObject: any): void;
  83694. }
  83695. }
  83696. declare module BABYLON {
  83697. /**
  83698. * Particle emitter emitting particles from a point.
  83699. * It emits the particles randomly between 2 given directions.
  83700. */
  83701. export class PointParticleEmitter implements IParticleEmitterType {
  83702. /**
  83703. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83704. */
  83705. direction1: Vector3;
  83706. /**
  83707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83708. */
  83709. direction2: Vector3;
  83710. /**
  83711. * Creates a new instance PointParticleEmitter
  83712. */
  83713. constructor();
  83714. /**
  83715. * Called by the particle System when the direction is computed for the created particle.
  83716. * @param worldMatrix is the world matrix of the particle system
  83717. * @param directionToUpdate is the direction vector to update with the result
  83718. * @param particle is the particle we are computed the direction for
  83719. */
  83720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83721. /**
  83722. * Called by the particle System when the position is computed for the created particle.
  83723. * @param worldMatrix is the world matrix of the particle system
  83724. * @param positionToUpdate is the position vector to update with the result
  83725. * @param particle is the particle we are computed the position for
  83726. */
  83727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83728. /**
  83729. * Clones the current emitter and returns a copy of it
  83730. * @returns the new emitter
  83731. */
  83732. clone(): PointParticleEmitter;
  83733. /**
  83734. * Called by the GPUParticleSystem to setup the update shader
  83735. * @param effect defines the update shader
  83736. */
  83737. applyToShader(effect: Effect): void;
  83738. /**
  83739. * Returns a string to use to update the GPU particles update shader
  83740. * @returns a string containng the defines string
  83741. */
  83742. getEffectDefines(): string;
  83743. /**
  83744. * Returns the string "PointParticleEmitter"
  83745. * @returns a string containing the class name
  83746. */
  83747. getClassName(): string;
  83748. /**
  83749. * Serializes the particle system to a JSON object.
  83750. * @returns the JSON object
  83751. */
  83752. serialize(): any;
  83753. /**
  83754. * Parse properties from a JSON object
  83755. * @param serializationObject defines the JSON object
  83756. */
  83757. parse(serializationObject: any): void;
  83758. }
  83759. }
  83760. declare module BABYLON {
  83761. /**
  83762. * Particle emitter emitting particles from the inside of a sphere.
  83763. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83764. */
  83765. export class SphereParticleEmitter implements IParticleEmitterType {
  83766. /**
  83767. * The radius of the emission sphere.
  83768. */
  83769. radius: number;
  83770. /**
  83771. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83772. */
  83773. radiusRange: number;
  83774. /**
  83775. * How much to randomize the particle direction [0-1].
  83776. */
  83777. directionRandomizer: number;
  83778. /**
  83779. * Creates a new instance SphereParticleEmitter
  83780. * @param radius the radius of the emission sphere (1 by default)
  83781. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83782. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83783. */
  83784. constructor(
  83785. /**
  83786. * The radius of the emission sphere.
  83787. */
  83788. radius?: number,
  83789. /**
  83790. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83791. */
  83792. radiusRange?: number,
  83793. /**
  83794. * How much to randomize the particle direction [0-1].
  83795. */
  83796. directionRandomizer?: number);
  83797. /**
  83798. * Called by the particle System when the direction is computed for the created particle.
  83799. * @param worldMatrix is the world matrix of the particle system
  83800. * @param directionToUpdate is the direction vector to update with the result
  83801. * @param particle is the particle we are computed the direction for
  83802. */
  83803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83804. /**
  83805. * Called by the particle System when the position is computed for the created particle.
  83806. * @param worldMatrix is the world matrix of the particle system
  83807. * @param positionToUpdate is the position vector to update with the result
  83808. * @param particle is the particle we are computed the position for
  83809. */
  83810. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83811. /**
  83812. * Clones the current emitter and returns a copy of it
  83813. * @returns the new emitter
  83814. */
  83815. clone(): SphereParticleEmitter;
  83816. /**
  83817. * Called by the GPUParticleSystem to setup the update shader
  83818. * @param effect defines the update shader
  83819. */
  83820. applyToShader(effect: Effect): void;
  83821. /**
  83822. * Returns a string to use to update the GPU particles update shader
  83823. * @returns a string containng the defines string
  83824. */
  83825. getEffectDefines(): string;
  83826. /**
  83827. * Returns the string "SphereParticleEmitter"
  83828. * @returns a string containing the class name
  83829. */
  83830. getClassName(): string;
  83831. /**
  83832. * Serializes the particle system to a JSON object.
  83833. * @returns the JSON object
  83834. */
  83835. serialize(): any;
  83836. /**
  83837. * Parse properties from a JSON object
  83838. * @param serializationObject defines the JSON object
  83839. */
  83840. parse(serializationObject: any): void;
  83841. }
  83842. /**
  83843. * Particle emitter emitting particles from the inside of a sphere.
  83844. * It emits the particles randomly between two vectors.
  83845. */
  83846. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83847. /**
  83848. * The min limit of the emission direction.
  83849. */
  83850. direction1: Vector3;
  83851. /**
  83852. * The max limit of the emission direction.
  83853. */
  83854. direction2: Vector3;
  83855. /**
  83856. * Creates a new instance SphereDirectedParticleEmitter
  83857. * @param radius the radius of the emission sphere (1 by default)
  83858. * @param direction1 the min limit of the emission direction (up vector by default)
  83859. * @param direction2 the max limit of the emission direction (up vector by default)
  83860. */
  83861. constructor(radius?: number,
  83862. /**
  83863. * The min limit of the emission direction.
  83864. */
  83865. direction1?: Vector3,
  83866. /**
  83867. * The max limit of the emission direction.
  83868. */
  83869. direction2?: Vector3);
  83870. /**
  83871. * Called by the particle System when the direction is computed for the created particle.
  83872. * @param worldMatrix is the world matrix of the particle system
  83873. * @param directionToUpdate is the direction vector to update with the result
  83874. * @param particle is the particle we are computed the direction for
  83875. */
  83876. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83877. /**
  83878. * Clones the current emitter and returns a copy of it
  83879. * @returns the new emitter
  83880. */
  83881. clone(): SphereDirectedParticleEmitter;
  83882. /**
  83883. * Called by the GPUParticleSystem to setup the update shader
  83884. * @param effect defines the update shader
  83885. */
  83886. applyToShader(effect: Effect): void;
  83887. /**
  83888. * Returns a string to use to update the GPU particles update shader
  83889. * @returns a string containng the defines string
  83890. */
  83891. getEffectDefines(): string;
  83892. /**
  83893. * Returns the string "SphereDirectedParticleEmitter"
  83894. * @returns a string containing the class name
  83895. */
  83896. getClassName(): string;
  83897. /**
  83898. * Serializes the particle system to a JSON object.
  83899. * @returns the JSON object
  83900. */
  83901. serialize(): any;
  83902. /**
  83903. * Parse properties from a JSON object
  83904. * @param serializationObject defines the JSON object
  83905. */
  83906. parse(serializationObject: any): void;
  83907. }
  83908. }
  83909. declare module BABYLON {
  83910. /**
  83911. * Interface representing a particle system in Babylon.js.
  83912. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83913. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83914. */
  83915. export interface IParticleSystem {
  83916. /**
  83917. * List of animations used by the particle system.
  83918. */
  83919. animations: Animation[];
  83920. /**
  83921. * The id of the Particle system.
  83922. */
  83923. id: string;
  83924. /**
  83925. * The name of the Particle system.
  83926. */
  83927. name: string;
  83928. /**
  83929. * The emitter represents the Mesh or position we are attaching the particle system to.
  83930. */
  83931. emitter: Nullable<AbstractMesh | Vector3>;
  83932. /**
  83933. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83934. */
  83935. isBillboardBased: boolean;
  83936. /**
  83937. * The rendering group used by the Particle system to chose when to render.
  83938. */
  83939. renderingGroupId: number;
  83940. /**
  83941. * The layer mask we are rendering the particles through.
  83942. */
  83943. layerMask: number;
  83944. /**
  83945. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83946. */
  83947. updateSpeed: number;
  83948. /**
  83949. * The amount of time the particle system is running (depends of the overall update speed).
  83950. */
  83951. targetStopDuration: number;
  83952. /**
  83953. * The texture used to render each particle. (this can be a spritesheet)
  83954. */
  83955. particleTexture: Nullable<Texture>;
  83956. /**
  83957. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83958. */
  83959. blendMode: number;
  83960. /**
  83961. * Minimum life time of emitting particles.
  83962. */
  83963. minLifeTime: number;
  83964. /**
  83965. * Maximum life time of emitting particles.
  83966. */
  83967. maxLifeTime: number;
  83968. /**
  83969. * Minimum Size of emitting particles.
  83970. */
  83971. minSize: number;
  83972. /**
  83973. * Maximum Size of emitting particles.
  83974. */
  83975. maxSize: number;
  83976. /**
  83977. * Minimum scale of emitting particles on X axis.
  83978. */
  83979. minScaleX: number;
  83980. /**
  83981. * Maximum scale of emitting particles on X axis.
  83982. */
  83983. maxScaleX: number;
  83984. /**
  83985. * Minimum scale of emitting particles on Y axis.
  83986. */
  83987. minScaleY: number;
  83988. /**
  83989. * Maximum scale of emitting particles on Y axis.
  83990. */
  83991. maxScaleY: number;
  83992. /**
  83993. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83994. */
  83995. color1: Color4;
  83996. /**
  83997. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83998. */
  83999. color2: Color4;
  84000. /**
  84001. * Color the particle will have at the end of its lifetime.
  84002. */
  84003. colorDead: Color4;
  84004. /**
  84005. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  84006. */
  84007. emitRate: number;
  84008. /**
  84009. * You can use gravity if you want to give an orientation to your particles.
  84010. */
  84011. gravity: Vector3;
  84012. /**
  84013. * Minimum power of emitting particles.
  84014. */
  84015. minEmitPower: number;
  84016. /**
  84017. * Maximum power of emitting particles.
  84018. */
  84019. maxEmitPower: number;
  84020. /**
  84021. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84022. */
  84023. minAngularSpeed: number;
  84024. /**
  84025. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84026. */
  84027. maxAngularSpeed: number;
  84028. /**
  84029. * Gets or sets the minimal initial rotation in radians.
  84030. */
  84031. minInitialRotation: number;
  84032. /**
  84033. * Gets or sets the maximal initial rotation in radians.
  84034. */
  84035. maxInitialRotation: number;
  84036. /**
  84037. * The particle emitter type defines the emitter used by the particle system.
  84038. * It can be for example box, sphere, or cone...
  84039. */
  84040. particleEmitterType: Nullable<IParticleEmitterType>;
  84041. /**
  84042. * Defines the delay in milliseconds before starting the system (0 by default)
  84043. */
  84044. startDelay: number;
  84045. /**
  84046. * 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
  84047. */
  84048. preWarmCycles: number;
  84049. /**
  84050. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  84051. */
  84052. preWarmStepOffset: number;
  84053. /**
  84054. * 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)
  84055. */
  84056. spriteCellChangeSpeed: number;
  84057. /**
  84058. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84059. */
  84060. startSpriteCellID: number;
  84061. /**
  84062. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84063. */
  84064. endSpriteCellID: number;
  84065. /**
  84066. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84067. */
  84068. spriteCellWidth: number;
  84069. /**
  84070. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84071. */
  84072. spriteCellHeight: number;
  84073. /**
  84074. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84075. */
  84076. spriteRandomStartCell: boolean;
  84077. /**
  84078. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  84079. */
  84080. isAnimationSheetEnabled: boolean;
  84081. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84082. translationPivot: Vector2;
  84083. /**
  84084. * Gets or sets a texture used to add random noise to particle positions
  84085. */
  84086. noiseTexture: Nullable<BaseTexture>;
  84087. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84088. noiseStrength: Vector3;
  84089. /**
  84090. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84091. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84092. */
  84093. billboardMode: number;
  84094. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84095. limitVelocityDamping: number;
  84096. /**
  84097. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84098. */
  84099. beginAnimationOnStart: boolean;
  84100. /**
  84101. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84102. */
  84103. beginAnimationFrom: number;
  84104. /**
  84105. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84106. */
  84107. beginAnimationTo: number;
  84108. /**
  84109. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84110. */
  84111. beginAnimationLoop: boolean;
  84112. /**
  84113. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84114. */
  84115. disposeOnStop: boolean;
  84116. /**
  84117. * Gets the maximum number of particles active at the same time.
  84118. * @returns The max number of active particles.
  84119. */
  84120. getCapacity(): number;
  84121. /**
  84122. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84123. * @returns True if it has been started, otherwise false.
  84124. */
  84125. isStarted(): boolean;
  84126. /**
  84127. * Animates the particle system for this frame.
  84128. */
  84129. animate(): void;
  84130. /**
  84131. * Renders the particle system in its current state.
  84132. * @returns the current number of particles
  84133. */
  84134. render(): number;
  84135. /**
  84136. * Dispose the particle system and frees its associated resources.
  84137. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84138. */
  84139. dispose(disposeTexture?: boolean): void;
  84140. /**
  84141. * Clones the particle system.
  84142. * @param name The name of the cloned object
  84143. * @param newEmitter The new emitter to use
  84144. * @returns the cloned particle system
  84145. */
  84146. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84147. /**
  84148. * Serializes the particle system to a JSON object.
  84149. * @returns the JSON object
  84150. */
  84151. serialize(): any;
  84152. /**
  84153. * Rebuild the particle system
  84154. */
  84155. rebuild(): void;
  84156. /**
  84157. * Starts the particle system and begins to emit
  84158. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84159. */
  84160. start(delay?: number): void;
  84161. /**
  84162. * Stops the particle system.
  84163. */
  84164. stop(): void;
  84165. /**
  84166. * Remove all active particles
  84167. */
  84168. reset(): void;
  84169. /**
  84170. * Is this system ready to be used/rendered
  84171. * @return true if the system is ready
  84172. */
  84173. isReady(): boolean;
  84174. /**
  84175. * Adds a new color gradient
  84176. * @param gradient defines the gradient to use (between 0 and 1)
  84177. * @param color1 defines the color to affect to the specified gradient
  84178. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84179. * @returns the current particle system
  84180. */
  84181. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84182. /**
  84183. * Remove a specific color gradient
  84184. * @param gradient defines the gradient to remove
  84185. * @returns the current particle system
  84186. */
  84187. removeColorGradient(gradient: number): IParticleSystem;
  84188. /**
  84189. * Adds a new size gradient
  84190. * @param gradient defines the gradient to use (between 0 and 1)
  84191. * @param factor defines the size factor to affect to the specified gradient
  84192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84193. * @returns the current particle system
  84194. */
  84195. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84196. /**
  84197. * Remove a specific size gradient
  84198. * @param gradient defines the gradient to remove
  84199. * @returns the current particle system
  84200. */
  84201. removeSizeGradient(gradient: number): IParticleSystem;
  84202. /**
  84203. * Gets the current list of color gradients.
  84204. * You must use addColorGradient and removeColorGradient to udpate this list
  84205. * @returns the list of color gradients
  84206. */
  84207. getColorGradients(): Nullable<Array<ColorGradient>>;
  84208. /**
  84209. * Gets the current list of size gradients.
  84210. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84211. * @returns the list of size gradients
  84212. */
  84213. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84214. /**
  84215. * Gets the current list of angular speed gradients.
  84216. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84217. * @returns the list of angular speed gradients
  84218. */
  84219. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84220. /**
  84221. * Adds a new angular speed gradient
  84222. * @param gradient defines the gradient to use (between 0 and 1)
  84223. * @param factor defines the angular speed to affect to the specified gradient
  84224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84225. * @returns the current particle system
  84226. */
  84227. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84228. /**
  84229. * Remove a specific angular speed gradient
  84230. * @param gradient defines the gradient to remove
  84231. * @returns the current particle system
  84232. */
  84233. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84234. /**
  84235. * Gets the current list of velocity gradients.
  84236. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84237. * @returns the list of velocity gradients
  84238. */
  84239. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84240. /**
  84241. * Adds a new velocity gradient
  84242. * @param gradient defines the gradient to use (between 0 and 1)
  84243. * @param factor defines the velocity to affect to the specified gradient
  84244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84245. * @returns the current particle system
  84246. */
  84247. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84248. /**
  84249. * Remove a specific velocity gradient
  84250. * @param gradient defines the gradient to remove
  84251. * @returns the current particle system
  84252. */
  84253. removeVelocityGradient(gradient: number): IParticleSystem;
  84254. /**
  84255. * Gets the current list of limit velocity gradients.
  84256. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84257. * @returns the list of limit velocity gradients
  84258. */
  84259. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84260. /**
  84261. * Adds a new limit velocity gradient
  84262. * @param gradient defines the gradient to use (between 0 and 1)
  84263. * @param factor defines the limit velocity to affect to the specified gradient
  84264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84265. * @returns the current particle system
  84266. */
  84267. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84268. /**
  84269. * Remove a specific limit velocity gradient
  84270. * @param gradient defines the gradient to remove
  84271. * @returns the current particle system
  84272. */
  84273. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84274. /**
  84275. * Adds a new drag gradient
  84276. * @param gradient defines the gradient to use (between 0 and 1)
  84277. * @param factor defines the drag to affect to the specified gradient
  84278. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84279. * @returns the current particle system
  84280. */
  84281. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84282. /**
  84283. * Remove a specific drag gradient
  84284. * @param gradient defines the gradient to remove
  84285. * @returns the current particle system
  84286. */
  84287. removeDragGradient(gradient: number): IParticleSystem;
  84288. /**
  84289. * Gets the current list of drag gradients.
  84290. * You must use addDragGradient and removeDragGradient to udpate this list
  84291. * @returns the list of drag gradients
  84292. */
  84293. getDragGradients(): Nullable<Array<FactorGradient>>;
  84294. /**
  84295. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84296. * @param gradient defines the gradient to use (between 0 and 1)
  84297. * @param factor defines the emit rate to affect to the specified gradient
  84298. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84299. * @returns the current particle system
  84300. */
  84301. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84302. /**
  84303. * Remove a specific emit rate gradient
  84304. * @param gradient defines the gradient to remove
  84305. * @returns the current particle system
  84306. */
  84307. removeEmitRateGradient(gradient: number): IParticleSystem;
  84308. /**
  84309. * Gets the current list of emit rate gradients.
  84310. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84311. * @returns the list of emit rate gradients
  84312. */
  84313. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84314. /**
  84315. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84316. * @param gradient defines the gradient to use (between 0 and 1)
  84317. * @param factor defines the start size to affect to the specified gradient
  84318. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84319. * @returns the current particle system
  84320. */
  84321. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84322. /**
  84323. * Remove a specific start size gradient
  84324. * @param gradient defines the gradient to remove
  84325. * @returns the current particle system
  84326. */
  84327. removeStartSizeGradient(gradient: number): IParticleSystem;
  84328. /**
  84329. * Gets the current list of start size gradients.
  84330. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84331. * @returns the list of start size gradients
  84332. */
  84333. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84334. /**
  84335. * Adds a new life time gradient
  84336. * @param gradient defines the gradient to use (between 0 and 1)
  84337. * @param factor defines the life time factor to affect to the specified gradient
  84338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84339. * @returns the current particle system
  84340. */
  84341. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84342. /**
  84343. * Remove a specific life time gradient
  84344. * @param gradient defines the gradient to remove
  84345. * @returns the current particle system
  84346. */
  84347. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84348. /**
  84349. * Gets the current list of life time gradients.
  84350. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84351. * @returns the list of life time gradients
  84352. */
  84353. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84354. /**
  84355. * Gets the current list of color gradients.
  84356. * You must use addColorGradient and removeColorGradient to udpate this list
  84357. * @returns the list of color gradients
  84358. */
  84359. getColorGradients(): Nullable<Array<ColorGradient>>;
  84360. /**
  84361. * Adds a new ramp gradient used to remap particle colors
  84362. * @param gradient defines the gradient to use (between 0 and 1)
  84363. * @param color defines the color to affect to the specified gradient
  84364. * @returns the current particle system
  84365. */
  84366. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84367. /**
  84368. * Gets the current list of ramp gradients.
  84369. * You must use addRampGradient and removeRampGradient to udpate this list
  84370. * @returns the list of ramp gradients
  84371. */
  84372. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84373. /** Gets or sets a boolean indicating that ramp gradients must be used
  84374. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84375. */
  84376. useRampGradients: boolean;
  84377. /**
  84378. * Adds a new color remap gradient
  84379. * @param gradient defines the gradient to use (between 0 and 1)
  84380. * @param min defines the color remap minimal range
  84381. * @param max defines the color remap maximal range
  84382. * @returns the current particle system
  84383. */
  84384. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84385. /**
  84386. * Gets the current list of color remap gradients.
  84387. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84388. * @returns the list of color remap gradients
  84389. */
  84390. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84391. /**
  84392. * Adds a new alpha remap gradient
  84393. * @param gradient defines the gradient to use (between 0 and 1)
  84394. * @param min defines the alpha remap minimal range
  84395. * @param max defines the alpha remap maximal range
  84396. * @returns the current particle system
  84397. */
  84398. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84399. /**
  84400. * Gets the current list of alpha remap gradients.
  84401. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84402. * @returns the list of alpha remap gradients
  84403. */
  84404. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84405. /**
  84406. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84407. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84408. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84409. * @returns the emitter
  84410. */
  84411. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84412. /**
  84413. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84414. * @param radius The radius of the hemisphere to emit from
  84415. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84416. * @returns the emitter
  84417. */
  84418. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84419. /**
  84420. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84421. * @param radius The radius of the sphere to emit from
  84422. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84423. * @returns the emitter
  84424. */
  84425. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84426. /**
  84427. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84428. * @param radius The radius of the sphere to emit from
  84429. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84430. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84431. * @returns the emitter
  84432. */
  84433. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84434. /**
  84435. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84436. * @param radius The radius of the emission cylinder
  84437. * @param height The height of the emission cylinder
  84438. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84439. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84440. * @returns the emitter
  84441. */
  84442. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84443. /**
  84444. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84445. * @param radius The radius of the cylinder to emit from
  84446. * @param height The height of the emission cylinder
  84447. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84448. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84449. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84450. * @returns the emitter
  84451. */
  84452. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84453. /**
  84454. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84455. * @param radius The radius of the cone to emit from
  84456. * @param angle The base angle of the cone
  84457. * @returns the emitter
  84458. */
  84459. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84460. /**
  84461. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84462. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84463. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84464. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84465. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84466. * @returns the emitter
  84467. */
  84468. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84469. /**
  84470. * Get hosting scene
  84471. * @returns the scene
  84472. */
  84473. getScene(): Scene;
  84474. }
  84475. }
  84476. declare module BABYLON {
  84477. /**
  84478. * Creates an instance based on a source mesh.
  84479. */
  84480. export class InstancedMesh extends AbstractMesh {
  84481. private _sourceMesh;
  84482. private _currentLOD;
  84483. /** @hidden */
  84484. _indexInSourceMeshInstanceArray: number;
  84485. constructor(name: string, source: Mesh);
  84486. /**
  84487. * Returns the string "InstancedMesh".
  84488. */
  84489. getClassName(): string;
  84490. /** Gets the list of lights affecting that mesh */
  84491. readonly lightSources: Light[];
  84492. _resyncLightSources(): void;
  84493. _resyncLighSource(light: Light): void;
  84494. _removeLightSource(light: Light, dispose: boolean): void;
  84495. /**
  84496. * If the source mesh receives shadows
  84497. */
  84498. readonly receiveShadows: boolean;
  84499. /**
  84500. * The material of the source mesh
  84501. */
  84502. readonly material: Nullable<Material>;
  84503. /**
  84504. * Visibility of the source mesh
  84505. */
  84506. readonly visibility: number;
  84507. /**
  84508. * Skeleton of the source mesh
  84509. */
  84510. readonly skeleton: Nullable<Skeleton>;
  84511. /**
  84512. * Rendering ground id of the source mesh
  84513. */
  84514. renderingGroupId: number;
  84515. /**
  84516. * Returns the total number of vertices (integer).
  84517. */
  84518. getTotalVertices(): number;
  84519. /**
  84520. * Returns a positive integer : the total number of indices in this mesh geometry.
  84521. * @returns the numner of indices or zero if the mesh has no geometry.
  84522. */
  84523. getTotalIndices(): number;
  84524. /**
  84525. * The source mesh of the instance
  84526. */
  84527. readonly sourceMesh: Mesh;
  84528. /**
  84529. * Is this node ready to be used/rendered
  84530. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84531. * @return {boolean} is it ready
  84532. */
  84533. isReady(completeCheck?: boolean): boolean;
  84534. /**
  84535. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84536. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84537. * @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.
  84538. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84539. */
  84540. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84541. /**
  84542. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84543. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84544. * The `data` are either a numeric array either a Float32Array.
  84545. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84546. * 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).
  84547. * Note that a new underlying VertexBuffer object is created each call.
  84548. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84549. *
  84550. * Possible `kind` values :
  84551. * - VertexBuffer.PositionKind
  84552. * - VertexBuffer.UVKind
  84553. * - VertexBuffer.UV2Kind
  84554. * - VertexBuffer.UV3Kind
  84555. * - VertexBuffer.UV4Kind
  84556. * - VertexBuffer.UV5Kind
  84557. * - VertexBuffer.UV6Kind
  84558. * - VertexBuffer.ColorKind
  84559. * - VertexBuffer.MatricesIndicesKind
  84560. * - VertexBuffer.MatricesIndicesExtraKind
  84561. * - VertexBuffer.MatricesWeightsKind
  84562. * - VertexBuffer.MatricesWeightsExtraKind
  84563. *
  84564. * Returns the Mesh.
  84565. */
  84566. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84567. /**
  84568. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84569. * If the mesh has no geometry, it is simply returned as it is.
  84570. * The `data` are either a numeric array either a Float32Array.
  84571. * No new underlying VertexBuffer object is created.
  84572. * 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.
  84573. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84574. *
  84575. * Possible `kind` values :
  84576. * - VertexBuffer.PositionKind
  84577. * - VertexBuffer.UVKind
  84578. * - VertexBuffer.UV2Kind
  84579. * - VertexBuffer.UV3Kind
  84580. * - VertexBuffer.UV4Kind
  84581. * - VertexBuffer.UV5Kind
  84582. * - VertexBuffer.UV6Kind
  84583. * - VertexBuffer.ColorKind
  84584. * - VertexBuffer.MatricesIndicesKind
  84585. * - VertexBuffer.MatricesIndicesExtraKind
  84586. * - VertexBuffer.MatricesWeightsKind
  84587. * - VertexBuffer.MatricesWeightsExtraKind
  84588. *
  84589. * Returns the Mesh.
  84590. */
  84591. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84592. /**
  84593. * Sets the mesh indices.
  84594. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84595. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84596. * This method creates a new index buffer each call.
  84597. * Returns the Mesh.
  84598. */
  84599. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84600. /**
  84601. * Boolean : True if the mesh owns the requested kind of data.
  84602. */
  84603. isVerticesDataPresent(kind: string): boolean;
  84604. /**
  84605. * Returns an array of indices (IndicesArray).
  84606. */
  84607. getIndices(): Nullable<IndicesArray>;
  84608. readonly _positions: Nullable<Vector3[]>;
  84609. /**
  84610. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84611. * This means the mesh underlying bounding box and sphere are recomputed.
  84612. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84613. * @returns the current mesh
  84614. */
  84615. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84616. /** @hidden */
  84617. _preActivate(): InstancedMesh;
  84618. /** @hidden */
  84619. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84620. /** @hidden */
  84621. _postActivate(): void;
  84622. getWorldMatrix(): Matrix;
  84623. readonly isAnInstance: boolean;
  84624. /**
  84625. * Returns the current associated LOD AbstractMesh.
  84626. */
  84627. getLOD(camera: Camera): AbstractMesh;
  84628. /** @hidden */
  84629. _syncSubMeshes(): InstancedMesh;
  84630. /** @hidden */
  84631. _generatePointsArray(): boolean;
  84632. /**
  84633. * Creates a new InstancedMesh from the current mesh.
  84634. * - name (string) : the cloned mesh name
  84635. * - newParent (optional Node) : the optional Node to parent the clone to.
  84636. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84637. *
  84638. * Returns the clone.
  84639. */
  84640. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84641. /**
  84642. * Disposes the InstancedMesh.
  84643. * Returns nothing.
  84644. */
  84645. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84646. }
  84647. }
  84648. declare module BABYLON {
  84649. /**
  84650. * Defines the options associated with the creation of a shader material.
  84651. */
  84652. export interface IShaderMaterialOptions {
  84653. /**
  84654. * Does the material work in alpha blend mode
  84655. */
  84656. needAlphaBlending: boolean;
  84657. /**
  84658. * Does the material work in alpha test mode
  84659. */
  84660. needAlphaTesting: boolean;
  84661. /**
  84662. * The list of attribute names used in the shader
  84663. */
  84664. attributes: string[];
  84665. /**
  84666. * The list of unifrom names used in the shader
  84667. */
  84668. uniforms: string[];
  84669. /**
  84670. * The list of UBO names used in the shader
  84671. */
  84672. uniformBuffers: string[];
  84673. /**
  84674. * The list of sampler names used in the shader
  84675. */
  84676. samplers: string[];
  84677. /**
  84678. * The list of defines used in the shader
  84679. */
  84680. defines: string[];
  84681. }
  84682. /**
  84683. * 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.
  84684. *
  84685. * This returned material effects how the mesh will look based on the code in the shaders.
  84686. *
  84687. * @see http://doc.babylonjs.com/how_to/shader_material
  84688. */
  84689. export class ShaderMaterial extends Material {
  84690. private _shaderPath;
  84691. private _options;
  84692. private _textures;
  84693. private _textureArrays;
  84694. private _floats;
  84695. private _ints;
  84696. private _floatsArrays;
  84697. private _colors3;
  84698. private _colors3Arrays;
  84699. private _colors4;
  84700. private _colors4Arrays;
  84701. private _vectors2;
  84702. private _vectors3;
  84703. private _vectors4;
  84704. private _matrices;
  84705. private _matrices3x3;
  84706. private _matrices2x2;
  84707. private _vectors2Arrays;
  84708. private _vectors3Arrays;
  84709. private _vectors4Arrays;
  84710. private _cachedWorldViewMatrix;
  84711. private _cachedWorldViewProjectionMatrix;
  84712. private _renderId;
  84713. /**
  84714. * Instantiate a new shader material.
  84715. * 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.
  84716. * This returned material effects how the mesh will look based on the code in the shaders.
  84717. * @see http://doc.babylonjs.com/how_to/shader_material
  84718. * @param name Define the name of the material in the scene
  84719. * @param scene Define the scene the material belongs to
  84720. * @param shaderPath Defines the route to the shader code in one of three ways:
  84721. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84722. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  84723. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  84724. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84725. * @param options Define the options used to create the shader
  84726. */
  84727. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84728. /**
  84729. * Gets the options used to compile the shader.
  84730. * They can be modified to trigger a new compilation
  84731. */
  84732. readonly options: IShaderMaterialOptions;
  84733. /**
  84734. * Gets the current class name of the material e.g. "ShaderMaterial"
  84735. * Mainly use in serialization.
  84736. * @returns the class name
  84737. */
  84738. getClassName(): string;
  84739. /**
  84740. * Specifies if the material will require alpha blending
  84741. * @returns a boolean specifying if alpha blending is needed
  84742. */
  84743. needAlphaBlending(): boolean;
  84744. /**
  84745. * Specifies if this material should be rendered in alpha test mode
  84746. * @returns a boolean specifying if an alpha test is needed.
  84747. */
  84748. needAlphaTesting(): boolean;
  84749. private _checkUniform;
  84750. /**
  84751. * Set a texture in the shader.
  84752. * @param name Define the name of the uniform samplers as defined in the shader
  84753. * @param texture Define the texture to bind to this sampler
  84754. * @return the material itself allowing "fluent" like uniform updates
  84755. */
  84756. setTexture(name: string, texture: Texture): ShaderMaterial;
  84757. /**
  84758. * Set a texture array in the shader.
  84759. * @param name Define the name of the uniform sampler array as defined in the shader
  84760. * @param textures Define the list of textures to bind to this sampler
  84761. * @return the material itself allowing "fluent" like uniform updates
  84762. */
  84763. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84764. /**
  84765. * Set a float in the shader.
  84766. * @param name Define the name of the uniform as defined in the shader
  84767. * @param value Define the value to give to the uniform
  84768. * @return the material itself allowing "fluent" like uniform updates
  84769. */
  84770. setFloat(name: string, value: number): ShaderMaterial;
  84771. /**
  84772. * Set a int in the shader.
  84773. * @param name Define the name of the uniform as defined in the shader
  84774. * @param value Define the value to give to the uniform
  84775. * @return the material itself allowing "fluent" like uniform updates
  84776. */
  84777. setInt(name: string, value: number): ShaderMaterial;
  84778. /**
  84779. * Set an array of floats in the shader.
  84780. * @param name Define the name of the uniform as defined in the shader
  84781. * @param value Define the value to give to the uniform
  84782. * @return the material itself allowing "fluent" like uniform updates
  84783. */
  84784. setFloats(name: string, value: number[]): ShaderMaterial;
  84785. /**
  84786. * Set a vec3 in the shader from a Color3.
  84787. * @param name Define the name of the uniform as defined in the shader
  84788. * @param value Define the value to give to the uniform
  84789. * @return the material itself allowing "fluent" like uniform updates
  84790. */
  84791. setColor3(name: string, value: Color3): ShaderMaterial;
  84792. /**
  84793. * Set a vec3 array in the shader from a Color3 array.
  84794. * @param name Define the name of the uniform as defined in the shader
  84795. * @param value Define the value to give to the uniform
  84796. * @return the material itself allowing "fluent" like uniform updates
  84797. */
  84798. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84799. /**
  84800. * Set a vec4 in the shader from a Color4.
  84801. * @param name Define the name of the uniform as defined in the shader
  84802. * @param value Define the value to give to the uniform
  84803. * @return the material itself allowing "fluent" like uniform updates
  84804. */
  84805. setColor4(name: string, value: Color4): ShaderMaterial;
  84806. /**
  84807. * Set a vec4 array in the shader from a Color4 array.
  84808. * @param name Define the name of the uniform as defined in the shader
  84809. * @param value Define the value to give to the uniform
  84810. * @return the material itself allowing "fluent" like uniform updates
  84811. */
  84812. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84813. /**
  84814. * Set a vec2 in the shader from a Vector2.
  84815. * @param name Define the name of the uniform as defined in the shader
  84816. * @param value Define the value to give to the uniform
  84817. * @return the material itself allowing "fluent" like uniform updates
  84818. */
  84819. setVector2(name: string, value: Vector2): ShaderMaterial;
  84820. /**
  84821. * Set a vec3 in the shader from a Vector3.
  84822. * @param name Define the name of the uniform as defined in the shader
  84823. * @param value Define the value to give to the uniform
  84824. * @return the material itself allowing "fluent" like uniform updates
  84825. */
  84826. setVector3(name: string, value: Vector3): ShaderMaterial;
  84827. /**
  84828. * Set a vec4 in the shader from a Vector4.
  84829. * @param name Define the name of the uniform as defined in the shader
  84830. * @param value Define the value to give to the uniform
  84831. * @return the material itself allowing "fluent" like uniform updates
  84832. */
  84833. setVector4(name: string, value: Vector4): ShaderMaterial;
  84834. /**
  84835. * Set a mat4 in the shader from a Matrix.
  84836. * @param name Define the name of the uniform as defined in the shader
  84837. * @param value Define the value to give to the uniform
  84838. * @return the material itself allowing "fluent" like uniform updates
  84839. */
  84840. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84841. /**
  84842. * Set a mat3 in the shader from a Float32Array.
  84843. * @param name Define the name of the uniform as defined in the shader
  84844. * @param value Define the value to give to the uniform
  84845. * @return the material itself allowing "fluent" like uniform updates
  84846. */
  84847. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84848. /**
  84849. * Set a mat2 in the shader from a Float32Array.
  84850. * @param name Define the name of the uniform as defined in the shader
  84851. * @param value Define the value to give to the uniform
  84852. * @return the material itself allowing "fluent" like uniform updates
  84853. */
  84854. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84855. /**
  84856. * Set a vec2 array in the shader from a number array.
  84857. * @param name Define the name of the uniform as defined in the shader
  84858. * @param value Define the value to give to the uniform
  84859. * @return the material itself allowing "fluent" like uniform updates
  84860. */
  84861. setArray2(name: string, value: number[]): ShaderMaterial;
  84862. /**
  84863. * Set a vec3 array in the shader from a number array.
  84864. * @param name Define the name of the uniform as defined in the shader
  84865. * @param value Define the value to give to the uniform
  84866. * @return the material itself allowing "fluent" like uniform updates
  84867. */
  84868. setArray3(name: string, value: number[]): ShaderMaterial;
  84869. /**
  84870. * Set a vec4 array in the shader from a number array.
  84871. * @param name Define the name of the uniform as defined in the shader
  84872. * @param value Define the value to give to the uniform
  84873. * @return the material itself allowing "fluent" like uniform updates
  84874. */
  84875. setArray4(name: string, value: number[]): ShaderMaterial;
  84876. private _checkCache;
  84877. /**
  84878. * Specifies that the submesh is ready to be used
  84879. * @param mesh defines the mesh to check
  84880. * @param subMesh defines which submesh to check
  84881. * @param useInstances specifies that instances should be used
  84882. * @returns a boolean indicating that the submesh is ready or not
  84883. */
  84884. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84885. /**
  84886. * Checks if the material is ready to render the requested mesh
  84887. * @param mesh Define the mesh to render
  84888. * @param useInstances Define whether or not the material is used with instances
  84889. * @returns true if ready, otherwise false
  84890. */
  84891. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84892. /**
  84893. * Binds the world matrix to the material
  84894. * @param world defines the world transformation matrix
  84895. */
  84896. bindOnlyWorldMatrix(world: Matrix): void;
  84897. /**
  84898. * Binds the material to the mesh
  84899. * @param world defines the world transformation matrix
  84900. * @param mesh defines the mesh to bind the material to
  84901. */
  84902. bind(world: Matrix, mesh?: Mesh): void;
  84903. /**
  84904. * Gets the active textures from the material
  84905. * @returns an array of textures
  84906. */
  84907. getActiveTextures(): BaseTexture[];
  84908. /**
  84909. * Specifies if the material uses a texture
  84910. * @param texture defines the texture to check against the material
  84911. * @returns a boolean specifying if the material uses the texture
  84912. */
  84913. hasTexture(texture: BaseTexture): boolean;
  84914. /**
  84915. * Makes a duplicate of the material, and gives it a new name
  84916. * @param name defines the new name for the duplicated material
  84917. * @returns the cloned material
  84918. */
  84919. clone(name: string): ShaderMaterial;
  84920. /**
  84921. * Disposes the material
  84922. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84923. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84924. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84925. */
  84926. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84927. /**
  84928. * Serializes this material in a JSON representation
  84929. * @returns the serialized material object
  84930. */
  84931. serialize(): any;
  84932. /**
  84933. * Creates a shader material from parsed shader material data
  84934. * @param source defines the JSON represnetation of the material
  84935. * @param scene defines the hosting scene
  84936. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84937. * @returns a new material
  84938. */
  84939. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  84940. }
  84941. }
  84942. declare module BABYLON {
  84943. /** @hidden */
  84944. export var colorPixelShader: {
  84945. name: string;
  84946. shader: string;
  84947. };
  84948. }
  84949. declare module BABYLON {
  84950. /** @hidden */
  84951. export var colorVertexShader: {
  84952. name: string;
  84953. shader: string;
  84954. };
  84955. }
  84956. declare module BABYLON {
  84957. /**
  84958. * Line mesh
  84959. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84960. */
  84961. export class LinesMesh extends Mesh {
  84962. /**
  84963. * If vertex color should be applied to the mesh
  84964. */
  84965. readonly useVertexColor?: boolean | undefined;
  84966. /**
  84967. * If vertex alpha should be applied to the mesh
  84968. */
  84969. readonly useVertexAlpha?: boolean | undefined;
  84970. /**
  84971. * Color of the line (Default: White)
  84972. */
  84973. color: Color3;
  84974. /**
  84975. * Alpha of the line (Default: 1)
  84976. */
  84977. alpha: number;
  84978. /**
  84979. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84980. * This margin is expressed in world space coordinates, so its value may vary.
  84981. * Default value is 0.1
  84982. */
  84983. intersectionThreshold: number;
  84984. private _colorShader;
  84985. private color4;
  84986. /**
  84987. * Creates a new LinesMesh
  84988. * @param name defines the name
  84989. * @param scene defines the hosting scene
  84990. * @param parent defines the parent mesh if any
  84991. * @param source defines the optional source LinesMesh used to clone data from
  84992. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84993. * When false, achieved by calling a clone(), also passing False.
  84994. * This will make creation of children, recursive.
  84995. * @param useVertexColor defines if this LinesMesh supports vertex color
  84996. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84997. */
  84998. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  84999. /**
  85000. * If vertex color should be applied to the mesh
  85001. */
  85002. useVertexColor?: boolean | undefined,
  85003. /**
  85004. * If vertex alpha should be applied to the mesh
  85005. */
  85006. useVertexAlpha?: boolean | undefined);
  85007. private _addClipPlaneDefine;
  85008. private _removeClipPlaneDefine;
  85009. isReady(): boolean;
  85010. /**
  85011. * Returns the string "LineMesh"
  85012. */
  85013. getClassName(): string;
  85014. /**
  85015. * @hidden
  85016. */
  85017. /**
  85018. * @hidden
  85019. */
  85020. material: Material;
  85021. /**
  85022. * @hidden
  85023. */
  85024. readonly checkCollisions: boolean;
  85025. /** @hidden */
  85026. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85027. /** @hidden */
  85028. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85029. /**
  85030. * Disposes of the line mesh
  85031. * @param doNotRecurse If children should be disposed
  85032. */
  85033. dispose(doNotRecurse?: boolean): void;
  85034. /**
  85035. * Returns a new LineMesh object cloned from the current one.
  85036. */
  85037. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85038. /**
  85039. * Creates a new InstancedLinesMesh object from the mesh model.
  85040. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85041. * @param name defines the name of the new instance
  85042. * @returns a new InstancedLinesMesh
  85043. */
  85044. createInstance(name: string): InstancedLinesMesh;
  85045. }
  85046. /**
  85047. * Creates an instance based on a source LinesMesh
  85048. */
  85049. export class InstancedLinesMesh extends InstancedMesh {
  85050. /**
  85051. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85052. * This margin is expressed in world space coordinates, so its value may vary.
  85053. * Initilized with the intersectionThreshold value of the source LinesMesh
  85054. */
  85055. intersectionThreshold: number;
  85056. constructor(name: string, source: LinesMesh);
  85057. /**
  85058. * Returns the string "InstancedLinesMesh".
  85059. */
  85060. getClassName(): string;
  85061. }
  85062. }
  85063. declare module BABYLON {
  85064. /** @hidden */
  85065. export var linePixelShader: {
  85066. name: string;
  85067. shader: string;
  85068. };
  85069. }
  85070. declare module BABYLON {
  85071. /** @hidden */
  85072. export var lineVertexShader: {
  85073. name: string;
  85074. shader: string;
  85075. };
  85076. }
  85077. declare module BABYLON {
  85078. interface AbstractMesh {
  85079. /**
  85080. * Gets the edgesRenderer associated with the mesh
  85081. */
  85082. edgesRenderer: Nullable<EdgesRenderer>;
  85083. }
  85084. interface LinesMesh {
  85085. /**
  85086. * Enables the edge rendering mode on the mesh.
  85087. * This mode makes the mesh edges visible
  85088. * @param epsilon defines the maximal distance between two angles to detect a face
  85089. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85090. * @returns the currentAbstractMesh
  85091. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85092. */
  85093. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85094. }
  85095. interface InstancedLinesMesh {
  85096. /**
  85097. * Enables the edge rendering mode on the mesh.
  85098. * This mode makes the mesh edges visible
  85099. * @param epsilon defines the maximal distance between two angles to detect a face
  85100. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85101. * @returns the current InstancedLinesMesh
  85102. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85103. */
  85104. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  85105. }
  85106. /**
  85107. * Defines the minimum contract an Edges renderer should follow.
  85108. */
  85109. export interface IEdgesRenderer extends IDisposable {
  85110. /**
  85111. * Gets or sets a boolean indicating if the edgesRenderer is active
  85112. */
  85113. isEnabled: boolean;
  85114. /**
  85115. * Renders the edges of the attached mesh,
  85116. */
  85117. render(): void;
  85118. /**
  85119. * Checks wether or not the edges renderer is ready to render.
  85120. * @return true if ready, otherwise false.
  85121. */
  85122. isReady(): boolean;
  85123. }
  85124. /**
  85125. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85126. */
  85127. export class EdgesRenderer implements IEdgesRenderer {
  85128. /**
  85129. * Define the size of the edges with an orthographic camera
  85130. */
  85131. edgesWidthScalerForOrthographic: number;
  85132. /**
  85133. * Define the size of the edges with a perspective camera
  85134. */
  85135. edgesWidthScalerForPerspective: number;
  85136. protected _source: AbstractMesh;
  85137. protected _linesPositions: number[];
  85138. protected _linesNormals: number[];
  85139. protected _linesIndices: number[];
  85140. protected _epsilon: number;
  85141. protected _indicesCount: number;
  85142. protected _lineShader: ShaderMaterial;
  85143. protected _ib: DataBuffer;
  85144. protected _buffers: {
  85145. [key: string]: Nullable<VertexBuffer>;
  85146. };
  85147. protected _checkVerticesInsteadOfIndices: boolean;
  85148. private _meshRebuildObserver;
  85149. private _meshDisposeObserver;
  85150. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85151. isEnabled: boolean;
  85152. /**
  85153. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85154. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85155. * @param source Mesh used to create edges
  85156. * @param epsilon sum of angles in adjacency to check for edge
  85157. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85158. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85159. */
  85160. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85161. protected _prepareRessources(): void;
  85162. /** @hidden */
  85163. _rebuild(): void;
  85164. /**
  85165. * Releases the required resources for the edges renderer
  85166. */
  85167. dispose(): void;
  85168. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85169. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85170. /**
  85171. * Checks if the pair of p0 and p1 is en edge
  85172. * @param faceIndex
  85173. * @param edge
  85174. * @param faceNormals
  85175. * @param p0
  85176. * @param p1
  85177. * @private
  85178. */
  85179. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85180. /**
  85181. * push line into the position, normal and index buffer
  85182. * @protected
  85183. */
  85184. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85185. /**
  85186. * Generates lines edges from adjacencjes
  85187. * @private
  85188. */
  85189. _generateEdgesLines(): void;
  85190. /**
  85191. * Checks wether or not the edges renderer is ready to render.
  85192. * @return true if ready, otherwise false.
  85193. */
  85194. isReady(): boolean;
  85195. /**
  85196. * Renders the edges of the attached mesh,
  85197. */
  85198. render(): void;
  85199. }
  85200. /**
  85201. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85202. */
  85203. export class LineEdgesRenderer extends EdgesRenderer {
  85204. /**
  85205. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85206. * @param source LineMesh used to generate edges
  85207. * @param epsilon not important (specified angle for edge detection)
  85208. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85209. */
  85210. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85211. /**
  85212. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85213. */
  85214. _generateEdgesLines(): void;
  85215. }
  85216. }
  85217. declare module BABYLON {
  85218. /**
  85219. * This represents the object necessary to create a rendering group.
  85220. * This is exclusively used and created by the rendering manager.
  85221. * To modify the behavior, you use the available helpers in your scene or meshes.
  85222. * @hidden
  85223. */
  85224. export class RenderingGroup {
  85225. index: number;
  85226. private static _zeroVector;
  85227. private _scene;
  85228. private _opaqueSubMeshes;
  85229. private _transparentSubMeshes;
  85230. private _alphaTestSubMeshes;
  85231. private _depthOnlySubMeshes;
  85232. private _particleSystems;
  85233. private _spriteManagers;
  85234. private _opaqueSortCompareFn;
  85235. private _alphaTestSortCompareFn;
  85236. private _transparentSortCompareFn;
  85237. private _renderOpaque;
  85238. private _renderAlphaTest;
  85239. private _renderTransparent;
  85240. /** @hidden */
  85241. _edgesRenderers: SmartArray<IEdgesRenderer>;
  85242. onBeforeTransparentRendering: () => void;
  85243. /**
  85244. * Set the opaque sort comparison function.
  85245. * If null the sub meshes will be render in the order they were created
  85246. */
  85247. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85248. /**
  85249. * Set the alpha test sort comparison function.
  85250. * If null the sub meshes will be render in the order they were created
  85251. */
  85252. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85253. /**
  85254. * Set the transparent sort comparison function.
  85255. * If null the sub meshes will be render in the order they were created
  85256. */
  85257. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85258. /**
  85259. * Creates a new rendering group.
  85260. * @param index The rendering group index
  85261. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  85262. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  85263. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  85264. */
  85265. 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>);
  85266. /**
  85267. * Render all the sub meshes contained in the group.
  85268. * @param customRenderFunction Used to override the default render behaviour of the group.
  85269. * @returns true if rendered some submeshes.
  85270. */
  85271. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  85272. /**
  85273. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  85274. * @param subMeshes The submeshes to render
  85275. */
  85276. private renderOpaqueSorted;
  85277. /**
  85278. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  85279. * @param subMeshes The submeshes to render
  85280. */
  85281. private renderAlphaTestSorted;
  85282. /**
  85283. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  85284. * @param subMeshes The submeshes to render
  85285. */
  85286. private renderTransparentSorted;
  85287. /**
  85288. * Renders the submeshes in a specified order.
  85289. * @param subMeshes The submeshes to sort before render
  85290. * @param sortCompareFn The comparison function use to sort
  85291. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  85292. * @param transparent Specifies to activate blending if true
  85293. */
  85294. private static renderSorted;
  85295. /**
  85296. * Renders the submeshes in the order they were dispatched (no sort applied).
  85297. * @param subMeshes The submeshes to render
  85298. */
  85299. private static renderUnsorted;
  85300. /**
  85301. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85302. * are rendered back to front if in the same alpha index.
  85303. *
  85304. * @param a The first submesh
  85305. * @param b The second submesh
  85306. * @returns The result of the comparison
  85307. */
  85308. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  85309. /**
  85310. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85311. * are rendered back to front.
  85312. *
  85313. * @param a The first submesh
  85314. * @param b The second submesh
  85315. * @returns The result of the comparison
  85316. */
  85317. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  85318. /**
  85319. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85320. * are rendered front to back (prevent overdraw).
  85321. *
  85322. * @param a The first submesh
  85323. * @param b The second submesh
  85324. * @returns The result of the comparison
  85325. */
  85326. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  85327. /**
  85328. * Resets the different lists of submeshes to prepare a new frame.
  85329. */
  85330. prepare(): void;
  85331. dispose(): void;
  85332. /**
  85333. * Inserts the submesh in its correct queue depending on its material.
  85334. * @param subMesh The submesh to dispatch
  85335. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85336. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85337. */
  85338. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85339. dispatchSprites(spriteManager: ISpriteManager): void;
  85340. dispatchParticles(particleSystem: IParticleSystem): void;
  85341. private _renderParticles;
  85342. private _renderSprites;
  85343. }
  85344. }
  85345. declare module BABYLON {
  85346. /**
  85347. * Interface describing the different options available in the rendering manager
  85348. * regarding Auto Clear between groups.
  85349. */
  85350. export interface IRenderingManagerAutoClearSetup {
  85351. /**
  85352. * Defines whether or not autoclear is enable.
  85353. */
  85354. autoClear: boolean;
  85355. /**
  85356. * Defines whether or not to autoclear the depth buffer.
  85357. */
  85358. depth: boolean;
  85359. /**
  85360. * Defines whether or not to autoclear the stencil buffer.
  85361. */
  85362. stencil: boolean;
  85363. }
  85364. /**
  85365. * This class is used by the onRenderingGroupObservable
  85366. */
  85367. export class RenderingGroupInfo {
  85368. /**
  85369. * The Scene that being rendered
  85370. */
  85371. scene: Scene;
  85372. /**
  85373. * The camera currently used for the rendering pass
  85374. */
  85375. camera: Nullable<Camera>;
  85376. /**
  85377. * The ID of the renderingGroup being processed
  85378. */
  85379. renderingGroupId: number;
  85380. }
  85381. /**
  85382. * This is the manager responsible of all the rendering for meshes sprites and particles.
  85383. * It is enable to manage the different groups as well as the different necessary sort functions.
  85384. * This should not be used directly aside of the few static configurations
  85385. */
  85386. export class RenderingManager {
  85387. /**
  85388. * The max id used for rendering groups (not included)
  85389. */
  85390. static MAX_RENDERINGGROUPS: number;
  85391. /**
  85392. * The min id used for rendering groups (included)
  85393. */
  85394. static MIN_RENDERINGGROUPS: number;
  85395. /**
  85396. * Used to globally prevent autoclearing scenes.
  85397. */
  85398. static AUTOCLEAR: boolean;
  85399. /**
  85400. * @hidden
  85401. */
  85402. _useSceneAutoClearSetup: boolean;
  85403. private _scene;
  85404. private _renderingGroups;
  85405. private _depthStencilBufferAlreadyCleaned;
  85406. private _autoClearDepthStencil;
  85407. private _customOpaqueSortCompareFn;
  85408. private _customAlphaTestSortCompareFn;
  85409. private _customTransparentSortCompareFn;
  85410. private _renderingGroupInfo;
  85411. /**
  85412. * Instantiates a new rendering group for a particular scene
  85413. * @param scene Defines the scene the groups belongs to
  85414. */
  85415. constructor(scene: Scene);
  85416. private _clearDepthStencilBuffer;
  85417. /**
  85418. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85419. * @hidden
  85420. */
  85421. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85422. /**
  85423. * Resets the different information of the group to prepare a new frame
  85424. * @hidden
  85425. */
  85426. reset(): void;
  85427. /**
  85428. * Dispose and release the group and its associated resources.
  85429. * @hidden
  85430. */
  85431. dispose(): void;
  85432. /**
  85433. * Clear the info related to rendering groups preventing retention points during dispose.
  85434. */
  85435. freeRenderingGroups(): void;
  85436. private _prepareRenderingGroup;
  85437. /**
  85438. * Add a sprite manager to the rendering manager in order to render it this frame.
  85439. * @param spriteManager Define the sprite manager to render
  85440. */
  85441. dispatchSprites(spriteManager: ISpriteManager): void;
  85442. /**
  85443. * Add a particle system to the rendering manager in order to render it this frame.
  85444. * @param particleSystem Define the particle system to render
  85445. */
  85446. dispatchParticles(particleSystem: IParticleSystem): void;
  85447. /**
  85448. * Add a submesh to the manager in order to render it this frame
  85449. * @param subMesh The submesh to dispatch
  85450. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85451. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85452. */
  85453. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85454. /**
  85455. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85456. * This allowed control for front to back rendering or reversly depending of the special needs.
  85457. *
  85458. * @param renderingGroupId The rendering group id corresponding to its index
  85459. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85460. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85461. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85462. */
  85463. 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;
  85464. /**
  85465. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85466. *
  85467. * @param renderingGroupId The rendering group id corresponding to its index
  85468. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85469. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85470. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85471. */
  85472. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85473. /**
  85474. * Gets the current auto clear configuration for one rendering group of the rendering
  85475. * manager.
  85476. * @param index the rendering group index to get the information for
  85477. * @returns The auto clear setup for the requested rendering group
  85478. */
  85479. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85480. }
  85481. }
  85482. declare module BABYLON {
  85483. /**
  85484. * This Helps creating a texture that will be created from a camera in your scene.
  85485. * It is basically a dynamic texture that could be used to create special effects for instance.
  85486. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85487. */
  85488. export class RenderTargetTexture extends Texture {
  85489. isCube: boolean;
  85490. /**
  85491. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85492. */
  85493. static readonly REFRESHRATE_RENDER_ONCE: number;
  85494. /**
  85495. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85496. */
  85497. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85498. /**
  85499. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85500. * the central point of your effect and can save a lot of performances.
  85501. */
  85502. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85503. /**
  85504. * Use this predicate to dynamically define the list of mesh you want to render.
  85505. * If set, the renderList property will be overwritten.
  85506. */
  85507. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85508. private _renderList;
  85509. /**
  85510. * Use this list to define the list of mesh you want to render.
  85511. */
  85512. renderList: Nullable<Array<AbstractMesh>>;
  85513. private _hookArray;
  85514. /**
  85515. * Define if particles should be rendered in your texture.
  85516. */
  85517. renderParticles: boolean;
  85518. /**
  85519. * Define if sprites should be rendered in your texture.
  85520. */
  85521. renderSprites: boolean;
  85522. /**
  85523. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85524. */
  85525. coordinatesMode: number;
  85526. /**
  85527. * Define the camera used to render the texture.
  85528. */
  85529. activeCamera: Nullable<Camera>;
  85530. /**
  85531. * Override the render function of the texture with your own one.
  85532. */
  85533. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85534. /**
  85535. * Define if camera post processes should be use while rendering the texture.
  85536. */
  85537. useCameraPostProcesses: boolean;
  85538. /**
  85539. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85540. */
  85541. ignoreCameraViewport: boolean;
  85542. private _postProcessManager;
  85543. private _postProcesses;
  85544. private _resizeObserver;
  85545. /**
  85546. * An event triggered when the texture is unbind.
  85547. */
  85548. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85549. /**
  85550. * An event triggered when the texture is unbind.
  85551. */
  85552. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85553. private _onAfterUnbindObserver;
  85554. /**
  85555. * Set a after unbind callback in the texture.
  85556. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85557. */
  85558. onAfterUnbind: () => void;
  85559. /**
  85560. * An event triggered before rendering the texture
  85561. */
  85562. onBeforeRenderObservable: Observable<number>;
  85563. private _onBeforeRenderObserver;
  85564. /**
  85565. * Set a before render callback in the texture.
  85566. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85567. */
  85568. onBeforeRender: (faceIndex: number) => void;
  85569. /**
  85570. * An event triggered after rendering the texture
  85571. */
  85572. onAfterRenderObservable: Observable<number>;
  85573. private _onAfterRenderObserver;
  85574. /**
  85575. * Set a after render callback in the texture.
  85576. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85577. */
  85578. onAfterRender: (faceIndex: number) => void;
  85579. /**
  85580. * An event triggered after the texture clear
  85581. */
  85582. onClearObservable: Observable<Engine>;
  85583. private _onClearObserver;
  85584. /**
  85585. * Set a clear callback in the texture.
  85586. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85587. */
  85588. onClear: (Engine: Engine) => void;
  85589. /**
  85590. * An event triggered when the texture is resized.
  85591. */
  85592. onResizeObservable: Observable<RenderTargetTexture>;
  85593. /**
  85594. * Define the clear color of the Render Target if it should be different from the scene.
  85595. */
  85596. clearColor: Color4;
  85597. protected _size: number | {
  85598. width: number;
  85599. height: number;
  85600. };
  85601. protected _initialSizeParameter: number | {
  85602. width: number;
  85603. height: number;
  85604. } | {
  85605. ratio: number;
  85606. };
  85607. protected _sizeRatio: Nullable<number>;
  85608. /** @hidden */
  85609. _generateMipMaps: boolean;
  85610. protected _renderingManager: RenderingManager;
  85611. /** @hidden */
  85612. _waitingRenderList: string[];
  85613. protected _doNotChangeAspectRatio: boolean;
  85614. protected _currentRefreshId: number;
  85615. protected _refreshRate: number;
  85616. protected _textureMatrix: Matrix;
  85617. protected _samples: number;
  85618. protected _renderTargetOptions: RenderTargetCreationOptions;
  85619. /**
  85620. * Gets render target creation options that were used.
  85621. */
  85622. readonly renderTargetOptions: RenderTargetCreationOptions;
  85623. protected _engine: Engine;
  85624. protected _onRatioRescale(): void;
  85625. /**
  85626. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85627. * It must define where the camera used to render the texture is set
  85628. */
  85629. boundingBoxPosition: Vector3;
  85630. private _boundingBoxSize;
  85631. /**
  85632. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85633. * When defined, the cubemap will switch to local mode
  85634. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85635. * @example https://www.babylonjs-playground.com/#RNASML
  85636. */
  85637. boundingBoxSize: Vector3;
  85638. /**
  85639. * In case the RTT has been created with a depth texture, get the associated
  85640. * depth texture.
  85641. * Otherwise, return null.
  85642. */
  85643. depthStencilTexture: Nullable<InternalTexture>;
  85644. /**
  85645. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85646. * or used a shadow, depth texture...
  85647. * @param name The friendly name of the texture
  85648. * @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)
  85649. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85650. * @param generateMipMaps True if mip maps need to be generated after render.
  85651. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85652. * @param type The type of the buffer in the RTT (int, half float, float...)
  85653. * @param isCube True if a cube texture needs to be created
  85654. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85655. * @param generateDepthBuffer True to generate a depth buffer
  85656. * @param generateStencilBuffer True to generate a stencil buffer
  85657. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85658. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85659. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85660. */
  85661. constructor(name: string, size: number | {
  85662. width: number;
  85663. height: number;
  85664. } | {
  85665. ratio: number;
  85666. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85667. /**
  85668. * Creates a depth stencil texture.
  85669. * This is only available in WebGL 2 or with the depth texture extension available.
  85670. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85671. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85672. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85673. */
  85674. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85675. private _processSizeParameter;
  85676. /**
  85677. * Define the number of samples to use in case of MSAA.
  85678. * It defaults to one meaning no MSAA has been enabled.
  85679. */
  85680. samples: number;
  85681. /**
  85682. * Resets the refresh counter of the texture and start bak from scratch.
  85683. * Could be useful to regenerate the texture if it is setup to render only once.
  85684. */
  85685. resetRefreshCounter(): void;
  85686. /**
  85687. * Define the refresh rate of the texture or the rendering frequency.
  85688. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85689. */
  85690. refreshRate: number;
  85691. /**
  85692. * Adds a post process to the render target rendering passes.
  85693. * @param postProcess define the post process to add
  85694. */
  85695. addPostProcess(postProcess: PostProcess): void;
  85696. /**
  85697. * Clear all the post processes attached to the render target
  85698. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85699. */
  85700. clearPostProcesses(dispose?: boolean): void;
  85701. /**
  85702. * Remove one of the post process from the list of attached post processes to the texture
  85703. * @param postProcess define the post process to remove from the list
  85704. */
  85705. removePostProcess(postProcess: PostProcess): void;
  85706. /** @hidden */
  85707. _shouldRender(): boolean;
  85708. /**
  85709. * Gets the actual render size of the texture.
  85710. * @returns the width of the render size
  85711. */
  85712. getRenderSize(): number;
  85713. /**
  85714. * Gets the actual render width of the texture.
  85715. * @returns the width of the render size
  85716. */
  85717. getRenderWidth(): number;
  85718. /**
  85719. * Gets the actual render height of the texture.
  85720. * @returns the height of the render size
  85721. */
  85722. getRenderHeight(): number;
  85723. /**
  85724. * Get if the texture can be rescaled or not.
  85725. */
  85726. readonly canRescale: boolean;
  85727. /**
  85728. * Resize the texture using a ratio.
  85729. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85730. */
  85731. scale(ratio: number): void;
  85732. /**
  85733. * Get the texture reflection matrix used to rotate/transform the reflection.
  85734. * @returns the reflection matrix
  85735. */
  85736. getReflectionTextureMatrix(): Matrix;
  85737. /**
  85738. * Resize the texture to a new desired size.
  85739. * Be carrefull as it will recreate all the data in the new texture.
  85740. * @param size Define the new size. It can be:
  85741. * - a number for squared texture,
  85742. * - an object containing { width: number, height: number }
  85743. * - or an object containing a ratio { ratio: number }
  85744. */
  85745. resize(size: number | {
  85746. width: number;
  85747. height: number;
  85748. } | {
  85749. ratio: number;
  85750. }): void;
  85751. /**
  85752. * Renders all the objects from the render list into the texture.
  85753. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85754. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85755. */
  85756. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85757. private _bestReflectionRenderTargetDimension;
  85758. /**
  85759. * @hidden
  85760. * @param faceIndex face index to bind to if this is a cubetexture
  85761. */
  85762. _bindFrameBuffer(faceIndex?: number): void;
  85763. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85764. private renderToTarget;
  85765. /**
  85766. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85767. * This allowed control for front to back rendering or reversly depending of the special needs.
  85768. *
  85769. * @param renderingGroupId The rendering group id corresponding to its index
  85770. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85771. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85772. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85773. */
  85774. 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;
  85775. /**
  85776. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85777. *
  85778. * @param renderingGroupId The rendering group id corresponding to its index
  85779. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85780. */
  85781. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85782. /**
  85783. * Clones the texture.
  85784. * @returns the cloned texture
  85785. */
  85786. clone(): RenderTargetTexture;
  85787. /**
  85788. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85789. * @returns The JSON representation of the texture
  85790. */
  85791. serialize(): any;
  85792. /**
  85793. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85794. */
  85795. disposeFramebufferObjects(): void;
  85796. /**
  85797. * Dispose the texture and release its associated resources.
  85798. */
  85799. dispose(): void;
  85800. /** @hidden */
  85801. _rebuild(): void;
  85802. /**
  85803. * Clear the info related to rendering groups preventing retention point in material dispose.
  85804. */
  85805. freeRenderingGroups(): void;
  85806. /**
  85807. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85808. * @returns the view count
  85809. */
  85810. getViewCount(): number;
  85811. }
  85812. }
  85813. declare module BABYLON {
  85814. /**
  85815. * Base class for the main features of a material in Babylon.js
  85816. */
  85817. export class Material implements IAnimatable {
  85818. /**
  85819. * Returns the triangle fill mode
  85820. */
  85821. static readonly TriangleFillMode: number;
  85822. /**
  85823. * Returns the wireframe mode
  85824. */
  85825. static readonly WireFrameFillMode: number;
  85826. /**
  85827. * Returns the point fill mode
  85828. */
  85829. static readonly PointFillMode: number;
  85830. /**
  85831. * Returns the point list draw mode
  85832. */
  85833. static readonly PointListDrawMode: number;
  85834. /**
  85835. * Returns the line list draw mode
  85836. */
  85837. static readonly LineListDrawMode: number;
  85838. /**
  85839. * Returns the line loop draw mode
  85840. */
  85841. static readonly LineLoopDrawMode: number;
  85842. /**
  85843. * Returns the line strip draw mode
  85844. */
  85845. static readonly LineStripDrawMode: number;
  85846. /**
  85847. * Returns the triangle strip draw mode
  85848. */
  85849. static readonly TriangleStripDrawMode: number;
  85850. /**
  85851. * Returns the triangle fan draw mode
  85852. */
  85853. static readonly TriangleFanDrawMode: number;
  85854. /**
  85855. * Stores the clock-wise side orientation
  85856. */
  85857. static readonly ClockWiseSideOrientation: number;
  85858. /**
  85859. * Stores the counter clock-wise side orientation
  85860. */
  85861. static readonly CounterClockWiseSideOrientation: number;
  85862. /**
  85863. * The dirty texture flag value
  85864. */
  85865. static readonly TextureDirtyFlag: number;
  85866. /**
  85867. * The dirty light flag value
  85868. */
  85869. static readonly LightDirtyFlag: number;
  85870. /**
  85871. * The dirty fresnel flag value
  85872. */
  85873. static readonly FresnelDirtyFlag: number;
  85874. /**
  85875. * The dirty attribute flag value
  85876. */
  85877. static readonly AttributesDirtyFlag: number;
  85878. /**
  85879. * The dirty misc flag value
  85880. */
  85881. static readonly MiscDirtyFlag: number;
  85882. /**
  85883. * The all dirty flag value
  85884. */
  85885. static readonly AllDirtyFlag: number;
  85886. /**
  85887. * The ID of the material
  85888. */
  85889. id: string;
  85890. /**
  85891. * Gets or sets the unique id of the material
  85892. */
  85893. uniqueId: number;
  85894. /**
  85895. * The name of the material
  85896. */
  85897. name: string;
  85898. /**
  85899. * Gets or sets user defined metadata
  85900. */
  85901. metadata: any;
  85902. /**
  85903. * For internal use only. Please do not use.
  85904. */
  85905. reservedDataStore: any;
  85906. /**
  85907. * Specifies if the ready state should be checked on each call
  85908. */
  85909. checkReadyOnEveryCall: boolean;
  85910. /**
  85911. * Specifies if the ready state should be checked once
  85912. */
  85913. checkReadyOnlyOnce: boolean;
  85914. /**
  85915. * The state of the material
  85916. */
  85917. state: string;
  85918. /**
  85919. * The alpha value of the material
  85920. */
  85921. protected _alpha: number;
  85922. /**
  85923. * List of inspectable custom properties (used by the Inspector)
  85924. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85925. */
  85926. inspectableCustomProperties: IInspectable[];
  85927. /**
  85928. * Sets the alpha value of the material
  85929. */
  85930. /**
  85931. * Gets the alpha value of the material
  85932. */
  85933. alpha: number;
  85934. /**
  85935. * Specifies if back face culling is enabled
  85936. */
  85937. protected _backFaceCulling: boolean;
  85938. /**
  85939. * Sets the back-face culling state
  85940. */
  85941. /**
  85942. * Gets the back-face culling state
  85943. */
  85944. backFaceCulling: boolean;
  85945. /**
  85946. * Stores the value for side orientation
  85947. */
  85948. sideOrientation: number;
  85949. /**
  85950. * Callback triggered when the material is compiled
  85951. */
  85952. onCompiled: Nullable<(effect: Effect) => void>;
  85953. /**
  85954. * Callback triggered when an error occurs
  85955. */
  85956. onError: Nullable<(effect: Effect, errors: string) => void>;
  85957. /**
  85958. * Callback triggered to get the render target textures
  85959. */
  85960. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85961. /**
  85962. * Gets a boolean indicating that current material needs to register RTT
  85963. */
  85964. readonly hasRenderTargetTextures: boolean;
  85965. /**
  85966. * Specifies if the material should be serialized
  85967. */
  85968. doNotSerialize: boolean;
  85969. /**
  85970. * @hidden
  85971. */
  85972. _storeEffectOnSubMeshes: boolean;
  85973. /**
  85974. * Stores the animations for the material
  85975. */
  85976. animations: Nullable<Array<Animation>>;
  85977. /**
  85978. * An event triggered when the material is disposed
  85979. */
  85980. onDisposeObservable: Observable<Material>;
  85981. /**
  85982. * An observer which watches for dispose events
  85983. */
  85984. private _onDisposeObserver;
  85985. private _onUnBindObservable;
  85986. /**
  85987. * Called during a dispose event
  85988. */
  85989. onDispose: () => void;
  85990. private _onBindObservable;
  85991. /**
  85992. * An event triggered when the material is bound
  85993. */
  85994. readonly onBindObservable: Observable<AbstractMesh>;
  85995. /**
  85996. * An observer which watches for bind events
  85997. */
  85998. private _onBindObserver;
  85999. /**
  86000. * Called during a bind event
  86001. */
  86002. onBind: (Mesh: AbstractMesh) => void;
  86003. /**
  86004. * An event triggered when the material is unbound
  86005. */
  86006. readonly onUnBindObservable: Observable<Material>;
  86007. /**
  86008. * Stores the value of the alpha mode
  86009. */
  86010. private _alphaMode;
  86011. /**
  86012. * Sets the value of the alpha mode.
  86013. *
  86014. * | Value | Type | Description |
  86015. * | --- | --- | --- |
  86016. * | 0 | ALPHA_DISABLE | |
  86017. * | 1 | ALPHA_ADD | |
  86018. * | 2 | ALPHA_COMBINE | |
  86019. * | 3 | ALPHA_SUBTRACT | |
  86020. * | 4 | ALPHA_MULTIPLY | |
  86021. * | 5 | ALPHA_MAXIMIZED | |
  86022. * | 6 | ALPHA_ONEONE | |
  86023. * | 7 | ALPHA_PREMULTIPLIED | |
  86024. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86025. * | 9 | ALPHA_INTERPOLATE | |
  86026. * | 10 | ALPHA_SCREENMODE | |
  86027. *
  86028. */
  86029. /**
  86030. * Gets the value of the alpha mode
  86031. */
  86032. alphaMode: number;
  86033. /**
  86034. * Stores the state of the need depth pre-pass value
  86035. */
  86036. private _needDepthPrePass;
  86037. /**
  86038. * Sets the need depth pre-pass value
  86039. */
  86040. /**
  86041. * Gets the depth pre-pass value
  86042. */
  86043. needDepthPrePass: boolean;
  86044. /**
  86045. * Specifies if depth writing should be disabled
  86046. */
  86047. disableDepthWrite: boolean;
  86048. /**
  86049. * Specifies if depth writing should be forced
  86050. */
  86051. forceDepthWrite: boolean;
  86052. /**
  86053. * Specifies if there should be a separate pass for culling
  86054. */
  86055. separateCullingPass: boolean;
  86056. /**
  86057. * Stores the state specifing if fog should be enabled
  86058. */
  86059. private _fogEnabled;
  86060. /**
  86061. * Sets the state for enabling fog
  86062. */
  86063. /**
  86064. * Gets the value of the fog enabled state
  86065. */
  86066. fogEnabled: boolean;
  86067. /**
  86068. * Stores the size of points
  86069. */
  86070. pointSize: number;
  86071. /**
  86072. * Stores the z offset value
  86073. */
  86074. zOffset: number;
  86075. /**
  86076. * Gets a value specifying if wireframe mode is enabled
  86077. */
  86078. /**
  86079. * Sets the state of wireframe mode
  86080. */
  86081. wireframe: boolean;
  86082. /**
  86083. * Gets the value specifying if point clouds are enabled
  86084. */
  86085. /**
  86086. * Sets the state of point cloud mode
  86087. */
  86088. pointsCloud: boolean;
  86089. /**
  86090. * Gets the material fill mode
  86091. */
  86092. /**
  86093. * Sets the material fill mode
  86094. */
  86095. fillMode: number;
  86096. /**
  86097. * @hidden
  86098. * Stores the effects for the material
  86099. */
  86100. _effect: Nullable<Effect>;
  86101. /**
  86102. * @hidden
  86103. * Specifies if the material was previously ready
  86104. */
  86105. _wasPreviouslyReady: boolean;
  86106. /**
  86107. * Specifies if uniform buffers should be used
  86108. */
  86109. private _useUBO;
  86110. /**
  86111. * Stores a reference to the scene
  86112. */
  86113. private _scene;
  86114. /**
  86115. * Stores the fill mode state
  86116. */
  86117. private _fillMode;
  86118. /**
  86119. * Specifies if the depth write state should be cached
  86120. */
  86121. private _cachedDepthWriteState;
  86122. /**
  86123. * Stores the uniform buffer
  86124. */
  86125. protected _uniformBuffer: UniformBuffer;
  86126. /** @hidden */
  86127. _indexInSceneMaterialArray: number;
  86128. /** @hidden */
  86129. meshMap: Nullable<{
  86130. [id: string]: AbstractMesh | undefined;
  86131. }>;
  86132. /**
  86133. * Creates a material instance
  86134. * @param name defines the name of the material
  86135. * @param scene defines the scene to reference
  86136. * @param doNotAdd specifies if the material should be added to the scene
  86137. */
  86138. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86139. /**
  86140. * Returns a string representation of the current material
  86141. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86142. * @returns a string with material information
  86143. */
  86144. toString(fullDetails?: boolean): string;
  86145. /**
  86146. * Gets the class name of the material
  86147. * @returns a string with the class name of the material
  86148. */
  86149. getClassName(): string;
  86150. /**
  86151. * Specifies if updates for the material been locked
  86152. */
  86153. readonly isFrozen: boolean;
  86154. /**
  86155. * Locks updates for the material
  86156. */
  86157. freeze(): void;
  86158. /**
  86159. * Unlocks updates for the material
  86160. */
  86161. unfreeze(): void;
  86162. /**
  86163. * Specifies if the material is ready to be used
  86164. * @param mesh defines the mesh to check
  86165. * @param useInstances specifies if instances should be used
  86166. * @returns a boolean indicating if the material is ready to be used
  86167. */
  86168. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86169. /**
  86170. * Specifies that the submesh is ready to be used
  86171. * @param mesh defines the mesh to check
  86172. * @param subMesh defines which submesh to check
  86173. * @param useInstances specifies that instances should be used
  86174. * @returns a boolean indicating that the submesh is ready or not
  86175. */
  86176. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86177. /**
  86178. * Returns the material effect
  86179. * @returns the effect associated with the material
  86180. */
  86181. getEffect(): Nullable<Effect>;
  86182. /**
  86183. * Returns the current scene
  86184. * @returns a Scene
  86185. */
  86186. getScene(): Scene;
  86187. /**
  86188. * Specifies if the material will require alpha blending
  86189. * @returns a boolean specifying if alpha blending is needed
  86190. */
  86191. needAlphaBlending(): boolean;
  86192. /**
  86193. * Specifies if the mesh will require alpha blending
  86194. * @param mesh defines the mesh to check
  86195. * @returns a boolean specifying if alpha blending is needed for the mesh
  86196. */
  86197. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86198. /**
  86199. * Specifies if this material should be rendered in alpha test mode
  86200. * @returns a boolean specifying if an alpha test is needed.
  86201. */
  86202. needAlphaTesting(): boolean;
  86203. /**
  86204. * Gets the texture used for the alpha test
  86205. * @returns the texture to use for alpha testing
  86206. */
  86207. getAlphaTestTexture(): Nullable<BaseTexture>;
  86208. /**
  86209. * Marks the material to indicate that it needs to be re-calculated
  86210. */
  86211. markDirty(): void;
  86212. /** @hidden */
  86213. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86214. /**
  86215. * Binds the material to the mesh
  86216. * @param world defines the world transformation matrix
  86217. * @param mesh defines the mesh to bind the material to
  86218. */
  86219. bind(world: Matrix, mesh?: Mesh): void;
  86220. /**
  86221. * Binds the submesh to the material
  86222. * @param world defines the world transformation matrix
  86223. * @param mesh defines the mesh containing the submesh
  86224. * @param subMesh defines the submesh to bind the material to
  86225. */
  86226. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86227. /**
  86228. * Binds the world matrix to the material
  86229. * @param world defines the world transformation matrix
  86230. */
  86231. bindOnlyWorldMatrix(world: Matrix): void;
  86232. /**
  86233. * Binds the scene's uniform buffer to the effect.
  86234. * @param effect defines the effect to bind to the scene uniform buffer
  86235. * @param sceneUbo defines the uniform buffer storing scene data
  86236. */
  86237. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  86238. /**
  86239. * Binds the view matrix to the effect
  86240. * @param effect defines the effect to bind the view matrix to
  86241. */
  86242. bindView(effect: Effect): void;
  86243. /**
  86244. * Binds the view projection matrix to the effect
  86245. * @param effect defines the effect to bind the view projection matrix to
  86246. */
  86247. bindViewProjection(effect: Effect): void;
  86248. /**
  86249. * Specifies if material alpha testing should be turned on for the mesh
  86250. * @param mesh defines the mesh to check
  86251. */
  86252. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  86253. /**
  86254. * Processes to execute after binding the material to a mesh
  86255. * @param mesh defines the rendered mesh
  86256. */
  86257. protected _afterBind(mesh?: Mesh): void;
  86258. /**
  86259. * Unbinds the material from the mesh
  86260. */
  86261. unbind(): void;
  86262. /**
  86263. * Gets the active textures from the material
  86264. * @returns an array of textures
  86265. */
  86266. getActiveTextures(): BaseTexture[];
  86267. /**
  86268. * Specifies if the material uses a texture
  86269. * @param texture defines the texture to check against the material
  86270. * @returns a boolean specifying if the material uses the texture
  86271. */
  86272. hasTexture(texture: BaseTexture): boolean;
  86273. /**
  86274. * Makes a duplicate of the material, and gives it a new name
  86275. * @param name defines the new name for the duplicated material
  86276. * @returns the cloned material
  86277. */
  86278. clone(name: string): Nullable<Material>;
  86279. /**
  86280. * Gets the meshes bound to the material
  86281. * @returns an array of meshes bound to the material
  86282. */
  86283. getBindedMeshes(): AbstractMesh[];
  86284. /**
  86285. * Force shader compilation
  86286. * @param mesh defines the mesh associated with this material
  86287. * @param onCompiled defines a function to execute once the material is compiled
  86288. * @param options defines the options to configure the compilation
  86289. */
  86290. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  86291. clipPlane: boolean;
  86292. }>): void;
  86293. /**
  86294. * Force shader compilation
  86295. * @param mesh defines the mesh that will use this material
  86296. * @param options defines additional options for compiling the shaders
  86297. * @returns a promise that resolves when the compilation completes
  86298. */
  86299. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  86300. clipPlane: boolean;
  86301. }>): Promise<void>;
  86302. private static readonly _AllDirtyCallBack;
  86303. private static readonly _ImageProcessingDirtyCallBack;
  86304. private static readonly _TextureDirtyCallBack;
  86305. private static readonly _FresnelDirtyCallBack;
  86306. private static readonly _MiscDirtyCallBack;
  86307. private static readonly _LightsDirtyCallBack;
  86308. private static readonly _AttributeDirtyCallBack;
  86309. private static _FresnelAndMiscDirtyCallBack;
  86310. private static _TextureAndMiscDirtyCallBack;
  86311. private static readonly _DirtyCallbackArray;
  86312. private static readonly _RunDirtyCallBacks;
  86313. /**
  86314. * Marks a define in the material to indicate that it needs to be re-computed
  86315. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  86316. */
  86317. markAsDirty(flag: number): void;
  86318. /**
  86319. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  86320. * @param func defines a function which checks material defines against the submeshes
  86321. */
  86322. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  86323. /**
  86324. * Indicates that we need to re-calculated for all submeshes
  86325. */
  86326. protected _markAllSubMeshesAsAllDirty(): void;
  86327. /**
  86328. * Indicates that image processing needs to be re-calculated for all submeshes
  86329. */
  86330. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  86331. /**
  86332. * Indicates that textures need to be re-calculated for all submeshes
  86333. */
  86334. protected _markAllSubMeshesAsTexturesDirty(): void;
  86335. /**
  86336. * Indicates that fresnel needs to be re-calculated for all submeshes
  86337. */
  86338. protected _markAllSubMeshesAsFresnelDirty(): void;
  86339. /**
  86340. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  86341. */
  86342. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  86343. /**
  86344. * Indicates that lights need to be re-calculated for all submeshes
  86345. */
  86346. protected _markAllSubMeshesAsLightsDirty(): void;
  86347. /**
  86348. * Indicates that attributes need to be re-calculated for all submeshes
  86349. */
  86350. protected _markAllSubMeshesAsAttributesDirty(): void;
  86351. /**
  86352. * Indicates that misc needs to be re-calculated for all submeshes
  86353. */
  86354. protected _markAllSubMeshesAsMiscDirty(): void;
  86355. /**
  86356. * Indicates that textures and misc need to be re-calculated for all submeshes
  86357. */
  86358. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  86359. /**
  86360. * Disposes the material
  86361. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86362. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86363. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86364. */
  86365. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86366. /** @hidden */
  86367. private releaseVertexArrayObject;
  86368. /**
  86369. * Serializes this material
  86370. * @returns the serialized material object
  86371. */
  86372. serialize(): any;
  86373. /**
  86374. * Creates a material from parsed material data
  86375. * @param parsedMaterial defines parsed material data
  86376. * @param scene defines the hosting scene
  86377. * @param rootUrl defines the root URL to use to load textures
  86378. * @returns a new material
  86379. */
  86380. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  86381. }
  86382. }
  86383. declare module BABYLON {
  86384. /**
  86385. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86386. * separate meshes. This can be use to improve performances.
  86387. * @see http://doc.babylonjs.com/how_to/multi_materials
  86388. */
  86389. export class MultiMaterial extends Material {
  86390. private _subMaterials;
  86391. /**
  86392. * Gets or Sets the list of Materials used within the multi material.
  86393. * They need to be ordered according to the submeshes order in the associated mesh
  86394. */
  86395. subMaterials: Nullable<Material>[];
  86396. /**
  86397. * Function used to align with Node.getChildren()
  86398. * @returns the list of Materials used within the multi material
  86399. */
  86400. getChildren(): Nullable<Material>[];
  86401. /**
  86402. * Instantiates a new Multi Material
  86403. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86404. * separate meshes. This can be use to improve performances.
  86405. * @see http://doc.babylonjs.com/how_to/multi_materials
  86406. * @param name Define the name in the scene
  86407. * @param scene Define the scene the material belongs to
  86408. */
  86409. constructor(name: string, scene: Scene);
  86410. private _hookArray;
  86411. /**
  86412. * Get one of the submaterial by its index in the submaterials array
  86413. * @param index The index to look the sub material at
  86414. * @returns The Material if the index has been defined
  86415. */
  86416. getSubMaterial(index: number): Nullable<Material>;
  86417. /**
  86418. * Get the list of active textures for the whole sub materials list.
  86419. * @returns All the textures that will be used during the rendering
  86420. */
  86421. getActiveTextures(): BaseTexture[];
  86422. /**
  86423. * Gets the current class name of the material e.g. "MultiMaterial"
  86424. * Mainly use in serialization.
  86425. * @returns the class name
  86426. */
  86427. getClassName(): string;
  86428. /**
  86429. * Checks if the material is ready to render the requested sub mesh
  86430. * @param mesh Define the mesh the submesh belongs to
  86431. * @param subMesh Define the sub mesh to look readyness for
  86432. * @param useInstances Define whether or not the material is used with instances
  86433. * @returns true if ready, otherwise false
  86434. */
  86435. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86436. /**
  86437. * Clones the current material and its related sub materials
  86438. * @param name Define the name of the newly cloned material
  86439. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86440. * @returns the cloned material
  86441. */
  86442. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86443. /**
  86444. * Serializes the materials into a JSON representation.
  86445. * @returns the JSON representation
  86446. */
  86447. serialize(): any;
  86448. /**
  86449. * Dispose the material and release its associated resources
  86450. * @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)
  86451. * @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)
  86452. * @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)
  86453. */
  86454. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86455. /**
  86456. * Creates a MultiMaterial from parsed MultiMaterial data.
  86457. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86458. * @param scene defines the hosting scene
  86459. * @returns a new MultiMaterial
  86460. */
  86461. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86462. }
  86463. }
  86464. declare module BABYLON {
  86465. /**
  86466. * Base class for submeshes
  86467. */
  86468. export class BaseSubMesh {
  86469. /** @hidden */
  86470. _materialDefines: Nullable<MaterialDefines>;
  86471. /** @hidden */
  86472. _materialEffect: Nullable<Effect>;
  86473. /**
  86474. * Gets associated effect
  86475. */
  86476. readonly effect: Nullable<Effect>;
  86477. /**
  86478. * Sets associated effect (effect used to render this submesh)
  86479. * @param effect defines the effect to associate with
  86480. * @param defines defines the set of defines used to compile this effect
  86481. */
  86482. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86483. }
  86484. /**
  86485. * Defines a subdivision inside a mesh
  86486. */
  86487. export class SubMesh extends BaseSubMesh implements ICullable {
  86488. /** the material index to use */
  86489. materialIndex: number;
  86490. /** vertex index start */
  86491. verticesStart: number;
  86492. /** vertices count */
  86493. verticesCount: number;
  86494. /** index start */
  86495. indexStart: number;
  86496. /** indices count */
  86497. indexCount: number;
  86498. /** @hidden */
  86499. _linesIndexCount: number;
  86500. private _mesh;
  86501. private _renderingMesh;
  86502. private _boundingInfo;
  86503. private _linesIndexBuffer;
  86504. /** @hidden */
  86505. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86506. /** @hidden */
  86507. _trianglePlanes: Plane[];
  86508. /** @hidden */
  86509. _lastColliderTransformMatrix: Nullable<Matrix>;
  86510. /** @hidden */
  86511. _renderId: number;
  86512. /** @hidden */
  86513. _alphaIndex: number;
  86514. /** @hidden */
  86515. _distanceToCamera: number;
  86516. /** @hidden */
  86517. _id: number;
  86518. private _currentMaterial;
  86519. /**
  86520. * Add a new submesh to a mesh
  86521. * @param materialIndex defines the material index to use
  86522. * @param verticesStart defines vertex index start
  86523. * @param verticesCount defines vertices count
  86524. * @param indexStart defines index start
  86525. * @param indexCount defines indices count
  86526. * @param mesh defines the parent mesh
  86527. * @param renderingMesh defines an optional rendering mesh
  86528. * @param createBoundingBox defines if bounding box should be created for this submesh
  86529. * @returns the new submesh
  86530. */
  86531. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86532. /**
  86533. * Creates a new submesh
  86534. * @param materialIndex defines the material index to use
  86535. * @param verticesStart defines vertex index start
  86536. * @param verticesCount defines vertices count
  86537. * @param indexStart defines index start
  86538. * @param indexCount defines indices count
  86539. * @param mesh defines the parent mesh
  86540. * @param renderingMesh defines an optional rendering mesh
  86541. * @param createBoundingBox defines if bounding box should be created for this submesh
  86542. */
  86543. constructor(
  86544. /** the material index to use */
  86545. materialIndex: number,
  86546. /** vertex index start */
  86547. verticesStart: number,
  86548. /** vertices count */
  86549. verticesCount: number,
  86550. /** index start */
  86551. indexStart: number,
  86552. /** indices count */
  86553. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86554. /**
  86555. * Returns true if this submesh covers the entire parent mesh
  86556. * @ignorenaming
  86557. */
  86558. readonly IsGlobal: boolean;
  86559. /**
  86560. * Returns the submesh BoudingInfo object
  86561. * @returns current bounding info (or mesh's one if the submesh is global)
  86562. */
  86563. getBoundingInfo(): BoundingInfo;
  86564. /**
  86565. * Sets the submesh BoundingInfo
  86566. * @param boundingInfo defines the new bounding info to use
  86567. * @returns the SubMesh
  86568. */
  86569. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86570. /**
  86571. * Returns the mesh of the current submesh
  86572. * @return the parent mesh
  86573. */
  86574. getMesh(): AbstractMesh;
  86575. /**
  86576. * Returns the rendering mesh of the submesh
  86577. * @returns the rendering mesh (could be different from parent mesh)
  86578. */
  86579. getRenderingMesh(): Mesh;
  86580. /**
  86581. * Returns the submesh material
  86582. * @returns null or the current material
  86583. */
  86584. getMaterial(): Nullable<Material>;
  86585. /**
  86586. * Sets a new updated BoundingInfo object to the submesh
  86587. * @param data defines an optional position array to use to determine the bounding info
  86588. * @returns the SubMesh
  86589. */
  86590. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86591. /** @hidden */
  86592. _checkCollision(collider: Collider): boolean;
  86593. /**
  86594. * Updates the submesh BoundingInfo
  86595. * @param world defines the world matrix to use to update the bounding info
  86596. * @returns the submesh
  86597. */
  86598. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86599. /**
  86600. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86601. * @param frustumPlanes defines the frustum planes
  86602. * @returns true if the submesh is intersecting with the frustum
  86603. */
  86604. isInFrustum(frustumPlanes: Plane[]): boolean;
  86605. /**
  86606. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86607. * @param frustumPlanes defines the frustum planes
  86608. * @returns true if the submesh is inside the frustum
  86609. */
  86610. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86611. /**
  86612. * Renders the submesh
  86613. * @param enableAlphaMode defines if alpha needs to be used
  86614. * @returns the submesh
  86615. */
  86616. render(enableAlphaMode: boolean): SubMesh;
  86617. /**
  86618. * @hidden
  86619. */
  86620. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86621. /**
  86622. * Checks if the submesh intersects with a ray
  86623. * @param ray defines the ray to test
  86624. * @returns true is the passed ray intersects the submesh bounding box
  86625. */
  86626. canIntersects(ray: Ray): boolean;
  86627. /**
  86628. * Intersects current submesh with a ray
  86629. * @param ray defines the ray to test
  86630. * @param positions defines mesh's positions array
  86631. * @param indices defines mesh's indices array
  86632. * @param fastCheck defines if only bounding info should be used
  86633. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86634. * @returns intersection info or null if no intersection
  86635. */
  86636. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86637. /** @hidden */
  86638. private _intersectLines;
  86639. /** @hidden */
  86640. private _intersectUnIndexedLines;
  86641. /** @hidden */
  86642. private _intersectTriangles;
  86643. /** @hidden */
  86644. private _intersectUnIndexedTriangles;
  86645. /** @hidden */
  86646. _rebuild(): void;
  86647. /**
  86648. * Creates a new submesh from the passed mesh
  86649. * @param newMesh defines the new hosting mesh
  86650. * @param newRenderingMesh defines an optional rendering mesh
  86651. * @returns the new submesh
  86652. */
  86653. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86654. /**
  86655. * Release associated resources
  86656. */
  86657. dispose(): void;
  86658. /**
  86659. * Gets the class name
  86660. * @returns the string "SubMesh".
  86661. */
  86662. getClassName(): string;
  86663. /**
  86664. * Creates a new submesh from indices data
  86665. * @param materialIndex the index of the main mesh material
  86666. * @param startIndex the index where to start the copy in the mesh indices array
  86667. * @param indexCount the number of indices to copy then from the startIndex
  86668. * @param mesh the main mesh to create the submesh from
  86669. * @param renderingMesh the optional rendering mesh
  86670. * @returns a new submesh
  86671. */
  86672. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86673. }
  86674. }
  86675. declare module BABYLON {
  86676. /**
  86677. * Class used to represent data loading progression
  86678. */
  86679. export class SceneLoaderFlags {
  86680. private static _ForceFullSceneLoadingForIncremental;
  86681. private static _ShowLoadingScreen;
  86682. private static _CleanBoneMatrixWeights;
  86683. private static _loggingLevel;
  86684. /**
  86685. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86686. */
  86687. static ForceFullSceneLoadingForIncremental: boolean;
  86688. /**
  86689. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86690. */
  86691. static ShowLoadingScreen: boolean;
  86692. /**
  86693. * Defines the current logging level (while loading the scene)
  86694. * @ignorenaming
  86695. */
  86696. static loggingLevel: number;
  86697. /**
  86698. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86699. */
  86700. static CleanBoneMatrixWeights: boolean;
  86701. }
  86702. }
  86703. declare module BABYLON {
  86704. /**
  86705. * Class used to store geometry data (vertex buffers + index buffer)
  86706. */
  86707. export class Geometry implements IGetSetVerticesData {
  86708. /**
  86709. * Gets or sets the ID of the geometry
  86710. */
  86711. id: string;
  86712. /**
  86713. * Gets or sets the unique ID of the geometry
  86714. */
  86715. uniqueId: number;
  86716. /**
  86717. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86718. */
  86719. delayLoadState: number;
  86720. /**
  86721. * Gets the file containing the data to load when running in delay load state
  86722. */
  86723. delayLoadingFile: Nullable<string>;
  86724. /**
  86725. * Callback called when the geometry is updated
  86726. */
  86727. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86728. private _scene;
  86729. private _engine;
  86730. private _meshes;
  86731. private _totalVertices;
  86732. /** @hidden */
  86733. _indices: IndicesArray;
  86734. /** @hidden */
  86735. _vertexBuffers: {
  86736. [key: string]: VertexBuffer;
  86737. };
  86738. private _isDisposed;
  86739. private _extend;
  86740. private _boundingBias;
  86741. /** @hidden */
  86742. _delayInfo: Array<string>;
  86743. private _indexBuffer;
  86744. private _indexBufferIsUpdatable;
  86745. /** @hidden */
  86746. _boundingInfo: Nullable<BoundingInfo>;
  86747. /** @hidden */
  86748. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86749. /** @hidden */
  86750. _softwareSkinningFrameId: number;
  86751. private _vertexArrayObjects;
  86752. private _updatable;
  86753. /** @hidden */
  86754. _positions: Nullable<Vector3[]>;
  86755. /**
  86756. * 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
  86757. */
  86758. /**
  86759. * 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
  86760. */
  86761. boundingBias: Vector2;
  86762. /**
  86763. * Static function used to attach a new empty geometry to a mesh
  86764. * @param mesh defines the mesh to attach the geometry to
  86765. * @returns the new Geometry
  86766. */
  86767. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86768. /**
  86769. * Creates a new geometry
  86770. * @param id defines the unique ID
  86771. * @param scene defines the hosting scene
  86772. * @param vertexData defines the VertexData used to get geometry data
  86773. * @param updatable defines if geometry must be updatable (false by default)
  86774. * @param mesh defines the mesh that will be associated with the geometry
  86775. */
  86776. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86777. /**
  86778. * Gets the current extend of the geometry
  86779. */
  86780. readonly extend: {
  86781. minimum: Vector3;
  86782. maximum: Vector3;
  86783. };
  86784. /**
  86785. * Gets the hosting scene
  86786. * @returns the hosting Scene
  86787. */
  86788. getScene(): Scene;
  86789. /**
  86790. * Gets the hosting engine
  86791. * @returns the hosting Engine
  86792. */
  86793. getEngine(): Engine;
  86794. /**
  86795. * Defines if the geometry is ready to use
  86796. * @returns true if the geometry is ready to be used
  86797. */
  86798. isReady(): boolean;
  86799. /**
  86800. * Gets a value indicating that the geometry should not be serialized
  86801. */
  86802. readonly doNotSerialize: boolean;
  86803. /** @hidden */
  86804. _rebuild(): void;
  86805. /**
  86806. * Affects all geometry data in one call
  86807. * @param vertexData defines the geometry data
  86808. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86809. */
  86810. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86811. /**
  86812. * Set specific vertex data
  86813. * @param kind defines the data kind (Position, normal, etc...)
  86814. * @param data defines the vertex data to use
  86815. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86816. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86817. */
  86818. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86819. /**
  86820. * Removes a specific vertex data
  86821. * @param kind defines the data kind (Position, normal, etc...)
  86822. */
  86823. removeVerticesData(kind: string): void;
  86824. /**
  86825. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86826. * @param buffer defines the vertex buffer to use
  86827. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86828. */
  86829. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86830. /**
  86831. * Update a specific vertex buffer
  86832. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86833. * It will do nothing if the buffer is not updatable
  86834. * @param kind defines the data kind (Position, normal, etc...)
  86835. * @param data defines the data to use
  86836. * @param offset defines the offset in the target buffer where to store the data
  86837. * @param useBytes set to true if the offset is in bytes
  86838. */
  86839. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86840. /**
  86841. * Update a specific vertex buffer
  86842. * This function will create a new buffer if the current one is not updatable
  86843. * @param kind defines the data kind (Position, normal, etc...)
  86844. * @param data defines the data to use
  86845. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86846. */
  86847. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86848. private _updateBoundingInfo;
  86849. /** @hidden */
  86850. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86851. /**
  86852. * Gets total number of vertices
  86853. * @returns the total number of vertices
  86854. */
  86855. getTotalVertices(): number;
  86856. /**
  86857. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86858. * @param kind defines the data kind (Position, normal, etc...)
  86859. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86860. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86861. * @returns a float array containing vertex data
  86862. */
  86863. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86864. /**
  86865. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86866. * @param kind defines the data kind (Position, normal, etc...)
  86867. * @returns true if the vertex buffer with the specified kind is updatable
  86868. */
  86869. isVertexBufferUpdatable(kind: string): boolean;
  86870. /**
  86871. * Gets a specific vertex buffer
  86872. * @param kind defines the data kind (Position, normal, etc...)
  86873. * @returns a VertexBuffer
  86874. */
  86875. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86876. /**
  86877. * Returns all vertex buffers
  86878. * @return an object holding all vertex buffers indexed by kind
  86879. */
  86880. getVertexBuffers(): Nullable<{
  86881. [key: string]: VertexBuffer;
  86882. }>;
  86883. /**
  86884. * Gets a boolean indicating if specific vertex buffer is present
  86885. * @param kind defines the data kind (Position, normal, etc...)
  86886. * @returns true if data is present
  86887. */
  86888. isVerticesDataPresent(kind: string): boolean;
  86889. /**
  86890. * Gets a list of all attached data kinds (Position, normal, etc...)
  86891. * @returns a list of string containing all kinds
  86892. */
  86893. getVerticesDataKinds(): string[];
  86894. /**
  86895. * Update index buffer
  86896. * @param indices defines the indices to store in the index buffer
  86897. * @param offset defines the offset in the target buffer where to store the data
  86898. * @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)
  86899. */
  86900. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86901. /**
  86902. * Creates a new index buffer
  86903. * @param indices defines the indices to store in the index buffer
  86904. * @param totalVertices defines the total number of vertices (could be null)
  86905. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86906. */
  86907. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86908. /**
  86909. * Return the total number of indices
  86910. * @returns the total number of indices
  86911. */
  86912. getTotalIndices(): number;
  86913. /**
  86914. * Gets the index buffer array
  86915. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86916. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86917. * @returns the index buffer array
  86918. */
  86919. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86920. /**
  86921. * Gets the index buffer
  86922. * @return the index buffer
  86923. */
  86924. getIndexBuffer(): Nullable<DataBuffer>;
  86925. /** @hidden */
  86926. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86927. /**
  86928. * Release the associated resources for a specific mesh
  86929. * @param mesh defines the source mesh
  86930. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86931. */
  86932. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86933. /**
  86934. * Apply current geometry to a given mesh
  86935. * @param mesh defines the mesh to apply geometry to
  86936. */
  86937. applyToMesh(mesh: Mesh): void;
  86938. private _updateExtend;
  86939. private _applyToMesh;
  86940. private notifyUpdate;
  86941. /**
  86942. * Load the geometry if it was flagged as delay loaded
  86943. * @param scene defines the hosting scene
  86944. * @param onLoaded defines a callback called when the geometry is loaded
  86945. */
  86946. load(scene: Scene, onLoaded?: () => void): void;
  86947. private _queueLoad;
  86948. /**
  86949. * Invert the geometry to move from a right handed system to a left handed one.
  86950. */
  86951. toLeftHanded(): void;
  86952. /** @hidden */
  86953. _resetPointsArrayCache(): void;
  86954. /** @hidden */
  86955. _generatePointsArray(): boolean;
  86956. /**
  86957. * Gets a value indicating if the geometry is disposed
  86958. * @returns true if the geometry was disposed
  86959. */
  86960. isDisposed(): boolean;
  86961. private _disposeVertexArrayObjects;
  86962. /**
  86963. * Free all associated resources
  86964. */
  86965. dispose(): void;
  86966. /**
  86967. * Clone the current geometry into a new geometry
  86968. * @param id defines the unique ID of the new geometry
  86969. * @returns a new geometry object
  86970. */
  86971. copy(id: string): Geometry;
  86972. /**
  86973. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86974. * @return a JSON representation of the current geometry data (without the vertices data)
  86975. */
  86976. serialize(): any;
  86977. private toNumberArray;
  86978. /**
  86979. * Serialize all vertices data into a JSON oject
  86980. * @returns a JSON representation of the current geometry data
  86981. */
  86982. serializeVerticeData(): any;
  86983. /**
  86984. * Extracts a clone of a mesh geometry
  86985. * @param mesh defines the source mesh
  86986. * @param id defines the unique ID of the new geometry object
  86987. * @returns the new geometry object
  86988. */
  86989. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86990. /**
  86991. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86992. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86993. * Be aware Math.random() could cause collisions, but:
  86994. * "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"
  86995. * @returns a string containing a new GUID
  86996. */
  86997. static RandomId(): string;
  86998. /** @hidden */
  86999. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  87000. private static _CleanMatricesWeights;
  87001. /**
  87002. * Create a new geometry from persisted data (Using .babylon file format)
  87003. * @param parsedVertexData defines the persisted data
  87004. * @param scene defines the hosting scene
  87005. * @param rootUrl defines the root url to use to load assets (like delayed data)
  87006. * @returns the new geometry object
  87007. */
  87008. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  87009. }
  87010. }
  87011. declare module BABYLON {
  87012. /**
  87013. * Define an interface for all classes that will get and set the data on vertices
  87014. */
  87015. export interface IGetSetVerticesData {
  87016. /**
  87017. * Gets a boolean indicating if specific vertex data is present
  87018. * @param kind defines the vertex data kind to use
  87019. * @returns true is data kind is present
  87020. */
  87021. isVerticesDataPresent(kind: string): boolean;
  87022. /**
  87023. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87024. * @param kind defines the data kind (Position, normal, etc...)
  87025. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87026. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87027. * @returns a float array containing vertex data
  87028. */
  87029. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87030. /**
  87031. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87032. * @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.
  87033. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87034. * @returns the indices array or an empty array if the mesh has no geometry
  87035. */
  87036. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87037. /**
  87038. * Set specific vertex data
  87039. * @param kind defines the data kind (Position, normal, etc...)
  87040. * @param data defines the vertex data to use
  87041. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87042. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87043. */
  87044. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  87045. /**
  87046. * Update a specific associated vertex buffer
  87047. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87048. * - VertexBuffer.PositionKind
  87049. * - VertexBuffer.UVKind
  87050. * - VertexBuffer.UV2Kind
  87051. * - VertexBuffer.UV3Kind
  87052. * - VertexBuffer.UV4Kind
  87053. * - VertexBuffer.UV5Kind
  87054. * - VertexBuffer.UV6Kind
  87055. * - VertexBuffer.ColorKind
  87056. * - VertexBuffer.MatricesIndicesKind
  87057. * - VertexBuffer.MatricesIndicesExtraKind
  87058. * - VertexBuffer.MatricesWeightsKind
  87059. * - VertexBuffer.MatricesWeightsExtraKind
  87060. * @param data defines the data source
  87061. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87062. * @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)
  87063. */
  87064. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  87065. /**
  87066. * Creates a new index buffer
  87067. * @param indices defines the indices to store in the index buffer
  87068. * @param totalVertices defines the total number of vertices (could be null)
  87069. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87070. */
  87071. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  87072. }
  87073. /**
  87074. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  87075. */
  87076. export class VertexData {
  87077. /**
  87078. * Mesh side orientation : usually the external or front surface
  87079. */
  87080. static readonly FRONTSIDE: number;
  87081. /**
  87082. * Mesh side orientation : usually the internal or back surface
  87083. */
  87084. static readonly BACKSIDE: number;
  87085. /**
  87086. * Mesh side orientation : both internal and external or front and back surfaces
  87087. */
  87088. static readonly DOUBLESIDE: number;
  87089. /**
  87090. * Mesh side orientation : by default, `FRONTSIDE`
  87091. */
  87092. static readonly DEFAULTSIDE: number;
  87093. /**
  87094. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  87095. */
  87096. positions: Nullable<FloatArray>;
  87097. /**
  87098. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  87099. */
  87100. normals: Nullable<FloatArray>;
  87101. /**
  87102. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  87103. */
  87104. tangents: Nullable<FloatArray>;
  87105. /**
  87106. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87107. */
  87108. uvs: Nullable<FloatArray>;
  87109. /**
  87110. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87111. */
  87112. uvs2: Nullable<FloatArray>;
  87113. /**
  87114. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87115. */
  87116. uvs3: Nullable<FloatArray>;
  87117. /**
  87118. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87119. */
  87120. uvs4: Nullable<FloatArray>;
  87121. /**
  87122. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87123. */
  87124. uvs5: Nullable<FloatArray>;
  87125. /**
  87126. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87127. */
  87128. uvs6: Nullable<FloatArray>;
  87129. /**
  87130. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87131. */
  87132. colors: Nullable<FloatArray>;
  87133. /**
  87134. * 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).
  87135. */
  87136. matricesIndices: Nullable<FloatArray>;
  87137. /**
  87138. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87139. */
  87140. matricesWeights: Nullable<FloatArray>;
  87141. /**
  87142. * An array extending the number of possible indices
  87143. */
  87144. matricesIndicesExtra: Nullable<FloatArray>;
  87145. /**
  87146. * An array extending the number of possible weights when the number of indices is extended
  87147. */
  87148. matricesWeightsExtra: Nullable<FloatArray>;
  87149. /**
  87150. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87151. */
  87152. indices: Nullable<IndicesArray>;
  87153. /**
  87154. * Uses the passed data array to set the set the values for the specified kind of data
  87155. * @param data a linear array of floating numbers
  87156. * @param kind the type of data that is being set, eg positions, colors etc
  87157. */
  87158. set(data: FloatArray, kind: string): void;
  87159. /**
  87160. * Associates the vertexData to the passed Mesh.
  87161. * Sets it as updatable or not (default `false`)
  87162. * @param mesh the mesh the vertexData is applied to
  87163. * @param updatable when used and having the value true allows new data to update the vertexData
  87164. * @returns the VertexData
  87165. */
  87166. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87167. /**
  87168. * Associates the vertexData to the passed Geometry.
  87169. * Sets it as updatable or not (default `false`)
  87170. * @param geometry the geometry the vertexData is applied to
  87171. * @param updatable when used and having the value true allows new data to update the vertexData
  87172. * @returns VertexData
  87173. */
  87174. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87175. /**
  87176. * Updates the associated mesh
  87177. * @param mesh the mesh to be updated
  87178. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87179. * @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
  87180. * @returns VertexData
  87181. */
  87182. updateMesh(mesh: Mesh): VertexData;
  87183. /**
  87184. * Updates the associated geometry
  87185. * @param geometry the geometry to be updated
  87186. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87187. * @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
  87188. * @returns VertexData.
  87189. */
  87190. updateGeometry(geometry: Geometry): VertexData;
  87191. private _applyTo;
  87192. private _update;
  87193. /**
  87194. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87195. * @param matrix the transforming matrix
  87196. * @returns the VertexData
  87197. */
  87198. transform(matrix: Matrix): VertexData;
  87199. /**
  87200. * Merges the passed VertexData into the current one
  87201. * @param other the VertexData to be merged into the current one
  87202. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87203. * @returns the modified VertexData
  87204. */
  87205. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87206. private _mergeElement;
  87207. private _validate;
  87208. /**
  87209. * Serializes the VertexData
  87210. * @returns a serialized object
  87211. */
  87212. serialize(): any;
  87213. /**
  87214. * Extracts the vertexData from a mesh
  87215. * @param mesh the mesh from which to extract the VertexData
  87216. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87217. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87218. * @returns the object VertexData associated to the passed mesh
  87219. */
  87220. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87221. /**
  87222. * Extracts the vertexData from the geometry
  87223. * @param geometry the geometry from which to extract the VertexData
  87224. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87225. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87226. * @returns the object VertexData associated to the passed mesh
  87227. */
  87228. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87229. private static _ExtractFrom;
  87230. /**
  87231. * Creates the VertexData for a Ribbon
  87232. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87233. * * pathArray array of paths, each of which an array of successive Vector3
  87234. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87235. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87236. * * 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
  87237. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87238. * * 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)
  87239. * * 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)
  87240. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87241. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87242. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87243. * @returns the VertexData of the ribbon
  87244. */
  87245. static CreateRibbon(options: {
  87246. pathArray: Vector3[][];
  87247. closeArray?: boolean;
  87248. closePath?: boolean;
  87249. offset?: number;
  87250. sideOrientation?: number;
  87251. frontUVs?: Vector4;
  87252. backUVs?: Vector4;
  87253. invertUV?: boolean;
  87254. uvs?: Vector2[];
  87255. colors?: Color4[];
  87256. }): VertexData;
  87257. /**
  87258. * Creates the VertexData for a box
  87259. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87260. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87261. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87262. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87263. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87264. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87265. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87267. * * 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)
  87268. * * 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)
  87269. * @returns the VertexData of the box
  87270. */
  87271. static CreateBox(options: {
  87272. size?: number;
  87273. width?: number;
  87274. height?: number;
  87275. depth?: number;
  87276. faceUV?: Vector4[];
  87277. faceColors?: Color4[];
  87278. sideOrientation?: number;
  87279. frontUVs?: Vector4;
  87280. backUVs?: Vector4;
  87281. }): VertexData;
  87282. /**
  87283. * Creates the VertexData for a tiled box
  87284. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87285. * * faceTiles sets the pattern, tile size and number of tiles for a face
  87286. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87287. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87288. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87289. * @returns the VertexData of the box
  87290. */
  87291. static CreateTiledBox(options: {
  87292. pattern?: number;
  87293. width?: number;
  87294. height?: number;
  87295. depth?: number;
  87296. tileSize?: number;
  87297. tileWidth?: number;
  87298. tileHeight?: number;
  87299. alignHorizontal?: number;
  87300. alignVertical?: number;
  87301. faceUV?: Vector4[];
  87302. faceColors?: Color4[];
  87303. sideOrientation?: number;
  87304. }): VertexData;
  87305. /**
  87306. * Creates the VertexData for a tiled plane
  87307. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87308. * * pattern a limited pattern arrangement depending on the number
  87309. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  87310. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  87311. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  87312. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87313. * * 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)
  87314. * * 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)
  87315. * @returns the VertexData of the tiled plane
  87316. */
  87317. static CreateTiledPlane(options: {
  87318. pattern?: number;
  87319. tileSize?: number;
  87320. tileWidth?: number;
  87321. tileHeight?: number;
  87322. size?: number;
  87323. width?: number;
  87324. height?: number;
  87325. alignHorizontal?: number;
  87326. alignVertical?: number;
  87327. sideOrientation?: number;
  87328. frontUVs?: Vector4;
  87329. backUVs?: Vector4;
  87330. }): VertexData;
  87331. /**
  87332. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87333. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87334. * * segments sets the number of horizontal strips optional, default 32
  87335. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87336. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87337. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87338. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87339. * * 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
  87340. * * 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
  87341. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87342. * * 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)
  87343. * * 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)
  87344. * @returns the VertexData of the ellipsoid
  87345. */
  87346. static CreateSphere(options: {
  87347. segments?: number;
  87348. diameter?: number;
  87349. diameterX?: number;
  87350. diameterY?: number;
  87351. diameterZ?: number;
  87352. arc?: number;
  87353. slice?: number;
  87354. sideOrientation?: number;
  87355. frontUVs?: Vector4;
  87356. backUVs?: Vector4;
  87357. }): VertexData;
  87358. /**
  87359. * Creates the VertexData for a cylinder, cone or prism
  87360. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87361. * * height sets the height (y direction) of the cylinder, optional, default 2
  87362. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87363. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87364. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87365. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87366. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87367. * * 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
  87368. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87369. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87370. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87371. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87372. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87373. * * 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)
  87374. * * 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)
  87375. * @returns the VertexData of the cylinder, cone or prism
  87376. */
  87377. static CreateCylinder(options: {
  87378. height?: number;
  87379. diameterTop?: number;
  87380. diameterBottom?: number;
  87381. diameter?: number;
  87382. tessellation?: number;
  87383. subdivisions?: number;
  87384. arc?: number;
  87385. faceColors?: Color4[];
  87386. faceUV?: Vector4[];
  87387. hasRings?: boolean;
  87388. enclose?: boolean;
  87389. sideOrientation?: number;
  87390. frontUVs?: Vector4;
  87391. backUVs?: Vector4;
  87392. }): VertexData;
  87393. /**
  87394. * Creates the VertexData for a torus
  87395. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87396. * * diameter the diameter of the torus, optional default 1
  87397. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87398. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87399. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87400. * * 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)
  87401. * * 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)
  87402. * @returns the VertexData of the torus
  87403. */
  87404. static CreateTorus(options: {
  87405. diameter?: number;
  87406. thickness?: number;
  87407. tessellation?: number;
  87408. sideOrientation?: number;
  87409. frontUVs?: Vector4;
  87410. backUVs?: Vector4;
  87411. }): VertexData;
  87412. /**
  87413. * Creates the VertexData of the LineSystem
  87414. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87415. * - lines an array of lines, each line being an array of successive Vector3
  87416. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87417. * @returns the VertexData of the LineSystem
  87418. */
  87419. static CreateLineSystem(options: {
  87420. lines: Vector3[][];
  87421. colors?: Nullable<Color4[][]>;
  87422. }): VertexData;
  87423. /**
  87424. * Create the VertexData for a DashedLines
  87425. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87426. * - points an array successive Vector3
  87427. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87428. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87429. * - dashNb the intended total number of dashes, optional, default 200
  87430. * @returns the VertexData for the DashedLines
  87431. */
  87432. static CreateDashedLines(options: {
  87433. points: Vector3[];
  87434. dashSize?: number;
  87435. gapSize?: number;
  87436. dashNb?: number;
  87437. }): VertexData;
  87438. /**
  87439. * Creates the VertexData for a Ground
  87440. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87441. * - width the width (x direction) of the ground, optional, default 1
  87442. * - height the height (z direction) of the ground, optional, default 1
  87443. * - subdivisions the number of subdivisions per side, optional, default 1
  87444. * @returns the VertexData of the Ground
  87445. */
  87446. static CreateGround(options: {
  87447. width?: number;
  87448. height?: number;
  87449. subdivisions?: number;
  87450. subdivisionsX?: number;
  87451. subdivisionsY?: number;
  87452. }): VertexData;
  87453. /**
  87454. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87455. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87456. * * xmin the ground minimum X coordinate, optional, default -1
  87457. * * zmin the ground minimum Z coordinate, optional, default -1
  87458. * * xmax the ground maximum X coordinate, optional, default 1
  87459. * * zmax the ground maximum Z coordinate, optional, default 1
  87460. * * 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}
  87461. * * 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}
  87462. * @returns the VertexData of the TiledGround
  87463. */
  87464. static CreateTiledGround(options: {
  87465. xmin: number;
  87466. zmin: number;
  87467. xmax: number;
  87468. zmax: number;
  87469. subdivisions?: {
  87470. w: number;
  87471. h: number;
  87472. };
  87473. precision?: {
  87474. w: number;
  87475. h: number;
  87476. };
  87477. }): VertexData;
  87478. /**
  87479. * Creates the VertexData of the Ground designed from a heightmap
  87480. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87481. * * width the width (x direction) of the ground
  87482. * * height the height (z direction) of the ground
  87483. * * subdivisions the number of subdivisions per side
  87484. * * minHeight the minimum altitude on the ground, optional, default 0
  87485. * * maxHeight the maximum altitude on the ground, optional default 1
  87486. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87487. * * buffer the array holding the image color data
  87488. * * bufferWidth the width of image
  87489. * * bufferHeight the height of image
  87490. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87491. * @returns the VertexData of the Ground designed from a heightmap
  87492. */
  87493. static CreateGroundFromHeightMap(options: {
  87494. width: number;
  87495. height: number;
  87496. subdivisions: number;
  87497. minHeight: number;
  87498. maxHeight: number;
  87499. colorFilter: Color3;
  87500. buffer: Uint8Array;
  87501. bufferWidth: number;
  87502. bufferHeight: number;
  87503. alphaFilter: number;
  87504. }): VertexData;
  87505. /**
  87506. * Creates the VertexData for a Plane
  87507. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87508. * * size sets the width and height of the plane to the value of size, optional default 1
  87509. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87510. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87511. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87512. * * 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)
  87513. * * 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)
  87514. * @returns the VertexData of the box
  87515. */
  87516. static CreatePlane(options: {
  87517. size?: number;
  87518. width?: number;
  87519. height?: number;
  87520. sideOrientation?: number;
  87521. frontUVs?: Vector4;
  87522. backUVs?: Vector4;
  87523. }): VertexData;
  87524. /**
  87525. * Creates the VertexData of the Disc or regular Polygon
  87526. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87527. * * radius the radius of the disc, optional default 0.5
  87528. * * tessellation the number of polygon sides, optional, default 64
  87529. * * 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
  87530. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87531. * * 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)
  87532. * * 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)
  87533. * @returns the VertexData of the box
  87534. */
  87535. static CreateDisc(options: {
  87536. radius?: number;
  87537. tessellation?: number;
  87538. arc?: number;
  87539. sideOrientation?: number;
  87540. frontUVs?: Vector4;
  87541. backUVs?: Vector4;
  87542. }): VertexData;
  87543. /**
  87544. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87545. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87546. * @param polygon a mesh built from polygonTriangulation.build()
  87547. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87548. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87549. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87550. * @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)
  87551. * @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)
  87552. * @returns the VertexData of the Polygon
  87553. */
  87554. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87555. /**
  87556. * Creates the VertexData of the IcoSphere
  87557. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87558. * * radius the radius of the IcoSphere, optional default 1
  87559. * * radiusX allows stretching in the x direction, optional, default radius
  87560. * * radiusY allows stretching in the y direction, optional, default radius
  87561. * * radiusZ allows stretching in the z direction, optional, default radius
  87562. * * flat when true creates a flat shaded mesh, optional, default true
  87563. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87564. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87565. * * 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)
  87566. * * 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)
  87567. * @returns the VertexData of the IcoSphere
  87568. */
  87569. static CreateIcoSphere(options: {
  87570. radius?: number;
  87571. radiusX?: number;
  87572. radiusY?: number;
  87573. radiusZ?: number;
  87574. flat?: boolean;
  87575. subdivisions?: number;
  87576. sideOrientation?: number;
  87577. frontUVs?: Vector4;
  87578. backUVs?: Vector4;
  87579. }): VertexData;
  87580. /**
  87581. * Creates the VertexData for a Polyhedron
  87582. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87583. * * type provided types are:
  87584. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87585. * * 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)
  87586. * * size the size of the IcoSphere, optional default 1
  87587. * * sizeX allows stretching in the x direction, optional, default size
  87588. * * sizeY allows stretching in the y direction, optional, default size
  87589. * * sizeZ allows stretching in the z direction, optional, default size
  87590. * * 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
  87591. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87592. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87593. * * flat when true creates a flat shaded mesh, optional, default true
  87594. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87595. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87596. * * 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)
  87597. * * 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)
  87598. * @returns the VertexData of the Polyhedron
  87599. */
  87600. static CreatePolyhedron(options: {
  87601. type?: number;
  87602. size?: number;
  87603. sizeX?: number;
  87604. sizeY?: number;
  87605. sizeZ?: number;
  87606. custom?: any;
  87607. faceUV?: Vector4[];
  87608. faceColors?: Color4[];
  87609. flat?: boolean;
  87610. sideOrientation?: number;
  87611. frontUVs?: Vector4;
  87612. backUVs?: Vector4;
  87613. }): VertexData;
  87614. /**
  87615. * Creates the VertexData for a TorusKnot
  87616. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87617. * * radius the radius of the torus knot, optional, default 2
  87618. * * tube the thickness of the tube, optional, default 0.5
  87619. * * radialSegments the number of sides on each tube segments, optional, default 32
  87620. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87621. * * p the number of windings around the z axis, optional, default 2
  87622. * * q the number of windings around the x axis, optional, default 3
  87623. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87624. * * 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)
  87625. * * 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)
  87626. * @returns the VertexData of the Torus Knot
  87627. */
  87628. static CreateTorusKnot(options: {
  87629. radius?: number;
  87630. tube?: number;
  87631. radialSegments?: number;
  87632. tubularSegments?: number;
  87633. p?: number;
  87634. q?: number;
  87635. sideOrientation?: number;
  87636. frontUVs?: Vector4;
  87637. backUVs?: Vector4;
  87638. }): VertexData;
  87639. /**
  87640. * Compute normals for given positions and indices
  87641. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87642. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87643. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87644. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87645. * * facetNormals : optional array of facet normals (vector3)
  87646. * * facetPositions : optional array of facet positions (vector3)
  87647. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87648. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87649. * * bInfo : optional bounding info, required for facetPartitioning computation
  87650. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87651. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87652. * * useRightHandedSystem: optional boolean to for right handed system computation
  87653. * * depthSort : optional boolean to enable the facet depth sort computation
  87654. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87655. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87656. */
  87657. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87658. facetNormals?: any;
  87659. facetPositions?: any;
  87660. facetPartitioning?: any;
  87661. ratio?: number;
  87662. bInfo?: any;
  87663. bbSize?: Vector3;
  87664. subDiv?: any;
  87665. useRightHandedSystem?: boolean;
  87666. depthSort?: boolean;
  87667. distanceTo?: Vector3;
  87668. depthSortedFacets?: any;
  87669. }): void;
  87670. /** @hidden */
  87671. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87672. /**
  87673. * Applies VertexData created from the imported parameters to the geometry
  87674. * @param parsedVertexData the parsed data from an imported file
  87675. * @param geometry the geometry to apply the VertexData to
  87676. */
  87677. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87678. }
  87679. }
  87680. declare module BABYLON {
  87681. /**
  87682. * Defines a target to use with MorphTargetManager
  87683. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87684. */
  87685. export class MorphTarget implements IAnimatable {
  87686. /** defines the name of the target */
  87687. name: string;
  87688. /**
  87689. * Gets or sets the list of animations
  87690. */
  87691. animations: Animation[];
  87692. private _scene;
  87693. private _positions;
  87694. private _normals;
  87695. private _tangents;
  87696. private _uvs;
  87697. private _influence;
  87698. /**
  87699. * Observable raised when the influence changes
  87700. */
  87701. onInfluenceChanged: Observable<boolean>;
  87702. /** @hidden */
  87703. _onDataLayoutChanged: Observable<void>;
  87704. /**
  87705. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87706. */
  87707. influence: number;
  87708. /**
  87709. * Gets or sets the id of the morph Target
  87710. */
  87711. id: string;
  87712. private _animationPropertiesOverride;
  87713. /**
  87714. * Gets or sets the animation properties override
  87715. */
  87716. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87717. /**
  87718. * Creates a new MorphTarget
  87719. * @param name defines the name of the target
  87720. * @param influence defines the influence to use
  87721. * @param scene defines the scene the morphtarget belongs to
  87722. */
  87723. constructor(
  87724. /** defines the name of the target */
  87725. name: string, influence?: number, scene?: Nullable<Scene>);
  87726. /**
  87727. * Gets a boolean defining if the target contains position data
  87728. */
  87729. readonly hasPositions: boolean;
  87730. /**
  87731. * Gets a boolean defining if the target contains normal data
  87732. */
  87733. readonly hasNormals: boolean;
  87734. /**
  87735. * Gets a boolean defining if the target contains tangent data
  87736. */
  87737. readonly hasTangents: boolean;
  87738. /**
  87739. * Gets a boolean defining if the target contains texture coordinates data
  87740. */
  87741. readonly hasUVs: boolean;
  87742. /**
  87743. * Affects position data to this target
  87744. * @param data defines the position data to use
  87745. */
  87746. setPositions(data: Nullable<FloatArray>): void;
  87747. /**
  87748. * Gets the position data stored in this target
  87749. * @returns a FloatArray containing the position data (or null if not present)
  87750. */
  87751. getPositions(): Nullable<FloatArray>;
  87752. /**
  87753. * Affects normal data to this target
  87754. * @param data defines the normal data to use
  87755. */
  87756. setNormals(data: Nullable<FloatArray>): void;
  87757. /**
  87758. * Gets the normal data stored in this target
  87759. * @returns a FloatArray containing the normal data (or null if not present)
  87760. */
  87761. getNormals(): Nullable<FloatArray>;
  87762. /**
  87763. * Affects tangent data to this target
  87764. * @param data defines the tangent data to use
  87765. */
  87766. setTangents(data: Nullable<FloatArray>): void;
  87767. /**
  87768. * Gets the tangent data stored in this target
  87769. * @returns a FloatArray containing the tangent data (or null if not present)
  87770. */
  87771. getTangents(): Nullable<FloatArray>;
  87772. /**
  87773. * Affects texture coordinates data to this target
  87774. * @param data defines the texture coordinates data to use
  87775. */
  87776. setUVs(data: Nullable<FloatArray>): void;
  87777. /**
  87778. * Gets the texture coordinates data stored in this target
  87779. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87780. */
  87781. getUVs(): Nullable<FloatArray>;
  87782. /**
  87783. * Serializes the current target into a Serialization object
  87784. * @returns the serialized object
  87785. */
  87786. serialize(): any;
  87787. /**
  87788. * Returns the string "MorphTarget"
  87789. * @returns "MorphTarget"
  87790. */
  87791. getClassName(): string;
  87792. /**
  87793. * Creates a new target from serialized data
  87794. * @param serializationObject defines the serialized data to use
  87795. * @returns a new MorphTarget
  87796. */
  87797. static Parse(serializationObject: any): MorphTarget;
  87798. /**
  87799. * Creates a MorphTarget from mesh data
  87800. * @param mesh defines the source mesh
  87801. * @param name defines the name to use for the new target
  87802. * @param influence defines the influence to attach to the target
  87803. * @returns a new MorphTarget
  87804. */
  87805. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87806. }
  87807. }
  87808. declare module BABYLON {
  87809. /**
  87810. * This class is used to deform meshes using morphing between different targets
  87811. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87812. */
  87813. export class MorphTargetManager {
  87814. private _targets;
  87815. private _targetInfluenceChangedObservers;
  87816. private _targetDataLayoutChangedObservers;
  87817. private _activeTargets;
  87818. private _scene;
  87819. private _influences;
  87820. private _supportsNormals;
  87821. private _supportsTangents;
  87822. private _supportsUVs;
  87823. private _vertexCount;
  87824. private _uniqueId;
  87825. private _tempInfluences;
  87826. /**
  87827. * Gets or sets a boolean indicating if normals must be morphed
  87828. */
  87829. enableNormalMorphing: boolean;
  87830. /**
  87831. * Gets or sets a boolean indicating if tangents must be morphed
  87832. */
  87833. enableTangentMorphing: boolean;
  87834. /**
  87835. * Gets or sets a boolean indicating if UV must be morphed
  87836. */
  87837. enableUVMorphing: boolean;
  87838. /**
  87839. * Creates a new MorphTargetManager
  87840. * @param scene defines the current scene
  87841. */
  87842. constructor(scene?: Nullable<Scene>);
  87843. /**
  87844. * Gets the unique ID of this manager
  87845. */
  87846. readonly uniqueId: number;
  87847. /**
  87848. * Gets the number of vertices handled by this manager
  87849. */
  87850. readonly vertexCount: number;
  87851. /**
  87852. * Gets a boolean indicating if this manager supports morphing of normals
  87853. */
  87854. readonly supportsNormals: boolean;
  87855. /**
  87856. * Gets a boolean indicating if this manager supports morphing of tangents
  87857. */
  87858. readonly supportsTangents: boolean;
  87859. /**
  87860. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87861. */
  87862. readonly supportsUVs: boolean;
  87863. /**
  87864. * Gets the number of targets stored in this manager
  87865. */
  87866. readonly numTargets: number;
  87867. /**
  87868. * Gets the number of influencers (ie. the number of targets with influences > 0)
  87869. */
  87870. readonly numInfluencers: number;
  87871. /**
  87872. * Gets the list of influences (one per target)
  87873. */
  87874. readonly influences: Float32Array;
  87875. /**
  87876. * Gets the active target at specified index. An active target is a target with an influence > 0
  87877. * @param index defines the index to check
  87878. * @returns the requested target
  87879. */
  87880. getActiveTarget(index: number): MorphTarget;
  87881. /**
  87882. * Gets the target at specified index
  87883. * @param index defines the index to check
  87884. * @returns the requested target
  87885. */
  87886. getTarget(index: number): MorphTarget;
  87887. /**
  87888. * Add a new target to this manager
  87889. * @param target defines the target to add
  87890. */
  87891. addTarget(target: MorphTarget): void;
  87892. /**
  87893. * Removes a target from the manager
  87894. * @param target defines the target to remove
  87895. */
  87896. removeTarget(target: MorphTarget): void;
  87897. /**
  87898. * Serializes the current manager into a Serialization object
  87899. * @returns the serialized object
  87900. */
  87901. serialize(): any;
  87902. private _syncActiveTargets;
  87903. /**
  87904. * Syncrhonize the targets with all the meshes using this morph target manager
  87905. */
  87906. synchronize(): void;
  87907. /**
  87908. * Creates a new MorphTargetManager from serialized data
  87909. * @param serializationObject defines the serialized data
  87910. * @param scene defines the hosting scene
  87911. * @returns the new MorphTargetManager
  87912. */
  87913. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  87914. }
  87915. }
  87916. declare module BABYLON {
  87917. /**
  87918. * Class used to represent a specific level of detail of a mesh
  87919. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87920. */
  87921. export class MeshLODLevel {
  87922. /** Defines the distance where this level should start being displayed */
  87923. distance: number;
  87924. /** Defines the mesh to use to render this level */
  87925. mesh: Nullable<Mesh>;
  87926. /**
  87927. * Creates a new LOD level
  87928. * @param distance defines the distance where this level should star being displayed
  87929. * @param mesh defines the mesh to use to render this level
  87930. */
  87931. constructor(
  87932. /** Defines the distance where this level should start being displayed */
  87933. distance: number,
  87934. /** Defines the mesh to use to render this level */
  87935. mesh: Nullable<Mesh>);
  87936. }
  87937. }
  87938. declare module BABYLON {
  87939. /**
  87940. * Mesh representing the gorund
  87941. */
  87942. export class GroundMesh extends Mesh {
  87943. /** If octree should be generated */
  87944. generateOctree: boolean;
  87945. private _heightQuads;
  87946. /** @hidden */
  87947. _subdivisionsX: number;
  87948. /** @hidden */
  87949. _subdivisionsY: number;
  87950. /** @hidden */
  87951. _width: number;
  87952. /** @hidden */
  87953. _height: number;
  87954. /** @hidden */
  87955. _minX: number;
  87956. /** @hidden */
  87957. _maxX: number;
  87958. /** @hidden */
  87959. _minZ: number;
  87960. /** @hidden */
  87961. _maxZ: number;
  87962. constructor(name: string, scene: Scene);
  87963. /**
  87964. * "GroundMesh"
  87965. * @returns "GroundMesh"
  87966. */
  87967. getClassName(): string;
  87968. /**
  87969. * The minimum of x and y subdivisions
  87970. */
  87971. readonly subdivisions: number;
  87972. /**
  87973. * X subdivisions
  87974. */
  87975. readonly subdivisionsX: number;
  87976. /**
  87977. * Y subdivisions
  87978. */
  87979. readonly subdivisionsY: number;
  87980. /**
  87981. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87982. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87983. * @param chunksCount the number of subdivisions for x and y
  87984. * @param octreeBlocksSize (Default: 32)
  87985. */
  87986. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87987. /**
  87988. * Returns a height (y) value in the Worl system :
  87989. * the ground altitude at the coordinates (x, z) expressed in the World system.
  87990. * @param x x coordinate
  87991. * @param z z coordinate
  87992. * @returns the ground y position if (x, z) are outside the ground surface.
  87993. */
  87994. getHeightAtCoordinates(x: number, z: number): number;
  87995. /**
  87996. * Returns a normalized vector (Vector3) orthogonal to the ground
  87997. * at the ground coordinates (x, z) expressed in the World system.
  87998. * @param x x coordinate
  87999. * @param z z coordinate
  88000. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  88001. */
  88002. getNormalAtCoordinates(x: number, z: number): Vector3;
  88003. /**
  88004. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88005. * at the ground coordinates (x, z) expressed in the World system.
  88006. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88007. * @param x x coordinate
  88008. * @param z z coordinate
  88009. * @param ref vector to store the result
  88010. * @returns the GroundMesh.
  88011. */
  88012. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  88013. /**
  88014. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88015. * if the ground has been updated.
  88016. * This can be used in the render loop.
  88017. * @returns the GroundMesh.
  88018. */
  88019. updateCoordinateHeights(): GroundMesh;
  88020. private _getFacetAt;
  88021. private _initHeightQuads;
  88022. private _computeHeightQuads;
  88023. /**
  88024. * Serializes this ground mesh
  88025. * @param serializationObject object to write serialization to
  88026. */
  88027. serialize(serializationObject: any): void;
  88028. /**
  88029. * Parses a serialized ground mesh
  88030. * @param parsedMesh the serialized mesh
  88031. * @param scene the scene to create the ground mesh in
  88032. * @returns the created ground mesh
  88033. */
  88034. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  88035. }
  88036. }
  88037. declare module BABYLON {
  88038. /**
  88039. * Interface for Physics-Joint data
  88040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88041. */
  88042. export interface PhysicsJointData {
  88043. /**
  88044. * The main pivot of the joint
  88045. */
  88046. mainPivot?: Vector3;
  88047. /**
  88048. * The connected pivot of the joint
  88049. */
  88050. connectedPivot?: Vector3;
  88051. /**
  88052. * The main axis of the joint
  88053. */
  88054. mainAxis?: Vector3;
  88055. /**
  88056. * The connected axis of the joint
  88057. */
  88058. connectedAxis?: Vector3;
  88059. /**
  88060. * The collision of the joint
  88061. */
  88062. collision?: boolean;
  88063. /**
  88064. * Native Oimo/Cannon/Energy data
  88065. */
  88066. nativeParams?: any;
  88067. }
  88068. /**
  88069. * This is a holder class for the physics joint created by the physics plugin
  88070. * It holds a set of functions to control the underlying joint
  88071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88072. */
  88073. export class PhysicsJoint {
  88074. /**
  88075. * The type of the physics joint
  88076. */
  88077. type: number;
  88078. /**
  88079. * The data for the physics joint
  88080. */
  88081. jointData: PhysicsJointData;
  88082. private _physicsJoint;
  88083. protected _physicsPlugin: IPhysicsEnginePlugin;
  88084. /**
  88085. * Initializes the physics joint
  88086. * @param type The type of the physics joint
  88087. * @param jointData The data for the physics joint
  88088. */
  88089. constructor(
  88090. /**
  88091. * The type of the physics joint
  88092. */
  88093. type: number,
  88094. /**
  88095. * The data for the physics joint
  88096. */
  88097. jointData: PhysicsJointData);
  88098. /**
  88099. * Gets the physics joint
  88100. */
  88101. /**
  88102. * Sets the physics joint
  88103. */
  88104. physicsJoint: any;
  88105. /**
  88106. * Sets the physics plugin
  88107. */
  88108. physicsPlugin: IPhysicsEnginePlugin;
  88109. /**
  88110. * Execute a function that is physics-plugin specific.
  88111. * @param {Function} func the function that will be executed.
  88112. * It accepts two parameters: the physics world and the physics joint
  88113. */
  88114. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88115. /**
  88116. * Distance-Joint type
  88117. */
  88118. static DistanceJoint: number;
  88119. /**
  88120. * Hinge-Joint type
  88121. */
  88122. static HingeJoint: number;
  88123. /**
  88124. * Ball-and-Socket joint type
  88125. */
  88126. static BallAndSocketJoint: number;
  88127. /**
  88128. * Wheel-Joint type
  88129. */
  88130. static WheelJoint: number;
  88131. /**
  88132. * Slider-Joint type
  88133. */
  88134. static SliderJoint: number;
  88135. /**
  88136. * Prismatic-Joint type
  88137. */
  88138. static PrismaticJoint: number;
  88139. /**
  88140. * Universal-Joint type
  88141. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88142. */
  88143. static UniversalJoint: number;
  88144. /**
  88145. * Hinge-Joint 2 type
  88146. */
  88147. static Hinge2Joint: number;
  88148. /**
  88149. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88150. */
  88151. static PointToPointJoint: number;
  88152. /**
  88153. * Spring-Joint type
  88154. */
  88155. static SpringJoint: number;
  88156. /**
  88157. * Lock-Joint type
  88158. */
  88159. static LockJoint: number;
  88160. }
  88161. /**
  88162. * A class representing a physics distance joint
  88163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88164. */
  88165. export class DistanceJoint extends PhysicsJoint {
  88166. /**
  88167. *
  88168. * @param jointData The data for the Distance-Joint
  88169. */
  88170. constructor(jointData: DistanceJointData);
  88171. /**
  88172. * Update the predefined distance.
  88173. * @param maxDistance The maximum preferred distance
  88174. * @param minDistance The minimum preferred distance
  88175. */
  88176. updateDistance(maxDistance: number, minDistance?: number): void;
  88177. }
  88178. /**
  88179. * Represents a Motor-Enabled Joint
  88180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88181. */
  88182. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88183. /**
  88184. * Initializes the Motor-Enabled Joint
  88185. * @param type The type of the joint
  88186. * @param jointData The physica joint data for the joint
  88187. */
  88188. constructor(type: number, jointData: PhysicsJointData);
  88189. /**
  88190. * Set the motor values.
  88191. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88192. * @param force the force to apply
  88193. * @param maxForce max force for this motor.
  88194. */
  88195. setMotor(force?: number, maxForce?: number): void;
  88196. /**
  88197. * Set the motor's limits.
  88198. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88199. * @param upperLimit The upper limit of the motor
  88200. * @param lowerLimit The lower limit of the motor
  88201. */
  88202. setLimit(upperLimit: number, lowerLimit?: number): void;
  88203. }
  88204. /**
  88205. * This class represents a single physics Hinge-Joint
  88206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88207. */
  88208. export class HingeJoint extends MotorEnabledJoint {
  88209. /**
  88210. * Initializes the Hinge-Joint
  88211. * @param jointData The joint data for the Hinge-Joint
  88212. */
  88213. constructor(jointData: PhysicsJointData);
  88214. /**
  88215. * Set the motor values.
  88216. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88217. * @param {number} force the force to apply
  88218. * @param {number} maxForce max force for this motor.
  88219. */
  88220. setMotor(force?: number, maxForce?: number): void;
  88221. /**
  88222. * Set the motor's limits.
  88223. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88224. * @param upperLimit The upper limit of the motor
  88225. * @param lowerLimit The lower limit of the motor
  88226. */
  88227. setLimit(upperLimit: number, lowerLimit?: number): void;
  88228. }
  88229. /**
  88230. * This class represents a dual hinge physics joint (same as wheel joint)
  88231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88232. */
  88233. export class Hinge2Joint extends MotorEnabledJoint {
  88234. /**
  88235. * Initializes the Hinge2-Joint
  88236. * @param jointData The joint data for the Hinge2-Joint
  88237. */
  88238. constructor(jointData: PhysicsJointData);
  88239. /**
  88240. * Set the motor values.
  88241. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88242. * @param {number} targetSpeed the speed the motor is to reach
  88243. * @param {number} maxForce max force for this motor.
  88244. * @param {motorIndex} the motor's index, 0 or 1.
  88245. */
  88246. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  88247. /**
  88248. * Set the motor limits.
  88249. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88250. * @param {number} upperLimit the upper limit
  88251. * @param {number} lowerLimit lower limit
  88252. * @param {motorIndex} the motor's index, 0 or 1.
  88253. */
  88254. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88255. }
  88256. /**
  88257. * Interface for a motor enabled joint
  88258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88259. */
  88260. export interface IMotorEnabledJoint {
  88261. /**
  88262. * Physics joint
  88263. */
  88264. physicsJoint: any;
  88265. /**
  88266. * Sets the motor of the motor-enabled joint
  88267. * @param force The force of the motor
  88268. * @param maxForce The maximum force of the motor
  88269. * @param motorIndex The index of the motor
  88270. */
  88271. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  88272. /**
  88273. * Sets the limit of the motor
  88274. * @param upperLimit The upper limit of the motor
  88275. * @param lowerLimit The lower limit of the motor
  88276. * @param motorIndex The index of the motor
  88277. */
  88278. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88279. }
  88280. /**
  88281. * Joint data for a Distance-Joint
  88282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88283. */
  88284. export interface DistanceJointData extends PhysicsJointData {
  88285. /**
  88286. * Max distance the 2 joint objects can be apart
  88287. */
  88288. maxDistance: number;
  88289. }
  88290. /**
  88291. * Joint data from a spring joint
  88292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88293. */
  88294. export interface SpringJointData extends PhysicsJointData {
  88295. /**
  88296. * Length of the spring
  88297. */
  88298. length: number;
  88299. /**
  88300. * Stiffness of the spring
  88301. */
  88302. stiffness: number;
  88303. /**
  88304. * Damping of the spring
  88305. */
  88306. damping: number;
  88307. /** this callback will be called when applying the force to the impostors. */
  88308. forceApplicationCallback: () => void;
  88309. }
  88310. }
  88311. declare module BABYLON {
  88312. /**
  88313. * Holds the data for the raycast result
  88314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88315. */
  88316. export class PhysicsRaycastResult {
  88317. private _hasHit;
  88318. private _hitDistance;
  88319. private _hitNormalWorld;
  88320. private _hitPointWorld;
  88321. private _rayFromWorld;
  88322. private _rayToWorld;
  88323. /**
  88324. * Gets if there was a hit
  88325. */
  88326. readonly hasHit: boolean;
  88327. /**
  88328. * Gets the distance from the hit
  88329. */
  88330. readonly hitDistance: number;
  88331. /**
  88332. * Gets the hit normal/direction in the world
  88333. */
  88334. readonly hitNormalWorld: Vector3;
  88335. /**
  88336. * Gets the hit point in the world
  88337. */
  88338. readonly hitPointWorld: Vector3;
  88339. /**
  88340. * Gets the ray "start point" of the ray in the world
  88341. */
  88342. readonly rayFromWorld: Vector3;
  88343. /**
  88344. * Gets the ray "end point" of the ray in the world
  88345. */
  88346. readonly rayToWorld: Vector3;
  88347. /**
  88348. * Sets the hit data (normal & point in world space)
  88349. * @param hitNormalWorld defines the normal in world space
  88350. * @param hitPointWorld defines the point in world space
  88351. */
  88352. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  88353. /**
  88354. * Sets the distance from the start point to the hit point
  88355. * @param distance
  88356. */
  88357. setHitDistance(distance: number): void;
  88358. /**
  88359. * Calculates the distance manually
  88360. */
  88361. calculateHitDistance(): void;
  88362. /**
  88363. * Resets all the values to default
  88364. * @param from The from point on world space
  88365. * @param to The to point on world space
  88366. */
  88367. reset(from?: Vector3, to?: Vector3): void;
  88368. }
  88369. /**
  88370. * Interface for the size containing width and height
  88371. */
  88372. interface IXYZ {
  88373. /**
  88374. * X
  88375. */
  88376. x: number;
  88377. /**
  88378. * Y
  88379. */
  88380. y: number;
  88381. /**
  88382. * Z
  88383. */
  88384. z: number;
  88385. }
  88386. }
  88387. declare module BABYLON {
  88388. /**
  88389. * Interface used to describe a physics joint
  88390. */
  88391. export interface PhysicsImpostorJoint {
  88392. /** Defines the main impostor to which the joint is linked */
  88393. mainImpostor: PhysicsImpostor;
  88394. /** Defines the impostor that is connected to the main impostor using this joint */
  88395. connectedImpostor: PhysicsImpostor;
  88396. /** Defines the joint itself */
  88397. joint: PhysicsJoint;
  88398. }
  88399. /** @hidden */
  88400. export interface IPhysicsEnginePlugin {
  88401. world: any;
  88402. name: string;
  88403. setGravity(gravity: Vector3): void;
  88404. setTimeStep(timeStep: number): void;
  88405. getTimeStep(): number;
  88406. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88407. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88408. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88409. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88410. removePhysicsBody(impostor: PhysicsImpostor): void;
  88411. generateJoint(joint: PhysicsImpostorJoint): void;
  88412. removeJoint(joint: PhysicsImpostorJoint): void;
  88413. isSupported(): boolean;
  88414. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88415. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88416. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88417. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88418. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88419. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88420. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88421. getBodyMass(impostor: PhysicsImpostor): number;
  88422. getBodyFriction(impostor: PhysicsImpostor): number;
  88423. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88424. getBodyRestitution(impostor: PhysicsImpostor): number;
  88425. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88426. getBodyPressure?(impostor: PhysicsImpostor): number;
  88427. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88428. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88429. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88430. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88431. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88432. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88433. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88434. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88435. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88436. sleepBody(impostor: PhysicsImpostor): void;
  88437. wakeUpBody(impostor: PhysicsImpostor): void;
  88438. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88439. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88440. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88441. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88442. getRadius(impostor: PhysicsImpostor): number;
  88443. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88444. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88445. dispose(): void;
  88446. }
  88447. /**
  88448. * Interface used to define a physics engine
  88449. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88450. */
  88451. export interface IPhysicsEngine {
  88452. /**
  88453. * Gets the gravity vector used by the simulation
  88454. */
  88455. gravity: Vector3;
  88456. /**
  88457. * Sets the gravity vector used by the simulation
  88458. * @param gravity defines the gravity vector to use
  88459. */
  88460. setGravity(gravity: Vector3): void;
  88461. /**
  88462. * Set the time step of the physics engine.
  88463. * Default is 1/60.
  88464. * To slow it down, enter 1/600 for example.
  88465. * To speed it up, 1/30
  88466. * @param newTimeStep the new timestep to apply to this world.
  88467. */
  88468. setTimeStep(newTimeStep: number): void;
  88469. /**
  88470. * Get the time step of the physics engine.
  88471. * @returns the current time step
  88472. */
  88473. getTimeStep(): number;
  88474. /**
  88475. * Release all resources
  88476. */
  88477. dispose(): void;
  88478. /**
  88479. * Gets the name of the current physics plugin
  88480. * @returns the name of the plugin
  88481. */
  88482. getPhysicsPluginName(): string;
  88483. /**
  88484. * Adding a new impostor for the impostor tracking.
  88485. * This will be done by the impostor itself.
  88486. * @param impostor the impostor to add
  88487. */
  88488. addImpostor(impostor: PhysicsImpostor): void;
  88489. /**
  88490. * Remove an impostor from the engine.
  88491. * This impostor and its mesh will not longer be updated by the physics engine.
  88492. * @param impostor the impostor to remove
  88493. */
  88494. removeImpostor(impostor: PhysicsImpostor): void;
  88495. /**
  88496. * Add a joint to the physics engine
  88497. * @param mainImpostor defines the main impostor to which the joint is added.
  88498. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88499. * @param joint defines the joint that will connect both impostors.
  88500. */
  88501. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88502. /**
  88503. * Removes a joint from the simulation
  88504. * @param mainImpostor defines the impostor used with the joint
  88505. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88506. * @param joint defines the joint to remove
  88507. */
  88508. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88509. /**
  88510. * Gets the current plugin used to run the simulation
  88511. * @returns current plugin
  88512. */
  88513. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88514. /**
  88515. * Gets the list of physic impostors
  88516. * @returns an array of PhysicsImpostor
  88517. */
  88518. getImpostors(): Array<PhysicsImpostor>;
  88519. /**
  88520. * Gets the impostor for a physics enabled object
  88521. * @param object defines the object impersonated by the impostor
  88522. * @returns the PhysicsImpostor or null if not found
  88523. */
  88524. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88525. /**
  88526. * Gets the impostor for a physics body object
  88527. * @param body defines physics body used by the impostor
  88528. * @returns the PhysicsImpostor or null if not found
  88529. */
  88530. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88531. /**
  88532. * Does a raycast in the physics world
  88533. * @param from when should the ray start?
  88534. * @param to when should the ray end?
  88535. * @returns PhysicsRaycastResult
  88536. */
  88537. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88538. /**
  88539. * Called by the scene. No need to call it.
  88540. * @param delta defines the timespam between frames
  88541. */
  88542. _step(delta: number): void;
  88543. }
  88544. }
  88545. declare module BABYLON {
  88546. /**
  88547. * The interface for the physics imposter parameters
  88548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88549. */
  88550. export interface PhysicsImpostorParameters {
  88551. /**
  88552. * The mass of the physics imposter
  88553. */
  88554. mass: number;
  88555. /**
  88556. * The friction of the physics imposter
  88557. */
  88558. friction?: number;
  88559. /**
  88560. * The coefficient of restitution of the physics imposter
  88561. */
  88562. restitution?: number;
  88563. /**
  88564. * The native options of the physics imposter
  88565. */
  88566. nativeOptions?: any;
  88567. /**
  88568. * Specifies if the parent should be ignored
  88569. */
  88570. ignoreParent?: boolean;
  88571. /**
  88572. * Specifies if bi-directional transformations should be disabled
  88573. */
  88574. disableBidirectionalTransformation?: boolean;
  88575. /**
  88576. * The pressure inside the physics imposter, soft object only
  88577. */
  88578. pressure?: number;
  88579. /**
  88580. * The stiffness the physics imposter, soft object only
  88581. */
  88582. stiffness?: number;
  88583. /**
  88584. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88585. */
  88586. velocityIterations?: number;
  88587. /**
  88588. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88589. */
  88590. positionIterations?: number;
  88591. /**
  88592. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88593. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88594. * Add to fix multiple points
  88595. */
  88596. fixedPoints?: number;
  88597. /**
  88598. * The collision margin around a soft object
  88599. */
  88600. margin?: number;
  88601. /**
  88602. * The collision margin around a soft object
  88603. */
  88604. damping?: number;
  88605. /**
  88606. * The path for a rope based on an extrusion
  88607. */
  88608. path?: any;
  88609. /**
  88610. * The shape of an extrusion used for a rope based on an extrusion
  88611. */
  88612. shape?: any;
  88613. }
  88614. /**
  88615. * Interface for a physics-enabled object
  88616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88617. */
  88618. export interface IPhysicsEnabledObject {
  88619. /**
  88620. * The position of the physics-enabled object
  88621. */
  88622. position: Vector3;
  88623. /**
  88624. * The rotation of the physics-enabled object
  88625. */
  88626. rotationQuaternion: Nullable<Quaternion>;
  88627. /**
  88628. * The scale of the physics-enabled object
  88629. */
  88630. scaling: Vector3;
  88631. /**
  88632. * The rotation of the physics-enabled object
  88633. */
  88634. rotation?: Vector3;
  88635. /**
  88636. * The parent of the physics-enabled object
  88637. */
  88638. parent?: any;
  88639. /**
  88640. * The bounding info of the physics-enabled object
  88641. * @returns The bounding info of the physics-enabled object
  88642. */
  88643. getBoundingInfo(): BoundingInfo;
  88644. /**
  88645. * Computes the world matrix
  88646. * @param force Specifies if the world matrix should be computed by force
  88647. * @returns A world matrix
  88648. */
  88649. computeWorldMatrix(force: boolean): Matrix;
  88650. /**
  88651. * Gets the world matrix
  88652. * @returns A world matrix
  88653. */
  88654. getWorldMatrix?(): Matrix;
  88655. /**
  88656. * Gets the child meshes
  88657. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88658. * @returns An array of abstract meshes
  88659. */
  88660. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88661. /**
  88662. * Gets the vertex data
  88663. * @param kind The type of vertex data
  88664. * @returns A nullable array of numbers, or a float32 array
  88665. */
  88666. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88667. /**
  88668. * Gets the indices from the mesh
  88669. * @returns A nullable array of index arrays
  88670. */
  88671. getIndices?(): Nullable<IndicesArray>;
  88672. /**
  88673. * Gets the scene from the mesh
  88674. * @returns the indices array or null
  88675. */
  88676. getScene?(): Scene;
  88677. /**
  88678. * Gets the absolute position from the mesh
  88679. * @returns the absolute position
  88680. */
  88681. getAbsolutePosition(): Vector3;
  88682. /**
  88683. * Gets the absolute pivot point from the mesh
  88684. * @returns the absolute pivot point
  88685. */
  88686. getAbsolutePivotPoint(): Vector3;
  88687. /**
  88688. * Rotates the mesh
  88689. * @param axis The axis of rotation
  88690. * @param amount The amount of rotation
  88691. * @param space The space of the rotation
  88692. * @returns The rotation transform node
  88693. */
  88694. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88695. /**
  88696. * Translates the mesh
  88697. * @param axis The axis of translation
  88698. * @param distance The distance of translation
  88699. * @param space The space of the translation
  88700. * @returns The transform node
  88701. */
  88702. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88703. /**
  88704. * Sets the absolute position of the mesh
  88705. * @param absolutePosition The absolute position of the mesh
  88706. * @returns The transform node
  88707. */
  88708. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88709. /**
  88710. * Gets the class name of the mesh
  88711. * @returns The class name
  88712. */
  88713. getClassName(): string;
  88714. }
  88715. /**
  88716. * Represents a physics imposter
  88717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88718. */
  88719. export class PhysicsImpostor {
  88720. /**
  88721. * The physics-enabled object used as the physics imposter
  88722. */
  88723. object: IPhysicsEnabledObject;
  88724. /**
  88725. * The type of the physics imposter
  88726. */
  88727. type: number;
  88728. private _options;
  88729. private _scene?;
  88730. /**
  88731. * The default object size of the imposter
  88732. */
  88733. static DEFAULT_OBJECT_SIZE: Vector3;
  88734. /**
  88735. * The identity quaternion of the imposter
  88736. */
  88737. static IDENTITY_QUATERNION: Quaternion;
  88738. /** @hidden */
  88739. _pluginData: any;
  88740. private _physicsEngine;
  88741. private _physicsBody;
  88742. private _bodyUpdateRequired;
  88743. private _onBeforePhysicsStepCallbacks;
  88744. private _onAfterPhysicsStepCallbacks;
  88745. /** @hidden */
  88746. _onPhysicsCollideCallbacks: Array<{
  88747. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88748. otherImpostors: Array<PhysicsImpostor>;
  88749. }>;
  88750. private _deltaPosition;
  88751. private _deltaRotation;
  88752. private _deltaRotationConjugated;
  88753. /** @hidden */
  88754. _isFromLine: boolean;
  88755. private _parent;
  88756. private _isDisposed;
  88757. private static _tmpVecs;
  88758. private static _tmpQuat;
  88759. /**
  88760. * Specifies if the physics imposter is disposed
  88761. */
  88762. readonly isDisposed: boolean;
  88763. /**
  88764. * Gets the mass of the physics imposter
  88765. */
  88766. mass: number;
  88767. /**
  88768. * Gets the coefficient of friction
  88769. */
  88770. /**
  88771. * Sets the coefficient of friction
  88772. */
  88773. friction: number;
  88774. /**
  88775. * Gets the coefficient of restitution
  88776. */
  88777. /**
  88778. * Sets the coefficient of restitution
  88779. */
  88780. restitution: number;
  88781. /**
  88782. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88783. */
  88784. /**
  88785. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88786. */
  88787. pressure: number;
  88788. /**
  88789. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88790. */
  88791. /**
  88792. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88793. */
  88794. stiffness: number;
  88795. /**
  88796. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88797. */
  88798. /**
  88799. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88800. */
  88801. velocityIterations: number;
  88802. /**
  88803. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88804. */
  88805. /**
  88806. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88807. */
  88808. positionIterations: number;
  88809. /**
  88810. * The unique id of the physics imposter
  88811. * set by the physics engine when adding this impostor to the array
  88812. */
  88813. uniqueId: number;
  88814. /**
  88815. * @hidden
  88816. */
  88817. soft: boolean;
  88818. /**
  88819. * @hidden
  88820. */
  88821. segments: number;
  88822. private _joints;
  88823. /**
  88824. * Initializes the physics imposter
  88825. * @param object The physics-enabled object used as the physics imposter
  88826. * @param type The type of the physics imposter
  88827. * @param _options The options for the physics imposter
  88828. * @param _scene The Babylon scene
  88829. */
  88830. constructor(
  88831. /**
  88832. * The physics-enabled object used as the physics imposter
  88833. */
  88834. object: IPhysicsEnabledObject,
  88835. /**
  88836. * The type of the physics imposter
  88837. */
  88838. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88839. /**
  88840. * This function will completly initialize this impostor.
  88841. * It will create a new body - but only if this mesh has no parent.
  88842. * If it has, this impostor will not be used other than to define the impostor
  88843. * of the child mesh.
  88844. * @hidden
  88845. */
  88846. _init(): void;
  88847. private _getPhysicsParent;
  88848. /**
  88849. * Should a new body be generated.
  88850. * @returns boolean specifying if body initialization is required
  88851. */
  88852. isBodyInitRequired(): boolean;
  88853. /**
  88854. * Sets the updated scaling
  88855. * @param updated Specifies if the scaling is updated
  88856. */
  88857. setScalingUpdated(): void;
  88858. /**
  88859. * Force a regeneration of this or the parent's impostor's body.
  88860. * Use under cautious - This will remove all joints already implemented.
  88861. */
  88862. forceUpdate(): void;
  88863. /**
  88864. * Gets the body that holds this impostor. Either its own, or its parent.
  88865. */
  88866. /**
  88867. * Set the physics body. Used mainly by the physics engine/plugin
  88868. */
  88869. physicsBody: any;
  88870. /**
  88871. * Get the parent of the physics imposter
  88872. * @returns Physics imposter or null
  88873. */
  88874. /**
  88875. * Sets the parent of the physics imposter
  88876. */
  88877. parent: Nullable<PhysicsImpostor>;
  88878. /**
  88879. * Resets the update flags
  88880. */
  88881. resetUpdateFlags(): void;
  88882. /**
  88883. * Gets the object extend size
  88884. * @returns the object extend size
  88885. */
  88886. getObjectExtendSize(): Vector3;
  88887. /**
  88888. * Gets the object center
  88889. * @returns The object center
  88890. */
  88891. getObjectCenter(): Vector3;
  88892. /**
  88893. * Get a specific parametes from the options parameter
  88894. * @param paramName The object parameter name
  88895. * @returns The object parameter
  88896. */
  88897. getParam(paramName: string): any;
  88898. /**
  88899. * Sets a specific parameter in the options given to the physics plugin
  88900. * @param paramName The parameter name
  88901. * @param value The value of the parameter
  88902. */
  88903. setParam(paramName: string, value: number): void;
  88904. /**
  88905. * Specifically change the body's mass option. Won't recreate the physics body object
  88906. * @param mass The mass of the physics imposter
  88907. */
  88908. setMass(mass: number): void;
  88909. /**
  88910. * Gets the linear velocity
  88911. * @returns linear velocity or null
  88912. */
  88913. getLinearVelocity(): Nullable<Vector3>;
  88914. /**
  88915. * Sets the linear velocity
  88916. * @param velocity linear velocity or null
  88917. */
  88918. setLinearVelocity(velocity: Nullable<Vector3>): void;
  88919. /**
  88920. * Gets the angular velocity
  88921. * @returns angular velocity or null
  88922. */
  88923. getAngularVelocity(): Nullable<Vector3>;
  88924. /**
  88925. * Sets the angular velocity
  88926. * @param velocity The velocity or null
  88927. */
  88928. setAngularVelocity(velocity: Nullable<Vector3>): void;
  88929. /**
  88930. * Execute a function with the physics plugin native code
  88931. * Provide a function the will have two variables - the world object and the physics body object
  88932. * @param func The function to execute with the physics plugin native code
  88933. */
  88934. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  88935. /**
  88936. * Register a function that will be executed before the physics world is stepping forward
  88937. * @param func The function to execute before the physics world is stepped forward
  88938. */
  88939. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88940. /**
  88941. * Unregister a function that will be executed before the physics world is stepping forward
  88942. * @param func The function to execute before the physics world is stepped forward
  88943. */
  88944. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88945. /**
  88946. * Register a function that will be executed after the physics step
  88947. * @param func The function to execute after physics step
  88948. */
  88949. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88950. /**
  88951. * Unregisters a function that will be executed after the physics step
  88952. * @param func The function to execute after physics step
  88953. */
  88954. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88955. /**
  88956. * register a function that will be executed when this impostor collides against a different body
  88957. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  88958. * @param func Callback that is executed on collision
  88959. */
  88960. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  88961. /**
  88962. * Unregisters the physics imposter on contact
  88963. * @param collideAgainst The physics object to collide against
  88964. * @param func Callback to execute on collision
  88965. */
  88966. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  88967. private _tmpQuat;
  88968. private _tmpQuat2;
  88969. /**
  88970. * Get the parent rotation
  88971. * @returns The parent rotation
  88972. */
  88973. getParentsRotation(): Quaternion;
  88974. /**
  88975. * this function is executed by the physics engine.
  88976. */
  88977. beforeStep: () => void;
  88978. /**
  88979. * this function is executed by the physics engine
  88980. */
  88981. afterStep: () => void;
  88982. /**
  88983. * Legacy collision detection event support
  88984. */
  88985. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88986. /**
  88987. * event and body object due to cannon's event-based architecture.
  88988. */
  88989. onCollide: (e: {
  88990. body: any;
  88991. }) => void;
  88992. /**
  88993. * Apply a force
  88994. * @param force The force to apply
  88995. * @param contactPoint The contact point for the force
  88996. * @returns The physics imposter
  88997. */
  88998. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88999. /**
  89000. * Apply an impulse
  89001. * @param force The impulse force
  89002. * @param contactPoint The contact point for the impulse force
  89003. * @returns The physics imposter
  89004. */
  89005. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89006. /**
  89007. * A help function to create a joint
  89008. * @param otherImpostor A physics imposter used to create a joint
  89009. * @param jointType The type of joint
  89010. * @param jointData The data for the joint
  89011. * @returns The physics imposter
  89012. */
  89013. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  89014. /**
  89015. * Add a joint to this impostor with a different impostor
  89016. * @param otherImpostor A physics imposter used to add a joint
  89017. * @param joint The joint to add
  89018. * @returns The physics imposter
  89019. */
  89020. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  89021. /**
  89022. * Add an anchor to a cloth impostor
  89023. * @param otherImpostor rigid impostor to anchor to
  89024. * @param width ratio across width from 0 to 1
  89025. * @param height ratio up height from 0 to 1
  89026. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  89027. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  89028. * @returns impostor the soft imposter
  89029. */
  89030. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89031. /**
  89032. * Add a hook to a rope impostor
  89033. * @param otherImpostor rigid impostor to anchor to
  89034. * @param length ratio across rope from 0 to 1
  89035. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  89036. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  89037. * @returns impostor the rope imposter
  89038. */
  89039. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89040. /**
  89041. * Will keep this body still, in a sleep mode.
  89042. * @returns the physics imposter
  89043. */
  89044. sleep(): PhysicsImpostor;
  89045. /**
  89046. * Wake the body up.
  89047. * @returns The physics imposter
  89048. */
  89049. wakeUp(): PhysicsImpostor;
  89050. /**
  89051. * Clones the physics imposter
  89052. * @param newObject The physics imposter clones to this physics-enabled object
  89053. * @returns A nullable physics imposter
  89054. */
  89055. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89056. /**
  89057. * Disposes the physics imposter
  89058. */
  89059. dispose(): void;
  89060. /**
  89061. * Sets the delta position
  89062. * @param position The delta position amount
  89063. */
  89064. setDeltaPosition(position: Vector3): void;
  89065. /**
  89066. * Sets the delta rotation
  89067. * @param rotation The delta rotation amount
  89068. */
  89069. setDeltaRotation(rotation: Quaternion): void;
  89070. /**
  89071. * Gets the box size of the physics imposter and stores the result in the input parameter
  89072. * @param result Stores the box size
  89073. * @returns The physics imposter
  89074. */
  89075. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  89076. /**
  89077. * Gets the radius of the physics imposter
  89078. * @returns Radius of the physics imposter
  89079. */
  89080. getRadius(): number;
  89081. /**
  89082. * Sync a bone with this impostor
  89083. * @param bone The bone to sync to the impostor.
  89084. * @param boneMesh The mesh that the bone is influencing.
  89085. * @param jointPivot The pivot of the joint / bone in local space.
  89086. * @param distToJoint Optional distance from the impostor to the joint.
  89087. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89088. */
  89089. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  89090. /**
  89091. * Sync impostor to a bone
  89092. * @param bone The bone that the impostor will be synced to.
  89093. * @param boneMesh The mesh that the bone is influencing.
  89094. * @param jointPivot The pivot of the joint / bone in local space.
  89095. * @param distToJoint Optional distance from the impostor to the joint.
  89096. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89097. * @param boneAxis Optional vector3 axis the bone is aligned with
  89098. */
  89099. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  89100. /**
  89101. * No-Imposter type
  89102. */
  89103. static NoImpostor: number;
  89104. /**
  89105. * Sphere-Imposter type
  89106. */
  89107. static SphereImpostor: number;
  89108. /**
  89109. * Box-Imposter type
  89110. */
  89111. static BoxImpostor: number;
  89112. /**
  89113. * Plane-Imposter type
  89114. */
  89115. static PlaneImpostor: number;
  89116. /**
  89117. * Mesh-imposter type
  89118. */
  89119. static MeshImpostor: number;
  89120. /**
  89121. * Capsule-Impostor type (Ammo.js plugin only)
  89122. */
  89123. static CapsuleImpostor: number;
  89124. /**
  89125. * Cylinder-Imposter type
  89126. */
  89127. static CylinderImpostor: number;
  89128. /**
  89129. * Particle-Imposter type
  89130. */
  89131. static ParticleImpostor: number;
  89132. /**
  89133. * Heightmap-Imposter type
  89134. */
  89135. static HeightmapImpostor: number;
  89136. /**
  89137. * ConvexHull-Impostor type (Ammo.js plugin only)
  89138. */
  89139. static ConvexHullImpostor: number;
  89140. /**
  89141. * Rope-Imposter type
  89142. */
  89143. static RopeImpostor: number;
  89144. /**
  89145. * Cloth-Imposter type
  89146. */
  89147. static ClothImpostor: number;
  89148. /**
  89149. * Softbody-Imposter type
  89150. */
  89151. static SoftbodyImpostor: number;
  89152. }
  89153. }
  89154. declare module BABYLON {
  89155. /**
  89156. * @hidden
  89157. **/
  89158. export class _CreationDataStorage {
  89159. closePath?: boolean;
  89160. closeArray?: boolean;
  89161. idx: number[];
  89162. dashSize: number;
  89163. gapSize: number;
  89164. path3D: Path3D;
  89165. pathArray: Vector3[][];
  89166. arc: number;
  89167. radius: number;
  89168. cap: number;
  89169. tessellation: number;
  89170. }
  89171. /**
  89172. * @hidden
  89173. **/
  89174. class _InstanceDataStorage {
  89175. visibleInstances: any;
  89176. batchCache: _InstancesBatch;
  89177. instancesBufferSize: number;
  89178. instancesBuffer: Nullable<Buffer>;
  89179. instancesData: Float32Array;
  89180. overridenInstanceCount: number;
  89181. isFrozen: boolean;
  89182. previousBatch: Nullable<_InstancesBatch>;
  89183. hardwareInstancedRendering: boolean;
  89184. sideOrientation: number;
  89185. }
  89186. /**
  89187. * @hidden
  89188. **/
  89189. export class _InstancesBatch {
  89190. mustReturn: boolean;
  89191. visibleInstances: Nullable<InstancedMesh[]>[];
  89192. renderSelf: boolean[];
  89193. hardwareInstancedRendering: boolean[];
  89194. }
  89195. /**
  89196. * Class used to represent renderable models
  89197. */
  89198. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89199. /**
  89200. * Mesh side orientation : usually the external or front surface
  89201. */
  89202. static readonly FRONTSIDE: number;
  89203. /**
  89204. * Mesh side orientation : usually the internal or back surface
  89205. */
  89206. static readonly BACKSIDE: number;
  89207. /**
  89208. * Mesh side orientation : both internal and external or front and back surfaces
  89209. */
  89210. static readonly DOUBLESIDE: number;
  89211. /**
  89212. * Mesh side orientation : by default, `FRONTSIDE`
  89213. */
  89214. static readonly DEFAULTSIDE: number;
  89215. /**
  89216. * Mesh cap setting : no cap
  89217. */
  89218. static readonly NO_CAP: number;
  89219. /**
  89220. * Mesh cap setting : one cap at the beginning of the mesh
  89221. */
  89222. static readonly CAP_START: number;
  89223. /**
  89224. * Mesh cap setting : one cap at the end of the mesh
  89225. */
  89226. static readonly CAP_END: number;
  89227. /**
  89228. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89229. */
  89230. static readonly CAP_ALL: number;
  89231. /**
  89232. * Mesh pattern setting : no flip or rotate
  89233. */
  89234. static readonly NO_FLIP: number;
  89235. /**
  89236. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  89237. */
  89238. static readonly FLIP_TILE: number;
  89239. /**
  89240. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  89241. */
  89242. static readonly ROTATE_TILE: number;
  89243. /**
  89244. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  89245. */
  89246. static readonly FLIP_ROW: number;
  89247. /**
  89248. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  89249. */
  89250. static readonly ROTATE_ROW: number;
  89251. /**
  89252. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  89253. */
  89254. static readonly FLIP_N_ROTATE_TILE: number;
  89255. /**
  89256. * Mesh pattern setting : rotate pattern and rotate
  89257. */
  89258. static readonly FLIP_N_ROTATE_ROW: number;
  89259. /**
  89260. * Mesh tile positioning : part tiles same on left/right or top/bottom
  89261. */
  89262. static readonly CENTER: number;
  89263. /**
  89264. * Mesh tile positioning : part tiles on left
  89265. */
  89266. static readonly LEFT: number;
  89267. /**
  89268. * Mesh tile positioning : part tiles on right
  89269. */
  89270. static readonly RIGHT: number;
  89271. /**
  89272. * Mesh tile positioning : part tiles on top
  89273. */
  89274. static readonly TOP: number;
  89275. /**
  89276. * Mesh tile positioning : part tiles on bottom
  89277. */
  89278. static readonly BOTTOM: number;
  89279. /**
  89280. * Gets the default side orientation.
  89281. * @param orientation the orientation to value to attempt to get
  89282. * @returns the default orientation
  89283. * @hidden
  89284. */
  89285. static _GetDefaultSideOrientation(orientation?: number): number;
  89286. private _internalMeshDataInfo;
  89287. /**
  89288. * An event triggered before rendering the mesh
  89289. */
  89290. readonly onBeforeRenderObservable: Observable<Mesh>;
  89291. /**
  89292. * An event triggered before binding the mesh
  89293. */
  89294. readonly onBeforeBindObservable: Observable<Mesh>;
  89295. /**
  89296. * An event triggered after rendering the mesh
  89297. */
  89298. readonly onAfterRenderObservable: Observable<Mesh>;
  89299. /**
  89300. * An event triggered before drawing the mesh
  89301. */
  89302. readonly onBeforeDrawObservable: Observable<Mesh>;
  89303. private _onBeforeDrawObserver;
  89304. /**
  89305. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89306. */
  89307. onBeforeDraw: () => void;
  89308. readonly hasInstances: boolean;
  89309. /**
  89310. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89311. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89312. */
  89313. delayLoadState: number;
  89314. /**
  89315. * Gets the list of instances created from this mesh
  89316. * it is not supposed to be modified manually.
  89317. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89318. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89319. */
  89320. instances: InstancedMesh[];
  89321. /**
  89322. * Gets the file containing delay loading data for this mesh
  89323. */
  89324. delayLoadingFile: string;
  89325. /** @hidden */
  89326. _binaryInfo: any;
  89327. /**
  89328. * User defined function used to change how LOD level selection is done
  89329. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89330. */
  89331. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  89332. /**
  89333. * Gets or sets the morph target manager
  89334. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89335. */
  89336. morphTargetManager: Nullable<MorphTargetManager>;
  89337. /** @hidden */
  89338. _creationDataStorage: Nullable<_CreationDataStorage>;
  89339. /** @hidden */
  89340. _geometry: Nullable<Geometry>;
  89341. /** @hidden */
  89342. _delayInfo: Array<string>;
  89343. /** @hidden */
  89344. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  89345. /** @hidden */
  89346. _instanceDataStorage: _InstanceDataStorage;
  89347. private _effectiveMaterial;
  89348. /** @hidden */
  89349. _shouldGenerateFlatShading: boolean;
  89350. /** @hidden */
  89351. _originalBuilderSideOrientation: number;
  89352. /**
  89353. * Use this property to change the original side orientation defined at construction time
  89354. */
  89355. overrideMaterialSideOrientation: Nullable<number>;
  89356. /**
  89357. * Gets the source mesh (the one used to clone this one from)
  89358. */
  89359. readonly source: Nullable<Mesh>;
  89360. /**
  89361. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89362. */
  89363. isUnIndexed: boolean;
  89364. /**
  89365. * @constructor
  89366. * @param name The value used by scene.getMeshByName() to do a lookup.
  89367. * @param scene The scene to add this mesh to.
  89368. * @param parent The parent of this mesh, if it has one
  89369. * @param source An optional Mesh from which geometry is shared, cloned.
  89370. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89371. * When false, achieved by calling a clone(), also passing False.
  89372. * This will make creation of children, recursive.
  89373. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89374. */
  89375. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  89376. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  89377. /**
  89378. * Gets the class name
  89379. * @returns the string "Mesh".
  89380. */
  89381. getClassName(): string;
  89382. /** @hidden */
  89383. readonly _isMesh: boolean;
  89384. /**
  89385. * Returns a description of this mesh
  89386. * @param fullDetails define if full details about this mesh must be used
  89387. * @returns a descriptive string representing this mesh
  89388. */
  89389. toString(fullDetails?: boolean): string;
  89390. /** @hidden */
  89391. _unBindEffect(): void;
  89392. /**
  89393. * Gets a boolean indicating if this mesh has LOD
  89394. */
  89395. readonly hasLODLevels: boolean;
  89396. /**
  89397. * Gets the list of MeshLODLevel associated with the current mesh
  89398. * @returns an array of MeshLODLevel
  89399. */
  89400. getLODLevels(): MeshLODLevel[];
  89401. private _sortLODLevels;
  89402. /**
  89403. * Add a mesh as LOD level triggered at the given distance.
  89404. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89405. * @param distance The distance from the center of the object to show this level
  89406. * @param mesh The mesh to be added as LOD level (can be null)
  89407. * @return This mesh (for chaining)
  89408. */
  89409. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89410. /**
  89411. * Returns the LOD level mesh at the passed distance or null if not found.
  89412. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89413. * @param distance The distance from the center of the object to show this level
  89414. * @returns a Mesh or `null`
  89415. */
  89416. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89417. /**
  89418. * Remove a mesh from the LOD array
  89419. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89420. * @param mesh defines the mesh to be removed
  89421. * @return This mesh (for chaining)
  89422. */
  89423. removeLODLevel(mesh: Mesh): Mesh;
  89424. /**
  89425. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89426. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89427. * @param camera defines the camera to use to compute distance
  89428. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89429. * @return This mesh (for chaining)
  89430. */
  89431. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89432. /**
  89433. * Gets the mesh internal Geometry object
  89434. */
  89435. readonly geometry: Nullable<Geometry>;
  89436. /**
  89437. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89438. * @returns the total number of vertices
  89439. */
  89440. getTotalVertices(): number;
  89441. /**
  89442. * Returns the content of an associated vertex buffer
  89443. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89444. * - VertexBuffer.PositionKind
  89445. * - VertexBuffer.UVKind
  89446. * - VertexBuffer.UV2Kind
  89447. * - VertexBuffer.UV3Kind
  89448. * - VertexBuffer.UV4Kind
  89449. * - VertexBuffer.UV5Kind
  89450. * - VertexBuffer.UV6Kind
  89451. * - VertexBuffer.ColorKind
  89452. * - VertexBuffer.MatricesIndicesKind
  89453. * - VertexBuffer.MatricesIndicesExtraKind
  89454. * - VertexBuffer.MatricesWeightsKind
  89455. * - VertexBuffer.MatricesWeightsExtraKind
  89456. * @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
  89457. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89458. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89459. */
  89460. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89461. /**
  89462. * Returns the mesh VertexBuffer object from the requested `kind`
  89463. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89464. * - VertexBuffer.PositionKind
  89465. * - VertexBuffer.NormalKind
  89466. * - VertexBuffer.UVKind
  89467. * - VertexBuffer.UV2Kind
  89468. * - VertexBuffer.UV3Kind
  89469. * - VertexBuffer.UV4Kind
  89470. * - VertexBuffer.UV5Kind
  89471. * - VertexBuffer.UV6Kind
  89472. * - VertexBuffer.ColorKind
  89473. * - VertexBuffer.MatricesIndicesKind
  89474. * - VertexBuffer.MatricesIndicesExtraKind
  89475. * - VertexBuffer.MatricesWeightsKind
  89476. * - VertexBuffer.MatricesWeightsExtraKind
  89477. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89478. */
  89479. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89480. /**
  89481. * Tests if a specific vertex buffer is associated with this mesh
  89482. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89483. * - VertexBuffer.PositionKind
  89484. * - VertexBuffer.NormalKind
  89485. * - VertexBuffer.UVKind
  89486. * - VertexBuffer.UV2Kind
  89487. * - VertexBuffer.UV3Kind
  89488. * - VertexBuffer.UV4Kind
  89489. * - VertexBuffer.UV5Kind
  89490. * - VertexBuffer.UV6Kind
  89491. * - VertexBuffer.ColorKind
  89492. * - VertexBuffer.MatricesIndicesKind
  89493. * - VertexBuffer.MatricesIndicesExtraKind
  89494. * - VertexBuffer.MatricesWeightsKind
  89495. * - VertexBuffer.MatricesWeightsExtraKind
  89496. * @returns a boolean
  89497. */
  89498. isVerticesDataPresent(kind: string): boolean;
  89499. /**
  89500. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89501. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89502. * - VertexBuffer.PositionKind
  89503. * - VertexBuffer.UVKind
  89504. * - VertexBuffer.UV2Kind
  89505. * - VertexBuffer.UV3Kind
  89506. * - VertexBuffer.UV4Kind
  89507. * - VertexBuffer.UV5Kind
  89508. * - VertexBuffer.UV6Kind
  89509. * - VertexBuffer.ColorKind
  89510. * - VertexBuffer.MatricesIndicesKind
  89511. * - VertexBuffer.MatricesIndicesExtraKind
  89512. * - VertexBuffer.MatricesWeightsKind
  89513. * - VertexBuffer.MatricesWeightsExtraKind
  89514. * @returns a boolean
  89515. */
  89516. isVertexBufferUpdatable(kind: string): boolean;
  89517. /**
  89518. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89519. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89520. * - VertexBuffer.PositionKind
  89521. * - VertexBuffer.NormalKind
  89522. * - VertexBuffer.UVKind
  89523. * - VertexBuffer.UV2Kind
  89524. * - VertexBuffer.UV3Kind
  89525. * - VertexBuffer.UV4Kind
  89526. * - VertexBuffer.UV5Kind
  89527. * - VertexBuffer.UV6Kind
  89528. * - VertexBuffer.ColorKind
  89529. * - VertexBuffer.MatricesIndicesKind
  89530. * - VertexBuffer.MatricesIndicesExtraKind
  89531. * - VertexBuffer.MatricesWeightsKind
  89532. * - VertexBuffer.MatricesWeightsExtraKind
  89533. * @returns an array of strings
  89534. */
  89535. getVerticesDataKinds(): string[];
  89536. /**
  89537. * Returns a positive integer : the total number of indices in this mesh geometry.
  89538. * @returns the numner of indices or zero if the mesh has no geometry.
  89539. */
  89540. getTotalIndices(): number;
  89541. /**
  89542. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89543. * @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.
  89544. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89545. * @returns the indices array or an empty array if the mesh has no geometry
  89546. */
  89547. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89548. readonly isBlocked: boolean;
  89549. /**
  89550. * Determine if the current mesh is ready to be rendered
  89551. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89552. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89553. * @returns true if all associated assets are ready (material, textures, shaders)
  89554. */
  89555. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89556. /**
  89557. * 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.
  89558. */
  89559. readonly areNormalsFrozen: boolean;
  89560. /**
  89561. * 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.
  89562. * @returns the current mesh
  89563. */
  89564. freezeNormals(): Mesh;
  89565. /**
  89566. * 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
  89567. * @returns the current mesh
  89568. */
  89569. unfreezeNormals(): Mesh;
  89570. /**
  89571. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89572. */
  89573. overridenInstanceCount: number;
  89574. /** @hidden */
  89575. _preActivate(): Mesh;
  89576. /** @hidden */
  89577. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89578. /** @hidden */
  89579. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89580. /**
  89581. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89582. * This means the mesh underlying bounding box and sphere are recomputed.
  89583. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89584. * @returns the current mesh
  89585. */
  89586. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89587. /** @hidden */
  89588. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89589. /**
  89590. * This function will subdivide the mesh into multiple submeshes
  89591. * @param count defines the expected number of submeshes
  89592. */
  89593. subdivide(count: number): void;
  89594. /**
  89595. * Copy a FloatArray into a specific associated vertex buffer
  89596. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89597. * - VertexBuffer.PositionKind
  89598. * - VertexBuffer.UVKind
  89599. * - VertexBuffer.UV2Kind
  89600. * - VertexBuffer.UV3Kind
  89601. * - VertexBuffer.UV4Kind
  89602. * - VertexBuffer.UV5Kind
  89603. * - VertexBuffer.UV6Kind
  89604. * - VertexBuffer.ColorKind
  89605. * - VertexBuffer.MatricesIndicesKind
  89606. * - VertexBuffer.MatricesIndicesExtraKind
  89607. * - VertexBuffer.MatricesWeightsKind
  89608. * - VertexBuffer.MatricesWeightsExtraKind
  89609. * @param data defines the data source
  89610. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89611. * @param stride defines the data stride size (can be null)
  89612. * @returns the current mesh
  89613. */
  89614. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89615. /**
  89616. * Flags an associated vertex buffer as updatable
  89617. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89618. * - VertexBuffer.PositionKind
  89619. * - VertexBuffer.UVKind
  89620. * - VertexBuffer.UV2Kind
  89621. * - VertexBuffer.UV3Kind
  89622. * - VertexBuffer.UV4Kind
  89623. * - VertexBuffer.UV5Kind
  89624. * - VertexBuffer.UV6Kind
  89625. * - VertexBuffer.ColorKind
  89626. * - VertexBuffer.MatricesIndicesKind
  89627. * - VertexBuffer.MatricesIndicesExtraKind
  89628. * - VertexBuffer.MatricesWeightsKind
  89629. * - VertexBuffer.MatricesWeightsExtraKind
  89630. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89631. */
  89632. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89633. /**
  89634. * Sets the mesh global Vertex Buffer
  89635. * @param buffer defines the buffer to use
  89636. * @returns the current mesh
  89637. */
  89638. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89639. /**
  89640. * Update a specific associated vertex buffer
  89641. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89642. * - VertexBuffer.PositionKind
  89643. * - VertexBuffer.UVKind
  89644. * - VertexBuffer.UV2Kind
  89645. * - VertexBuffer.UV3Kind
  89646. * - VertexBuffer.UV4Kind
  89647. * - VertexBuffer.UV5Kind
  89648. * - VertexBuffer.UV6Kind
  89649. * - VertexBuffer.ColorKind
  89650. * - VertexBuffer.MatricesIndicesKind
  89651. * - VertexBuffer.MatricesIndicesExtraKind
  89652. * - VertexBuffer.MatricesWeightsKind
  89653. * - VertexBuffer.MatricesWeightsExtraKind
  89654. * @param data defines the data source
  89655. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89656. * @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)
  89657. * @returns the current mesh
  89658. */
  89659. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89660. /**
  89661. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89662. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89663. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89664. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89665. * @returns the current mesh
  89666. */
  89667. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89668. /**
  89669. * Creates a un-shared specific occurence of the geometry for the mesh.
  89670. * @returns the current mesh
  89671. */
  89672. makeGeometryUnique(): Mesh;
  89673. /**
  89674. * Set the index buffer of this mesh
  89675. * @param indices defines the source data
  89676. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89677. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89678. * @returns the current mesh
  89679. */
  89680. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89681. /**
  89682. * Update the current index buffer
  89683. * @param indices defines the source data
  89684. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89685. * @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)
  89686. * @returns the current mesh
  89687. */
  89688. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89689. /**
  89690. * Invert the geometry to move from a right handed system to a left handed one.
  89691. * @returns the current mesh
  89692. */
  89693. toLeftHanded(): Mesh;
  89694. /** @hidden */
  89695. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89696. /** @hidden */
  89697. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89698. /**
  89699. * Registers for this mesh a javascript function called just before the rendering process
  89700. * @param func defines the function to call before rendering this mesh
  89701. * @returns the current mesh
  89702. */
  89703. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89704. /**
  89705. * Disposes a previously registered javascript function called before the rendering
  89706. * @param func defines the function to remove
  89707. * @returns the current mesh
  89708. */
  89709. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89710. /**
  89711. * Registers for this mesh a javascript function called just after the rendering is complete
  89712. * @param func defines the function to call after rendering this mesh
  89713. * @returns the current mesh
  89714. */
  89715. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89716. /**
  89717. * Disposes a previously registered javascript function called after the rendering.
  89718. * @param func defines the function to remove
  89719. * @returns the current mesh
  89720. */
  89721. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89722. /** @hidden */
  89723. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89724. /** @hidden */
  89725. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89726. /** @hidden */
  89727. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89728. /** @hidden */
  89729. _rebuild(): void;
  89730. /** @hidden */
  89731. _freeze(): void;
  89732. /** @hidden */
  89733. _unFreeze(): void;
  89734. /**
  89735. * 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
  89736. * @param subMesh defines the subMesh to render
  89737. * @param enableAlphaMode defines if alpha mode can be changed
  89738. * @returns the current mesh
  89739. */
  89740. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89741. private _onBeforeDraw;
  89742. /**
  89743. * Renormalize the mesh and patch it up if there are no weights
  89744. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89745. * However in the case of zero weights then we set just a single influence to 1.
  89746. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89747. */
  89748. cleanMatrixWeights(): void;
  89749. private normalizeSkinFourWeights;
  89750. private normalizeSkinWeightsAndExtra;
  89751. /**
  89752. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89753. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89754. * the user know there was an issue with importing the mesh
  89755. * @returns a validation object with skinned, valid and report string
  89756. */
  89757. validateSkinning(): {
  89758. skinned: boolean;
  89759. valid: boolean;
  89760. report: string;
  89761. };
  89762. /** @hidden */
  89763. _checkDelayState(): Mesh;
  89764. private _queueLoad;
  89765. /**
  89766. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89767. * A mesh is in the frustum if its bounding box intersects the frustum
  89768. * @param frustumPlanes defines the frustum to test
  89769. * @returns true if the mesh is in the frustum planes
  89770. */
  89771. isInFrustum(frustumPlanes: Plane[]): boolean;
  89772. /**
  89773. * Sets the mesh material by the material or multiMaterial `id` property
  89774. * @param id is a string identifying the material or the multiMaterial
  89775. * @returns the current mesh
  89776. */
  89777. setMaterialByID(id: string): Mesh;
  89778. /**
  89779. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89780. * @returns an array of IAnimatable
  89781. */
  89782. getAnimatables(): IAnimatable[];
  89783. /**
  89784. * Modifies the mesh geometry according to the passed transformation matrix.
  89785. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89786. * The mesh normals are modified using the same transformation.
  89787. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89788. * @param transform defines the transform matrix to use
  89789. * @see http://doc.babylonjs.com/resources/baking_transformations
  89790. * @returns the current mesh
  89791. */
  89792. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89793. /**
  89794. * Modifies the mesh geometry according to its own current World Matrix.
  89795. * The mesh World Matrix is then reset.
  89796. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89797. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89798. * @see http://doc.babylonjs.com/resources/baking_transformations
  89799. * @returns the current mesh
  89800. */
  89801. bakeCurrentTransformIntoVertices(): Mesh;
  89802. /** @hidden */
  89803. readonly _positions: Nullable<Vector3[]>;
  89804. /** @hidden */
  89805. _resetPointsArrayCache(): Mesh;
  89806. /** @hidden */
  89807. _generatePointsArray(): boolean;
  89808. /**
  89809. * Returns a new Mesh object generated from the current mesh properties.
  89810. * This method must not get confused with createInstance()
  89811. * @param name is a string, the name given to the new mesh
  89812. * @param newParent can be any Node object (default `null`)
  89813. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89814. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89815. * @returns a new mesh
  89816. */
  89817. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89818. /**
  89819. * Releases resources associated with this mesh.
  89820. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89821. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89822. */
  89823. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89824. /**
  89825. * Modifies the mesh geometry according to a displacement map.
  89826. * 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.
  89827. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89828. * @param url is a string, the URL from the image file is to be downloaded.
  89829. * @param minHeight is the lower limit of the displacement.
  89830. * @param maxHeight is the upper limit of the displacement.
  89831. * @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.
  89832. * @param uvOffset is an optional vector2 used to offset UV.
  89833. * @param uvScale is an optional vector2 used to scale UV.
  89834. * @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.
  89835. * @returns the Mesh.
  89836. */
  89837. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89838. /**
  89839. * Modifies the mesh geometry according to a displacementMap buffer.
  89840. * 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.
  89841. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89842. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89843. * @param heightMapWidth is the width of the buffer image.
  89844. * @param heightMapHeight is the height of the buffer image.
  89845. * @param minHeight is the lower limit of the displacement.
  89846. * @param maxHeight is the upper limit of the displacement.
  89847. * @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.
  89848. * @param uvOffset is an optional vector2 used to offset UV.
  89849. * @param uvScale is an optional vector2 used to scale UV.
  89850. * @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.
  89851. * @returns the Mesh.
  89852. */
  89853. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89854. /**
  89855. * Modify the mesh to get a flat shading rendering.
  89856. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89857. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89858. * @returns current mesh
  89859. */
  89860. convertToFlatShadedMesh(): Mesh;
  89861. /**
  89862. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89863. * In other words, more vertices, no more indices and a single bigger VBO.
  89864. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89865. * @returns current mesh
  89866. */
  89867. convertToUnIndexedMesh(): Mesh;
  89868. /**
  89869. * Inverses facet orientations.
  89870. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89871. * @param flipNormals will also inverts the normals
  89872. * @returns current mesh
  89873. */
  89874. flipFaces(flipNormals?: boolean): Mesh;
  89875. /**
  89876. * Increase the number of facets and hence vertices in a mesh
  89877. * Vertex normals are interpolated from existing vertex normals
  89878. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89879. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89880. */
  89881. increaseVertices(numberPerEdge: number): void;
  89882. /**
  89883. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89884. * This will undo any application of covertToFlatShadedMesh
  89885. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89886. */
  89887. forceSharedVertices(): void;
  89888. /** @hidden */
  89889. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  89890. /** @hidden */
  89891. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  89892. /**
  89893. * Creates a new InstancedMesh object from the mesh model.
  89894. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89895. * @param name defines the name of the new instance
  89896. * @returns a new InstancedMesh
  89897. */
  89898. createInstance(name: string): InstancedMesh;
  89899. /**
  89900. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89901. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89902. * @returns the current mesh
  89903. */
  89904. synchronizeInstances(): Mesh;
  89905. /**
  89906. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89907. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89908. * This should be used together with the simplification to avoid disappearing triangles.
  89909. * @param successCallback an optional success callback to be called after the optimization finished.
  89910. * @returns the current mesh
  89911. */
  89912. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  89913. /**
  89914. * Serialize current mesh
  89915. * @param serializationObject defines the object which will receive the serialization data
  89916. */
  89917. serialize(serializationObject: any): void;
  89918. /** @hidden */
  89919. _syncGeometryWithMorphTargetManager(): void;
  89920. /** @hidden */
  89921. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  89922. /**
  89923. * Returns a new Mesh object parsed from the source provided.
  89924. * @param parsedMesh is the source
  89925. * @param scene defines the hosting scene
  89926. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89927. * @returns a new Mesh
  89928. */
  89929. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  89930. /**
  89931. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89932. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89933. * @param name defines the name of the mesh to create
  89934. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89935. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89936. * @param closePath creates a seam between the first and the last points of each path of the path array
  89937. * @param offset is taken in account only if the `pathArray` is containing a single path
  89938. * @param scene defines the hosting scene
  89939. * @param updatable defines if the mesh must be flagged as updatable
  89940. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89941. * @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)
  89942. * @returns a new Mesh
  89943. */
  89944. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89945. /**
  89946. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89947. * @param name defines the name of the mesh to create
  89948. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89949. * @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
  89950. * @param scene defines the hosting scene
  89951. * @param updatable defines if the mesh must be flagged as updatable
  89952. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89953. * @returns a new Mesh
  89954. */
  89955. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89956. /**
  89957. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89958. * @param name defines the name of the mesh to create
  89959. * @param size sets the size (float) of each box side (default 1)
  89960. * @param scene defines the hosting scene
  89961. * @param updatable defines if the mesh must be flagged as updatable
  89962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89963. * @returns a new Mesh
  89964. */
  89965. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89966. /**
  89967. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89968. * @param name defines the name of the mesh to create
  89969. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89970. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89971. * @param scene defines the hosting scene
  89972. * @param updatable defines if the mesh must be flagged as updatable
  89973. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89974. * @returns a new Mesh
  89975. */
  89976. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89977. /**
  89978. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89979. * @param name defines the name of the mesh to create
  89980. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89981. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89982. * @param scene defines the hosting scene
  89983. * @returns a new Mesh
  89984. */
  89985. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89986. /**
  89987. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89988. * @param name defines the name of the mesh to create
  89989. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89990. * @param diameterTop set the top cap diameter (floats, default 1)
  89991. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89992. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89993. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89994. * @param scene defines the hosting scene
  89995. * @param updatable defines if the mesh must be flagged as updatable
  89996. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89997. * @returns a new Mesh
  89998. */
  89999. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  90000. /**
  90001. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90002. * @param name defines the name of the mesh to create
  90003. * @param diameter sets the diameter size (float) of the torus (default 1)
  90004. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90005. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90006. * @param scene defines the hosting scene
  90007. * @param updatable defines if the mesh must be flagged as updatable
  90008. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90009. * @returns a new Mesh
  90010. */
  90011. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90012. /**
  90013. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90014. * @param name defines the name of the mesh to create
  90015. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90016. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90017. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90018. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90019. * @param p the number of windings on X axis (positive integers, default 2)
  90020. * @param q the number of windings on Y axis (positive integers, default 3)
  90021. * @param scene defines the hosting scene
  90022. * @param updatable defines if the mesh must be flagged as updatable
  90023. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90024. * @returns a new Mesh
  90025. */
  90026. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90027. /**
  90028. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90029. * @param name defines the name of the mesh to create
  90030. * @param points is an array successive Vector3
  90031. * @param scene defines the hosting scene
  90032. * @param updatable defines if the mesh must be flagged as updatable
  90033. * @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).
  90034. * @returns a new Mesh
  90035. */
  90036. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  90037. /**
  90038. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90039. * @param name defines the name of the mesh to create
  90040. * @param points is an array successive Vector3
  90041. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90042. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90043. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90044. * @param scene defines the hosting scene
  90045. * @param updatable defines if the mesh must be flagged as updatable
  90046. * @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)
  90047. * @returns a new Mesh
  90048. */
  90049. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  90050. /**
  90051. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90052. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90053. * 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.
  90054. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90055. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90056. * Remember you can only change the shape positions, not their number when updating a polygon.
  90057. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90058. * @param name defines the name of the mesh to create
  90059. * @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
  90060. * @param scene defines the hosting scene
  90061. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90062. * @param updatable defines if the mesh must be flagged as updatable
  90063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90064. * @param earcutInjection can be used to inject your own earcut reference
  90065. * @returns a new Mesh
  90066. */
  90067. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90068. /**
  90069. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90070. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90071. * @param name defines the name of the mesh to create
  90072. * @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
  90073. * @param depth defines the height of extrusion
  90074. * @param scene defines the hosting scene
  90075. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90076. * @param updatable defines if the mesh must be flagged as updatable
  90077. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90078. * @param earcutInjection can be used to inject your own earcut reference
  90079. * @returns a new Mesh
  90080. */
  90081. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90082. /**
  90083. * Creates an extruded shape mesh.
  90084. * 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
  90085. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90086. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90087. * @param name defines the name of the mesh to create
  90088. * @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
  90089. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90090. * @param scale is the value to scale the shape
  90091. * @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
  90092. * @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
  90093. * @param scene defines the hosting scene
  90094. * @param updatable defines if the mesh must be flagged as updatable
  90095. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90096. * @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)
  90097. * @returns a new Mesh
  90098. */
  90099. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90100. /**
  90101. * Creates an custom extruded shape mesh.
  90102. * The custom extrusion is a parametric shape.
  90103. * It has no predefined shape. Its final shape will depend on the input parameters.
  90104. * Please consider using the same method from the MeshBuilder class instead
  90105. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90106. * @param name defines the name of the mesh to create
  90107. * @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
  90108. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90109. * @param scaleFunction is a custom Javascript function called on each path point
  90110. * @param rotationFunction is a custom Javascript function called on each path point
  90111. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90112. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90113. * @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
  90114. * @param scene defines the hosting scene
  90115. * @param updatable defines if the mesh must be flagged as updatable
  90116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90117. * @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)
  90118. * @returns a new Mesh
  90119. */
  90120. 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;
  90121. /**
  90122. * Creates lathe mesh.
  90123. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90124. * Please consider using the same method from the MeshBuilder class instead
  90125. * @param name defines the name of the mesh to create
  90126. * @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
  90127. * @param radius is the radius value of the lathe
  90128. * @param tessellation is the side number of the lathe.
  90129. * @param scene defines the hosting scene
  90130. * @param updatable defines if the mesh must be flagged as updatable
  90131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90132. * @returns a new Mesh
  90133. */
  90134. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90135. /**
  90136. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90137. * @param name defines the name of the mesh to create
  90138. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90139. * @param scene defines the hosting scene
  90140. * @param updatable defines if the mesh must be flagged as updatable
  90141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90142. * @returns a new Mesh
  90143. */
  90144. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90145. /**
  90146. * Creates a ground mesh.
  90147. * Please consider using the same method from the MeshBuilder class instead
  90148. * @param name defines the name of the mesh to create
  90149. * @param width set the width of the ground
  90150. * @param height set the height of the ground
  90151. * @param subdivisions sets the number of subdivisions per side
  90152. * @param scene defines the hosting scene
  90153. * @param updatable defines if the mesh must be flagged as updatable
  90154. * @returns a new Mesh
  90155. */
  90156. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90157. /**
  90158. * Creates a tiled ground mesh.
  90159. * Please consider using the same method from the MeshBuilder class instead
  90160. * @param name defines the name of the mesh to create
  90161. * @param xmin set the ground minimum X coordinate
  90162. * @param zmin set the ground minimum Y coordinate
  90163. * @param xmax set the ground maximum X coordinate
  90164. * @param zmax set the ground maximum Z coordinate
  90165. * @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
  90166. * @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
  90167. * @param scene defines the hosting scene
  90168. * @param updatable defines if the mesh must be flagged as updatable
  90169. * @returns a new Mesh
  90170. */
  90171. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90172. w: number;
  90173. h: number;
  90174. }, precision: {
  90175. w: number;
  90176. h: number;
  90177. }, scene: Scene, updatable?: boolean): Mesh;
  90178. /**
  90179. * Creates a ground mesh from a height map.
  90180. * Please consider using the same method from the MeshBuilder class instead
  90181. * @see http://doc.babylonjs.com/babylon101/height_map
  90182. * @param name defines the name of the mesh to create
  90183. * @param url sets the URL of the height map image resource
  90184. * @param width set the ground width size
  90185. * @param height set the ground height size
  90186. * @param subdivisions sets the number of subdivision per side
  90187. * @param minHeight is the minimum altitude on the ground
  90188. * @param maxHeight is the maximum altitude on the ground
  90189. * @param scene defines the hosting scene
  90190. * @param updatable defines if the mesh must be flagged as updatable
  90191. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90192. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90193. * @returns a new Mesh
  90194. */
  90195. 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;
  90196. /**
  90197. * Creates a tube mesh.
  90198. * The tube is a parametric shape.
  90199. * It has no predefined shape. Its final shape will depend on the input parameters.
  90200. * Please consider using the same method from the MeshBuilder class instead
  90201. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90202. * @param name defines the name of the mesh to create
  90203. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90204. * @param radius sets the tube radius size
  90205. * @param tessellation is the number of sides on the tubular surface
  90206. * @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
  90207. * @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
  90208. * @param scene defines the hosting scene
  90209. * @param updatable defines if the mesh must be flagged as updatable
  90210. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90211. * @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)
  90212. * @returns a new Mesh
  90213. */
  90214. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90215. (i: number, distance: number): number;
  90216. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90217. /**
  90218. * Creates a polyhedron mesh.
  90219. * Please consider using the same method from the MeshBuilder class instead.
  90220. * * 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
  90221. * * The parameter `size` (positive float, default 1) sets the polygon size
  90222. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90223. * * 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`
  90224. * * 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
  90225. * * 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)`)
  90226. * * 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
  90227. * * 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
  90228. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90229. * * If you create a double-sided mesh, you can choose what parts of 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
  90230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90231. * @param name defines the name of the mesh to create
  90232. * @param options defines the options used to create the mesh
  90233. * @param scene defines the hosting scene
  90234. * @returns a new Mesh
  90235. */
  90236. static CreatePolyhedron(name: string, options: {
  90237. type?: number;
  90238. size?: number;
  90239. sizeX?: number;
  90240. sizeY?: number;
  90241. sizeZ?: number;
  90242. custom?: any;
  90243. faceUV?: Vector4[];
  90244. faceColors?: Color4[];
  90245. updatable?: boolean;
  90246. sideOrientation?: number;
  90247. }, scene: Scene): Mesh;
  90248. /**
  90249. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90250. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90251. * * 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`)
  90252. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90253. * * 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
  90254. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90255. * * If you create a double-sided mesh, you can choose what parts of 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
  90256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90257. * @param name defines the name of the mesh
  90258. * @param options defines the options used to create the mesh
  90259. * @param scene defines the hosting scene
  90260. * @returns a new Mesh
  90261. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90262. */
  90263. static CreateIcoSphere(name: string, options: {
  90264. radius?: number;
  90265. flat?: boolean;
  90266. subdivisions?: number;
  90267. sideOrientation?: number;
  90268. updatable?: boolean;
  90269. }, scene: Scene): Mesh;
  90270. /**
  90271. * Creates a decal mesh.
  90272. * Please consider using the same method from the MeshBuilder class instead.
  90273. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90274. * @param name defines the name of the mesh
  90275. * @param sourceMesh defines the mesh receiving the decal
  90276. * @param position sets the position of the decal in world coordinates
  90277. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90278. * @param size sets the decal scaling
  90279. * @param angle sets the angle to rotate the decal
  90280. * @returns a new Mesh
  90281. */
  90282. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  90283. /**
  90284. * Prepare internal position array for software CPU skinning
  90285. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90286. */
  90287. setPositionsForCPUSkinning(): Float32Array;
  90288. /**
  90289. * Prepare internal normal array for software CPU skinning
  90290. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90291. */
  90292. setNormalsForCPUSkinning(): Float32Array;
  90293. /**
  90294. * Updates the vertex buffer by applying transformation from the bones
  90295. * @param skeleton defines the skeleton to apply to current mesh
  90296. * @returns the current mesh
  90297. */
  90298. applySkeleton(skeleton: Skeleton): Mesh;
  90299. /**
  90300. * 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
  90301. * @param meshes defines the list of meshes to scan
  90302. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90303. */
  90304. static MinMax(meshes: AbstractMesh[]): {
  90305. min: Vector3;
  90306. max: Vector3;
  90307. };
  90308. /**
  90309. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90310. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90311. * @returns a vector3
  90312. */
  90313. static Center(meshesOrMinMaxVector: {
  90314. min: Vector3;
  90315. max: Vector3;
  90316. } | AbstractMesh[]): Vector3;
  90317. /**
  90318. * Merge the array of meshes into a single mesh for performance reasons.
  90319. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90320. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90321. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90322. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90323. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90324. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90325. * @returns a new mesh
  90326. */
  90327. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  90328. /** @hidden */
  90329. addInstance(instance: InstancedMesh): void;
  90330. /** @hidden */
  90331. removeInstance(instance: InstancedMesh): void;
  90332. }
  90333. }
  90334. declare module BABYLON {
  90335. /**
  90336. * This is the base class of all the camera used in the application.
  90337. * @see http://doc.babylonjs.com/features/cameras
  90338. */
  90339. export class Camera extends Node {
  90340. /** @hidden */
  90341. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90342. /**
  90343. * This is the default projection mode used by the cameras.
  90344. * It helps recreating a feeling of perspective and better appreciate depth.
  90345. * This is the best way to simulate real life cameras.
  90346. */
  90347. static readonly PERSPECTIVE_CAMERA: number;
  90348. /**
  90349. * This helps creating camera with an orthographic mode.
  90350. * 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.
  90351. */
  90352. static readonly ORTHOGRAPHIC_CAMERA: number;
  90353. /**
  90354. * This is the default FOV mode for perspective cameras.
  90355. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90356. */
  90357. static readonly FOVMODE_VERTICAL_FIXED: number;
  90358. /**
  90359. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90360. */
  90361. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90362. /**
  90363. * This specifies ther is no need for a camera rig.
  90364. * Basically only one eye is rendered corresponding to the camera.
  90365. */
  90366. static readonly RIG_MODE_NONE: number;
  90367. /**
  90368. * Simulates a camera Rig with one blue eye and one red eye.
  90369. * This can be use with 3d blue and red glasses.
  90370. */
  90371. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90372. /**
  90373. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90374. */
  90375. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90376. /**
  90377. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90378. */
  90379. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90380. /**
  90381. * Defines that both eyes of the camera will be rendered over under each other.
  90382. */
  90383. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90384. /**
  90385. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90386. */
  90387. static readonly RIG_MODE_VR: number;
  90388. /**
  90389. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90390. */
  90391. static readonly RIG_MODE_WEBVR: number;
  90392. /**
  90393. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90394. */
  90395. static readonly RIG_MODE_CUSTOM: number;
  90396. /**
  90397. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90398. */
  90399. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90400. /**
  90401. * Define the input manager associated with the camera.
  90402. */
  90403. inputs: CameraInputsManager<Camera>;
  90404. /** @hidden */
  90405. _position: Vector3;
  90406. /**
  90407. * Define the current local position of the camera in the scene
  90408. */
  90409. position: Vector3;
  90410. /**
  90411. * The vector the camera should consider as up.
  90412. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90413. */
  90414. upVector: Vector3;
  90415. /**
  90416. * Define the current limit on the left side for an orthographic camera
  90417. * In scene unit
  90418. */
  90419. orthoLeft: Nullable<number>;
  90420. /**
  90421. * Define the current limit on the right side for an orthographic camera
  90422. * In scene unit
  90423. */
  90424. orthoRight: Nullable<number>;
  90425. /**
  90426. * Define the current limit on the bottom side for an orthographic camera
  90427. * In scene unit
  90428. */
  90429. orthoBottom: Nullable<number>;
  90430. /**
  90431. * Define the current limit on the top side for an orthographic camera
  90432. * In scene unit
  90433. */
  90434. orthoTop: Nullable<number>;
  90435. /**
  90436. * Field Of View is set in Radians. (default is 0.8)
  90437. */
  90438. fov: number;
  90439. /**
  90440. * Define the minimum distance the camera can see from.
  90441. * This is important to note that the depth buffer are not infinite and the closer it starts
  90442. * the more your scene might encounter depth fighting issue.
  90443. */
  90444. minZ: number;
  90445. /**
  90446. * Define the maximum distance the camera can see to.
  90447. * This is important to note that the depth buffer are not infinite and the further it end
  90448. * the more your scene might encounter depth fighting issue.
  90449. */
  90450. maxZ: number;
  90451. /**
  90452. * Define the default inertia of the camera.
  90453. * This helps giving a smooth feeling to the camera movement.
  90454. */
  90455. inertia: number;
  90456. /**
  90457. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90458. */
  90459. mode: number;
  90460. /**
  90461. * Define wether the camera is intermediate.
  90462. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90463. */
  90464. isIntermediate: boolean;
  90465. /**
  90466. * Define the viewport of the camera.
  90467. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90468. */
  90469. viewport: Viewport;
  90470. /**
  90471. * Restricts the camera to viewing objects with the same layerMask.
  90472. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90473. */
  90474. layerMask: number;
  90475. /**
  90476. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90477. */
  90478. fovMode: number;
  90479. /**
  90480. * Rig mode of the camera.
  90481. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90482. * This is normally controlled byt the camera themselves as internal use.
  90483. */
  90484. cameraRigMode: number;
  90485. /**
  90486. * Defines the distance between both "eyes" in case of a RIG
  90487. */
  90488. interaxialDistance: number;
  90489. /**
  90490. * Defines if stereoscopic rendering is done side by side or over under.
  90491. */
  90492. isStereoscopicSideBySide: boolean;
  90493. /**
  90494. * 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
  90495. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90496. * else in the scene. (Eg. security camera)
  90497. *
  90498. * 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)
  90499. */
  90500. customRenderTargets: RenderTargetTexture[];
  90501. /**
  90502. * When set, the camera will render to this render target instead of the default canvas
  90503. *
  90504. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90505. */
  90506. outputRenderTarget: Nullable<RenderTargetTexture>;
  90507. /**
  90508. * Observable triggered when the camera view matrix has changed.
  90509. */
  90510. onViewMatrixChangedObservable: Observable<Camera>;
  90511. /**
  90512. * Observable triggered when the camera Projection matrix has changed.
  90513. */
  90514. onProjectionMatrixChangedObservable: Observable<Camera>;
  90515. /**
  90516. * Observable triggered when the inputs have been processed.
  90517. */
  90518. onAfterCheckInputsObservable: Observable<Camera>;
  90519. /**
  90520. * Observable triggered when reset has been called and applied to the camera.
  90521. */
  90522. onRestoreStateObservable: Observable<Camera>;
  90523. /** @hidden */
  90524. _cameraRigParams: any;
  90525. /** @hidden */
  90526. _rigCameras: Camera[];
  90527. /** @hidden */
  90528. _rigPostProcess: Nullable<PostProcess>;
  90529. protected _webvrViewMatrix: Matrix;
  90530. /** @hidden */
  90531. _skipRendering: boolean;
  90532. /** @hidden */
  90533. _projectionMatrix: Matrix;
  90534. /** @hidden */
  90535. _postProcesses: Nullable<PostProcess>[];
  90536. /** @hidden */
  90537. _activeMeshes: SmartArray<AbstractMesh>;
  90538. protected _globalPosition: Vector3;
  90539. /** @hidden */
  90540. _computedViewMatrix: Matrix;
  90541. private _doNotComputeProjectionMatrix;
  90542. private _transformMatrix;
  90543. private _frustumPlanes;
  90544. private _refreshFrustumPlanes;
  90545. private _storedFov;
  90546. private _stateStored;
  90547. /**
  90548. * Instantiates a new camera object.
  90549. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90550. * @see http://doc.babylonjs.com/features/cameras
  90551. * @param name Defines the name of the camera in the scene
  90552. * @param position Defines the position of the camera
  90553. * @param scene Defines the scene the camera belongs too
  90554. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90555. */
  90556. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90557. /**
  90558. * Store current camera state (fov, position, etc..)
  90559. * @returns the camera
  90560. */
  90561. storeState(): Camera;
  90562. /**
  90563. * Restores the camera state values if it has been stored. You must call storeState() first
  90564. */
  90565. protected _restoreStateValues(): boolean;
  90566. /**
  90567. * Restored camera state. You must call storeState() first.
  90568. * @returns true if restored and false otherwise
  90569. */
  90570. restoreState(): boolean;
  90571. /**
  90572. * Gets the class name of the camera.
  90573. * @returns the class name
  90574. */
  90575. getClassName(): string;
  90576. /** @hidden */
  90577. readonly _isCamera: boolean;
  90578. /**
  90579. * Gets a string representation of the camera useful for debug purpose.
  90580. * @param fullDetails Defines that a more verboe level of logging is required
  90581. * @returns the string representation
  90582. */
  90583. toString(fullDetails?: boolean): string;
  90584. /**
  90585. * Gets the current world space position of the camera.
  90586. */
  90587. readonly globalPosition: Vector3;
  90588. /**
  90589. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90590. * @returns the active meshe list
  90591. */
  90592. getActiveMeshes(): SmartArray<AbstractMesh>;
  90593. /**
  90594. * Check wether a mesh is part of the current active mesh list of the camera
  90595. * @param mesh Defines the mesh to check
  90596. * @returns true if active, false otherwise
  90597. */
  90598. isActiveMesh(mesh: Mesh): boolean;
  90599. /**
  90600. * Is this camera ready to be used/rendered
  90601. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90602. * @return true if the camera is ready
  90603. */
  90604. isReady(completeCheck?: boolean): boolean;
  90605. /** @hidden */
  90606. _initCache(): void;
  90607. /** @hidden */
  90608. _updateCache(ignoreParentClass?: boolean): void;
  90609. /** @hidden */
  90610. _isSynchronized(): boolean;
  90611. /** @hidden */
  90612. _isSynchronizedViewMatrix(): boolean;
  90613. /** @hidden */
  90614. _isSynchronizedProjectionMatrix(): boolean;
  90615. /**
  90616. * Attach the input controls to a specific dom element to get the input from.
  90617. * @param element Defines the element the controls should be listened from
  90618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90619. */
  90620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90621. /**
  90622. * Detach the current controls from the specified dom element.
  90623. * @param element Defines the element to stop listening the inputs from
  90624. */
  90625. detachControl(element: HTMLElement): void;
  90626. /**
  90627. * Update the camera state according to the different inputs gathered during the frame.
  90628. */
  90629. update(): void;
  90630. /** @hidden */
  90631. _checkInputs(): void;
  90632. /** @hidden */
  90633. readonly rigCameras: Camera[];
  90634. /**
  90635. * Gets the post process used by the rig cameras
  90636. */
  90637. readonly rigPostProcess: Nullable<PostProcess>;
  90638. /**
  90639. * Internal, gets the first post proces.
  90640. * @returns the first post process to be run on this camera.
  90641. */
  90642. _getFirstPostProcess(): Nullable<PostProcess>;
  90643. private _cascadePostProcessesToRigCams;
  90644. /**
  90645. * Attach a post process to the camera.
  90646. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90647. * @param postProcess The post process to attach to the camera
  90648. * @param insertAt The position of the post process in case several of them are in use in the scene
  90649. * @returns the position the post process has been inserted at
  90650. */
  90651. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90652. /**
  90653. * Detach a post process to the camera.
  90654. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90655. * @param postProcess The post process to detach from the camera
  90656. */
  90657. detachPostProcess(postProcess: PostProcess): void;
  90658. /**
  90659. * Gets the current world matrix of the camera
  90660. */
  90661. getWorldMatrix(): Matrix;
  90662. /** @hidden */
  90663. _getViewMatrix(): Matrix;
  90664. /**
  90665. * Gets the current view matrix of the camera.
  90666. * @param force forces the camera to recompute the matrix without looking at the cached state
  90667. * @returns the view matrix
  90668. */
  90669. getViewMatrix(force?: boolean): Matrix;
  90670. /**
  90671. * Freeze the projection matrix.
  90672. * It will prevent the cache check of the camera projection compute and can speed up perf
  90673. * if no parameter of the camera are meant to change
  90674. * @param projection Defines manually a projection if necessary
  90675. */
  90676. freezeProjectionMatrix(projection?: Matrix): void;
  90677. /**
  90678. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90679. */
  90680. unfreezeProjectionMatrix(): void;
  90681. /**
  90682. * Gets the current projection matrix of the camera.
  90683. * @param force forces the camera to recompute the matrix without looking at the cached state
  90684. * @returns the projection matrix
  90685. */
  90686. getProjectionMatrix(force?: boolean): Matrix;
  90687. /**
  90688. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90689. * @returns a Matrix
  90690. */
  90691. getTransformationMatrix(): Matrix;
  90692. private _updateFrustumPlanes;
  90693. /**
  90694. * Checks if a cullable object (mesh...) is in the camera frustum
  90695. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90696. * @param target The object to check
  90697. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90698. * @returns true if the object is in frustum otherwise false
  90699. */
  90700. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90701. /**
  90702. * Checks if a cullable object (mesh...) is in the camera frustum
  90703. * Unlike isInFrustum this cheks the full bounding box
  90704. * @param target The object to check
  90705. * @returns true if the object is in frustum otherwise false
  90706. */
  90707. isCompletelyInFrustum(target: ICullable): boolean;
  90708. /**
  90709. * Gets a ray in the forward direction from the camera.
  90710. * @param length Defines the length of the ray to create
  90711. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90712. * @param origin Defines the start point of the ray which defaults to the camera position
  90713. * @returns the forward ray
  90714. */
  90715. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90716. /**
  90717. * Releases resources associated with this node.
  90718. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90719. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90720. */
  90721. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90722. /** @hidden */
  90723. _isLeftCamera: boolean;
  90724. /**
  90725. * Gets the left camera of a rig setup in case of Rigged Camera
  90726. */
  90727. readonly isLeftCamera: boolean;
  90728. /** @hidden */
  90729. _isRightCamera: boolean;
  90730. /**
  90731. * Gets the right camera of a rig setup in case of Rigged Camera
  90732. */
  90733. readonly isRightCamera: boolean;
  90734. /**
  90735. * Gets the left camera of a rig setup in case of Rigged Camera
  90736. */
  90737. readonly leftCamera: Nullable<FreeCamera>;
  90738. /**
  90739. * Gets the right camera of a rig setup in case of Rigged Camera
  90740. */
  90741. readonly rightCamera: Nullable<FreeCamera>;
  90742. /**
  90743. * Gets the left camera target of a rig setup in case of Rigged Camera
  90744. * @returns the target position
  90745. */
  90746. getLeftTarget(): Nullable<Vector3>;
  90747. /**
  90748. * Gets the right camera target of a rig setup in case of Rigged Camera
  90749. * @returns the target position
  90750. */
  90751. getRightTarget(): Nullable<Vector3>;
  90752. /**
  90753. * @hidden
  90754. */
  90755. setCameraRigMode(mode: number, rigParams: any): void;
  90756. /** @hidden */
  90757. static _setStereoscopicRigMode(camera: Camera): void;
  90758. /** @hidden */
  90759. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90760. /** @hidden */
  90761. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90762. /** @hidden */
  90763. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90764. /** @hidden */
  90765. _getVRProjectionMatrix(): Matrix;
  90766. protected _updateCameraRotationMatrix(): void;
  90767. protected _updateWebVRCameraRotationMatrix(): void;
  90768. /**
  90769. * This function MUST be overwritten by the different WebVR cameras available.
  90770. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90771. * @hidden
  90772. */
  90773. _getWebVRProjectionMatrix(): Matrix;
  90774. /**
  90775. * This function MUST be overwritten by the different WebVR cameras available.
  90776. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90777. * @hidden
  90778. */
  90779. _getWebVRViewMatrix(): Matrix;
  90780. /** @hidden */
  90781. setCameraRigParameter(name: string, value: any): void;
  90782. /**
  90783. * needs to be overridden by children so sub has required properties to be copied
  90784. * @hidden
  90785. */
  90786. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90787. /**
  90788. * May need to be overridden by children
  90789. * @hidden
  90790. */
  90791. _updateRigCameras(): void;
  90792. /** @hidden */
  90793. _setupInputs(): void;
  90794. /**
  90795. * Serialiaze the camera setup to a json represention
  90796. * @returns the JSON representation
  90797. */
  90798. serialize(): any;
  90799. /**
  90800. * Clones the current camera.
  90801. * @param name The cloned camera name
  90802. * @returns the cloned camera
  90803. */
  90804. clone(name: string): Camera;
  90805. /**
  90806. * Gets the direction of the camera relative to a given local axis.
  90807. * @param localAxis Defines the reference axis to provide a relative direction.
  90808. * @return the direction
  90809. */
  90810. getDirection(localAxis: Vector3): Vector3;
  90811. /**
  90812. * Returns the current camera absolute rotation
  90813. */
  90814. readonly absoluteRotation: Quaternion;
  90815. /**
  90816. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90817. * @param localAxis Defines the reference axis to provide a relative direction.
  90818. * @param result Defines the vector to store the result in
  90819. */
  90820. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90821. /**
  90822. * Gets a camera constructor for a given camera type
  90823. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90824. * @param name The name of the camera the result will be able to instantiate
  90825. * @param scene The scene the result will construct the camera in
  90826. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90827. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90828. * @returns a factory method to construc the camera
  90829. */
  90830. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90831. /**
  90832. * Compute the world matrix of the camera.
  90833. * @returns the camera workd matrix
  90834. */
  90835. computeWorldMatrix(): Matrix;
  90836. /**
  90837. * Parse a JSON and creates the camera from the parsed information
  90838. * @param parsedCamera The JSON to parse
  90839. * @param scene The scene to instantiate the camera in
  90840. * @returns the newly constructed camera
  90841. */
  90842. static Parse(parsedCamera: any, scene: Scene): Camera;
  90843. }
  90844. }
  90845. declare module BABYLON {
  90846. /**
  90847. * Class containing static functions to help procedurally build meshes
  90848. */
  90849. export class DiscBuilder {
  90850. /**
  90851. * Creates a plane polygonal mesh. By default, this is a disc
  90852. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90853. * * 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
  90854. * * 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
  90855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90858. * @param name defines the name of the mesh
  90859. * @param options defines the options used to create the mesh
  90860. * @param scene defines the hosting scene
  90861. * @returns the plane polygonal mesh
  90862. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90863. */
  90864. static CreateDisc(name: string, options: {
  90865. radius?: number;
  90866. tessellation?: number;
  90867. arc?: number;
  90868. updatable?: boolean;
  90869. sideOrientation?: number;
  90870. frontUVs?: Vector4;
  90871. backUVs?: Vector4;
  90872. }, scene?: Nullable<Scene>): Mesh;
  90873. }
  90874. }
  90875. declare module BABYLON {
  90876. /**
  90877. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  90878. *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.
  90879. * The SPS is also a particle system. It provides some methods to manage the particles.
  90880. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  90881. *
  90882. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  90883. */
  90884. export class SolidParticleSystem implements IDisposable {
  90885. /**
  90886. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  90887. * Example : var p = SPS.particles[i];
  90888. */
  90889. particles: SolidParticle[];
  90890. /**
  90891. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  90892. */
  90893. nbParticles: number;
  90894. /**
  90895. * If the particles must ever face the camera (default false). Useful for planar particles.
  90896. */
  90897. billboard: boolean;
  90898. /**
  90899. * Recompute normals when adding a shape
  90900. */
  90901. recomputeNormals: boolean;
  90902. /**
  90903. * This a counter ofr your own usage. It's not set by any SPS functions.
  90904. */
  90905. counter: number;
  90906. /**
  90907. * The SPS name. This name is also given to the underlying mesh.
  90908. */
  90909. name: string;
  90910. /**
  90911. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  90912. */
  90913. mesh: Mesh;
  90914. /**
  90915. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  90916. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  90917. */
  90918. vars: any;
  90919. /**
  90920. * This array is populated when the SPS is set as 'pickable'.
  90921. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  90922. * Each element of this array is an object `{idx: int, faceId: int}`.
  90923. * `idx` is the picked particle index in the `SPS.particles` array
  90924. * `faceId` is the picked face index counted within this particle.
  90925. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  90926. */
  90927. pickedParticles: {
  90928. idx: number;
  90929. faceId: number;
  90930. }[];
  90931. /**
  90932. * This array is populated when `enableDepthSort` is set to true.
  90933. * Each element of this array is an instance of the class DepthSortedParticle.
  90934. */
  90935. depthSortedParticles: DepthSortedParticle[];
  90936. /**
  90937. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  90938. * @hidden
  90939. */
  90940. _bSphereOnly: boolean;
  90941. /**
  90942. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  90943. * @hidden
  90944. */
  90945. _bSphereRadiusFactor: number;
  90946. private _scene;
  90947. private _positions;
  90948. private _indices;
  90949. private _normals;
  90950. private _colors;
  90951. private _uvs;
  90952. private _indices32;
  90953. private _positions32;
  90954. private _normals32;
  90955. private _fixedNormal32;
  90956. private _colors32;
  90957. private _uvs32;
  90958. private _index;
  90959. private _updatable;
  90960. private _pickable;
  90961. private _isVisibilityBoxLocked;
  90962. private _alwaysVisible;
  90963. private _depthSort;
  90964. private _shapeCounter;
  90965. private _copy;
  90966. private _color;
  90967. private _computeParticleColor;
  90968. private _computeParticleTexture;
  90969. private _computeParticleRotation;
  90970. private _computeParticleVertex;
  90971. private _computeBoundingBox;
  90972. private _depthSortParticles;
  90973. private _camera;
  90974. private _mustUnrotateFixedNormals;
  90975. private _particlesIntersect;
  90976. private _needs32Bits;
  90977. /**
  90978. * Creates a SPS (Solid Particle System) object.
  90979. * @param name (String) is the SPS name, this will be the underlying mesh name.
  90980. * @param scene (Scene) is the scene in which the SPS is added.
  90981. * @param options defines the options of the sps e.g.
  90982. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  90983. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90984. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90985. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90986. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90987. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  90988. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  90989. */
  90990. constructor(name: string, scene: Scene, options?: {
  90991. updatable?: boolean;
  90992. isPickable?: boolean;
  90993. enableDepthSort?: boolean;
  90994. particleIntersection?: boolean;
  90995. boundingSphereOnly?: boolean;
  90996. bSphereRadiusFactor?: number;
  90997. });
  90998. /**
  90999. * Builds the SPS underlying mesh. Returns a standard Mesh.
  91000. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  91001. * @returns the created mesh
  91002. */
  91003. buildMesh(): Mesh;
  91004. /**
  91005. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  91006. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  91007. * Thus the particles generated from `digest()` have their property `position` set yet.
  91008. * @param mesh ( Mesh ) is the mesh to be digested
  91009. * @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
  91010. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  91011. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  91012. * @returns the current SPS
  91013. */
  91014. digest(mesh: Mesh, options?: {
  91015. facetNb?: number;
  91016. number?: number;
  91017. delta?: number;
  91018. }): SolidParticleSystem;
  91019. private _unrotateFixedNormals;
  91020. private _resetCopy;
  91021. private _meshBuilder;
  91022. private _posToShape;
  91023. private _uvsToShapeUV;
  91024. private _addParticle;
  91025. /**
  91026. * Adds some particles to the SPS from the model shape. Returns the shape id.
  91027. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  91028. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  91029. * @param nb (positive integer) the number of particles to be created from this model
  91030. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  91031. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  91032. * @returns the number of shapes in the system
  91033. */
  91034. addShape(mesh: Mesh, nb: number, options?: {
  91035. positionFunction?: any;
  91036. vertexFunction?: any;
  91037. }): number;
  91038. private _rebuildParticle;
  91039. /**
  91040. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  91041. * @returns the SPS.
  91042. */
  91043. rebuildMesh(): SolidParticleSystem;
  91044. /**
  91045. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  91046. * This method calls `updateParticle()` for each particle of the SPS.
  91047. * For an animated SPS, it is usually called within the render loop.
  91048. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  91049. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  91050. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  91051. * @returns the SPS.
  91052. */
  91053. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  91054. /**
  91055. * Disposes the SPS.
  91056. */
  91057. dispose(): void;
  91058. /**
  91059. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  91060. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91061. * @returns the SPS.
  91062. */
  91063. refreshVisibleSize(): SolidParticleSystem;
  91064. /**
  91065. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  91066. * @param size the size (float) of the visibility box
  91067. * note : this doesn't lock the SPS mesh bounding box.
  91068. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91069. */
  91070. setVisibilityBox(size: number): void;
  91071. /**
  91072. * Gets whether the SPS as always visible or not
  91073. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91074. */
  91075. /**
  91076. * Sets the SPS as always visible or not
  91077. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91078. */
  91079. isAlwaysVisible: boolean;
  91080. /**
  91081. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91082. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91083. */
  91084. /**
  91085. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91086. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91087. */
  91088. isVisibilityBoxLocked: boolean;
  91089. /**
  91090. * Tells to `setParticles()` to compute the particle rotations or not.
  91091. * Default value : true. The SPS is faster when it's set to false.
  91092. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91093. */
  91094. /**
  91095. * Gets if `setParticles()` computes the particle rotations or not.
  91096. * Default value : true. The SPS is faster when it's set to false.
  91097. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91098. */
  91099. computeParticleRotation: boolean;
  91100. /**
  91101. * Tells to `setParticles()` to compute the particle colors or not.
  91102. * Default value : true. The SPS is faster when it's set to false.
  91103. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91104. */
  91105. /**
  91106. * Gets if `setParticles()` computes the particle colors or not.
  91107. * Default value : true. The SPS is faster when it's set to false.
  91108. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91109. */
  91110. computeParticleColor: boolean;
  91111. /**
  91112. * Gets if `setParticles()` computes the particle textures or not.
  91113. * Default value : true. The SPS is faster when it's set to false.
  91114. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91115. */
  91116. computeParticleTexture: boolean;
  91117. /**
  91118. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91119. * Default value : false. The SPS is faster when it's set to false.
  91120. * Note : the particle custom vertex positions aren't stored values.
  91121. */
  91122. /**
  91123. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91124. * Default value : false. The SPS is faster when it's set to false.
  91125. * Note : the particle custom vertex positions aren't stored values.
  91126. */
  91127. computeParticleVertex: boolean;
  91128. /**
  91129. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91130. */
  91131. /**
  91132. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91133. */
  91134. computeBoundingBox: boolean;
  91135. /**
  91136. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91137. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91138. * Default : `true`
  91139. */
  91140. /**
  91141. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91142. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91143. * Default : `true`
  91144. */
  91145. depthSortParticles: boolean;
  91146. /**
  91147. * This function does nothing. It may be overwritten to set all the particle first values.
  91148. * The SPS doesn't call this function, you may have to call it by your own.
  91149. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91150. */
  91151. initParticles(): void;
  91152. /**
  91153. * This function does nothing. It may be overwritten to recycle a particle.
  91154. * The SPS doesn't call this function, you may have to call it by your own.
  91155. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91156. * @param particle The particle to recycle
  91157. * @returns the recycled particle
  91158. */
  91159. recycleParticle(particle: SolidParticle): SolidParticle;
  91160. /**
  91161. * Updates a particle : this function should be overwritten by the user.
  91162. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91163. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91164. * @example : just set a particle position or velocity and recycle conditions
  91165. * @param particle The particle to update
  91166. * @returns the updated particle
  91167. */
  91168. updateParticle(particle: SolidParticle): SolidParticle;
  91169. /**
  91170. * Updates a vertex of a particle : it can be overwritten by the user.
  91171. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91172. * @param particle the current particle
  91173. * @param vertex the current index of the current particle
  91174. * @param pt the index of the current vertex in the particle shape
  91175. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91176. * @example : just set a vertex particle position
  91177. * @returns the updated vertex
  91178. */
  91179. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91180. /**
  91181. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91182. * This does nothing and may be overwritten by the user.
  91183. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91184. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91185. * @param update the boolean update value actually passed to setParticles()
  91186. */
  91187. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91188. /**
  91189. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91190. * This will be passed three parameters.
  91191. * This does nothing and may be overwritten by the user.
  91192. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91193. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91194. * @param update the boolean update value actually passed to setParticles()
  91195. */
  91196. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91197. }
  91198. }
  91199. declare module BABYLON {
  91200. /**
  91201. * Represents one particle of a solid particle system.
  91202. */
  91203. export class SolidParticle {
  91204. /**
  91205. * particle global index
  91206. */
  91207. idx: number;
  91208. /**
  91209. * The color of the particle
  91210. */
  91211. color: Nullable<Color4>;
  91212. /**
  91213. * The world space position of the particle.
  91214. */
  91215. position: Vector3;
  91216. /**
  91217. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91218. */
  91219. rotation: Vector3;
  91220. /**
  91221. * The world space rotation quaternion of the particle.
  91222. */
  91223. rotationQuaternion: Nullable<Quaternion>;
  91224. /**
  91225. * The scaling of the particle.
  91226. */
  91227. scaling: Vector3;
  91228. /**
  91229. * The uvs of the particle.
  91230. */
  91231. uvs: Vector4;
  91232. /**
  91233. * The current speed of the particle.
  91234. */
  91235. velocity: Vector3;
  91236. /**
  91237. * The pivot point in the particle local space.
  91238. */
  91239. pivot: Vector3;
  91240. /**
  91241. * Must the particle be translated from its pivot point in its local space ?
  91242. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  91243. * Default : false
  91244. */
  91245. translateFromPivot: boolean;
  91246. /**
  91247. * Is the particle active or not ?
  91248. */
  91249. alive: boolean;
  91250. /**
  91251. * Is the particle visible or not ?
  91252. */
  91253. isVisible: boolean;
  91254. /**
  91255. * Index of this particle in the global "positions" array (Internal use)
  91256. * @hidden
  91257. */
  91258. _pos: number;
  91259. /**
  91260. * @hidden Index of this particle in the global "indices" array (Internal use)
  91261. */
  91262. _ind: number;
  91263. /**
  91264. * @hidden ModelShape of this particle (Internal use)
  91265. */
  91266. _model: ModelShape;
  91267. /**
  91268. * ModelShape id of this particle
  91269. */
  91270. shapeId: number;
  91271. /**
  91272. * Index of the particle in its shape id
  91273. */
  91274. idxInShape: number;
  91275. /**
  91276. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  91277. */
  91278. _modelBoundingInfo: BoundingInfo;
  91279. /**
  91280. * @hidden Particle BoundingInfo object (Internal use)
  91281. */
  91282. _boundingInfo: BoundingInfo;
  91283. /**
  91284. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  91285. */
  91286. _sps: SolidParticleSystem;
  91287. /**
  91288. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  91289. */
  91290. _stillInvisible: boolean;
  91291. /**
  91292. * @hidden Last computed particle rotation matrix
  91293. */
  91294. _rotationMatrix: number[];
  91295. /**
  91296. * Parent particle Id, if any.
  91297. * Default null.
  91298. */
  91299. parentId: Nullable<number>;
  91300. /**
  91301. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  91302. * The possible values are :
  91303. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91304. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91305. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91306. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91307. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91308. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  91309. * */
  91310. cullingStrategy: number;
  91311. /**
  91312. * @hidden Internal global position in the SPS.
  91313. */
  91314. _globalPosition: Vector3;
  91315. /**
  91316. * Creates a Solid Particle object.
  91317. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  91318. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  91319. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  91320. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  91321. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  91322. * @param shapeId (integer) is the model shape identifier in the SPS.
  91323. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  91324. * @param sps defines the sps it is associated to
  91325. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  91326. */
  91327. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  91328. /**
  91329. * Legacy support, changed scale to scaling
  91330. */
  91331. /**
  91332. * Legacy support, changed scale to scaling
  91333. */
  91334. scale: Vector3;
  91335. /**
  91336. * Legacy support, changed quaternion to rotationQuaternion
  91337. */
  91338. /**
  91339. * Legacy support, changed quaternion to rotationQuaternion
  91340. */
  91341. quaternion: Nullable<Quaternion>;
  91342. /**
  91343. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  91344. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  91345. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  91346. * @returns true if it intersects
  91347. */
  91348. intersectsMesh(target: Mesh | SolidParticle): boolean;
  91349. /**
  91350. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  91351. * A particle is in the frustum if its bounding box intersects the frustum
  91352. * @param frustumPlanes defines the frustum to test
  91353. * @returns true if the particle is in the frustum planes
  91354. */
  91355. isInFrustum(frustumPlanes: Plane[]): boolean;
  91356. /**
  91357. * get the rotation matrix of the particle
  91358. * @hidden
  91359. */
  91360. getRotationMatrix(m: Matrix): void;
  91361. }
  91362. /**
  91363. * Represents the shape of the model used by one particle of a solid particle system.
  91364. * SPS internal tool, don't use it manually.
  91365. */
  91366. export class ModelShape {
  91367. /**
  91368. * The shape id
  91369. * @hidden
  91370. */
  91371. shapeID: number;
  91372. /**
  91373. * flat array of model positions (internal use)
  91374. * @hidden
  91375. */
  91376. _shape: Vector3[];
  91377. /**
  91378. * flat array of model UVs (internal use)
  91379. * @hidden
  91380. */
  91381. _shapeUV: number[];
  91382. /**
  91383. * length of the shape in the model indices array (internal use)
  91384. * @hidden
  91385. */
  91386. _indicesLength: number;
  91387. /**
  91388. * Custom position function (internal use)
  91389. * @hidden
  91390. */
  91391. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  91392. /**
  91393. * Custom vertex function (internal use)
  91394. * @hidden
  91395. */
  91396. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  91397. /**
  91398. * 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.
  91399. * SPS internal tool, don't use it manually.
  91400. * @hidden
  91401. */
  91402. 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>);
  91403. }
  91404. /**
  91405. * Represents a Depth Sorted Particle in the solid particle system.
  91406. */
  91407. export class DepthSortedParticle {
  91408. /**
  91409. * Index of the particle in the "indices" array
  91410. */
  91411. ind: number;
  91412. /**
  91413. * Length of the particle shape in the "indices" array
  91414. */
  91415. indicesLength: number;
  91416. /**
  91417. * Squared distance from the particle to the camera
  91418. */
  91419. sqDistance: number;
  91420. }
  91421. }
  91422. declare module BABYLON {
  91423. /**
  91424. * @hidden
  91425. */
  91426. export class _MeshCollisionData {
  91427. _checkCollisions: boolean;
  91428. _collisionMask: number;
  91429. _collisionGroup: number;
  91430. _collider: Nullable<Collider>;
  91431. _oldPositionForCollisions: Vector3;
  91432. _diffPositionForCollisions: Vector3;
  91433. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91434. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91435. }
  91436. }
  91437. declare module BABYLON {
  91438. /** @hidden */
  91439. class _FacetDataStorage {
  91440. facetPositions: Vector3[];
  91441. facetNormals: Vector3[];
  91442. facetPartitioning: number[][];
  91443. facetNb: number;
  91444. partitioningSubdivisions: number;
  91445. partitioningBBoxRatio: number;
  91446. facetDataEnabled: boolean;
  91447. facetParameters: any;
  91448. bbSize: Vector3;
  91449. subDiv: {
  91450. max: number;
  91451. X: number;
  91452. Y: number;
  91453. Z: number;
  91454. };
  91455. facetDepthSort: boolean;
  91456. facetDepthSortEnabled: boolean;
  91457. depthSortedIndices: IndicesArray;
  91458. depthSortedFacets: {
  91459. ind: number;
  91460. sqDistance: number;
  91461. }[];
  91462. facetDepthSortFunction: (f1: {
  91463. ind: number;
  91464. sqDistance: number;
  91465. }, f2: {
  91466. ind: number;
  91467. sqDistance: number;
  91468. }) => number;
  91469. facetDepthSortFrom: Vector3;
  91470. facetDepthSortOrigin: Vector3;
  91471. invertedMatrix: Matrix;
  91472. }
  91473. /**
  91474. * @hidden
  91475. **/
  91476. class _InternalAbstractMeshDataInfo {
  91477. _hasVertexAlpha: boolean;
  91478. _useVertexColors: boolean;
  91479. _numBoneInfluencers: number;
  91480. _applyFog: boolean;
  91481. _receiveShadows: boolean;
  91482. _facetData: _FacetDataStorage;
  91483. _visibility: number;
  91484. _skeleton: Nullable<Skeleton>;
  91485. _layerMask: number;
  91486. _computeBonesUsingShaders: boolean;
  91487. _isActive: boolean;
  91488. _onlyForInstances: boolean;
  91489. _isActiveIntermediate: boolean;
  91490. _onlyForInstancesIntermediate: boolean;
  91491. }
  91492. /**
  91493. * Class used to store all common mesh properties
  91494. */
  91495. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91496. /** No occlusion */
  91497. static OCCLUSION_TYPE_NONE: number;
  91498. /** Occlusion set to optimisitic */
  91499. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91500. /** Occlusion set to strict */
  91501. static OCCLUSION_TYPE_STRICT: number;
  91502. /** Use an accurante occlusion algorithm */
  91503. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91504. /** Use a conservative occlusion algorithm */
  91505. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91506. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91507. * Test order :
  91508. * Is the bounding sphere outside the frustum ?
  91509. * If not, are the bounding box vertices outside the frustum ?
  91510. * It not, then the cullable object is in the frustum.
  91511. */
  91512. static readonly CULLINGSTRATEGY_STANDARD: number;
  91513. /** Culling strategy : Bounding Sphere Only.
  91514. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91515. * It's also less accurate than the standard because some not visible objects can still be selected.
  91516. * Test : is the bounding sphere outside the frustum ?
  91517. * If not, then the cullable object is in the frustum.
  91518. */
  91519. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91520. /** Culling strategy : Optimistic Inclusion.
  91521. * This in an inclusion test first, then the standard exclusion test.
  91522. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91523. * 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.
  91524. * Anyway, it's as accurate as the standard strategy.
  91525. * Test :
  91526. * Is the cullable object bounding sphere center in the frustum ?
  91527. * If not, apply the default culling strategy.
  91528. */
  91529. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91530. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91531. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91532. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91533. * 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.
  91534. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91535. * Test :
  91536. * Is the cullable object bounding sphere center in the frustum ?
  91537. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91538. */
  91539. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91540. /**
  91541. * No billboard
  91542. */
  91543. static readonly BILLBOARDMODE_NONE: number;
  91544. /** Billboard on X axis */
  91545. static readonly BILLBOARDMODE_X: number;
  91546. /** Billboard on Y axis */
  91547. static readonly BILLBOARDMODE_Y: number;
  91548. /** Billboard on Z axis */
  91549. static readonly BILLBOARDMODE_Z: number;
  91550. /** Billboard on all axes */
  91551. static readonly BILLBOARDMODE_ALL: number;
  91552. /** Billboard on using position instead of orientation */
  91553. static readonly BILLBOARDMODE_USE_POSITION: number;
  91554. /** @hidden */
  91555. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91556. /**
  91557. * The culling strategy to use to check whether the mesh must be rendered or not.
  91558. * This value can be changed at any time and will be used on the next render mesh selection.
  91559. * The possible values are :
  91560. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91561. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91562. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91563. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91564. * Please read each static variable documentation to get details about the culling process.
  91565. * */
  91566. cullingStrategy: number;
  91567. /**
  91568. * Gets the number of facets in the mesh
  91569. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91570. */
  91571. readonly facetNb: number;
  91572. /**
  91573. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91574. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91575. */
  91576. partitioningSubdivisions: number;
  91577. /**
  91578. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91579. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91581. */
  91582. partitioningBBoxRatio: number;
  91583. /**
  91584. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91585. * Works only for updatable meshes.
  91586. * Doesn't work with multi-materials
  91587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91588. */
  91589. mustDepthSortFacets: boolean;
  91590. /**
  91591. * The location (Vector3) where the facet depth sort must be computed from.
  91592. * By default, the active camera position.
  91593. * Used only when facet depth sort is enabled
  91594. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91595. */
  91596. facetDepthSortFrom: Vector3;
  91597. /**
  91598. * gets a boolean indicating if facetData is enabled
  91599. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91600. */
  91601. readonly isFacetDataEnabled: boolean;
  91602. /** @hidden */
  91603. _updateNonUniformScalingState(value: boolean): boolean;
  91604. /**
  91605. * An event triggered when this mesh collides with another one
  91606. */
  91607. onCollideObservable: Observable<AbstractMesh>;
  91608. /** Set a function to call when this mesh collides with another one */
  91609. onCollide: () => void;
  91610. /**
  91611. * An event triggered when the collision's position changes
  91612. */
  91613. onCollisionPositionChangeObservable: Observable<Vector3>;
  91614. /** Set a function to call when the collision's position changes */
  91615. onCollisionPositionChange: () => void;
  91616. /**
  91617. * An event triggered when material is changed
  91618. */
  91619. onMaterialChangedObservable: Observable<AbstractMesh>;
  91620. /**
  91621. * Gets or sets the orientation for POV movement & rotation
  91622. */
  91623. definedFacingForward: boolean;
  91624. /** @hidden */
  91625. _occlusionQuery: Nullable<WebGLQuery>;
  91626. /** @hidden */
  91627. _renderingGroup: Nullable<RenderingGroup>;
  91628. /**
  91629. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91630. */
  91631. /**
  91632. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91633. */
  91634. visibility: number;
  91635. /** Gets or sets the alpha index used to sort transparent meshes
  91636. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91637. */
  91638. alphaIndex: number;
  91639. /**
  91640. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91641. */
  91642. isVisible: boolean;
  91643. /**
  91644. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91645. */
  91646. isPickable: boolean;
  91647. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91648. showSubMeshesBoundingBox: boolean;
  91649. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91650. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91651. */
  91652. isBlocker: boolean;
  91653. /**
  91654. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91655. */
  91656. enablePointerMoveEvents: boolean;
  91657. /**
  91658. * Specifies the rendering group id for this mesh (0 by default)
  91659. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91660. */
  91661. renderingGroupId: number;
  91662. private _material;
  91663. /** Gets or sets current material */
  91664. material: Nullable<Material>;
  91665. /**
  91666. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91667. * @see http://doc.babylonjs.com/babylon101/shadows
  91668. */
  91669. receiveShadows: boolean;
  91670. /** Defines color to use when rendering outline */
  91671. outlineColor: Color3;
  91672. /** Define width to use when rendering outline */
  91673. outlineWidth: number;
  91674. /** Defines color to use when rendering overlay */
  91675. overlayColor: Color3;
  91676. /** Defines alpha to use when rendering overlay */
  91677. overlayAlpha: number;
  91678. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91679. hasVertexAlpha: boolean;
  91680. /** 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) */
  91681. useVertexColors: boolean;
  91682. /**
  91683. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91684. */
  91685. computeBonesUsingShaders: boolean;
  91686. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91687. numBoneInfluencers: number;
  91688. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91689. applyFog: boolean;
  91690. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91691. useOctreeForRenderingSelection: boolean;
  91692. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91693. useOctreeForPicking: boolean;
  91694. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91695. useOctreeForCollisions: boolean;
  91696. /**
  91697. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91698. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91699. */
  91700. layerMask: number;
  91701. /**
  91702. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91703. */
  91704. alwaysSelectAsActiveMesh: boolean;
  91705. /**
  91706. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91707. */
  91708. doNotSyncBoundingInfo: boolean;
  91709. /**
  91710. * Gets or sets the current action manager
  91711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91712. */
  91713. actionManager: Nullable<AbstractActionManager>;
  91714. private _meshCollisionData;
  91715. /**
  91716. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91717. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91718. */
  91719. ellipsoid: Vector3;
  91720. /**
  91721. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91722. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91723. */
  91724. ellipsoidOffset: Vector3;
  91725. /**
  91726. * Gets or sets a collision mask used to mask collisions (default is -1).
  91727. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91728. */
  91729. collisionMask: number;
  91730. /**
  91731. * Gets or sets the current collision group mask (-1 by default).
  91732. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91733. */
  91734. collisionGroup: number;
  91735. /**
  91736. * Defines edge width used when edgesRenderer is enabled
  91737. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91738. */
  91739. edgesWidth: number;
  91740. /**
  91741. * Defines edge color used when edgesRenderer is enabled
  91742. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91743. */
  91744. edgesColor: Color4;
  91745. /** @hidden */
  91746. _edgesRenderer: Nullable<IEdgesRenderer>;
  91747. /** @hidden */
  91748. _masterMesh: Nullable<AbstractMesh>;
  91749. /** @hidden */
  91750. _boundingInfo: Nullable<BoundingInfo>;
  91751. /** @hidden */
  91752. _renderId: number;
  91753. /**
  91754. * Gets or sets the list of subMeshes
  91755. * @see http://doc.babylonjs.com/how_to/multi_materials
  91756. */
  91757. subMeshes: SubMesh[];
  91758. /** @hidden */
  91759. _intersectionsInProgress: AbstractMesh[];
  91760. /** @hidden */
  91761. _unIndexed: boolean;
  91762. /** @hidden */
  91763. _lightSources: Light[];
  91764. /** Gets the list of lights affecting that mesh */
  91765. readonly lightSources: Light[];
  91766. /** @hidden */
  91767. readonly _positions: Nullable<Vector3[]>;
  91768. /** @hidden */
  91769. _waitingData: {
  91770. lods: Nullable<any>;
  91771. actions: Nullable<any>;
  91772. freezeWorldMatrix: Nullable<boolean>;
  91773. };
  91774. /** @hidden */
  91775. _bonesTransformMatrices: Nullable<Float32Array>;
  91776. /** @hidden */
  91777. _transformMatrixTexture: Nullable<RawTexture>;
  91778. /**
  91779. * Gets or sets a skeleton to apply skining transformations
  91780. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91781. */
  91782. skeleton: Nullable<Skeleton>;
  91783. /**
  91784. * An event triggered when the mesh is rebuilt.
  91785. */
  91786. onRebuildObservable: Observable<AbstractMesh>;
  91787. /**
  91788. * Creates a new AbstractMesh
  91789. * @param name defines the name of the mesh
  91790. * @param scene defines the hosting scene
  91791. */
  91792. constructor(name: string, scene?: Nullable<Scene>);
  91793. /**
  91794. * Returns the string "AbstractMesh"
  91795. * @returns "AbstractMesh"
  91796. */
  91797. getClassName(): string;
  91798. /**
  91799. * Gets a string representation of the current mesh
  91800. * @param fullDetails defines a boolean indicating if full details must be included
  91801. * @returns a string representation of the current mesh
  91802. */
  91803. toString(fullDetails?: boolean): string;
  91804. /**
  91805. * @hidden
  91806. */
  91807. protected _getEffectiveParent(): Nullable<Node>;
  91808. /** @hidden */
  91809. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91810. /** @hidden */
  91811. _rebuild(): void;
  91812. /** @hidden */
  91813. _resyncLightSources(): void;
  91814. /** @hidden */
  91815. _resyncLighSource(light: Light): void;
  91816. /** @hidden */
  91817. _unBindEffect(): void;
  91818. /** @hidden */
  91819. _removeLightSource(light: Light, dispose: boolean): void;
  91820. private _markSubMeshesAsDirty;
  91821. /** @hidden */
  91822. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91823. /** @hidden */
  91824. _markSubMeshesAsAttributesDirty(): void;
  91825. /** @hidden */
  91826. _markSubMeshesAsMiscDirty(): void;
  91827. /**
  91828. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91829. */
  91830. scaling: Vector3;
  91831. /**
  91832. * Returns true if the mesh is blocked. Implemented by child classes
  91833. */
  91834. readonly isBlocked: boolean;
  91835. /**
  91836. * Returns the mesh itself by default. Implemented by child classes
  91837. * @param camera defines the camera to use to pick the right LOD level
  91838. * @returns the currentAbstractMesh
  91839. */
  91840. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91841. /**
  91842. * Returns 0 by default. Implemented by child classes
  91843. * @returns an integer
  91844. */
  91845. getTotalVertices(): number;
  91846. /**
  91847. * Returns a positive integer : the total number of indices in this mesh geometry.
  91848. * @returns the numner of indices or zero if the mesh has no geometry.
  91849. */
  91850. getTotalIndices(): number;
  91851. /**
  91852. * Returns null by default. Implemented by child classes
  91853. * @returns null
  91854. */
  91855. getIndices(): Nullable<IndicesArray>;
  91856. /**
  91857. * Returns the array of the requested vertex data kind. Implemented by child classes
  91858. * @param kind defines the vertex data kind to use
  91859. * @returns null
  91860. */
  91861. getVerticesData(kind: string): Nullable<FloatArray>;
  91862. /**
  91863. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91864. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91865. * Note that a new underlying VertexBuffer object is created each call.
  91866. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91867. * @param kind defines vertex data kind:
  91868. * * VertexBuffer.PositionKind
  91869. * * VertexBuffer.UVKind
  91870. * * VertexBuffer.UV2Kind
  91871. * * VertexBuffer.UV3Kind
  91872. * * VertexBuffer.UV4Kind
  91873. * * VertexBuffer.UV5Kind
  91874. * * VertexBuffer.UV6Kind
  91875. * * VertexBuffer.ColorKind
  91876. * * VertexBuffer.MatricesIndicesKind
  91877. * * VertexBuffer.MatricesIndicesExtraKind
  91878. * * VertexBuffer.MatricesWeightsKind
  91879. * * VertexBuffer.MatricesWeightsExtraKind
  91880. * @param data defines the data source
  91881. * @param updatable defines if the data must be flagged as updatable (or static)
  91882. * @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
  91883. * @returns the current mesh
  91884. */
  91885. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91886. /**
  91887. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91888. * If the mesh has no geometry, it is simply returned as it is.
  91889. * @param kind defines vertex data kind:
  91890. * * VertexBuffer.PositionKind
  91891. * * VertexBuffer.UVKind
  91892. * * VertexBuffer.UV2Kind
  91893. * * VertexBuffer.UV3Kind
  91894. * * VertexBuffer.UV4Kind
  91895. * * VertexBuffer.UV5Kind
  91896. * * VertexBuffer.UV6Kind
  91897. * * VertexBuffer.ColorKind
  91898. * * VertexBuffer.MatricesIndicesKind
  91899. * * VertexBuffer.MatricesIndicesExtraKind
  91900. * * VertexBuffer.MatricesWeightsKind
  91901. * * VertexBuffer.MatricesWeightsExtraKind
  91902. * @param data defines the data source
  91903. * @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
  91904. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  91905. * @returns the current mesh
  91906. */
  91907. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91908. /**
  91909. * Sets the mesh indices,
  91910. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91911. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  91912. * @param totalVertices Defines the total number of vertices
  91913. * @returns the current mesh
  91914. */
  91915. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  91916. /**
  91917. * Gets a boolean indicating if specific vertex data is present
  91918. * @param kind defines the vertex data kind to use
  91919. * @returns true is data kind is present
  91920. */
  91921. isVerticesDataPresent(kind: string): boolean;
  91922. /**
  91923. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  91924. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  91925. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  91926. * @returns a BoundingInfo
  91927. */
  91928. getBoundingInfo(): BoundingInfo;
  91929. /**
  91930. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91931. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91932. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91933. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91934. * @returns the current mesh
  91935. */
  91936. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  91937. /**
  91938. * Overwrite the current bounding info
  91939. * @param boundingInfo defines the new bounding info
  91940. * @returns the current mesh
  91941. */
  91942. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  91943. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  91944. readonly useBones: boolean;
  91945. /** @hidden */
  91946. _preActivate(): void;
  91947. /** @hidden */
  91948. _preActivateForIntermediateRendering(renderId: number): void;
  91949. /** @hidden */
  91950. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91951. /** @hidden */
  91952. _postActivate(): void;
  91953. /** @hidden */
  91954. _freeze(): void;
  91955. /** @hidden */
  91956. _unFreeze(): void;
  91957. /**
  91958. * Gets the current world matrix
  91959. * @returns a Matrix
  91960. */
  91961. getWorldMatrix(): Matrix;
  91962. /** @hidden */
  91963. _getWorldMatrixDeterminant(): number;
  91964. /**
  91965. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  91966. */
  91967. readonly isAnInstance: boolean;
  91968. /**
  91969. * Gets a boolean indicating if this mesh has instances
  91970. */
  91971. readonly hasInstances: boolean;
  91972. /**
  91973. * Perform relative position change from the point of view of behind the front of the mesh.
  91974. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91975. * Supports definition of mesh facing forward or backward
  91976. * @param amountRight defines the distance on the right axis
  91977. * @param amountUp defines the distance on the up axis
  91978. * @param amountForward defines the distance on the forward axis
  91979. * @returns the current mesh
  91980. */
  91981. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  91982. /**
  91983. * Calculate relative position change from the point of view of behind the front of the mesh.
  91984. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91985. * Supports definition of mesh facing forward or backward
  91986. * @param amountRight defines the distance on the right axis
  91987. * @param amountUp defines the distance on the up axis
  91988. * @param amountForward defines the distance on the forward axis
  91989. * @returns the new displacement vector
  91990. */
  91991. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  91992. /**
  91993. * Perform relative rotation change from the point of view of behind the front of the mesh.
  91994. * Supports definition of mesh facing forward or backward
  91995. * @param flipBack defines the flip
  91996. * @param twirlClockwise defines the twirl
  91997. * @param tiltRight defines the tilt
  91998. * @returns the current mesh
  91999. */
  92000. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  92001. /**
  92002. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  92003. * Supports definition of mesh facing forward or backward.
  92004. * @param flipBack defines the flip
  92005. * @param twirlClockwise defines the twirl
  92006. * @param tiltRight defines the tilt
  92007. * @returns the new rotation vector
  92008. */
  92009. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  92010. /**
  92011. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92012. * This means the mesh underlying bounding box and sphere are recomputed.
  92013. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92014. * @returns the current mesh
  92015. */
  92016. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  92017. /** @hidden */
  92018. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  92019. /** @hidden */
  92020. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  92021. /** @hidden */
  92022. _updateBoundingInfo(): AbstractMesh;
  92023. /** @hidden */
  92024. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  92025. /** @hidden */
  92026. protected _afterComputeWorldMatrix(): void;
  92027. /** @hidden */
  92028. readonly _effectiveMesh: AbstractMesh;
  92029. /**
  92030. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92031. * A mesh is in the frustum if its bounding box intersects the frustum
  92032. * @param frustumPlanes defines the frustum to test
  92033. * @returns true if the mesh is in the frustum planes
  92034. */
  92035. isInFrustum(frustumPlanes: Plane[]): boolean;
  92036. /**
  92037. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  92038. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  92039. * @param frustumPlanes defines the frustum to test
  92040. * @returns true if the mesh is completely in the frustum planes
  92041. */
  92042. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92043. /**
  92044. * True if the mesh intersects another mesh or a SolidParticle object
  92045. * @param mesh defines a target mesh or SolidParticle to test
  92046. * @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)
  92047. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  92048. * @returns true if there is an intersection
  92049. */
  92050. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  92051. /**
  92052. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  92053. * @param point defines the point to test
  92054. * @returns true if there is an intersection
  92055. */
  92056. intersectsPoint(point: Vector3): boolean;
  92057. /**
  92058. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  92059. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92060. */
  92061. checkCollisions: boolean;
  92062. /**
  92063. * Gets Collider object used to compute collisions (not physics)
  92064. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92065. */
  92066. readonly collider: Nullable<Collider>;
  92067. /**
  92068. * Move the mesh using collision engine
  92069. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92070. * @param displacement defines the requested displacement vector
  92071. * @returns the current mesh
  92072. */
  92073. moveWithCollisions(displacement: Vector3): AbstractMesh;
  92074. private _onCollisionPositionChange;
  92075. /** @hidden */
  92076. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  92077. /** @hidden */
  92078. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  92079. /** @hidden */
  92080. _checkCollision(collider: Collider): AbstractMesh;
  92081. /** @hidden */
  92082. _generatePointsArray(): boolean;
  92083. /**
  92084. * Checks if the passed Ray intersects with the mesh
  92085. * @param ray defines the ray to use
  92086. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  92087. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92088. * @returns the picking info
  92089. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92090. */
  92091. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  92092. /**
  92093. * Clones the current mesh
  92094. * @param name defines the mesh name
  92095. * @param newParent defines the new mesh parent
  92096. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  92097. * @returns the new mesh
  92098. */
  92099. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  92100. /**
  92101. * Disposes all the submeshes of the current meshnp
  92102. * @returns the current mesh
  92103. */
  92104. releaseSubMeshes(): AbstractMesh;
  92105. /**
  92106. * Releases resources associated with this abstract mesh.
  92107. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92108. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92109. */
  92110. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92111. /**
  92112. * Adds the passed mesh as a child to the current mesh
  92113. * @param mesh defines the child mesh
  92114. * @returns the current mesh
  92115. */
  92116. addChild(mesh: AbstractMesh): AbstractMesh;
  92117. /**
  92118. * Removes the passed mesh from the current mesh children list
  92119. * @param mesh defines the child mesh
  92120. * @returns the current mesh
  92121. */
  92122. removeChild(mesh: AbstractMesh): AbstractMesh;
  92123. /** @hidden */
  92124. private _initFacetData;
  92125. /**
  92126. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92127. * This method can be called within the render loop.
  92128. * 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
  92129. * @returns the current mesh
  92130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92131. */
  92132. updateFacetData(): AbstractMesh;
  92133. /**
  92134. * Returns the facetLocalNormals array.
  92135. * The normals are expressed in the mesh local spac
  92136. * @returns an array of Vector3
  92137. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92138. */
  92139. getFacetLocalNormals(): Vector3[];
  92140. /**
  92141. * Returns the facetLocalPositions array.
  92142. * The facet positions are expressed in the mesh local space
  92143. * @returns an array of Vector3
  92144. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92145. */
  92146. getFacetLocalPositions(): Vector3[];
  92147. /**
  92148. * Returns the facetLocalPartioning array
  92149. * @returns an array of array of numbers
  92150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92151. */
  92152. getFacetLocalPartitioning(): number[][];
  92153. /**
  92154. * Returns the i-th facet position in the world system.
  92155. * This method allocates a new Vector3 per call
  92156. * @param i defines the facet index
  92157. * @returns a new Vector3
  92158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92159. */
  92160. getFacetPosition(i: number): Vector3;
  92161. /**
  92162. * Sets the reference Vector3 with the i-th facet position in the world system
  92163. * @param i defines the facet index
  92164. * @param ref defines the target vector
  92165. * @returns the current mesh
  92166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92167. */
  92168. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92169. /**
  92170. * Returns the i-th facet normal in the world system.
  92171. * This method allocates a new Vector3 per call
  92172. * @param i defines the facet index
  92173. * @returns a new Vector3
  92174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92175. */
  92176. getFacetNormal(i: number): Vector3;
  92177. /**
  92178. * Sets the reference Vector3 with the i-th facet normal in the world system
  92179. * @param i defines the facet index
  92180. * @param ref defines the target vector
  92181. * @returns the current mesh
  92182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92183. */
  92184. getFacetNormalToRef(i: number, ref: Vector3): this;
  92185. /**
  92186. * 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)
  92187. * @param x defines x coordinate
  92188. * @param y defines y coordinate
  92189. * @param z defines z coordinate
  92190. * @returns the array of facet indexes
  92191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92192. */
  92193. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92194. /**
  92195. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92196. * @param projected sets as the (x,y,z) world projection on the facet
  92197. * @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
  92198. * @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
  92199. * @param x defines x coordinate
  92200. * @param y defines y coordinate
  92201. * @param z defines z coordinate
  92202. * @returns the face index if found (or null instead)
  92203. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92204. */
  92205. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92206. /**
  92207. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92208. * @param projected sets as the (x,y,z) local projection on the facet
  92209. * @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
  92210. * @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
  92211. * @param x defines x coordinate
  92212. * @param y defines y coordinate
  92213. * @param z defines z coordinate
  92214. * @returns the face index if found (or null instead)
  92215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92216. */
  92217. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92218. /**
  92219. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92220. * @returns the parameters
  92221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92222. */
  92223. getFacetDataParameters(): any;
  92224. /**
  92225. * Disables the feature FacetData and frees the related memory
  92226. * @returns the current mesh
  92227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92228. */
  92229. disableFacetData(): AbstractMesh;
  92230. /**
  92231. * Updates the AbstractMesh indices array
  92232. * @param indices defines the data source
  92233. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92234. * @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)
  92235. * @returns the current mesh
  92236. */
  92237. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92238. /**
  92239. * Creates new normals data for the mesh
  92240. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  92241. * @returns the current mesh
  92242. */
  92243. createNormals(updatable: boolean): AbstractMesh;
  92244. /**
  92245. * Align the mesh with a normal
  92246. * @param normal defines the normal to use
  92247. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  92248. * @returns the current mesh
  92249. */
  92250. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  92251. /** @hidden */
  92252. _checkOcclusionQuery(): boolean;
  92253. /**
  92254. * Disables the mesh edge rendering mode
  92255. * @returns the currentAbstractMesh
  92256. */
  92257. disableEdgesRendering(): AbstractMesh;
  92258. /**
  92259. * Enables the edge rendering mode on the mesh.
  92260. * This mode makes the mesh edges visible
  92261. * @param epsilon defines the maximal distance between two angles to detect a face
  92262. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92263. * @returns the currentAbstractMesh
  92264. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92265. */
  92266. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92267. }
  92268. }
  92269. declare module BABYLON {
  92270. /**
  92271. * Interface used to define ActionEvent
  92272. */
  92273. export interface IActionEvent {
  92274. /** The mesh or sprite that triggered the action */
  92275. source: any;
  92276. /** The X mouse cursor position at the time of the event */
  92277. pointerX: number;
  92278. /** The Y mouse cursor position at the time of the event */
  92279. pointerY: number;
  92280. /** The mesh that is currently pointed at (can be null) */
  92281. meshUnderPointer: Nullable<AbstractMesh>;
  92282. /** the original (browser) event that triggered the ActionEvent */
  92283. sourceEvent?: any;
  92284. /** additional data for the event */
  92285. additionalData?: any;
  92286. }
  92287. /**
  92288. * ActionEvent is the event being sent when an action is triggered.
  92289. */
  92290. export class ActionEvent implements IActionEvent {
  92291. /** The mesh or sprite that triggered the action */
  92292. source: any;
  92293. /** The X mouse cursor position at the time of the event */
  92294. pointerX: number;
  92295. /** The Y mouse cursor position at the time of the event */
  92296. pointerY: number;
  92297. /** The mesh that is currently pointed at (can be null) */
  92298. meshUnderPointer: Nullable<AbstractMesh>;
  92299. /** the original (browser) event that triggered the ActionEvent */
  92300. sourceEvent?: any;
  92301. /** additional data for the event */
  92302. additionalData?: any;
  92303. /**
  92304. * Creates a new ActionEvent
  92305. * @param source The mesh or sprite that triggered the action
  92306. * @param pointerX The X mouse cursor position at the time of the event
  92307. * @param pointerY The Y mouse cursor position at the time of the event
  92308. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  92309. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  92310. * @param additionalData additional data for the event
  92311. */
  92312. constructor(
  92313. /** The mesh or sprite that triggered the action */
  92314. source: any,
  92315. /** The X mouse cursor position at the time of the event */
  92316. pointerX: number,
  92317. /** The Y mouse cursor position at the time of the event */
  92318. pointerY: number,
  92319. /** The mesh that is currently pointed at (can be null) */
  92320. meshUnderPointer: Nullable<AbstractMesh>,
  92321. /** the original (browser) event that triggered the ActionEvent */
  92322. sourceEvent?: any,
  92323. /** additional data for the event */
  92324. additionalData?: any);
  92325. /**
  92326. * Helper function to auto-create an ActionEvent from a source mesh.
  92327. * @param source The source mesh that triggered the event
  92328. * @param evt The original (browser) event
  92329. * @param additionalData additional data for the event
  92330. * @returns the new ActionEvent
  92331. */
  92332. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  92333. /**
  92334. * Helper function to auto-create an ActionEvent from a source sprite
  92335. * @param source The source sprite that triggered the event
  92336. * @param scene Scene associated with the sprite
  92337. * @param evt The original (browser) event
  92338. * @param additionalData additional data for the event
  92339. * @returns the new ActionEvent
  92340. */
  92341. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  92342. /**
  92343. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  92344. * @param scene the scene where the event occurred
  92345. * @param evt The original (browser) event
  92346. * @returns the new ActionEvent
  92347. */
  92348. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  92349. /**
  92350. * Helper function to auto-create an ActionEvent from a primitive
  92351. * @param prim defines the target primitive
  92352. * @param pointerPos defines the pointer position
  92353. * @param evt The original (browser) event
  92354. * @param additionalData additional data for the event
  92355. * @returns the new ActionEvent
  92356. */
  92357. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  92358. }
  92359. }
  92360. declare module BABYLON {
  92361. /**
  92362. * Abstract class used to decouple action Manager from scene and meshes.
  92363. * Do not instantiate.
  92364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92365. */
  92366. export abstract class AbstractActionManager implements IDisposable {
  92367. /** Gets the list of active triggers */
  92368. static Triggers: {
  92369. [key: string]: number;
  92370. };
  92371. /** Gets the cursor to use when hovering items */
  92372. hoverCursor: string;
  92373. /** Gets the list of actions */
  92374. actions: IAction[];
  92375. /**
  92376. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  92377. */
  92378. isRecursive: boolean;
  92379. /**
  92380. * Releases all associated resources
  92381. */
  92382. abstract dispose(): void;
  92383. /**
  92384. * Does this action manager has pointer triggers
  92385. */
  92386. abstract readonly hasPointerTriggers: boolean;
  92387. /**
  92388. * Does this action manager has pick triggers
  92389. */
  92390. abstract readonly hasPickTriggers: boolean;
  92391. /**
  92392. * Process a specific trigger
  92393. * @param trigger defines the trigger to process
  92394. * @param evt defines the event details to be processed
  92395. */
  92396. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  92397. /**
  92398. * Does this action manager handles actions of any of the given triggers
  92399. * @param triggers defines the triggers to be tested
  92400. * @return a boolean indicating whether one (or more) of the triggers is handled
  92401. */
  92402. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92403. /**
  92404. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92405. * speed.
  92406. * @param triggerA defines the trigger to be tested
  92407. * @param triggerB defines the trigger to be tested
  92408. * @return a boolean indicating whether one (or more) of the triggers is handled
  92409. */
  92410. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92411. /**
  92412. * Does this action manager handles actions of a given trigger
  92413. * @param trigger defines the trigger to be tested
  92414. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92415. * @return whether the trigger is handled
  92416. */
  92417. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92418. /**
  92419. * Serialize this manager to a JSON object
  92420. * @param name defines the property name to store this manager
  92421. * @returns a JSON representation of this manager
  92422. */
  92423. abstract serialize(name: string): any;
  92424. /**
  92425. * Registers an action to this action manager
  92426. * @param action defines the action to be registered
  92427. * @return the action amended (prepared) after registration
  92428. */
  92429. abstract registerAction(action: IAction): Nullable<IAction>;
  92430. /**
  92431. * Unregisters an action to this action manager
  92432. * @param action defines the action to be unregistered
  92433. * @return a boolean indicating whether the action has been unregistered
  92434. */
  92435. abstract unregisterAction(action: IAction): Boolean;
  92436. /**
  92437. * Does exist one action manager with at least one trigger
  92438. **/
  92439. static readonly HasTriggers: boolean;
  92440. /**
  92441. * Does exist one action manager with at least one pick trigger
  92442. **/
  92443. static readonly HasPickTriggers: boolean;
  92444. /**
  92445. * Does exist one action manager that handles actions of a given trigger
  92446. * @param trigger defines the trigger to be tested
  92447. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92448. **/
  92449. static HasSpecificTrigger(trigger: number): boolean;
  92450. }
  92451. }
  92452. declare module BABYLON {
  92453. /**
  92454. * Defines how a node can be built from a string name.
  92455. */
  92456. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92457. /**
  92458. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92459. */
  92460. export class Node implements IBehaviorAware<Node> {
  92461. /** @hidden */
  92462. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92463. private static _NodeConstructors;
  92464. /**
  92465. * Add a new node constructor
  92466. * @param type defines the type name of the node to construct
  92467. * @param constructorFunc defines the constructor function
  92468. */
  92469. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92470. /**
  92471. * Returns a node constructor based on type name
  92472. * @param type defines the type name
  92473. * @param name defines the new node name
  92474. * @param scene defines the hosting scene
  92475. * @param options defines optional options to transmit to constructors
  92476. * @returns the new constructor or null
  92477. */
  92478. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92479. /**
  92480. * Gets or sets the name of the node
  92481. */
  92482. name: string;
  92483. /**
  92484. * Gets or sets the id of the node
  92485. */
  92486. id: string;
  92487. /**
  92488. * Gets or sets the unique id of the node
  92489. */
  92490. uniqueId: number;
  92491. /**
  92492. * Gets or sets a string used to store user defined state for the node
  92493. */
  92494. state: string;
  92495. /**
  92496. * Gets or sets an object used to store user defined information for the node
  92497. */
  92498. metadata: any;
  92499. /**
  92500. * For internal use only. Please do not use.
  92501. */
  92502. reservedDataStore: any;
  92503. /**
  92504. * List of inspectable custom properties (used by the Inspector)
  92505. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92506. */
  92507. inspectableCustomProperties: IInspectable[];
  92508. /**
  92509. * Gets or sets a boolean used to define if the node must be serialized
  92510. */
  92511. doNotSerialize: boolean;
  92512. /** @hidden */
  92513. _isDisposed: boolean;
  92514. /**
  92515. * Gets a list of Animations associated with the node
  92516. */
  92517. animations: Animation[];
  92518. protected _ranges: {
  92519. [name: string]: Nullable<AnimationRange>;
  92520. };
  92521. /**
  92522. * Callback raised when the node is ready to be used
  92523. */
  92524. onReady: Nullable<(node: Node) => void>;
  92525. private _isEnabled;
  92526. private _isParentEnabled;
  92527. private _isReady;
  92528. /** @hidden */
  92529. _currentRenderId: number;
  92530. private _parentUpdateId;
  92531. /** @hidden */
  92532. _childUpdateId: number;
  92533. /** @hidden */
  92534. _waitingParentId: Nullable<string>;
  92535. /** @hidden */
  92536. _scene: Scene;
  92537. /** @hidden */
  92538. _cache: any;
  92539. private _parentNode;
  92540. private _children;
  92541. /** @hidden */
  92542. _worldMatrix: Matrix;
  92543. /** @hidden */
  92544. _worldMatrixDeterminant: number;
  92545. /** @hidden */
  92546. _worldMatrixDeterminantIsDirty: boolean;
  92547. /** @hidden */
  92548. private _sceneRootNodesIndex;
  92549. /**
  92550. * Gets a boolean indicating if the node has been disposed
  92551. * @returns true if the node was disposed
  92552. */
  92553. isDisposed(): boolean;
  92554. /**
  92555. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92556. * @see https://doc.babylonjs.com/how_to/parenting
  92557. */
  92558. parent: Nullable<Node>;
  92559. private addToSceneRootNodes;
  92560. private removeFromSceneRootNodes;
  92561. private _animationPropertiesOverride;
  92562. /**
  92563. * Gets or sets the animation properties override
  92564. */
  92565. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92566. /**
  92567. * Gets a string idenfifying the name of the class
  92568. * @returns "Node" string
  92569. */
  92570. getClassName(): string;
  92571. /** @hidden */
  92572. readonly _isNode: boolean;
  92573. /**
  92574. * An event triggered when the mesh is disposed
  92575. */
  92576. onDisposeObservable: Observable<Node>;
  92577. private _onDisposeObserver;
  92578. /**
  92579. * Sets a callback that will be raised when the node will be disposed
  92580. */
  92581. onDispose: () => void;
  92582. /**
  92583. * Creates a new Node
  92584. * @param name the name and id to be given to this node
  92585. * @param scene the scene this node will be added to
  92586. * @param addToRootNodes the node will be added to scene.rootNodes
  92587. */
  92588. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92589. /**
  92590. * Gets the scene of the node
  92591. * @returns a scene
  92592. */
  92593. getScene(): Scene;
  92594. /**
  92595. * Gets the engine of the node
  92596. * @returns a Engine
  92597. */
  92598. getEngine(): Engine;
  92599. private _behaviors;
  92600. /**
  92601. * Attach a behavior to the node
  92602. * @see http://doc.babylonjs.com/features/behaviour
  92603. * @param behavior defines the behavior to attach
  92604. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92605. * @returns the current Node
  92606. */
  92607. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92608. /**
  92609. * Remove an attached behavior
  92610. * @see http://doc.babylonjs.com/features/behaviour
  92611. * @param behavior defines the behavior to attach
  92612. * @returns the current Node
  92613. */
  92614. removeBehavior(behavior: Behavior<Node>): Node;
  92615. /**
  92616. * Gets the list of attached behaviors
  92617. * @see http://doc.babylonjs.com/features/behaviour
  92618. */
  92619. readonly behaviors: Behavior<Node>[];
  92620. /**
  92621. * Gets an attached behavior by name
  92622. * @param name defines the name of the behavior to look for
  92623. * @see http://doc.babylonjs.com/features/behaviour
  92624. * @returns null if behavior was not found else the requested behavior
  92625. */
  92626. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92627. /**
  92628. * Returns the latest update of the World matrix
  92629. * @returns a Matrix
  92630. */
  92631. getWorldMatrix(): Matrix;
  92632. /** @hidden */
  92633. _getWorldMatrixDeterminant(): number;
  92634. /**
  92635. * Returns directly the latest state of the mesh World matrix.
  92636. * A Matrix is returned.
  92637. */
  92638. readonly worldMatrixFromCache: Matrix;
  92639. /** @hidden */
  92640. _initCache(): void;
  92641. /** @hidden */
  92642. updateCache(force?: boolean): void;
  92643. /** @hidden */
  92644. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92645. /** @hidden */
  92646. _updateCache(ignoreParentClass?: boolean): void;
  92647. /** @hidden */
  92648. _isSynchronized(): boolean;
  92649. /** @hidden */
  92650. _markSyncedWithParent(): void;
  92651. /** @hidden */
  92652. isSynchronizedWithParent(): boolean;
  92653. /** @hidden */
  92654. isSynchronized(): boolean;
  92655. /**
  92656. * Is this node ready to be used/rendered
  92657. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92658. * @return true if the node is ready
  92659. */
  92660. isReady(completeCheck?: boolean): boolean;
  92661. /**
  92662. * Is this node enabled?
  92663. * 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
  92664. * @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
  92665. * @return whether this node (and its parent) is enabled
  92666. */
  92667. isEnabled(checkAncestors?: boolean): boolean;
  92668. /** @hidden */
  92669. protected _syncParentEnabledState(): void;
  92670. /**
  92671. * Set the enabled state of this node
  92672. * @param value defines the new enabled state
  92673. */
  92674. setEnabled(value: boolean): void;
  92675. /**
  92676. * Is this node a descendant of the given node?
  92677. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92678. * @param ancestor defines the parent node to inspect
  92679. * @returns a boolean indicating if this node is a descendant of the given node
  92680. */
  92681. isDescendantOf(ancestor: Node): boolean;
  92682. /** @hidden */
  92683. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92684. /**
  92685. * Will return all nodes that have this node as ascendant
  92686. * @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
  92687. * @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
  92688. * @return all children nodes of all types
  92689. */
  92690. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92691. /**
  92692. * Get all child-meshes of this node
  92693. * @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)
  92694. * @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
  92695. * @returns an array of AbstractMesh
  92696. */
  92697. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92698. /**
  92699. * Get all direct children of this node
  92700. * @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
  92701. * @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)
  92702. * @returns an array of Node
  92703. */
  92704. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92705. /** @hidden */
  92706. _setReady(state: boolean): void;
  92707. /**
  92708. * Get an animation by name
  92709. * @param name defines the name of the animation to look for
  92710. * @returns null if not found else the requested animation
  92711. */
  92712. getAnimationByName(name: string): Nullable<Animation>;
  92713. /**
  92714. * Creates an animation range for this node
  92715. * @param name defines the name of the range
  92716. * @param from defines the starting key
  92717. * @param to defines the end key
  92718. */
  92719. createAnimationRange(name: string, from: number, to: number): void;
  92720. /**
  92721. * Delete a specific animation range
  92722. * @param name defines the name of the range to delete
  92723. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92724. */
  92725. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92726. /**
  92727. * Get an animation range by name
  92728. * @param name defines the name of the animation range to look for
  92729. * @returns null if not found else the requested animation range
  92730. */
  92731. getAnimationRange(name: string): Nullable<AnimationRange>;
  92732. /**
  92733. * Gets the list of all animation ranges defined on this node
  92734. * @returns an array
  92735. */
  92736. getAnimationRanges(): Nullable<AnimationRange>[];
  92737. /**
  92738. * Will start the animation sequence
  92739. * @param name defines the range frames for animation sequence
  92740. * @param loop defines if the animation should loop (false by default)
  92741. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92742. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92743. * @returns the object created for this animation. If range does not exist, it will return null
  92744. */
  92745. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92746. /**
  92747. * Serialize animation ranges into a JSON compatible object
  92748. * @returns serialization object
  92749. */
  92750. serializeAnimationRanges(): any;
  92751. /**
  92752. * Computes the world matrix of the node
  92753. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92754. * @returns the world matrix
  92755. */
  92756. computeWorldMatrix(force?: boolean): Matrix;
  92757. /**
  92758. * Releases resources associated with this node.
  92759. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92760. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92761. */
  92762. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92763. /**
  92764. * Parse animation range data from a serialization object and store them into a given node
  92765. * @param node defines where to store the animation ranges
  92766. * @param parsedNode defines the serialization object to read data from
  92767. * @param scene defines the hosting scene
  92768. */
  92769. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92770. /**
  92771. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92772. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92773. * @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
  92774. * @returns the new bounding vectors
  92775. */
  92776. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92777. min: Vector3;
  92778. max: Vector3;
  92779. };
  92780. }
  92781. }
  92782. declare module BABYLON {
  92783. /**
  92784. * @hidden
  92785. */
  92786. export class _IAnimationState {
  92787. key: number;
  92788. repeatCount: number;
  92789. workValue?: any;
  92790. loopMode?: number;
  92791. offsetValue?: any;
  92792. highLimitValue?: any;
  92793. }
  92794. /**
  92795. * Class used to store any kind of animation
  92796. */
  92797. export class Animation {
  92798. /**Name of the animation */
  92799. name: string;
  92800. /**Property to animate */
  92801. targetProperty: string;
  92802. /**The frames per second of the animation */
  92803. framePerSecond: number;
  92804. /**The data type of the animation */
  92805. dataType: number;
  92806. /**The loop mode of the animation */
  92807. loopMode?: number | undefined;
  92808. /**Specifies if blending should be enabled */
  92809. enableBlending?: boolean | undefined;
  92810. /**
  92811. * Use matrix interpolation instead of using direct key value when animating matrices
  92812. */
  92813. static AllowMatricesInterpolation: boolean;
  92814. /**
  92815. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92816. */
  92817. static AllowMatrixDecomposeForInterpolation: boolean;
  92818. /**
  92819. * Stores the key frames of the animation
  92820. */
  92821. private _keys;
  92822. /**
  92823. * Stores the easing function of the animation
  92824. */
  92825. private _easingFunction;
  92826. /**
  92827. * @hidden Internal use only
  92828. */
  92829. _runtimeAnimations: RuntimeAnimation[];
  92830. /**
  92831. * The set of event that will be linked to this animation
  92832. */
  92833. private _events;
  92834. /**
  92835. * Stores an array of target property paths
  92836. */
  92837. targetPropertyPath: string[];
  92838. /**
  92839. * Stores the blending speed of the animation
  92840. */
  92841. blendingSpeed: number;
  92842. /**
  92843. * Stores the animation ranges for the animation
  92844. */
  92845. private _ranges;
  92846. /**
  92847. * @hidden Internal use
  92848. */
  92849. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92850. /**
  92851. * Sets up an animation
  92852. * @param property The property to animate
  92853. * @param animationType The animation type to apply
  92854. * @param framePerSecond The frames per second of the animation
  92855. * @param easingFunction The easing function used in the animation
  92856. * @returns The created animation
  92857. */
  92858. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92859. /**
  92860. * Create and start an animation on a node
  92861. * @param name defines the name of the global animation that will be run on all nodes
  92862. * @param node defines the root node where the animation will take place
  92863. * @param targetProperty defines property to animate
  92864. * @param framePerSecond defines the number of frame per second yo use
  92865. * @param totalFrame defines the number of frames in total
  92866. * @param from defines the initial value
  92867. * @param to defines the final value
  92868. * @param loopMode defines which loop mode you want to use (off by default)
  92869. * @param easingFunction defines the easing function to use (linear by default)
  92870. * @param onAnimationEnd defines the callback to call when animation end
  92871. * @returns the animatable created for this animation
  92872. */
  92873. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92874. /**
  92875. * Create and start an animation on a node and its descendants
  92876. * @param name defines the name of the global animation that will be run on all nodes
  92877. * @param node defines the root node where the animation will take place
  92878. * @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
  92879. * @param targetProperty defines property to animate
  92880. * @param framePerSecond defines the number of frame per second to use
  92881. * @param totalFrame defines the number of frames in total
  92882. * @param from defines the initial value
  92883. * @param to defines the final value
  92884. * @param loopMode defines which loop mode you want to use (off by default)
  92885. * @param easingFunction defines the easing function to use (linear by default)
  92886. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92887. * @returns the list of animatables created for all nodes
  92888. * @example https://www.babylonjs-playground.com/#MH0VLI
  92889. */
  92890. 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[]>;
  92891. /**
  92892. * Creates a new animation, merges it with the existing animations and starts it
  92893. * @param name Name of the animation
  92894. * @param node Node which contains the scene that begins the animations
  92895. * @param targetProperty Specifies which property to animate
  92896. * @param framePerSecond The frames per second of the animation
  92897. * @param totalFrame The total number of frames
  92898. * @param from The frame at the beginning of the animation
  92899. * @param to The frame at the end of the animation
  92900. * @param loopMode Specifies the loop mode of the animation
  92901. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  92902. * @param onAnimationEnd Callback to run once the animation is complete
  92903. * @returns Nullable animation
  92904. */
  92905. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92906. /**
  92907. * Transition property of an host to the target Value
  92908. * @param property The property to transition
  92909. * @param targetValue The target Value of the property
  92910. * @param host The object where the property to animate belongs
  92911. * @param scene Scene used to run the animation
  92912. * @param frameRate Framerate (in frame/s) to use
  92913. * @param transition The transition type we want to use
  92914. * @param duration The duration of the animation, in milliseconds
  92915. * @param onAnimationEnd Callback trigger at the end of the animation
  92916. * @returns Nullable animation
  92917. */
  92918. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  92919. /**
  92920. * Return the array of runtime animations currently using this animation
  92921. */
  92922. readonly runtimeAnimations: RuntimeAnimation[];
  92923. /**
  92924. * Specifies if any of the runtime animations are currently running
  92925. */
  92926. readonly hasRunningRuntimeAnimations: boolean;
  92927. /**
  92928. * Initializes the animation
  92929. * @param name Name of the animation
  92930. * @param targetProperty Property to animate
  92931. * @param framePerSecond The frames per second of the animation
  92932. * @param dataType The data type of the animation
  92933. * @param loopMode The loop mode of the animation
  92934. * @param enableBlending Specifies if blending should be enabled
  92935. */
  92936. constructor(
  92937. /**Name of the animation */
  92938. name: string,
  92939. /**Property to animate */
  92940. targetProperty: string,
  92941. /**The frames per second of the animation */
  92942. framePerSecond: number,
  92943. /**The data type of the animation */
  92944. dataType: number,
  92945. /**The loop mode of the animation */
  92946. loopMode?: number | undefined,
  92947. /**Specifies if blending should be enabled */
  92948. enableBlending?: boolean | undefined);
  92949. /**
  92950. * Converts the animation to a string
  92951. * @param fullDetails support for multiple levels of logging within scene loading
  92952. * @returns String form of the animation
  92953. */
  92954. toString(fullDetails?: boolean): string;
  92955. /**
  92956. * Add an event to this animation
  92957. * @param event Event to add
  92958. */
  92959. addEvent(event: AnimationEvent): void;
  92960. /**
  92961. * Remove all events found at the given frame
  92962. * @param frame The frame to remove events from
  92963. */
  92964. removeEvents(frame: number): void;
  92965. /**
  92966. * Retrieves all the events from the animation
  92967. * @returns Events from the animation
  92968. */
  92969. getEvents(): AnimationEvent[];
  92970. /**
  92971. * Creates an animation range
  92972. * @param name Name of the animation range
  92973. * @param from Starting frame of the animation range
  92974. * @param to Ending frame of the animation
  92975. */
  92976. createRange(name: string, from: number, to: number): void;
  92977. /**
  92978. * Deletes an animation range by name
  92979. * @param name Name of the animation range to delete
  92980. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  92981. */
  92982. deleteRange(name: string, deleteFrames?: boolean): void;
  92983. /**
  92984. * Gets the animation range by name, or null if not defined
  92985. * @param name Name of the animation range
  92986. * @returns Nullable animation range
  92987. */
  92988. getRange(name: string): Nullable<AnimationRange>;
  92989. /**
  92990. * Gets the key frames from the animation
  92991. * @returns The key frames of the animation
  92992. */
  92993. getKeys(): Array<IAnimationKey>;
  92994. /**
  92995. * Gets the highest frame rate of the animation
  92996. * @returns Highest frame rate of the animation
  92997. */
  92998. getHighestFrame(): number;
  92999. /**
  93000. * Gets the easing function of the animation
  93001. * @returns Easing function of the animation
  93002. */
  93003. getEasingFunction(): IEasingFunction;
  93004. /**
  93005. * Sets the easing function of the animation
  93006. * @param easingFunction A custom mathematical formula for animation
  93007. */
  93008. setEasingFunction(easingFunction: EasingFunction): void;
  93009. /**
  93010. * Interpolates a scalar linearly
  93011. * @param startValue Start value of the animation curve
  93012. * @param endValue End value of the animation curve
  93013. * @param gradient Scalar amount to interpolate
  93014. * @returns Interpolated scalar value
  93015. */
  93016. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  93017. /**
  93018. * Interpolates a scalar cubically
  93019. * @param startValue Start value of the animation curve
  93020. * @param outTangent End tangent of the animation
  93021. * @param endValue End value of the animation curve
  93022. * @param inTangent Start tangent of the animation curve
  93023. * @param gradient Scalar amount to interpolate
  93024. * @returns Interpolated scalar value
  93025. */
  93026. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  93027. /**
  93028. * Interpolates a quaternion using a spherical linear interpolation
  93029. * @param startValue Start value of the animation curve
  93030. * @param endValue End value of the animation curve
  93031. * @param gradient Scalar amount to interpolate
  93032. * @returns Interpolated quaternion value
  93033. */
  93034. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  93035. /**
  93036. * Interpolates a quaternion cubically
  93037. * @param startValue Start value of the animation curve
  93038. * @param outTangent End tangent of the animation curve
  93039. * @param endValue End value of the animation curve
  93040. * @param inTangent Start tangent of the animation curve
  93041. * @param gradient Scalar amount to interpolate
  93042. * @returns Interpolated quaternion value
  93043. */
  93044. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  93045. /**
  93046. * Interpolates a Vector3 linearl
  93047. * @param startValue Start value of the animation curve
  93048. * @param endValue End value of the animation curve
  93049. * @param gradient Scalar amount to interpolate
  93050. * @returns Interpolated scalar value
  93051. */
  93052. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  93053. /**
  93054. * Interpolates a Vector3 cubically
  93055. * @param startValue Start value of the animation curve
  93056. * @param outTangent End tangent of the animation
  93057. * @param endValue End value of the animation curve
  93058. * @param inTangent Start tangent of the animation curve
  93059. * @param gradient Scalar amount to interpolate
  93060. * @returns InterpolatedVector3 value
  93061. */
  93062. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  93063. /**
  93064. * Interpolates a Vector2 linearly
  93065. * @param startValue Start value of the animation curve
  93066. * @param endValue End value of the animation curve
  93067. * @param gradient Scalar amount to interpolate
  93068. * @returns Interpolated Vector2 value
  93069. */
  93070. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  93071. /**
  93072. * Interpolates a Vector2 cubically
  93073. * @param startValue Start value of the animation curve
  93074. * @param outTangent End tangent of the animation
  93075. * @param endValue End value of the animation curve
  93076. * @param inTangent Start tangent of the animation curve
  93077. * @param gradient Scalar amount to interpolate
  93078. * @returns Interpolated Vector2 value
  93079. */
  93080. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  93081. /**
  93082. * Interpolates a size linearly
  93083. * @param startValue Start value of the animation curve
  93084. * @param endValue End value of the animation curve
  93085. * @param gradient Scalar amount to interpolate
  93086. * @returns Interpolated Size value
  93087. */
  93088. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  93089. /**
  93090. * Interpolates a Color3 linearly
  93091. * @param startValue Start value of the animation curve
  93092. * @param endValue End value of the animation curve
  93093. * @param gradient Scalar amount to interpolate
  93094. * @returns Interpolated Color3 value
  93095. */
  93096. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  93097. /**
  93098. * @hidden Internal use only
  93099. */
  93100. _getKeyValue(value: any): any;
  93101. /**
  93102. * @hidden Internal use only
  93103. */
  93104. _interpolate(currentFrame: number, state: _IAnimationState): any;
  93105. /**
  93106. * Defines the function to use to interpolate matrices
  93107. * @param startValue defines the start matrix
  93108. * @param endValue defines the end matrix
  93109. * @param gradient defines the gradient between both matrices
  93110. * @param result defines an optional target matrix where to store the interpolation
  93111. * @returns the interpolated matrix
  93112. */
  93113. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93114. /**
  93115. * Makes a copy of the animation
  93116. * @returns Cloned animation
  93117. */
  93118. clone(): Animation;
  93119. /**
  93120. * Sets the key frames of the animation
  93121. * @param values The animation key frames to set
  93122. */
  93123. setKeys(values: Array<IAnimationKey>): void;
  93124. /**
  93125. * Serializes the animation to an object
  93126. * @returns Serialized object
  93127. */
  93128. serialize(): any;
  93129. /**
  93130. * Float animation type
  93131. */
  93132. private static _ANIMATIONTYPE_FLOAT;
  93133. /**
  93134. * Vector3 animation type
  93135. */
  93136. private static _ANIMATIONTYPE_VECTOR3;
  93137. /**
  93138. * Quaternion animation type
  93139. */
  93140. private static _ANIMATIONTYPE_QUATERNION;
  93141. /**
  93142. * Matrix animation type
  93143. */
  93144. private static _ANIMATIONTYPE_MATRIX;
  93145. /**
  93146. * Color3 animation type
  93147. */
  93148. private static _ANIMATIONTYPE_COLOR3;
  93149. /**
  93150. * Vector2 animation type
  93151. */
  93152. private static _ANIMATIONTYPE_VECTOR2;
  93153. /**
  93154. * Size animation type
  93155. */
  93156. private static _ANIMATIONTYPE_SIZE;
  93157. /**
  93158. * Relative Loop Mode
  93159. */
  93160. private static _ANIMATIONLOOPMODE_RELATIVE;
  93161. /**
  93162. * Cycle Loop Mode
  93163. */
  93164. private static _ANIMATIONLOOPMODE_CYCLE;
  93165. /**
  93166. * Constant Loop Mode
  93167. */
  93168. private static _ANIMATIONLOOPMODE_CONSTANT;
  93169. /**
  93170. * Get the float animation type
  93171. */
  93172. static readonly ANIMATIONTYPE_FLOAT: number;
  93173. /**
  93174. * Get the Vector3 animation type
  93175. */
  93176. static readonly ANIMATIONTYPE_VECTOR3: number;
  93177. /**
  93178. * Get the Vector2 animation type
  93179. */
  93180. static readonly ANIMATIONTYPE_VECTOR2: number;
  93181. /**
  93182. * Get the Size animation type
  93183. */
  93184. static readonly ANIMATIONTYPE_SIZE: number;
  93185. /**
  93186. * Get the Quaternion animation type
  93187. */
  93188. static readonly ANIMATIONTYPE_QUATERNION: number;
  93189. /**
  93190. * Get the Matrix animation type
  93191. */
  93192. static readonly ANIMATIONTYPE_MATRIX: number;
  93193. /**
  93194. * Get the Color3 animation type
  93195. */
  93196. static readonly ANIMATIONTYPE_COLOR3: number;
  93197. /**
  93198. * Get the Relative Loop Mode
  93199. */
  93200. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93201. /**
  93202. * Get the Cycle Loop Mode
  93203. */
  93204. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93205. /**
  93206. * Get the Constant Loop Mode
  93207. */
  93208. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93209. /** @hidden */
  93210. static _UniversalLerp(left: any, right: any, amount: number): any;
  93211. /**
  93212. * Parses an animation object and creates an animation
  93213. * @param parsedAnimation Parsed animation object
  93214. * @returns Animation object
  93215. */
  93216. static Parse(parsedAnimation: any): Animation;
  93217. /**
  93218. * Appends the serialized animations from the source animations
  93219. * @param source Source containing the animations
  93220. * @param destination Target to store the animations
  93221. */
  93222. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93223. }
  93224. }
  93225. declare module BABYLON {
  93226. /**
  93227. * Interface containing an array of animations
  93228. */
  93229. export interface IAnimatable {
  93230. /**
  93231. * Array of animations
  93232. */
  93233. animations: Nullable<Array<Animation>>;
  93234. }
  93235. }
  93236. declare module BABYLON {
  93237. /**
  93238. * This represents all the required information to add a fresnel effect on a material:
  93239. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93240. */
  93241. export class FresnelParameters {
  93242. private _isEnabled;
  93243. /**
  93244. * Define if the fresnel effect is enable or not.
  93245. */
  93246. isEnabled: boolean;
  93247. /**
  93248. * Define the color used on edges (grazing angle)
  93249. */
  93250. leftColor: Color3;
  93251. /**
  93252. * Define the color used on center
  93253. */
  93254. rightColor: Color3;
  93255. /**
  93256. * Define bias applied to computed fresnel term
  93257. */
  93258. bias: number;
  93259. /**
  93260. * Defined the power exponent applied to fresnel term
  93261. */
  93262. power: number;
  93263. /**
  93264. * Clones the current fresnel and its valuues
  93265. * @returns a clone fresnel configuration
  93266. */
  93267. clone(): FresnelParameters;
  93268. /**
  93269. * Serializes the current fresnel parameters to a JSON representation.
  93270. * @return the JSON serialization
  93271. */
  93272. serialize(): any;
  93273. /**
  93274. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93275. * @param parsedFresnelParameters Define the JSON representation
  93276. * @returns the parsed parameters
  93277. */
  93278. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93279. }
  93280. }
  93281. declare module BABYLON {
  93282. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93283. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93284. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93285. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93286. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93287. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93288. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93289. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93290. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93291. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93292. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93293. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93294. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93295. /**
  93296. * Decorator used to define property that can be serialized as reference to a camera
  93297. * @param sourceName defines the name of the property to decorate
  93298. */
  93299. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93300. /**
  93301. * Class used to help serialization objects
  93302. */
  93303. export class SerializationHelper {
  93304. /** @hidden */
  93305. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93306. /** @hidden */
  93307. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93308. /** @hidden */
  93309. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93310. /** @hidden */
  93311. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93312. /**
  93313. * Appends the serialized animations from the source animations
  93314. * @param source Source containing the animations
  93315. * @param destination Target to store the animations
  93316. */
  93317. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93318. /**
  93319. * Static function used to serialized a specific entity
  93320. * @param entity defines the entity to serialize
  93321. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93322. * @returns a JSON compatible object representing the serialization of the entity
  93323. */
  93324. static Serialize<T>(entity: T, serializationObject?: any): any;
  93325. /**
  93326. * Creates a new entity from a serialization data object
  93327. * @param creationFunction defines a function used to instanciated the new entity
  93328. * @param source defines the source serialization data
  93329. * @param scene defines the hosting scene
  93330. * @param rootUrl defines the root url for resources
  93331. * @returns a new entity
  93332. */
  93333. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93334. /**
  93335. * Clones an object
  93336. * @param creationFunction defines the function used to instanciate the new object
  93337. * @param source defines the source object
  93338. * @returns the cloned object
  93339. */
  93340. static Clone<T>(creationFunction: () => T, source: T): T;
  93341. /**
  93342. * Instanciates a new object based on a source one (some data will be shared between both object)
  93343. * @param creationFunction defines the function used to instanciate the new object
  93344. * @param source defines the source object
  93345. * @returns the new object
  93346. */
  93347. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93348. }
  93349. }
  93350. declare module BABYLON {
  93351. /**
  93352. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  93353. */
  93354. export interface CubeMapInfo {
  93355. /**
  93356. * The pixel array for the front face.
  93357. * This is stored in format, left to right, up to down format.
  93358. */
  93359. front: Nullable<ArrayBufferView>;
  93360. /**
  93361. * The pixel array for the back face.
  93362. * This is stored in format, left to right, up to down format.
  93363. */
  93364. back: Nullable<ArrayBufferView>;
  93365. /**
  93366. * The pixel array for the left face.
  93367. * This is stored in format, left to right, up to down format.
  93368. */
  93369. left: Nullable<ArrayBufferView>;
  93370. /**
  93371. * The pixel array for the right face.
  93372. * This is stored in format, left to right, up to down format.
  93373. */
  93374. right: Nullable<ArrayBufferView>;
  93375. /**
  93376. * The pixel array for the up face.
  93377. * This is stored in format, left to right, up to down format.
  93378. */
  93379. up: Nullable<ArrayBufferView>;
  93380. /**
  93381. * The pixel array for the down face.
  93382. * This is stored in format, left to right, up to down format.
  93383. */
  93384. down: Nullable<ArrayBufferView>;
  93385. /**
  93386. * The size of the cubemap stored.
  93387. *
  93388. * Each faces will be size * size pixels.
  93389. */
  93390. size: number;
  93391. /**
  93392. * The format of the texture.
  93393. *
  93394. * RGBA, RGB.
  93395. */
  93396. format: number;
  93397. /**
  93398. * The type of the texture data.
  93399. *
  93400. * UNSIGNED_INT, FLOAT.
  93401. */
  93402. type: number;
  93403. /**
  93404. * Specifies whether the texture is in gamma space.
  93405. */
  93406. gammaSpace: boolean;
  93407. }
  93408. /**
  93409. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93410. */
  93411. export class PanoramaToCubeMapTools {
  93412. private static FACE_FRONT;
  93413. private static FACE_BACK;
  93414. private static FACE_RIGHT;
  93415. private static FACE_LEFT;
  93416. private static FACE_DOWN;
  93417. private static FACE_UP;
  93418. /**
  93419. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93420. *
  93421. * @param float32Array The source data.
  93422. * @param inputWidth The width of the input panorama.
  93423. * @param inputHeight The height of the input panorama.
  93424. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93425. * @return The cubemap data
  93426. */
  93427. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93428. private static CreateCubemapTexture;
  93429. private static CalcProjectionSpherical;
  93430. }
  93431. }
  93432. declare module BABYLON {
  93433. /**
  93434. * Helper class dealing with the extraction of spherical polynomial dataArray
  93435. * from a cube map.
  93436. */
  93437. export class CubeMapToSphericalPolynomialTools {
  93438. private static FileFaces;
  93439. /**
  93440. * Converts a texture to the according Spherical Polynomial data.
  93441. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93442. *
  93443. * @param texture The texture to extract the information from.
  93444. * @return The Spherical Polynomial data.
  93445. */
  93446. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93447. /**
  93448. * Converts a cubemap to the according Spherical Polynomial data.
  93449. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93450. *
  93451. * @param cubeInfo The Cube map to extract the information from.
  93452. * @return The Spherical Polynomial data.
  93453. */
  93454. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93455. }
  93456. }
  93457. declare module BABYLON {
  93458. /**
  93459. * Class used to manipulate GUIDs
  93460. */
  93461. export class GUID {
  93462. /**
  93463. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93464. * Be aware Math.random() could cause collisions, but:
  93465. * "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"
  93466. * @returns a pseudo random id
  93467. */
  93468. static RandomId(): string;
  93469. }
  93470. }
  93471. declare module BABYLON {
  93472. /**
  93473. * Base class of all the textures in babylon.
  93474. * It groups all the common properties the materials, post process, lights... might need
  93475. * in order to make a correct use of the texture.
  93476. */
  93477. export class BaseTexture implements IAnimatable {
  93478. /**
  93479. * Default anisotropic filtering level for the application.
  93480. * It is set to 4 as a good tradeoff between perf and quality.
  93481. */
  93482. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93483. /**
  93484. * Gets or sets the unique id of the texture
  93485. */
  93486. uniqueId: number;
  93487. /**
  93488. * Define the name of the texture.
  93489. */
  93490. name: string;
  93491. /**
  93492. * Gets or sets an object used to store user defined information.
  93493. */
  93494. metadata: any;
  93495. /**
  93496. * For internal use only. Please do not use.
  93497. */
  93498. reservedDataStore: any;
  93499. private _hasAlpha;
  93500. /**
  93501. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93502. */
  93503. hasAlpha: boolean;
  93504. /**
  93505. * Defines if the alpha value should be determined via the rgb values.
  93506. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93507. */
  93508. getAlphaFromRGB: boolean;
  93509. /**
  93510. * Intensity or strength of the texture.
  93511. * It is commonly used by materials to fine tune the intensity of the texture
  93512. */
  93513. level: number;
  93514. /**
  93515. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93516. * This is part of the texture as textures usually maps to one uv set.
  93517. */
  93518. coordinatesIndex: number;
  93519. private _coordinatesMode;
  93520. /**
  93521. * How a texture is mapped.
  93522. *
  93523. * | Value | Type | Description |
  93524. * | ----- | ----------------------------------- | ----------- |
  93525. * | 0 | EXPLICIT_MODE | |
  93526. * | 1 | SPHERICAL_MODE | |
  93527. * | 2 | PLANAR_MODE | |
  93528. * | 3 | CUBIC_MODE | |
  93529. * | 4 | PROJECTION_MODE | |
  93530. * | 5 | SKYBOX_MODE | |
  93531. * | 6 | INVCUBIC_MODE | |
  93532. * | 7 | EQUIRECTANGULAR_MODE | |
  93533. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93534. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93535. */
  93536. coordinatesMode: number;
  93537. /**
  93538. * | Value | Type | Description |
  93539. * | ----- | ------------------ | ----------- |
  93540. * | 0 | CLAMP_ADDRESSMODE | |
  93541. * | 1 | WRAP_ADDRESSMODE | |
  93542. * | 2 | MIRROR_ADDRESSMODE | |
  93543. */
  93544. wrapU: number;
  93545. /**
  93546. * | Value | Type | Description |
  93547. * | ----- | ------------------ | ----------- |
  93548. * | 0 | CLAMP_ADDRESSMODE | |
  93549. * | 1 | WRAP_ADDRESSMODE | |
  93550. * | 2 | MIRROR_ADDRESSMODE | |
  93551. */
  93552. wrapV: number;
  93553. /**
  93554. * | Value | Type | Description |
  93555. * | ----- | ------------------ | ----------- |
  93556. * | 0 | CLAMP_ADDRESSMODE | |
  93557. * | 1 | WRAP_ADDRESSMODE | |
  93558. * | 2 | MIRROR_ADDRESSMODE | |
  93559. */
  93560. wrapR: number;
  93561. /**
  93562. * With compliant hardware and browser (supporting anisotropic filtering)
  93563. * this defines the level of anisotropic filtering in the texture.
  93564. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93565. */
  93566. anisotropicFilteringLevel: number;
  93567. /**
  93568. * Define if the texture is a cube texture or if false a 2d texture.
  93569. */
  93570. isCube: boolean;
  93571. /**
  93572. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93573. */
  93574. is3D: boolean;
  93575. /**
  93576. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93577. * HDR texture are usually stored in linear space.
  93578. * This only impacts the PBR and Background materials
  93579. */
  93580. gammaSpace: boolean;
  93581. /**
  93582. * Gets or sets whether or not the texture contains RGBD data.
  93583. */
  93584. isRGBD: boolean;
  93585. /**
  93586. * Is Z inverted in the texture (useful in a cube texture).
  93587. */
  93588. invertZ: boolean;
  93589. /**
  93590. * Are mip maps generated for this texture or not.
  93591. */
  93592. readonly noMipmap: boolean;
  93593. /**
  93594. * @hidden
  93595. */
  93596. lodLevelInAlpha: boolean;
  93597. /**
  93598. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93599. */
  93600. lodGenerationOffset: number;
  93601. /**
  93602. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93603. */
  93604. lodGenerationScale: number;
  93605. /**
  93606. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93607. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93608. * average roughness values.
  93609. */
  93610. linearSpecularLOD: boolean;
  93611. /**
  93612. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93613. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93614. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93615. */
  93616. irradianceTexture: Nullable<BaseTexture>;
  93617. /**
  93618. * Define if the texture is a render target.
  93619. */
  93620. isRenderTarget: boolean;
  93621. /**
  93622. * Define the unique id of the texture in the scene.
  93623. */
  93624. readonly uid: string;
  93625. /**
  93626. * Return a string representation of the texture.
  93627. * @returns the texture as a string
  93628. */
  93629. toString(): string;
  93630. /**
  93631. * Get the class name of the texture.
  93632. * @returns "BaseTexture"
  93633. */
  93634. getClassName(): string;
  93635. /**
  93636. * Define the list of animation attached to the texture.
  93637. */
  93638. animations: Animation[];
  93639. /**
  93640. * An event triggered when the texture is disposed.
  93641. */
  93642. onDisposeObservable: Observable<BaseTexture>;
  93643. private _onDisposeObserver;
  93644. /**
  93645. * Callback triggered when the texture has been disposed.
  93646. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93647. */
  93648. onDispose: () => void;
  93649. /**
  93650. * Define the current state of the loading sequence when in delayed load mode.
  93651. */
  93652. delayLoadState: number;
  93653. private _scene;
  93654. /** @hidden */
  93655. _texture: Nullable<InternalTexture>;
  93656. private _uid;
  93657. /**
  93658. * Define if the texture is preventinga material to render or not.
  93659. * If not and the texture is not ready, the engine will use a default black texture instead.
  93660. */
  93661. readonly isBlocking: boolean;
  93662. /**
  93663. * Instantiates a new BaseTexture.
  93664. * Base class of all the textures in babylon.
  93665. * It groups all the common properties the materials, post process, lights... might need
  93666. * in order to make a correct use of the texture.
  93667. * @param scene Define the scene the texture blongs to
  93668. */
  93669. constructor(scene: Nullable<Scene>);
  93670. /**
  93671. * Get the scene the texture belongs to.
  93672. * @returns the scene or null if undefined
  93673. */
  93674. getScene(): Nullable<Scene>;
  93675. /**
  93676. * Get the texture transform matrix used to offset tile the texture for istance.
  93677. * @returns the transformation matrix
  93678. */
  93679. getTextureMatrix(): Matrix;
  93680. /**
  93681. * Get the texture reflection matrix used to rotate/transform the reflection.
  93682. * @returns the reflection matrix
  93683. */
  93684. getReflectionTextureMatrix(): Matrix;
  93685. /**
  93686. * Get the underlying lower level texture from Babylon.
  93687. * @returns the insternal texture
  93688. */
  93689. getInternalTexture(): Nullable<InternalTexture>;
  93690. /**
  93691. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93692. * @returns true if ready or not blocking
  93693. */
  93694. isReadyOrNotBlocking(): boolean;
  93695. /**
  93696. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93697. * @returns true if fully ready
  93698. */
  93699. isReady(): boolean;
  93700. private _cachedSize;
  93701. /**
  93702. * Get the size of the texture.
  93703. * @returns the texture size.
  93704. */
  93705. getSize(): ISize;
  93706. /**
  93707. * Get the base size of the texture.
  93708. * It can be different from the size if the texture has been resized for POT for instance
  93709. * @returns the base size
  93710. */
  93711. getBaseSize(): ISize;
  93712. /**
  93713. * Update the sampling mode of the texture.
  93714. * Default is Trilinear mode.
  93715. *
  93716. * | Value | Type | Description |
  93717. * | ----- | ------------------ | ----------- |
  93718. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93719. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93720. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93721. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93722. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93723. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93724. * | 7 | NEAREST_LINEAR | |
  93725. * | 8 | NEAREST_NEAREST | |
  93726. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93727. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93728. * | 11 | LINEAR_LINEAR | |
  93729. * | 12 | LINEAR_NEAREST | |
  93730. *
  93731. * > _mag_: magnification filter (close to the viewer)
  93732. * > _min_: minification filter (far from the viewer)
  93733. * > _mip_: filter used between mip map levels
  93734. *@param samplingMode Define the new sampling mode of the texture
  93735. */
  93736. updateSamplingMode(samplingMode: number): void;
  93737. /**
  93738. * Scales the texture if is `canRescale()`
  93739. * @param ratio the resize factor we want to use to rescale
  93740. */
  93741. scale(ratio: number): void;
  93742. /**
  93743. * Get if the texture can rescale.
  93744. */
  93745. readonly canRescale: boolean;
  93746. /** @hidden */
  93747. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93748. /** @hidden */
  93749. _rebuild(): void;
  93750. /**
  93751. * Triggers the load sequence in delayed load mode.
  93752. */
  93753. delayLoad(): void;
  93754. /**
  93755. * Clones the texture.
  93756. * @returns the cloned texture
  93757. */
  93758. clone(): Nullable<BaseTexture>;
  93759. /**
  93760. * Get the texture underlying type (INT, FLOAT...)
  93761. */
  93762. readonly textureType: number;
  93763. /**
  93764. * Get the texture underlying format (RGB, RGBA...)
  93765. */
  93766. readonly textureFormat: number;
  93767. /**
  93768. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93769. * This will returns an RGBA array buffer containing either in values (0-255) or
  93770. * float values (0-1) depending of the underlying buffer type.
  93771. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93772. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93773. * @param buffer defines a user defined buffer to fill with data (can be null)
  93774. * @returns The Array buffer containing the pixels data.
  93775. */
  93776. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93777. /**
  93778. * Release and destroy the underlying lower level texture aka internalTexture.
  93779. */
  93780. releaseInternalTexture(): void;
  93781. /**
  93782. * Get the polynomial representation of the texture data.
  93783. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93784. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93785. */
  93786. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93787. /** @hidden */
  93788. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93789. /** @hidden */
  93790. readonly _lodTextureMid: Nullable<BaseTexture>;
  93791. /** @hidden */
  93792. readonly _lodTextureLow: Nullable<BaseTexture>;
  93793. /**
  93794. * Dispose the texture and release its associated resources.
  93795. */
  93796. dispose(): void;
  93797. /**
  93798. * Serialize the texture into a JSON representation that can be parsed later on.
  93799. * @returns the JSON representation of the texture
  93800. */
  93801. serialize(): any;
  93802. /**
  93803. * Helper function to be called back once a list of texture contains only ready textures.
  93804. * @param textures Define the list of textures to wait for
  93805. * @param callback Define the callback triggered once the entire list will be ready
  93806. */
  93807. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93808. }
  93809. }
  93810. declare module BABYLON {
  93811. /**
  93812. * Class used to store data associated with WebGL texture data for the engine
  93813. * This class should not be used directly
  93814. */
  93815. export class InternalTexture {
  93816. /** @hidden */
  93817. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93818. /**
  93819. * The source of the texture data is unknown
  93820. */
  93821. static DATASOURCE_UNKNOWN: number;
  93822. /**
  93823. * Texture data comes from an URL
  93824. */
  93825. static DATASOURCE_URL: number;
  93826. /**
  93827. * Texture data is only used for temporary storage
  93828. */
  93829. static DATASOURCE_TEMP: number;
  93830. /**
  93831. * Texture data comes from raw data (ArrayBuffer)
  93832. */
  93833. static DATASOURCE_RAW: number;
  93834. /**
  93835. * Texture content is dynamic (video or dynamic texture)
  93836. */
  93837. static DATASOURCE_DYNAMIC: number;
  93838. /**
  93839. * Texture content is generated by rendering to it
  93840. */
  93841. static DATASOURCE_RENDERTARGET: number;
  93842. /**
  93843. * Texture content is part of a multi render target process
  93844. */
  93845. static DATASOURCE_MULTIRENDERTARGET: number;
  93846. /**
  93847. * Texture data comes from a cube data file
  93848. */
  93849. static DATASOURCE_CUBE: number;
  93850. /**
  93851. * Texture data comes from a raw cube data
  93852. */
  93853. static DATASOURCE_CUBERAW: number;
  93854. /**
  93855. * Texture data come from a prefiltered cube data file
  93856. */
  93857. static DATASOURCE_CUBEPREFILTERED: number;
  93858. /**
  93859. * Texture content is raw 3D data
  93860. */
  93861. static DATASOURCE_RAW3D: number;
  93862. /**
  93863. * Texture content is a depth texture
  93864. */
  93865. static DATASOURCE_DEPTHTEXTURE: number;
  93866. /**
  93867. * Texture data comes from a raw cube data encoded with RGBD
  93868. */
  93869. static DATASOURCE_CUBERAW_RGBD: number;
  93870. /**
  93871. * Defines if the texture is ready
  93872. */
  93873. isReady: boolean;
  93874. /**
  93875. * Defines if the texture is a cube texture
  93876. */
  93877. isCube: boolean;
  93878. /**
  93879. * Defines if the texture contains 3D data
  93880. */
  93881. is3D: boolean;
  93882. /**
  93883. * Defines if the texture contains multiview data
  93884. */
  93885. isMultiview: boolean;
  93886. /**
  93887. * Gets the URL used to load this texture
  93888. */
  93889. url: string;
  93890. /**
  93891. * Gets the sampling mode of the texture
  93892. */
  93893. samplingMode: number;
  93894. /**
  93895. * Gets a boolean indicating if the texture needs mipmaps generation
  93896. */
  93897. generateMipMaps: boolean;
  93898. /**
  93899. * Gets the number of samples used by the texture (WebGL2+ only)
  93900. */
  93901. samples: number;
  93902. /**
  93903. * Gets the type of the texture (int, float...)
  93904. */
  93905. type: number;
  93906. /**
  93907. * Gets the format of the texture (RGB, RGBA...)
  93908. */
  93909. format: number;
  93910. /**
  93911. * Observable called when the texture is loaded
  93912. */
  93913. onLoadedObservable: Observable<InternalTexture>;
  93914. /**
  93915. * Gets the width of the texture
  93916. */
  93917. width: number;
  93918. /**
  93919. * Gets the height of the texture
  93920. */
  93921. height: number;
  93922. /**
  93923. * Gets the depth of the texture
  93924. */
  93925. depth: number;
  93926. /**
  93927. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  93928. */
  93929. baseWidth: number;
  93930. /**
  93931. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  93932. */
  93933. baseHeight: number;
  93934. /**
  93935. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  93936. */
  93937. baseDepth: number;
  93938. /**
  93939. * Gets a boolean indicating if the texture is inverted on Y axis
  93940. */
  93941. invertY: boolean;
  93942. /** @hidden */
  93943. _invertVScale: boolean;
  93944. /** @hidden */
  93945. _associatedChannel: number;
  93946. /** @hidden */
  93947. _dataSource: number;
  93948. /** @hidden */
  93949. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  93950. /** @hidden */
  93951. _bufferView: Nullable<ArrayBufferView>;
  93952. /** @hidden */
  93953. _bufferViewArray: Nullable<ArrayBufferView[]>;
  93954. /** @hidden */
  93955. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  93956. /** @hidden */
  93957. _size: number;
  93958. /** @hidden */
  93959. _extension: string;
  93960. /** @hidden */
  93961. _files: Nullable<string[]>;
  93962. /** @hidden */
  93963. _workingCanvas: Nullable<HTMLCanvasElement>;
  93964. /** @hidden */
  93965. _workingContext: Nullable<CanvasRenderingContext2D>;
  93966. /** @hidden */
  93967. _framebuffer: Nullable<WebGLFramebuffer>;
  93968. /** @hidden */
  93969. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  93970. /** @hidden */
  93971. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  93972. /** @hidden */
  93973. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  93974. /** @hidden */
  93975. _attachments: Nullable<number[]>;
  93976. /** @hidden */
  93977. _cachedCoordinatesMode: Nullable<number>;
  93978. /** @hidden */
  93979. _cachedWrapU: Nullable<number>;
  93980. /** @hidden */
  93981. _cachedWrapV: Nullable<number>;
  93982. /** @hidden */
  93983. _cachedWrapR: Nullable<number>;
  93984. /** @hidden */
  93985. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93986. /** @hidden */
  93987. _isDisabled: boolean;
  93988. /** @hidden */
  93989. _compression: Nullable<string>;
  93990. /** @hidden */
  93991. _generateStencilBuffer: boolean;
  93992. /** @hidden */
  93993. _generateDepthBuffer: boolean;
  93994. /** @hidden */
  93995. _comparisonFunction: number;
  93996. /** @hidden */
  93997. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  93998. /** @hidden */
  93999. _lodGenerationScale: number;
  94000. /** @hidden */
  94001. _lodGenerationOffset: number;
  94002. /** @hidden */
  94003. _colorTextureArray: Nullable<WebGLTexture>;
  94004. /** @hidden */
  94005. _depthStencilTextureArray: Nullable<WebGLTexture>;
  94006. /** @hidden */
  94007. _lodTextureHigh: Nullable<BaseTexture>;
  94008. /** @hidden */
  94009. _lodTextureMid: Nullable<BaseTexture>;
  94010. /** @hidden */
  94011. _lodTextureLow: Nullable<BaseTexture>;
  94012. /** @hidden */
  94013. _isRGBD: boolean;
  94014. /** @hidden */
  94015. _linearSpecularLOD: boolean;
  94016. /** @hidden */
  94017. _irradianceTexture: Nullable<BaseTexture>;
  94018. /** @hidden */
  94019. _webGLTexture: Nullable<WebGLTexture>;
  94020. /** @hidden */
  94021. _references: number;
  94022. private _engine;
  94023. /**
  94024. * Gets the Engine the texture belongs to.
  94025. * @returns The babylon engine
  94026. */
  94027. getEngine(): Engine;
  94028. /**
  94029. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  94030. */
  94031. readonly dataSource: number;
  94032. /**
  94033. * Creates a new InternalTexture
  94034. * @param engine defines the engine to use
  94035. * @param dataSource defines the type of data that will be used
  94036. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94037. */
  94038. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  94039. /**
  94040. * Increments the number of references (ie. the number of Texture that point to it)
  94041. */
  94042. incrementReferences(): void;
  94043. /**
  94044. * Change the size of the texture (not the size of the content)
  94045. * @param width defines the new width
  94046. * @param height defines the new height
  94047. * @param depth defines the new depth (1 by default)
  94048. */
  94049. updateSize(width: int, height: int, depth?: int): void;
  94050. /** @hidden */
  94051. _rebuild(): void;
  94052. /** @hidden */
  94053. _swapAndDie(target: InternalTexture): void;
  94054. /**
  94055. * Dispose the current allocated resources
  94056. */
  94057. dispose(): void;
  94058. }
  94059. }
  94060. declare module BABYLON {
  94061. /**
  94062. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94063. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94064. */
  94065. export class EffectFallbacks {
  94066. private _defines;
  94067. private _currentRank;
  94068. private _maxRank;
  94069. private _mesh;
  94070. /**
  94071. * Removes the fallback from the bound mesh.
  94072. */
  94073. unBindMesh(): void;
  94074. /**
  94075. * Adds a fallback on the specified property.
  94076. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94077. * @param define The name of the define in the shader
  94078. */
  94079. addFallback(rank: number, define: string): void;
  94080. /**
  94081. * Sets the mesh to use CPU skinning when needing to fallback.
  94082. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94083. * @param mesh The mesh to use the fallbacks.
  94084. */
  94085. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94086. /**
  94087. * Checks to see if more fallbacks are still availible.
  94088. */
  94089. readonly hasMoreFallbacks: boolean;
  94090. /**
  94091. * Removes the defines that should be removed when falling back.
  94092. * @param currentDefines defines the current define statements for the shader.
  94093. * @param effect defines the current effect we try to compile
  94094. * @returns The resulting defines with defines of the current rank removed.
  94095. */
  94096. reduce(currentDefines: string, effect: Effect): string;
  94097. }
  94098. /**
  94099. * Options to be used when creating an effect.
  94100. */
  94101. export class EffectCreationOptions {
  94102. /**
  94103. * Atrributes that will be used in the shader.
  94104. */
  94105. attributes: string[];
  94106. /**
  94107. * Uniform varible names that will be set in the shader.
  94108. */
  94109. uniformsNames: string[];
  94110. /**
  94111. * Uniform buffer varible names that will be set in the shader.
  94112. */
  94113. uniformBuffersNames: string[];
  94114. /**
  94115. * Sampler texture variable names that will be set in the shader.
  94116. */
  94117. samplers: string[];
  94118. /**
  94119. * Define statements that will be set in the shader.
  94120. */
  94121. defines: any;
  94122. /**
  94123. * Possible fallbacks for this effect to improve performance when needed.
  94124. */
  94125. fallbacks: Nullable<EffectFallbacks>;
  94126. /**
  94127. * Callback that will be called when the shader is compiled.
  94128. */
  94129. onCompiled: Nullable<(effect: Effect) => void>;
  94130. /**
  94131. * Callback that will be called if an error occurs during shader compilation.
  94132. */
  94133. onError: Nullable<(effect: Effect, errors: string) => void>;
  94134. /**
  94135. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94136. */
  94137. indexParameters: any;
  94138. /**
  94139. * Max number of lights that can be used in the shader.
  94140. */
  94141. maxSimultaneousLights: number;
  94142. /**
  94143. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94144. */
  94145. transformFeedbackVaryings: Nullable<string[]>;
  94146. }
  94147. /**
  94148. * Effect containing vertex and fragment shader that can be executed on an object.
  94149. */
  94150. export class Effect implements IDisposable {
  94151. /**
  94152. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94153. */
  94154. static ShadersRepository: string;
  94155. /**
  94156. * Name of the effect.
  94157. */
  94158. name: any;
  94159. /**
  94160. * String container all the define statements that should be set on the shader.
  94161. */
  94162. defines: string;
  94163. /**
  94164. * Callback that will be called when the shader is compiled.
  94165. */
  94166. onCompiled: Nullable<(effect: Effect) => void>;
  94167. /**
  94168. * Callback that will be called if an error occurs during shader compilation.
  94169. */
  94170. onError: Nullable<(effect: Effect, errors: string) => void>;
  94171. /**
  94172. * Callback that will be called when effect is bound.
  94173. */
  94174. onBind: Nullable<(effect: Effect) => void>;
  94175. /**
  94176. * Unique ID of the effect.
  94177. */
  94178. uniqueId: number;
  94179. /**
  94180. * Observable that will be called when the shader is compiled.
  94181. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94182. */
  94183. onCompileObservable: Observable<Effect>;
  94184. /**
  94185. * Observable that will be called if an error occurs during shader compilation.
  94186. */
  94187. onErrorObservable: Observable<Effect>;
  94188. /** @hidden */
  94189. _onBindObservable: Nullable<Observable<Effect>>;
  94190. /**
  94191. * Observable that will be called when effect is bound.
  94192. */
  94193. readonly onBindObservable: Observable<Effect>;
  94194. /** @hidden */
  94195. _bonesComputationForcedToCPU: boolean;
  94196. private static _uniqueIdSeed;
  94197. private _engine;
  94198. private _uniformBuffersNames;
  94199. private _uniformsNames;
  94200. private _samplerList;
  94201. private _samplers;
  94202. private _isReady;
  94203. private _compilationError;
  94204. private _attributesNames;
  94205. private _attributes;
  94206. private _uniforms;
  94207. /**
  94208. * Key for the effect.
  94209. * @hidden
  94210. */
  94211. _key: string;
  94212. private _indexParameters;
  94213. private _fallbacks;
  94214. private _vertexSourceCode;
  94215. private _fragmentSourceCode;
  94216. private _vertexSourceCodeOverride;
  94217. private _fragmentSourceCodeOverride;
  94218. private _transformFeedbackVaryings;
  94219. /**
  94220. * Compiled shader to webGL program.
  94221. * @hidden
  94222. */
  94223. _pipelineContext: Nullable<IPipelineContext>;
  94224. private _valueCache;
  94225. private static _baseCache;
  94226. /**
  94227. * Instantiates an effect.
  94228. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94229. * @param baseName Name of the effect.
  94230. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94231. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94232. * @param samplers List of sampler variables that will be passed to the shader.
  94233. * @param engine Engine to be used to render the effect
  94234. * @param defines Define statements to be added to the shader.
  94235. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94236. * @param onCompiled Callback that will be called when the shader is compiled.
  94237. * @param onError Callback that will be called if an error occurs during shader compilation.
  94238. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94239. */
  94240. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94241. private _useFinalCode;
  94242. /**
  94243. * Unique key for this effect
  94244. */
  94245. readonly key: string;
  94246. /**
  94247. * If the effect has been compiled and prepared.
  94248. * @returns if the effect is compiled and prepared.
  94249. */
  94250. isReady(): boolean;
  94251. private _isReadyInternal;
  94252. /**
  94253. * The engine the effect was initialized with.
  94254. * @returns the engine.
  94255. */
  94256. getEngine(): Engine;
  94257. /**
  94258. * The pipeline context for this effect
  94259. * @returns the associated pipeline context
  94260. */
  94261. getPipelineContext(): Nullable<IPipelineContext>;
  94262. /**
  94263. * The set of names of attribute variables for the shader.
  94264. * @returns An array of attribute names.
  94265. */
  94266. getAttributesNames(): string[];
  94267. /**
  94268. * Returns the attribute at the given index.
  94269. * @param index The index of the attribute.
  94270. * @returns The location of the attribute.
  94271. */
  94272. getAttributeLocation(index: number): number;
  94273. /**
  94274. * Returns the attribute based on the name of the variable.
  94275. * @param name of the attribute to look up.
  94276. * @returns the attribute location.
  94277. */
  94278. getAttributeLocationByName(name: string): number;
  94279. /**
  94280. * The number of attributes.
  94281. * @returns the numnber of attributes.
  94282. */
  94283. getAttributesCount(): number;
  94284. /**
  94285. * Gets the index of a uniform variable.
  94286. * @param uniformName of the uniform to look up.
  94287. * @returns the index.
  94288. */
  94289. getUniformIndex(uniformName: string): number;
  94290. /**
  94291. * Returns the attribute based on the name of the variable.
  94292. * @param uniformName of the uniform to look up.
  94293. * @returns the location of the uniform.
  94294. */
  94295. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94296. /**
  94297. * Returns an array of sampler variable names
  94298. * @returns The array of sampler variable neames.
  94299. */
  94300. getSamplers(): string[];
  94301. /**
  94302. * The error from the last compilation.
  94303. * @returns the error string.
  94304. */
  94305. getCompilationError(): string;
  94306. /**
  94307. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94308. * @param func The callback to be used.
  94309. */
  94310. executeWhenCompiled(func: (effect: Effect) => void): void;
  94311. private _checkIsReady;
  94312. /** @hidden */
  94313. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94314. /** @hidden */
  94315. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94316. /** @hidden */
  94317. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94318. /**
  94319. * Recompiles the webGL program
  94320. * @param vertexSourceCode The source code for the vertex shader.
  94321. * @param fragmentSourceCode The source code for the fragment shader.
  94322. * @param onCompiled Callback called when completed.
  94323. * @param onError Callback called on error.
  94324. * @hidden
  94325. */
  94326. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94327. /**
  94328. * Prepares the effect
  94329. * @hidden
  94330. */
  94331. _prepareEffect(): void;
  94332. private _processCompilationErrors;
  94333. /**
  94334. * Checks if the effect is supported. (Must be called after compilation)
  94335. */
  94336. readonly isSupported: boolean;
  94337. /**
  94338. * Binds a texture to the engine to be used as output of the shader.
  94339. * @param channel Name of the output variable.
  94340. * @param texture Texture to bind.
  94341. * @hidden
  94342. */
  94343. _bindTexture(channel: string, texture: InternalTexture): void;
  94344. /**
  94345. * Sets a texture on the engine to be used in the shader.
  94346. * @param channel Name of the sampler variable.
  94347. * @param texture Texture to set.
  94348. */
  94349. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94350. /**
  94351. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94352. * @param channel Name of the sampler variable.
  94353. * @param texture Texture to set.
  94354. */
  94355. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94356. /**
  94357. * Sets an array of textures on the engine to be used in the shader.
  94358. * @param channel Name of the variable.
  94359. * @param textures Textures to set.
  94360. */
  94361. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94362. /**
  94363. * 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)
  94364. * @param channel Name of the sampler variable.
  94365. * @param postProcess Post process to get the input texture from.
  94366. */
  94367. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94368. /**
  94369. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94370. * 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)
  94371. * @param channel Name of the sampler variable.
  94372. * @param postProcess Post process to get the output texture from.
  94373. */
  94374. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94375. /** @hidden */
  94376. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94377. /** @hidden */
  94378. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94379. /** @hidden */
  94380. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94381. /** @hidden */
  94382. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94383. /**
  94384. * Binds a buffer to a uniform.
  94385. * @param buffer Buffer to bind.
  94386. * @param name Name of the uniform variable to bind to.
  94387. */
  94388. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94389. /**
  94390. * Binds block to a uniform.
  94391. * @param blockName Name of the block to bind.
  94392. * @param index Index to bind.
  94393. */
  94394. bindUniformBlock(blockName: string, index: number): void;
  94395. /**
  94396. * Sets an interger value on a uniform variable.
  94397. * @param uniformName Name of the variable.
  94398. * @param value Value to be set.
  94399. * @returns this effect.
  94400. */
  94401. setInt(uniformName: string, value: number): Effect;
  94402. /**
  94403. * Sets an int array on a uniform variable.
  94404. * @param uniformName Name of the variable.
  94405. * @param array array to be set.
  94406. * @returns this effect.
  94407. */
  94408. setIntArray(uniformName: string, array: Int32Array): Effect;
  94409. /**
  94410. * 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)
  94411. * @param uniformName Name of the variable.
  94412. * @param array array to be set.
  94413. * @returns this effect.
  94414. */
  94415. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94416. /**
  94417. * 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)
  94418. * @param uniformName Name of the variable.
  94419. * @param array array to be set.
  94420. * @returns this effect.
  94421. */
  94422. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94423. /**
  94424. * 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)
  94425. * @param uniformName Name of the variable.
  94426. * @param array array to be set.
  94427. * @returns this effect.
  94428. */
  94429. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94430. /**
  94431. * Sets an float array on a uniform variable.
  94432. * @param uniformName Name of the variable.
  94433. * @param array array to be set.
  94434. * @returns this effect.
  94435. */
  94436. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94437. /**
  94438. * 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)
  94439. * @param uniformName Name of the variable.
  94440. * @param array array to be set.
  94441. * @returns this effect.
  94442. */
  94443. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94444. /**
  94445. * 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)
  94446. * @param uniformName Name of the variable.
  94447. * @param array array to be set.
  94448. * @returns this effect.
  94449. */
  94450. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94451. /**
  94452. * 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)
  94453. * @param uniformName Name of the variable.
  94454. * @param array array to be set.
  94455. * @returns this effect.
  94456. */
  94457. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94458. /**
  94459. * Sets an array on a uniform variable.
  94460. * @param uniformName Name of the variable.
  94461. * @param array array to be set.
  94462. * @returns this effect.
  94463. */
  94464. setArray(uniformName: string, array: number[]): Effect;
  94465. /**
  94466. * 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)
  94467. * @param uniformName Name of the variable.
  94468. * @param array array to be set.
  94469. * @returns this effect.
  94470. */
  94471. setArray2(uniformName: string, array: number[]): Effect;
  94472. /**
  94473. * 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)
  94474. * @param uniformName Name of the variable.
  94475. * @param array array to be set.
  94476. * @returns this effect.
  94477. */
  94478. setArray3(uniformName: string, array: number[]): Effect;
  94479. /**
  94480. * 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)
  94481. * @param uniformName Name of the variable.
  94482. * @param array array to be set.
  94483. * @returns this effect.
  94484. */
  94485. setArray4(uniformName: string, array: number[]): Effect;
  94486. /**
  94487. * Sets matrices on a uniform variable.
  94488. * @param uniformName Name of the variable.
  94489. * @param matrices matrices to be set.
  94490. * @returns this effect.
  94491. */
  94492. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94493. /**
  94494. * Sets matrix on a uniform variable.
  94495. * @param uniformName Name of the variable.
  94496. * @param matrix matrix to be set.
  94497. * @returns this effect.
  94498. */
  94499. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94500. /**
  94501. * 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)
  94502. * @param uniformName Name of the variable.
  94503. * @param matrix matrix to be set.
  94504. * @returns this effect.
  94505. */
  94506. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94507. /**
  94508. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94509. * @param uniformName Name of the variable.
  94510. * @param matrix matrix to be set.
  94511. * @returns this effect.
  94512. */
  94513. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94514. /**
  94515. * Sets a float on a uniform variable.
  94516. * @param uniformName Name of the variable.
  94517. * @param value value to be set.
  94518. * @returns this effect.
  94519. */
  94520. setFloat(uniformName: string, value: number): Effect;
  94521. /**
  94522. * Sets a boolean on a uniform variable.
  94523. * @param uniformName Name of the variable.
  94524. * @param bool value to be set.
  94525. * @returns this effect.
  94526. */
  94527. setBool(uniformName: string, bool: boolean): Effect;
  94528. /**
  94529. * Sets a Vector2 on a uniform variable.
  94530. * @param uniformName Name of the variable.
  94531. * @param vector2 vector2 to be set.
  94532. * @returns this effect.
  94533. */
  94534. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94535. /**
  94536. * Sets a float2 on a uniform variable.
  94537. * @param uniformName Name of the variable.
  94538. * @param x First float in float2.
  94539. * @param y Second float in float2.
  94540. * @returns this effect.
  94541. */
  94542. setFloat2(uniformName: string, x: number, y: number): Effect;
  94543. /**
  94544. * Sets a Vector3 on a uniform variable.
  94545. * @param uniformName Name of the variable.
  94546. * @param vector3 Value to be set.
  94547. * @returns this effect.
  94548. */
  94549. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94550. /**
  94551. * Sets a float3 on a uniform variable.
  94552. * @param uniformName Name of the variable.
  94553. * @param x First float in float3.
  94554. * @param y Second float in float3.
  94555. * @param z Third float in float3.
  94556. * @returns this effect.
  94557. */
  94558. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94559. /**
  94560. * Sets a Vector4 on a uniform variable.
  94561. * @param uniformName Name of the variable.
  94562. * @param vector4 Value to be set.
  94563. * @returns this effect.
  94564. */
  94565. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94566. /**
  94567. * Sets a float4 on a uniform variable.
  94568. * @param uniformName Name of the variable.
  94569. * @param x First float in float4.
  94570. * @param y Second float in float4.
  94571. * @param z Third float in float4.
  94572. * @param w Fourth float in float4.
  94573. * @returns this effect.
  94574. */
  94575. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94576. /**
  94577. * Sets a Color3 on a uniform variable.
  94578. * @param uniformName Name of the variable.
  94579. * @param color3 Value to be set.
  94580. * @returns this effect.
  94581. */
  94582. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94583. /**
  94584. * Sets a Color4 on a uniform variable.
  94585. * @param uniformName Name of the variable.
  94586. * @param color3 Value to be set.
  94587. * @param alpha Alpha value to be set.
  94588. * @returns this effect.
  94589. */
  94590. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94591. /**
  94592. * Sets a Color4 on a uniform variable
  94593. * @param uniformName defines the name of the variable
  94594. * @param color4 defines the value to be set
  94595. * @returns this effect.
  94596. */
  94597. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94598. /** Release all associated resources */
  94599. dispose(): void;
  94600. /**
  94601. * This function will add a new shader to the shader store
  94602. * @param name the name of the shader
  94603. * @param pixelShader optional pixel shader content
  94604. * @param vertexShader optional vertex shader content
  94605. */
  94606. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94607. /**
  94608. * Store of each shader (The can be looked up using effect.key)
  94609. */
  94610. static ShadersStore: {
  94611. [key: string]: string;
  94612. };
  94613. /**
  94614. * Store of each included file for a shader (The can be looked up using effect.key)
  94615. */
  94616. static IncludesShadersStore: {
  94617. [key: string]: string;
  94618. };
  94619. /**
  94620. * Resets the cache of effects.
  94621. */
  94622. static ResetCache(): void;
  94623. }
  94624. }
  94625. declare module BABYLON {
  94626. /**
  94627. * Uniform buffer objects.
  94628. *
  94629. * Handles blocks of uniform on the GPU.
  94630. *
  94631. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94632. *
  94633. * For more information, please refer to :
  94634. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94635. */
  94636. export class UniformBuffer {
  94637. private _engine;
  94638. private _buffer;
  94639. private _data;
  94640. private _bufferData;
  94641. private _dynamic?;
  94642. private _uniformLocations;
  94643. private _uniformSizes;
  94644. private _uniformLocationPointer;
  94645. private _needSync;
  94646. private _noUBO;
  94647. private _currentEffect;
  94648. private static _MAX_UNIFORM_SIZE;
  94649. private static _tempBuffer;
  94650. /**
  94651. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94652. * This is dynamic to allow compat with webgl 1 and 2.
  94653. * You will need to pass the name of the uniform as well as the value.
  94654. */
  94655. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94656. /**
  94657. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94658. * This is dynamic to allow compat with webgl 1 and 2.
  94659. * You will need to pass the name of the uniform as well as the value.
  94660. */
  94661. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94662. /**
  94663. * Lambda to Update a single float in a uniform buffer.
  94664. * This is dynamic to allow compat with webgl 1 and 2.
  94665. * You will need to pass the name of the uniform as well as the value.
  94666. */
  94667. updateFloat: (name: string, x: number) => void;
  94668. /**
  94669. * Lambda to Update a vec2 of float in a uniform buffer.
  94670. * This is dynamic to allow compat with webgl 1 and 2.
  94671. * You will need to pass the name of the uniform as well as the value.
  94672. */
  94673. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94674. /**
  94675. * Lambda to Update a vec3 of float in a uniform buffer.
  94676. * This is dynamic to allow compat with webgl 1 and 2.
  94677. * You will need to pass the name of the uniform as well as the value.
  94678. */
  94679. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94680. /**
  94681. * Lambda to Update a vec4 of float in a uniform buffer.
  94682. * This is dynamic to allow compat with webgl 1 and 2.
  94683. * You will need to pass the name of the uniform as well as the value.
  94684. */
  94685. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94686. /**
  94687. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94688. * This is dynamic to allow compat with webgl 1 and 2.
  94689. * You will need to pass the name of the uniform as well as the value.
  94690. */
  94691. updateMatrix: (name: string, mat: Matrix) => void;
  94692. /**
  94693. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94694. * This is dynamic to allow compat with webgl 1 and 2.
  94695. * You will need to pass the name of the uniform as well as the value.
  94696. */
  94697. updateVector3: (name: string, vector: Vector3) => void;
  94698. /**
  94699. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94700. * This is dynamic to allow compat with webgl 1 and 2.
  94701. * You will need to pass the name of the uniform as well as the value.
  94702. */
  94703. updateVector4: (name: string, vector: Vector4) => void;
  94704. /**
  94705. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94706. * This is dynamic to allow compat with webgl 1 and 2.
  94707. * You will need to pass the name of the uniform as well as the value.
  94708. */
  94709. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94710. /**
  94711. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94712. * This is dynamic to allow compat with webgl 1 and 2.
  94713. * You will need to pass the name of the uniform as well as the value.
  94714. */
  94715. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94716. /**
  94717. * Instantiates a new Uniform buffer objects.
  94718. *
  94719. * Handles blocks of uniform on the GPU.
  94720. *
  94721. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94722. *
  94723. * For more information, please refer to :
  94724. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94725. * @param engine Define the engine the buffer is associated with
  94726. * @param data Define the data contained in the buffer
  94727. * @param dynamic Define if the buffer is updatable
  94728. */
  94729. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94730. /**
  94731. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94732. * or just falling back on setUniformXXX calls.
  94733. */
  94734. readonly useUbo: boolean;
  94735. /**
  94736. * Indicates if the WebGL underlying uniform buffer is in sync
  94737. * with the javascript cache data.
  94738. */
  94739. readonly isSync: boolean;
  94740. /**
  94741. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94742. * Also, a dynamic UniformBuffer will disable cache verification and always
  94743. * update the underlying WebGL uniform buffer to the GPU.
  94744. * @returns if Dynamic, otherwise false
  94745. */
  94746. isDynamic(): boolean;
  94747. /**
  94748. * The data cache on JS side.
  94749. * @returns the underlying data as a float array
  94750. */
  94751. getData(): Float32Array;
  94752. /**
  94753. * The underlying WebGL Uniform buffer.
  94754. * @returns the webgl buffer
  94755. */
  94756. getBuffer(): Nullable<DataBuffer>;
  94757. /**
  94758. * std140 layout specifies how to align data within an UBO structure.
  94759. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94760. * for specs.
  94761. */
  94762. private _fillAlignment;
  94763. /**
  94764. * Adds an uniform in the buffer.
  94765. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94766. * for the layout to be correct !
  94767. * @param name Name of the uniform, as used in the uniform block in the shader.
  94768. * @param size Data size, or data directly.
  94769. */
  94770. addUniform(name: string, size: number | number[]): void;
  94771. /**
  94772. * Adds a Matrix 4x4 to the uniform buffer.
  94773. * @param name Name of the uniform, as used in the uniform block in the shader.
  94774. * @param mat A 4x4 matrix.
  94775. */
  94776. addMatrix(name: string, mat: Matrix): void;
  94777. /**
  94778. * Adds a vec2 to the uniform buffer.
  94779. * @param name Name of the uniform, as used in the uniform block in the shader.
  94780. * @param x Define the x component value of the vec2
  94781. * @param y Define the y component value of the vec2
  94782. */
  94783. addFloat2(name: string, x: number, y: number): void;
  94784. /**
  94785. * Adds a vec3 to the uniform buffer.
  94786. * @param name Name of the uniform, as used in the uniform block in the shader.
  94787. * @param x Define the x component value of the vec3
  94788. * @param y Define the y component value of the vec3
  94789. * @param z Define the z component value of the vec3
  94790. */
  94791. addFloat3(name: string, x: number, y: number, z: number): void;
  94792. /**
  94793. * Adds a vec3 to the uniform buffer.
  94794. * @param name Name of the uniform, as used in the uniform block in the shader.
  94795. * @param color Define the vec3 from a Color
  94796. */
  94797. addColor3(name: string, color: Color3): void;
  94798. /**
  94799. * Adds a vec4 to the uniform buffer.
  94800. * @param name Name of the uniform, as used in the uniform block in the shader.
  94801. * @param color Define the rgb components from a Color
  94802. * @param alpha Define the a component of the vec4
  94803. */
  94804. addColor4(name: string, color: Color3, alpha: number): void;
  94805. /**
  94806. * Adds a vec3 to the uniform buffer.
  94807. * @param name Name of the uniform, as used in the uniform block in the shader.
  94808. * @param vector Define the vec3 components from a Vector
  94809. */
  94810. addVector3(name: string, vector: Vector3): void;
  94811. /**
  94812. * Adds a Matrix 3x3 to the uniform buffer.
  94813. * @param name Name of the uniform, as used in the uniform block in the shader.
  94814. */
  94815. addMatrix3x3(name: string): void;
  94816. /**
  94817. * Adds a Matrix 2x2 to the uniform buffer.
  94818. * @param name Name of the uniform, as used in the uniform block in the shader.
  94819. */
  94820. addMatrix2x2(name: string): void;
  94821. /**
  94822. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94823. */
  94824. create(): void;
  94825. /** @hidden */
  94826. _rebuild(): void;
  94827. /**
  94828. * Updates the WebGL Uniform Buffer on the GPU.
  94829. * If the `dynamic` flag is set to true, no cache comparison is done.
  94830. * Otherwise, the buffer will be updated only if the cache differs.
  94831. */
  94832. update(): void;
  94833. /**
  94834. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94835. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94836. * @param data Define the flattened data
  94837. * @param size Define the size of the data.
  94838. */
  94839. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94840. private _valueCache;
  94841. private _cacheMatrix;
  94842. private _updateMatrix3x3ForUniform;
  94843. private _updateMatrix3x3ForEffect;
  94844. private _updateMatrix2x2ForEffect;
  94845. private _updateMatrix2x2ForUniform;
  94846. private _updateFloatForEffect;
  94847. private _updateFloatForUniform;
  94848. private _updateFloat2ForEffect;
  94849. private _updateFloat2ForUniform;
  94850. private _updateFloat3ForEffect;
  94851. private _updateFloat3ForUniform;
  94852. private _updateFloat4ForEffect;
  94853. private _updateFloat4ForUniform;
  94854. private _updateMatrixForEffect;
  94855. private _updateMatrixForUniform;
  94856. private _updateVector3ForEffect;
  94857. private _updateVector3ForUniform;
  94858. private _updateVector4ForEffect;
  94859. private _updateVector4ForUniform;
  94860. private _updateColor3ForEffect;
  94861. private _updateColor3ForUniform;
  94862. private _updateColor4ForEffect;
  94863. private _updateColor4ForUniform;
  94864. /**
  94865. * Sets a sampler uniform on the effect.
  94866. * @param name Define the name of the sampler.
  94867. * @param texture Define the texture to set in the sampler
  94868. */
  94869. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94870. /**
  94871. * Directly updates the value of the uniform in the cache AND on the GPU.
  94872. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94873. * @param data Define the flattened data
  94874. */
  94875. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94876. /**
  94877. * Binds this uniform buffer to an effect.
  94878. * @param effect Define the effect to bind the buffer to
  94879. * @param name Name of the uniform block in the shader.
  94880. */
  94881. bindToEffect(effect: Effect, name: string): void;
  94882. /**
  94883. * Disposes the uniform buffer.
  94884. */
  94885. dispose(): void;
  94886. }
  94887. }
  94888. declare module BABYLON {
  94889. /**
  94890. * Class used to work with sound analyzer using fast fourier transform (FFT)
  94891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94892. */
  94893. export class Analyser {
  94894. /**
  94895. * Gets or sets the smoothing
  94896. * @ignorenaming
  94897. */
  94898. SMOOTHING: number;
  94899. /**
  94900. * Gets or sets the FFT table size
  94901. * @ignorenaming
  94902. */
  94903. FFT_SIZE: number;
  94904. /**
  94905. * Gets or sets the bar graph amplitude
  94906. * @ignorenaming
  94907. */
  94908. BARGRAPHAMPLITUDE: number;
  94909. /**
  94910. * Gets or sets the position of the debug canvas
  94911. * @ignorenaming
  94912. */
  94913. DEBUGCANVASPOS: {
  94914. x: number;
  94915. y: number;
  94916. };
  94917. /**
  94918. * Gets or sets the debug canvas size
  94919. * @ignorenaming
  94920. */
  94921. DEBUGCANVASSIZE: {
  94922. width: number;
  94923. height: number;
  94924. };
  94925. private _byteFreqs;
  94926. private _byteTime;
  94927. private _floatFreqs;
  94928. private _webAudioAnalyser;
  94929. private _debugCanvas;
  94930. private _debugCanvasContext;
  94931. private _scene;
  94932. private _registerFunc;
  94933. private _audioEngine;
  94934. /**
  94935. * Creates a new analyser
  94936. * @param scene defines hosting scene
  94937. */
  94938. constructor(scene: Scene);
  94939. /**
  94940. * Get the number of data values you will have to play with for the visualization
  94941. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  94942. * @returns a number
  94943. */
  94944. getFrequencyBinCount(): number;
  94945. /**
  94946. * Gets the current frequency data as a byte array
  94947. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94948. * @returns a Uint8Array
  94949. */
  94950. getByteFrequencyData(): Uint8Array;
  94951. /**
  94952. * Gets the current waveform as a byte array
  94953. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  94954. * @returns a Uint8Array
  94955. */
  94956. getByteTimeDomainData(): Uint8Array;
  94957. /**
  94958. * Gets the current frequency data as a float array
  94959. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94960. * @returns a Float32Array
  94961. */
  94962. getFloatFrequencyData(): Float32Array;
  94963. /**
  94964. * Renders the debug canvas
  94965. */
  94966. drawDebugCanvas(): void;
  94967. /**
  94968. * Stops rendering the debug canvas and removes it
  94969. */
  94970. stopDebugCanvas(): void;
  94971. /**
  94972. * Connects two audio nodes
  94973. * @param inputAudioNode defines first node to connect
  94974. * @param outputAudioNode defines second node to connect
  94975. */
  94976. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  94977. /**
  94978. * Releases all associated resources
  94979. */
  94980. dispose(): void;
  94981. }
  94982. }
  94983. declare module BABYLON {
  94984. /**
  94985. * This represents an audio engine and it is responsible
  94986. * to play, synchronize and analyse sounds throughout the application.
  94987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94988. */
  94989. export interface IAudioEngine extends IDisposable {
  94990. /**
  94991. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94992. */
  94993. readonly canUseWebAudio: boolean;
  94994. /**
  94995. * Gets the current AudioContext if available.
  94996. */
  94997. readonly audioContext: Nullable<AudioContext>;
  94998. /**
  94999. * The master gain node defines the global audio volume of your audio engine.
  95000. */
  95001. readonly masterGain: GainNode;
  95002. /**
  95003. * Gets whether or not mp3 are supported by your browser.
  95004. */
  95005. readonly isMP3supported: boolean;
  95006. /**
  95007. * Gets whether or not ogg are supported by your browser.
  95008. */
  95009. readonly isOGGsupported: boolean;
  95010. /**
  95011. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95012. * @ignoreNaming
  95013. */
  95014. WarnedWebAudioUnsupported: boolean;
  95015. /**
  95016. * Defines if the audio engine relies on a custom unlocked button.
  95017. * In this case, the embedded button will not be displayed.
  95018. */
  95019. useCustomUnlockedButton: boolean;
  95020. /**
  95021. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  95022. */
  95023. readonly unlocked: boolean;
  95024. /**
  95025. * Event raised when audio has been unlocked on the browser.
  95026. */
  95027. onAudioUnlockedObservable: Observable<AudioEngine>;
  95028. /**
  95029. * Event raised when audio has been locked on the browser.
  95030. */
  95031. onAudioLockedObservable: Observable<AudioEngine>;
  95032. /**
  95033. * Flags the audio engine in Locked state.
  95034. * This happens due to new browser policies preventing audio to autoplay.
  95035. */
  95036. lock(): void;
  95037. /**
  95038. * Unlocks the audio engine once a user action has been done on the dom.
  95039. * This is helpful to resume play once browser policies have been satisfied.
  95040. */
  95041. unlock(): void;
  95042. }
  95043. /**
  95044. * This represents the default audio engine used in babylon.
  95045. * It is responsible to play, synchronize and analyse sounds throughout the application.
  95046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95047. */
  95048. export class AudioEngine implements IAudioEngine {
  95049. private _audioContext;
  95050. private _audioContextInitialized;
  95051. private _muteButton;
  95052. private _hostElement;
  95053. /**
  95054. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95055. */
  95056. canUseWebAudio: boolean;
  95057. /**
  95058. * The master gain node defines the global audio volume of your audio engine.
  95059. */
  95060. masterGain: GainNode;
  95061. /**
  95062. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95063. * @ignoreNaming
  95064. */
  95065. WarnedWebAudioUnsupported: boolean;
  95066. /**
  95067. * Gets whether or not mp3 are supported by your browser.
  95068. */
  95069. isMP3supported: boolean;
  95070. /**
  95071. * Gets whether or not ogg are supported by your browser.
  95072. */
  95073. isOGGsupported: boolean;
  95074. /**
  95075. * Gets whether audio has been unlocked on the device.
  95076. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  95077. * a user interaction has happened.
  95078. */
  95079. unlocked: boolean;
  95080. /**
  95081. * Defines if the audio engine relies on a custom unlocked button.
  95082. * In this case, the embedded button will not be displayed.
  95083. */
  95084. useCustomUnlockedButton: boolean;
  95085. /**
  95086. * Event raised when audio has been unlocked on the browser.
  95087. */
  95088. onAudioUnlockedObservable: Observable<AudioEngine>;
  95089. /**
  95090. * Event raised when audio has been locked on the browser.
  95091. */
  95092. onAudioLockedObservable: Observable<AudioEngine>;
  95093. /**
  95094. * Gets the current AudioContext if available.
  95095. */
  95096. readonly audioContext: Nullable<AudioContext>;
  95097. private _connectedAnalyser;
  95098. /**
  95099. * Instantiates a new audio engine.
  95100. *
  95101. * There should be only one per page as some browsers restrict the number
  95102. * of audio contexts you can create.
  95103. * @param hostElement defines the host element where to display the mute icon if necessary
  95104. */
  95105. constructor(hostElement?: Nullable<HTMLElement>);
  95106. /**
  95107. * Flags the audio engine in Locked state.
  95108. * This happens due to new browser policies preventing audio to autoplay.
  95109. */
  95110. lock(): void;
  95111. /**
  95112. * Unlocks the audio engine once a user action has been done on the dom.
  95113. * This is helpful to resume play once browser policies have been satisfied.
  95114. */
  95115. unlock(): void;
  95116. private _resumeAudioContext;
  95117. private _initializeAudioContext;
  95118. private _tryToRun;
  95119. private _triggerRunningState;
  95120. private _triggerSuspendedState;
  95121. private _displayMuteButton;
  95122. private _moveButtonToTopLeft;
  95123. private _onResize;
  95124. private _hideMuteButton;
  95125. /**
  95126. * Destroy and release the resources associated with the audio ccontext.
  95127. */
  95128. dispose(): void;
  95129. /**
  95130. * Gets the global volume sets on the master gain.
  95131. * @returns the global volume if set or -1 otherwise
  95132. */
  95133. getGlobalVolume(): number;
  95134. /**
  95135. * Sets the global volume of your experience (sets on the master gain).
  95136. * @param newVolume Defines the new global volume of the application
  95137. */
  95138. setGlobalVolume(newVolume: number): void;
  95139. /**
  95140. * Connect the audio engine to an audio analyser allowing some amazing
  95141. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  95142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  95143. * @param analyser The analyser to connect to the engine
  95144. */
  95145. connectToAnalyser(analyser: Analyser): void;
  95146. }
  95147. }
  95148. declare module BABYLON {
  95149. /**
  95150. * Interface used to present a loading screen while loading a scene
  95151. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95152. */
  95153. export interface ILoadingScreen {
  95154. /**
  95155. * Function called to display the loading screen
  95156. */
  95157. displayLoadingUI: () => void;
  95158. /**
  95159. * Function called to hide the loading screen
  95160. */
  95161. hideLoadingUI: () => void;
  95162. /**
  95163. * Gets or sets the color to use for the background
  95164. */
  95165. loadingUIBackgroundColor: string;
  95166. /**
  95167. * Gets or sets the text to display while loading
  95168. */
  95169. loadingUIText: string;
  95170. }
  95171. /**
  95172. * Class used for the default loading screen
  95173. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95174. */
  95175. export class DefaultLoadingScreen implements ILoadingScreen {
  95176. private _renderingCanvas;
  95177. private _loadingText;
  95178. private _loadingDivBackgroundColor;
  95179. private _loadingDiv;
  95180. private _loadingTextDiv;
  95181. /** Gets or sets the logo url to use for the default loading screen */
  95182. static DefaultLogoUrl: string;
  95183. /** Gets or sets the spinner url to use for the default loading screen */
  95184. static DefaultSpinnerUrl: string;
  95185. /**
  95186. * Creates a new default loading screen
  95187. * @param _renderingCanvas defines the canvas used to render the scene
  95188. * @param _loadingText defines the default text to display
  95189. * @param _loadingDivBackgroundColor defines the default background color
  95190. */
  95191. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  95192. /**
  95193. * Function called to display the loading screen
  95194. */
  95195. displayLoadingUI(): void;
  95196. /**
  95197. * Function called to hide the loading screen
  95198. */
  95199. hideLoadingUI(): void;
  95200. /**
  95201. * Gets or sets the text to display while loading
  95202. */
  95203. loadingUIText: string;
  95204. /**
  95205. * Gets or sets the color to use for the background
  95206. */
  95207. loadingUIBackgroundColor: string;
  95208. private _resizeLoadingUI;
  95209. }
  95210. }
  95211. declare module BABYLON {
  95212. /** @hidden */
  95213. export class WebGLPipelineContext implements IPipelineContext {
  95214. engine: Engine;
  95215. program: Nullable<WebGLProgram>;
  95216. context?: WebGLRenderingContext;
  95217. vertexShader?: WebGLShader;
  95218. fragmentShader?: WebGLShader;
  95219. isParallelCompiled: boolean;
  95220. onCompiled?: () => void;
  95221. transformFeedback?: WebGLTransformFeedback | null;
  95222. readonly isAsync: boolean;
  95223. readonly isReady: boolean;
  95224. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  95225. }
  95226. }
  95227. declare module BABYLON {
  95228. /** @hidden */
  95229. export class WebGLDataBuffer extends DataBuffer {
  95230. private _buffer;
  95231. constructor(resource: WebGLBuffer);
  95232. readonly underlyingResource: any;
  95233. }
  95234. }
  95235. declare module BABYLON {
  95236. /** @hidden */
  95237. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95238. attributeProcessor(attribute: string): string;
  95239. varyingProcessor(varying: string, isFragment: boolean): string;
  95240. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95241. }
  95242. }
  95243. declare module BABYLON {
  95244. /**
  95245. * This class is used to track a performance counter which is number based.
  95246. * The user has access to many properties which give statistics of different nature.
  95247. *
  95248. * The implementer can track two kinds of Performance Counter: time and count.
  95249. * 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.
  95250. * 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.
  95251. */
  95252. export class PerfCounter {
  95253. /**
  95254. * Gets or sets a global boolean to turn on and off all the counters
  95255. */
  95256. static Enabled: boolean;
  95257. /**
  95258. * Returns the smallest value ever
  95259. */
  95260. readonly min: number;
  95261. /**
  95262. * Returns the biggest value ever
  95263. */
  95264. readonly max: number;
  95265. /**
  95266. * Returns the average value since the performance counter is running
  95267. */
  95268. readonly average: number;
  95269. /**
  95270. * Returns the average value of the last second the counter was monitored
  95271. */
  95272. readonly lastSecAverage: number;
  95273. /**
  95274. * Returns the current value
  95275. */
  95276. readonly current: number;
  95277. /**
  95278. * Gets the accumulated total
  95279. */
  95280. readonly total: number;
  95281. /**
  95282. * Gets the total value count
  95283. */
  95284. readonly count: number;
  95285. /**
  95286. * Creates a new counter
  95287. */
  95288. constructor();
  95289. /**
  95290. * Call this method to start monitoring a new frame.
  95291. * 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.
  95292. */
  95293. fetchNewFrame(): void;
  95294. /**
  95295. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95296. * @param newCount the count value to add to the monitored count
  95297. * @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.
  95298. */
  95299. addCount(newCount: number, fetchResult: boolean): void;
  95300. /**
  95301. * Start monitoring this performance counter
  95302. */
  95303. beginMonitoring(): void;
  95304. /**
  95305. * Compute the time lapsed since the previous beginMonitoring() call.
  95306. * @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
  95307. */
  95308. endMonitoring(newFrame?: boolean): void;
  95309. private _fetchResult;
  95310. private _startMonitoringTime;
  95311. private _min;
  95312. private _max;
  95313. private _average;
  95314. private _current;
  95315. private _totalValueCount;
  95316. private _totalAccumulated;
  95317. private _lastSecAverage;
  95318. private _lastSecAccumulated;
  95319. private _lastSecTime;
  95320. private _lastSecValueCount;
  95321. }
  95322. }
  95323. declare module BABYLON {
  95324. /**
  95325. * Interface for any object that can request an animation frame
  95326. */
  95327. export interface ICustomAnimationFrameRequester {
  95328. /**
  95329. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  95330. */
  95331. renderFunction?: Function;
  95332. /**
  95333. * Called to request the next frame to render to
  95334. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  95335. */
  95336. requestAnimationFrame: Function;
  95337. /**
  95338. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  95339. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  95340. */
  95341. requestID?: number;
  95342. }
  95343. }
  95344. declare module BABYLON {
  95345. /**
  95346. * Settings for finer control over video usage
  95347. */
  95348. export interface VideoTextureSettings {
  95349. /**
  95350. * Applies `autoplay` to video, if specified
  95351. */
  95352. autoPlay?: boolean;
  95353. /**
  95354. * Applies `loop` to video, if specified
  95355. */
  95356. loop?: boolean;
  95357. /**
  95358. * Automatically updates internal texture from video at every frame in the render loop
  95359. */
  95360. autoUpdateTexture: boolean;
  95361. /**
  95362. * Image src displayed during the video loading or until the user interacts with the video.
  95363. */
  95364. poster?: string;
  95365. }
  95366. /**
  95367. * If you want to display a video in your scene, this is the special texture for that.
  95368. * This special texture works similar to other textures, with the exception of a few parameters.
  95369. * @see https://doc.babylonjs.com/how_to/video_texture
  95370. */
  95371. export class VideoTexture extends Texture {
  95372. /**
  95373. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95374. */
  95375. readonly autoUpdateTexture: boolean;
  95376. /**
  95377. * The video instance used by the texture internally
  95378. */
  95379. readonly video: HTMLVideoElement;
  95380. private _onUserActionRequestedObservable;
  95381. /**
  95382. * Event triggerd when a dom action is required by the user to play the video.
  95383. * This happens due to recent changes in browser policies preventing video to auto start.
  95384. */
  95385. readonly onUserActionRequestedObservable: Observable<Texture>;
  95386. private _generateMipMaps;
  95387. private _engine;
  95388. private _stillImageCaptured;
  95389. private _displayingPosterTexture;
  95390. private _settings;
  95391. private _createInternalTextureOnEvent;
  95392. private _frameId;
  95393. /**
  95394. * Creates a video texture.
  95395. * If you want to display a video in your scene, this is the special texture for that.
  95396. * This special texture works similar to other textures, with the exception of a few parameters.
  95397. * @see https://doc.babylonjs.com/how_to/video_texture
  95398. * @param name optional name, will detect from video source, if not defined
  95399. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95400. * @param scene is obviously the current scene.
  95401. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95402. * @param invertY is false by default but can be used to invert video on Y axis
  95403. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95404. * @param settings allows finer control over video usage
  95405. */
  95406. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95407. private _getName;
  95408. private _getVideo;
  95409. private _createInternalTexture;
  95410. private reset;
  95411. /**
  95412. * @hidden Internal method to initiate `update`.
  95413. */
  95414. _rebuild(): void;
  95415. /**
  95416. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95417. */
  95418. update(): void;
  95419. /**
  95420. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95421. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95422. */
  95423. updateTexture(isVisible: boolean): void;
  95424. protected _updateInternalTexture: () => void;
  95425. /**
  95426. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95427. * @param url New url.
  95428. */
  95429. updateURL(url: string): void;
  95430. /**
  95431. * Dispose the texture and release its associated resources.
  95432. */
  95433. dispose(): void;
  95434. /**
  95435. * Creates a video texture straight from a stream.
  95436. * @param scene Define the scene the texture should be created in
  95437. * @param stream Define the stream the texture should be created from
  95438. * @returns The created video texture as a promise
  95439. */
  95440. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95441. /**
  95442. * Creates a video texture straight from your WebCam video feed.
  95443. * @param scene Define the scene the texture should be created in
  95444. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95445. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95446. * @returns The created video texture as a promise
  95447. */
  95448. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95449. minWidth: number;
  95450. maxWidth: number;
  95451. minHeight: number;
  95452. maxHeight: number;
  95453. deviceId: string;
  95454. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95455. /**
  95456. * Creates a video texture straight from your WebCam video feed.
  95457. * @param scene Define the scene the texture should be created in
  95458. * @param onReady Define a callback to triggered once the texture will be ready
  95459. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95460. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95461. */
  95462. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95463. minWidth: number;
  95464. maxWidth: number;
  95465. minHeight: number;
  95466. maxHeight: number;
  95467. deviceId: string;
  95468. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95469. }
  95470. }
  95471. declare module BABYLON {
  95472. /**
  95473. * Defines the interface used by objects containing a viewport (like a camera)
  95474. */
  95475. interface IViewportOwnerLike {
  95476. /**
  95477. * Gets or sets the viewport
  95478. */
  95479. viewport: IViewportLike;
  95480. }
  95481. /**
  95482. * Interface for attribute information associated with buffer instanciation
  95483. */
  95484. export class InstancingAttributeInfo {
  95485. /**
  95486. * Index/offset of the attribute in the vertex shader
  95487. */
  95488. index: number;
  95489. /**
  95490. * size of the attribute, 1, 2, 3 or 4
  95491. */
  95492. attributeSize: number;
  95493. /**
  95494. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95495. * default is FLOAT
  95496. */
  95497. attribyteType: number;
  95498. /**
  95499. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95500. */
  95501. normalized: boolean;
  95502. /**
  95503. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95504. */
  95505. offset: number;
  95506. /**
  95507. * Name of the GLSL attribute, for debugging purpose only
  95508. */
  95509. attributeName: string;
  95510. }
  95511. /**
  95512. * Define options used to create a depth texture
  95513. */
  95514. export class DepthTextureCreationOptions {
  95515. /** Specifies whether or not a stencil should be allocated in the texture */
  95516. generateStencil?: boolean;
  95517. /** Specifies whether or not bilinear filtering is enable on the texture */
  95518. bilinearFiltering?: boolean;
  95519. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95520. comparisonFunction?: number;
  95521. /** Specifies if the created texture is a cube texture */
  95522. isCube?: boolean;
  95523. }
  95524. /**
  95525. * Class used to describe the capabilities of the engine relatively to the current browser
  95526. */
  95527. export class EngineCapabilities {
  95528. /** Maximum textures units per fragment shader */
  95529. maxTexturesImageUnits: number;
  95530. /** Maximum texture units per vertex shader */
  95531. maxVertexTextureImageUnits: number;
  95532. /** Maximum textures units in the entire pipeline */
  95533. maxCombinedTexturesImageUnits: number;
  95534. /** Maximum texture size */
  95535. maxTextureSize: number;
  95536. /** Maximum cube texture size */
  95537. maxCubemapTextureSize: number;
  95538. /** Maximum render texture size */
  95539. maxRenderTextureSize: number;
  95540. /** Maximum number of vertex attributes */
  95541. maxVertexAttribs: number;
  95542. /** Maximum number of varyings */
  95543. maxVaryingVectors: number;
  95544. /** Maximum number of uniforms per vertex shader */
  95545. maxVertexUniformVectors: number;
  95546. /** Maximum number of uniforms per fragment shader */
  95547. maxFragmentUniformVectors: number;
  95548. /** Defines if standard derivates (dx/dy) are supported */
  95549. standardDerivatives: boolean;
  95550. /** Defines if s3tc texture compression is supported */
  95551. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95552. /** Defines if pvrtc texture compression is supported */
  95553. pvrtc: any;
  95554. /** Defines if etc1 texture compression is supported */
  95555. etc1: any;
  95556. /** Defines if etc2 texture compression is supported */
  95557. etc2: any;
  95558. /** Defines if astc texture compression is supported */
  95559. astc: any;
  95560. /** Defines if float textures are supported */
  95561. textureFloat: boolean;
  95562. /** Defines if vertex array objects are supported */
  95563. vertexArrayObject: boolean;
  95564. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95565. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95566. /** Gets the maximum level of anisotropy supported */
  95567. maxAnisotropy: number;
  95568. /** Defines if instancing is supported */
  95569. instancedArrays: boolean;
  95570. /** Defines if 32 bits indices are supported */
  95571. uintIndices: boolean;
  95572. /** Defines if high precision shaders are supported */
  95573. highPrecisionShaderSupported: boolean;
  95574. /** Defines if depth reading in the fragment shader is supported */
  95575. fragmentDepthSupported: boolean;
  95576. /** Defines if float texture linear filtering is supported*/
  95577. textureFloatLinearFiltering: boolean;
  95578. /** Defines if rendering to float textures is supported */
  95579. textureFloatRender: boolean;
  95580. /** Defines if half float textures are supported*/
  95581. textureHalfFloat: boolean;
  95582. /** Defines if half float texture linear filtering is supported*/
  95583. textureHalfFloatLinearFiltering: boolean;
  95584. /** Defines if rendering to half float textures is supported */
  95585. textureHalfFloatRender: boolean;
  95586. /** Defines if textureLOD shader command is supported */
  95587. textureLOD: boolean;
  95588. /** Defines if draw buffers extension is supported */
  95589. drawBuffersExtension: boolean;
  95590. /** Defines if depth textures are supported */
  95591. depthTextureExtension: boolean;
  95592. /** Defines if float color buffer are supported */
  95593. colorBufferFloat: boolean;
  95594. /** Gets disjoint timer query extension (null if not supported) */
  95595. timerQuery: EXT_disjoint_timer_query;
  95596. /** Defines if timestamp can be used with timer query */
  95597. canUseTimestampForTimerQuery: boolean;
  95598. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95599. multiview: any;
  95600. /** Function used to let the system compiles shaders in background */
  95601. parallelShaderCompile: {
  95602. COMPLETION_STATUS_KHR: number;
  95603. };
  95604. /** Max number of texture samples for MSAA */
  95605. maxMSAASamples: number;
  95606. }
  95607. /** Interface defining initialization parameters for Engine class */
  95608. export interface EngineOptions extends WebGLContextAttributes {
  95609. /**
  95610. * Defines if the engine should no exceed a specified device ratio
  95611. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95612. */
  95613. limitDeviceRatio?: number;
  95614. /**
  95615. * Defines if webvr should be enabled automatically
  95616. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95617. */
  95618. autoEnableWebVR?: boolean;
  95619. /**
  95620. * Defines if webgl2 should be turned off even if supported
  95621. * @see http://doc.babylonjs.com/features/webgl2
  95622. */
  95623. disableWebGL2Support?: boolean;
  95624. /**
  95625. * Defines if webaudio should be initialized as well
  95626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95627. */
  95628. audioEngine?: boolean;
  95629. /**
  95630. * Defines if animations should run using a deterministic lock step
  95631. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95632. */
  95633. deterministicLockstep?: boolean;
  95634. /** Defines the maximum steps to use with deterministic lock step mode */
  95635. lockstepMaxSteps?: number;
  95636. /**
  95637. * Defines that engine should ignore context lost events
  95638. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95639. */
  95640. doNotHandleContextLost?: boolean;
  95641. /**
  95642. * Defines that engine should ignore modifying touch action attribute and style
  95643. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95644. */
  95645. doNotHandleTouchAction?: boolean;
  95646. /**
  95647. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95648. */
  95649. useHighPrecisionFloats?: boolean;
  95650. }
  95651. /**
  95652. * Defines the interface used by display changed events
  95653. */
  95654. export interface IDisplayChangedEventArgs {
  95655. /** Gets the vrDisplay object (if any) */
  95656. vrDisplay: Nullable<any>;
  95657. /** Gets a boolean indicating if webVR is supported */
  95658. vrSupported: boolean;
  95659. }
  95660. /**
  95661. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95662. */
  95663. export class Engine {
  95664. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95665. static ExceptionList: ({
  95666. key: string;
  95667. capture: string;
  95668. captureConstraint: number;
  95669. targets: string[];
  95670. } | {
  95671. key: string;
  95672. capture: null;
  95673. captureConstraint: null;
  95674. targets: string[];
  95675. })[];
  95676. /** Gets the list of created engines */
  95677. static readonly Instances: Engine[];
  95678. /**
  95679. * Gets the latest created engine
  95680. */
  95681. static readonly LastCreatedEngine: Nullable<Engine>;
  95682. /**
  95683. * Gets the latest created scene
  95684. */
  95685. static readonly LastCreatedScene: Nullable<Scene>;
  95686. /**
  95687. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95688. * @param flag defines which part of the materials must be marked as dirty
  95689. * @param predicate defines a predicate used to filter which materials should be affected
  95690. */
  95691. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95692. /** @hidden */
  95693. static _TextureLoaders: IInternalTextureLoader[];
  95694. /** Defines that alpha blending is disabled */
  95695. static readonly ALPHA_DISABLE: number;
  95696. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95697. static readonly ALPHA_ADD: number;
  95698. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95699. static readonly ALPHA_COMBINE: number;
  95700. /** Defines that alpha blending to DEST - SRC * DEST */
  95701. static readonly ALPHA_SUBTRACT: number;
  95702. /** Defines that alpha blending to SRC * DEST */
  95703. static readonly ALPHA_MULTIPLY: number;
  95704. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95705. static readonly ALPHA_MAXIMIZED: number;
  95706. /** Defines that alpha blending to SRC + DEST */
  95707. static readonly ALPHA_ONEONE: number;
  95708. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95709. static readonly ALPHA_PREMULTIPLIED: number;
  95710. /**
  95711. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95712. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95713. */
  95714. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95715. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95716. static readonly ALPHA_INTERPOLATE: number;
  95717. /**
  95718. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95719. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95720. */
  95721. static readonly ALPHA_SCREENMODE: number;
  95722. /** Defines that the ressource is not delayed*/
  95723. static readonly DELAYLOADSTATE_NONE: number;
  95724. /** Defines that the ressource was successfully delay loaded */
  95725. static readonly DELAYLOADSTATE_LOADED: number;
  95726. /** Defines that the ressource is currently delay loading */
  95727. static readonly DELAYLOADSTATE_LOADING: number;
  95728. /** Defines that the ressource is delayed and has not started loading */
  95729. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95730. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95731. static readonly NEVER: number;
  95732. /** 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 */
  95733. static readonly ALWAYS: number;
  95734. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95735. static readonly LESS: number;
  95736. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95737. static readonly EQUAL: number;
  95738. /** 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 */
  95739. static readonly LEQUAL: number;
  95740. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95741. static readonly GREATER: number;
  95742. /** 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 */
  95743. static readonly GEQUAL: number;
  95744. /** 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 */
  95745. static readonly NOTEQUAL: number;
  95746. /** Passed to stencilOperation to specify that stencil value must be kept */
  95747. static readonly KEEP: number;
  95748. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95749. static readonly REPLACE: number;
  95750. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95751. static readonly INCR: number;
  95752. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95753. static readonly DECR: number;
  95754. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95755. static readonly INVERT: number;
  95756. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95757. static readonly INCR_WRAP: number;
  95758. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95759. static readonly DECR_WRAP: number;
  95760. /** Texture is not repeating outside of 0..1 UVs */
  95761. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95762. /** Texture is repeating outside of 0..1 UVs */
  95763. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95764. /** Texture is repeating and mirrored */
  95765. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95766. /** ALPHA */
  95767. static readonly TEXTUREFORMAT_ALPHA: number;
  95768. /** LUMINANCE */
  95769. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95770. /** LUMINANCE_ALPHA */
  95771. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95772. /** RGB */
  95773. static readonly TEXTUREFORMAT_RGB: number;
  95774. /** RGBA */
  95775. static readonly TEXTUREFORMAT_RGBA: number;
  95776. /** RED */
  95777. static readonly TEXTUREFORMAT_RED: number;
  95778. /** RED (2nd reference) */
  95779. static readonly TEXTUREFORMAT_R: number;
  95780. /** RG */
  95781. static readonly TEXTUREFORMAT_RG: number;
  95782. /** RED_INTEGER */
  95783. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95784. /** RED_INTEGER (2nd reference) */
  95785. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95786. /** RG_INTEGER */
  95787. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95788. /** RGB_INTEGER */
  95789. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95790. /** RGBA_INTEGER */
  95791. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95792. /** UNSIGNED_BYTE */
  95793. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95794. /** UNSIGNED_BYTE (2nd reference) */
  95795. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95796. /** FLOAT */
  95797. static readonly TEXTURETYPE_FLOAT: number;
  95798. /** HALF_FLOAT */
  95799. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95800. /** BYTE */
  95801. static readonly TEXTURETYPE_BYTE: number;
  95802. /** SHORT */
  95803. static readonly TEXTURETYPE_SHORT: number;
  95804. /** UNSIGNED_SHORT */
  95805. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95806. /** INT */
  95807. static readonly TEXTURETYPE_INT: number;
  95808. /** UNSIGNED_INT */
  95809. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95810. /** UNSIGNED_SHORT_4_4_4_4 */
  95811. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95812. /** UNSIGNED_SHORT_5_5_5_1 */
  95813. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95814. /** UNSIGNED_SHORT_5_6_5 */
  95815. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95816. /** UNSIGNED_INT_2_10_10_10_REV */
  95817. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95818. /** UNSIGNED_INT_24_8 */
  95819. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95820. /** UNSIGNED_INT_10F_11F_11F_REV */
  95821. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95822. /** UNSIGNED_INT_5_9_9_9_REV */
  95823. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95824. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95825. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95826. /** nearest is mag = nearest and min = nearest and mip = linear */
  95827. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95828. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95829. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95830. /** Trilinear is mag = linear and min = linear and mip = linear */
  95831. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95832. /** nearest is mag = nearest and min = nearest and mip = linear */
  95833. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95834. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95835. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95836. /** Trilinear is mag = linear and min = linear and mip = linear */
  95837. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95838. /** mag = nearest and min = nearest and mip = nearest */
  95839. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95840. /** mag = nearest and min = linear and mip = nearest */
  95841. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95842. /** mag = nearest and min = linear and mip = linear */
  95843. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95844. /** mag = nearest and min = linear and mip = none */
  95845. static readonly TEXTURE_NEAREST_LINEAR: number;
  95846. /** mag = nearest and min = nearest and mip = none */
  95847. static readonly TEXTURE_NEAREST_NEAREST: number;
  95848. /** mag = linear and min = nearest and mip = nearest */
  95849. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95850. /** mag = linear and min = nearest and mip = linear */
  95851. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95852. /** mag = linear and min = linear and mip = none */
  95853. static readonly TEXTURE_LINEAR_LINEAR: number;
  95854. /** mag = linear and min = nearest and mip = none */
  95855. static readonly TEXTURE_LINEAR_NEAREST: number;
  95856. /** Explicit coordinates mode */
  95857. static readonly TEXTURE_EXPLICIT_MODE: number;
  95858. /** Spherical coordinates mode */
  95859. static readonly TEXTURE_SPHERICAL_MODE: number;
  95860. /** Planar coordinates mode */
  95861. static readonly TEXTURE_PLANAR_MODE: number;
  95862. /** Cubic coordinates mode */
  95863. static readonly TEXTURE_CUBIC_MODE: number;
  95864. /** Projection coordinates mode */
  95865. static readonly TEXTURE_PROJECTION_MODE: number;
  95866. /** Skybox coordinates mode */
  95867. static readonly TEXTURE_SKYBOX_MODE: number;
  95868. /** Inverse Cubic coordinates mode */
  95869. static readonly TEXTURE_INVCUBIC_MODE: number;
  95870. /** Equirectangular coordinates mode */
  95871. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  95872. /** Equirectangular Fixed coordinates mode */
  95873. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  95874. /** Equirectangular Fixed Mirrored coordinates mode */
  95875. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95876. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  95877. static readonly SCALEMODE_FLOOR: number;
  95878. /** Defines that texture rescaling will look for the nearest power of 2 size */
  95879. static readonly SCALEMODE_NEAREST: number;
  95880. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  95881. static readonly SCALEMODE_CEILING: number;
  95882. /**
  95883. * Returns the current npm package of the sdk
  95884. */
  95885. static readonly NpmPackage: string;
  95886. /**
  95887. * Returns the current version of the framework
  95888. */
  95889. static readonly Version: string;
  95890. /**
  95891. * Returns a string describing the current engine
  95892. */
  95893. readonly description: string;
  95894. /**
  95895. * Gets or sets the epsilon value used by collision engine
  95896. */
  95897. static CollisionsEpsilon: number;
  95898. /**
  95899. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95900. */
  95901. static ShadersRepository: string;
  95902. /**
  95903. * Method called to create the default loading screen.
  95904. * This can be overriden in your own app.
  95905. * @param canvas The rendering canvas element
  95906. * @returns The loading screen
  95907. */
  95908. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  95909. /**
  95910. * Method called to create the default rescale post process on each engine.
  95911. */
  95912. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  95913. /** @hidden */
  95914. _shaderProcessor: IShaderProcessor;
  95915. /**
  95916. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95917. */
  95918. forcePOTTextures: boolean;
  95919. /**
  95920. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95921. */
  95922. isFullscreen: boolean;
  95923. /**
  95924. * Gets a boolean indicating if the pointer is currently locked
  95925. */
  95926. isPointerLock: boolean;
  95927. /**
  95928. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95929. */
  95930. cullBackFaces: boolean;
  95931. /**
  95932. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95933. */
  95934. renderEvenInBackground: boolean;
  95935. /**
  95936. * Gets or sets a boolean indicating that cache can be kept between frames
  95937. */
  95938. preventCacheWipeBetweenFrames: boolean;
  95939. /**
  95940. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  95941. **/
  95942. enableOfflineSupport: boolean;
  95943. /**
  95944. * 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)
  95945. **/
  95946. disableManifestCheck: boolean;
  95947. /**
  95948. * Gets the list of created scenes
  95949. */
  95950. scenes: Scene[];
  95951. /**
  95952. * Event raised when a new scene is created
  95953. */
  95954. onNewSceneAddedObservable: Observable<Scene>;
  95955. /**
  95956. * Gets the list of created postprocesses
  95957. */
  95958. postProcesses: PostProcess[];
  95959. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95960. validateShaderPrograms: boolean;
  95961. /**
  95962. * Observable event triggered each time the rendering canvas is resized
  95963. */
  95964. onResizeObservable: Observable<Engine>;
  95965. /**
  95966. * Observable event triggered each time the canvas loses focus
  95967. */
  95968. onCanvasBlurObservable: Observable<Engine>;
  95969. /**
  95970. * Observable event triggered each time the canvas gains focus
  95971. */
  95972. onCanvasFocusObservable: Observable<Engine>;
  95973. /**
  95974. * Observable event triggered each time the canvas receives pointerout event
  95975. */
  95976. onCanvasPointerOutObservable: Observable<PointerEvent>;
  95977. /**
  95978. * Observable event triggered before each texture is initialized
  95979. */
  95980. onBeforeTextureInitObservable: Observable<Texture>;
  95981. /**
  95982. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95983. */
  95984. disableUniformBuffers: boolean;
  95985. /** @hidden */
  95986. _uniformBuffers: UniformBuffer[];
  95987. /**
  95988. * Gets a boolean indicating that the engine supports uniform buffers
  95989. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95990. */
  95991. readonly supportsUniformBuffers: boolean;
  95992. /**
  95993. * Observable raised when the engine begins a new frame
  95994. */
  95995. onBeginFrameObservable: Observable<Engine>;
  95996. /**
  95997. * If set, will be used to request the next animation frame for the render loop
  95998. */
  95999. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  96000. /**
  96001. * Observable raised when the engine ends the current frame
  96002. */
  96003. onEndFrameObservable: Observable<Engine>;
  96004. /**
  96005. * Observable raised when the engine is about to compile a shader
  96006. */
  96007. onBeforeShaderCompilationObservable: Observable<Engine>;
  96008. /**
  96009. * Observable raised when the engine has jsut compiled a shader
  96010. */
  96011. onAfterShaderCompilationObservable: Observable<Engine>;
  96012. /** @hidden */
  96013. _gl: WebGLRenderingContext;
  96014. private _renderingCanvas;
  96015. private _windowIsBackground;
  96016. protected _webGLVersion: number;
  96017. protected _highPrecisionShadersAllowed: boolean;
  96018. /** @hidden */
  96019. readonly _shouldUseHighPrecisionShader: boolean;
  96020. /**
  96021. * Gets a boolean indicating that only power of 2 textures are supported
  96022. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96023. */
  96024. readonly needPOTTextures: boolean;
  96025. /** @hidden */
  96026. _badOS: boolean;
  96027. /** @hidden */
  96028. _badDesktopOS: boolean;
  96029. /**
  96030. * Gets the audio engine
  96031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96032. * @ignorenaming
  96033. */
  96034. static audioEngine: IAudioEngine;
  96035. /**
  96036. * Default AudioEngine factory responsible of creating the Audio Engine.
  96037. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  96038. */
  96039. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  96040. /**
  96041. * Default offline support factory responsible of creating a tool used to store data locally.
  96042. * By default, this will create a Database object if the workload has been embedded.
  96043. */
  96044. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  96045. private _onFocus;
  96046. private _onBlur;
  96047. private _onCanvasPointerOut;
  96048. private _onCanvasBlur;
  96049. private _onCanvasFocus;
  96050. private _onFullscreenChange;
  96051. private _onPointerLockChange;
  96052. private _hardwareScalingLevel;
  96053. /** @hidden */
  96054. _caps: EngineCapabilities;
  96055. private _pointerLockRequested;
  96056. private _isStencilEnable;
  96057. protected _colorWrite: boolean;
  96058. private _loadingScreen;
  96059. /** @hidden */
  96060. _drawCalls: PerfCounter;
  96061. private _glVersion;
  96062. private _glRenderer;
  96063. private _glVendor;
  96064. private _videoTextureSupported;
  96065. private _renderingQueueLaunched;
  96066. private _activeRenderLoops;
  96067. private _deterministicLockstep;
  96068. private _lockstepMaxSteps;
  96069. /**
  96070. * Observable signaled when a context lost event is raised
  96071. */
  96072. onContextLostObservable: Observable<Engine>;
  96073. /**
  96074. * Observable signaled when a context restored event is raised
  96075. */
  96076. onContextRestoredObservable: Observable<Engine>;
  96077. private _onContextLost;
  96078. private _onContextRestored;
  96079. private _contextWasLost;
  96080. /** @hidden */
  96081. _doNotHandleContextLost: boolean;
  96082. /**
  96083. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96085. */
  96086. doNotHandleContextLost: boolean;
  96087. private _performanceMonitor;
  96088. private _fps;
  96089. private _deltaTime;
  96090. /**
  96091. * Turn this value on if you want to pause FPS computation when in background
  96092. */
  96093. disablePerformanceMonitorInBackground: boolean;
  96094. /**
  96095. * Gets the performance monitor attached to this engine
  96096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  96097. */
  96098. readonly performanceMonitor: PerformanceMonitor;
  96099. /**
  96100. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96101. */
  96102. disableVertexArrayObjects: boolean;
  96103. /** @hidden */
  96104. protected _depthCullingState: _DepthCullingState;
  96105. /** @hidden */
  96106. protected _stencilState: _StencilState;
  96107. /** @hidden */
  96108. protected _alphaState: _AlphaState;
  96109. /** @hidden */
  96110. protected _alphaMode: number;
  96111. /** @hidden */
  96112. _internalTexturesCache: InternalTexture[];
  96113. /** @hidden */
  96114. protected _activeChannel: number;
  96115. private _currentTextureChannel;
  96116. /** @hidden */
  96117. protected _boundTexturesCache: {
  96118. [key: string]: Nullable<InternalTexture>;
  96119. };
  96120. /** @hidden */
  96121. protected _currentEffect: Nullable<Effect>;
  96122. /** @hidden */
  96123. protected _currentProgram: Nullable<WebGLProgram>;
  96124. private _compiledEffects;
  96125. private _vertexAttribArraysEnabled;
  96126. /** @hidden */
  96127. protected _cachedViewport: Nullable<IViewportLike>;
  96128. private _cachedVertexArrayObject;
  96129. /** @hidden */
  96130. protected _cachedVertexBuffers: any;
  96131. /** @hidden */
  96132. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96133. /** @hidden */
  96134. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96135. /** @hidden */
  96136. _currentRenderTarget: Nullable<InternalTexture>;
  96137. private _uintIndicesCurrentlySet;
  96138. private _currentBoundBuffer;
  96139. /** @hidden */
  96140. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96141. private _currentBufferPointers;
  96142. private _currentInstanceLocations;
  96143. private _currentInstanceBuffers;
  96144. private _textureUnits;
  96145. /** @hidden */
  96146. _workingCanvas: Nullable<HTMLCanvasElement>;
  96147. /** @hidden */
  96148. _workingContext: Nullable<CanvasRenderingContext2D>;
  96149. private _rescalePostProcess;
  96150. private _dummyFramebuffer;
  96151. private _externalData;
  96152. /** @hidden */
  96153. _bindedRenderFunction: any;
  96154. private _vaoRecordInProgress;
  96155. private _mustWipeVertexAttributes;
  96156. private _emptyTexture;
  96157. private _emptyCubeTexture;
  96158. private _emptyTexture3D;
  96159. /** @hidden */
  96160. _frameHandler: number;
  96161. private _nextFreeTextureSlots;
  96162. private _maxSimultaneousTextures;
  96163. private _activeRequests;
  96164. private _texturesSupported;
  96165. /** @hidden */
  96166. _textureFormatInUse: Nullable<string>;
  96167. /**
  96168. * Gets the list of texture formats supported
  96169. */
  96170. readonly texturesSupported: Array<string>;
  96171. /**
  96172. * Gets the list of texture formats in use
  96173. */
  96174. readonly textureFormatInUse: Nullable<string>;
  96175. /**
  96176. * Gets the current viewport
  96177. */
  96178. readonly currentViewport: Nullable<IViewportLike>;
  96179. /**
  96180. * Gets the default empty texture
  96181. */
  96182. readonly emptyTexture: InternalTexture;
  96183. /**
  96184. * Gets the default empty 3D texture
  96185. */
  96186. readonly emptyTexture3D: InternalTexture;
  96187. /**
  96188. * Gets the default empty cube texture
  96189. */
  96190. readonly emptyCubeTexture: InternalTexture;
  96191. /**
  96192. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96193. */
  96194. readonly premultipliedAlpha: boolean;
  96195. /**
  96196. * Creates a new engine
  96197. * @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
  96198. * @param antialias defines enable antialiasing (default: false)
  96199. * @param options defines further options to be sent to the getContext() function
  96200. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96201. */
  96202. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96203. /**
  96204. * Initializes a webVR display and starts listening to display change events
  96205. * The onVRDisplayChangedObservable will be notified upon these changes
  96206. * @returns The onVRDisplayChangedObservable
  96207. */
  96208. initWebVR(): Observable<IDisplayChangedEventArgs>;
  96209. /** @hidden */
  96210. _prepareVRComponent(): void;
  96211. /** @hidden */
  96212. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  96213. /** @hidden */
  96214. _submitVRFrame(): void;
  96215. /**
  96216. * Call this function to leave webVR mode
  96217. * Will do nothing if webVR is not supported or if there is no webVR device
  96218. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96219. */
  96220. disableVR(): void;
  96221. /**
  96222. * Gets a boolean indicating that the system is in VR mode and is presenting
  96223. * @returns true if VR mode is engaged
  96224. */
  96225. isVRPresenting(): boolean;
  96226. /** @hidden */
  96227. _requestVRFrame(): void;
  96228. private _disableTouchAction;
  96229. private _rebuildInternalTextures;
  96230. private _rebuildEffects;
  96231. /**
  96232. * Gets a boolean indicating if all created effects are ready
  96233. * @returns true if all effects are ready
  96234. */
  96235. areAllEffectsReady(): boolean;
  96236. private _rebuildBuffers;
  96237. private _initGLContext;
  96238. /**
  96239. * Gets version of the current webGL context
  96240. */
  96241. readonly webGLVersion: number;
  96242. /**
  96243. * Gets a string idenfifying the name of the class
  96244. * @returns "Engine" string
  96245. */
  96246. getClassName(): string;
  96247. /**
  96248. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96249. */
  96250. readonly isStencilEnable: boolean;
  96251. /** @hidden */
  96252. _prepareWorkingCanvas(): void;
  96253. /**
  96254. * Reset the texture cache to empty state
  96255. */
  96256. resetTextureCache(): void;
  96257. /**
  96258. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  96259. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96260. * @returns true if engine is in deterministic lock step mode
  96261. */
  96262. isDeterministicLockStep(): boolean;
  96263. /**
  96264. * Gets the max steps when engine is running in deterministic lock step
  96265. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96266. * @returns the max steps
  96267. */
  96268. getLockstepMaxSteps(): number;
  96269. /**
  96270. * Gets an object containing information about the current webGL context
  96271. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96272. */
  96273. getGlInfo(): {
  96274. vendor: string;
  96275. renderer: string;
  96276. version: string;
  96277. };
  96278. /**
  96279. * Gets current aspect ratio
  96280. * @param viewportOwner defines the camera to use to get the aspect ratio
  96281. * @param useScreen defines if screen size must be used (or the current render target if any)
  96282. * @returns a number defining the aspect ratio
  96283. */
  96284. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  96285. /**
  96286. * Gets current screen aspect ratio
  96287. * @returns a number defining the aspect ratio
  96288. */
  96289. getScreenAspectRatio(): number;
  96290. /**
  96291. * Gets the current render width
  96292. * @param useScreen defines if screen size must be used (or the current render target if any)
  96293. * @returns a number defining the current render width
  96294. */
  96295. getRenderWidth(useScreen?: boolean): number;
  96296. /**
  96297. * Gets the current render height
  96298. * @param useScreen defines if screen size must be used (or the current render target if any)
  96299. * @returns a number defining the current render height
  96300. */
  96301. getRenderHeight(useScreen?: boolean): number;
  96302. /**
  96303. * Gets the HTML canvas attached with the current webGL context
  96304. * @returns a HTML canvas
  96305. */
  96306. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96307. /**
  96308. * Gets host window
  96309. * @returns the host window object
  96310. */
  96311. getHostWindow(): Window;
  96312. /**
  96313. * Gets host document
  96314. * @returns the host document object
  96315. */
  96316. getHostDocument(): Document;
  96317. /**
  96318. * Gets the client rect of the HTML canvas attached with the current webGL context
  96319. * @returns a client rectanglee
  96320. */
  96321. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  96322. /**
  96323. * Defines the hardware scaling level.
  96324. * By default the hardware scaling level is computed from the window device ratio.
  96325. * 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.
  96326. * @param level defines the level to use
  96327. */
  96328. setHardwareScalingLevel(level: number): void;
  96329. /**
  96330. * Gets the current hardware scaling level.
  96331. * By default the hardware scaling level is computed from the window device ratio.
  96332. * 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.
  96333. * @returns a number indicating the current hardware scaling level
  96334. */
  96335. getHardwareScalingLevel(): number;
  96336. /**
  96337. * Gets the list of loaded textures
  96338. * @returns an array containing all loaded textures
  96339. */
  96340. getLoadedTexturesCache(): InternalTexture[];
  96341. /**
  96342. * Gets the object containing all engine capabilities
  96343. * @returns the EngineCapabilities object
  96344. */
  96345. getCaps(): EngineCapabilities;
  96346. /**
  96347. * Gets the current depth function
  96348. * @returns a number defining the depth function
  96349. */
  96350. getDepthFunction(): Nullable<number>;
  96351. /**
  96352. * Sets the current depth function
  96353. * @param depthFunc defines the function to use
  96354. */
  96355. setDepthFunction(depthFunc: number): void;
  96356. /**
  96357. * Sets the current depth function to GREATER
  96358. */
  96359. setDepthFunctionToGreater(): void;
  96360. /**
  96361. * Sets the current depth function to GEQUAL
  96362. */
  96363. setDepthFunctionToGreaterOrEqual(): void;
  96364. /**
  96365. * Sets the current depth function to LESS
  96366. */
  96367. setDepthFunctionToLess(): void;
  96368. private _cachedStencilBuffer;
  96369. private _cachedStencilFunction;
  96370. private _cachedStencilMask;
  96371. private _cachedStencilOperationPass;
  96372. private _cachedStencilOperationFail;
  96373. private _cachedStencilOperationDepthFail;
  96374. private _cachedStencilReference;
  96375. /**
  96376. * Caches the the state of the stencil buffer
  96377. */
  96378. cacheStencilState(): void;
  96379. /**
  96380. * Restores the state of the stencil buffer
  96381. */
  96382. restoreStencilState(): void;
  96383. /**
  96384. * Sets the current depth function to LEQUAL
  96385. */
  96386. setDepthFunctionToLessOrEqual(): void;
  96387. /**
  96388. * Gets a boolean indicating if stencil buffer is enabled
  96389. * @returns the current stencil buffer state
  96390. */
  96391. getStencilBuffer(): boolean;
  96392. /**
  96393. * Enable or disable the stencil buffer
  96394. * @param enable defines if the stencil buffer must be enabled or disabled
  96395. */
  96396. setStencilBuffer(enable: boolean): void;
  96397. /**
  96398. * Gets the current stencil mask
  96399. * @returns a number defining the new stencil mask to use
  96400. */
  96401. getStencilMask(): number;
  96402. /**
  96403. * Sets the current stencil mask
  96404. * @param mask defines the new stencil mask to use
  96405. */
  96406. setStencilMask(mask: number): void;
  96407. /**
  96408. * Gets the current stencil function
  96409. * @returns a number defining the stencil function to use
  96410. */
  96411. getStencilFunction(): number;
  96412. /**
  96413. * Gets the current stencil reference value
  96414. * @returns a number defining the stencil reference value to use
  96415. */
  96416. getStencilFunctionReference(): number;
  96417. /**
  96418. * Gets the current stencil mask
  96419. * @returns a number defining the stencil mask to use
  96420. */
  96421. getStencilFunctionMask(): number;
  96422. /**
  96423. * Sets the current stencil function
  96424. * @param stencilFunc defines the new stencil function to use
  96425. */
  96426. setStencilFunction(stencilFunc: number): void;
  96427. /**
  96428. * Sets the current stencil reference
  96429. * @param reference defines the new stencil reference to use
  96430. */
  96431. setStencilFunctionReference(reference: number): void;
  96432. /**
  96433. * Sets the current stencil mask
  96434. * @param mask defines the new stencil mask to use
  96435. */
  96436. setStencilFunctionMask(mask: number): void;
  96437. /**
  96438. * Gets the current stencil operation when stencil fails
  96439. * @returns a number defining stencil operation to use when stencil fails
  96440. */
  96441. getStencilOperationFail(): number;
  96442. /**
  96443. * Gets the current stencil operation when depth fails
  96444. * @returns a number defining stencil operation to use when depth fails
  96445. */
  96446. getStencilOperationDepthFail(): number;
  96447. /**
  96448. * Gets the current stencil operation when stencil passes
  96449. * @returns a number defining stencil operation to use when stencil passes
  96450. */
  96451. getStencilOperationPass(): number;
  96452. /**
  96453. * Sets the stencil operation to use when stencil fails
  96454. * @param operation defines the stencil operation to use when stencil fails
  96455. */
  96456. setStencilOperationFail(operation: number): void;
  96457. /**
  96458. * Sets the stencil operation to use when depth fails
  96459. * @param operation defines the stencil operation to use when depth fails
  96460. */
  96461. setStencilOperationDepthFail(operation: number): void;
  96462. /**
  96463. * Sets the stencil operation to use when stencil passes
  96464. * @param operation defines the stencil operation to use when stencil passes
  96465. */
  96466. setStencilOperationPass(operation: number): void;
  96467. /**
  96468. * Sets a boolean indicating if the dithering state is enabled or disabled
  96469. * @param value defines the dithering state
  96470. */
  96471. setDitheringState(value: boolean): void;
  96472. /**
  96473. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96474. * @param value defines the rasterizer state
  96475. */
  96476. setRasterizerState(value: boolean): void;
  96477. /**
  96478. * stop executing a render loop function and remove it from the execution array
  96479. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96480. */
  96481. stopRenderLoop(renderFunction?: () => void): void;
  96482. /** @hidden */
  96483. _renderLoop(): void;
  96484. /**
  96485. * Can be used to override the current requestAnimationFrame requester.
  96486. * @hidden
  96487. */
  96488. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96489. /**
  96490. * Register and execute a render loop. The engine can have more than one render function
  96491. * @param renderFunction defines the function to continuously execute
  96492. */
  96493. runRenderLoop(renderFunction: () => void): void;
  96494. /**
  96495. * Toggle full screen mode
  96496. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96497. */
  96498. switchFullscreen(requestPointerLock: boolean): void;
  96499. /**
  96500. * Enters full screen mode
  96501. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96502. */
  96503. enterFullscreen(requestPointerLock: boolean): void;
  96504. /**
  96505. * Exits full screen mode
  96506. */
  96507. exitFullscreen(): void;
  96508. /**
  96509. * Enters Pointerlock mode
  96510. */
  96511. enterPointerlock(): void;
  96512. /**
  96513. * Exits Pointerlock mode
  96514. */
  96515. exitPointerlock(): void;
  96516. /**
  96517. * Clear the current render buffer or the current render target (if any is set up)
  96518. * @param color defines the color to use
  96519. * @param backBuffer defines if the back buffer must be cleared
  96520. * @param depth defines if the depth buffer must be cleared
  96521. * @param stencil defines if the stencil buffer must be cleared
  96522. */
  96523. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96524. /**
  96525. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96526. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96527. * @param y defines the y-coordinate of the corner of the clear rectangle
  96528. * @param width defines the width of the clear rectangle
  96529. * @param height defines the height of the clear rectangle
  96530. * @param clearColor defines the clear color
  96531. */
  96532. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96533. /**
  96534. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96535. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96536. * @param y defines the y-coordinate of the corner of the clear rectangle
  96537. * @param width defines the width of the clear rectangle
  96538. * @param height defines the height of the clear rectangle
  96539. */
  96540. enableScissor(x: number, y: number, width: number, height: number): void;
  96541. /**
  96542. * Disable previously set scissor test rectangle
  96543. */
  96544. disableScissor(): void;
  96545. private _viewportCached;
  96546. /** @hidden */
  96547. _viewport(x: number, y: number, width: number, height: number): void;
  96548. /**
  96549. * Set the WebGL's viewport
  96550. * @param viewport defines the viewport element to be used
  96551. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96552. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96553. */
  96554. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96555. /**
  96556. * Directly set the WebGL Viewport
  96557. * @param x defines the x coordinate of the viewport (in screen space)
  96558. * @param y defines the y coordinate of the viewport (in screen space)
  96559. * @param width defines the width of the viewport (in screen space)
  96560. * @param height defines the height of the viewport (in screen space)
  96561. * @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
  96562. */
  96563. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96564. /**
  96565. * Begin a new frame
  96566. */
  96567. beginFrame(): void;
  96568. /**
  96569. * Enf the current frame
  96570. */
  96571. endFrame(): void;
  96572. /**
  96573. * Resize the view according to the canvas' size
  96574. */
  96575. resize(): void;
  96576. /**
  96577. * Force a specific size of the canvas
  96578. * @param width defines the new canvas' width
  96579. * @param height defines the new canvas' height
  96580. */
  96581. setSize(width: number, height: number): void;
  96582. /**
  96583. * Binds the frame buffer to the specified texture.
  96584. * @param texture The texture to render to or null for the default canvas
  96585. * @param faceIndex The face of the texture to render to in case of cube texture
  96586. * @param requiredWidth The width of the target to render to
  96587. * @param requiredHeight The height of the target to render to
  96588. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96589. * @param depthStencilTexture The depth stencil texture to use to render
  96590. * @param lodLevel defines le lod level to bind to the frame buffer
  96591. */
  96592. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96593. /** @hidden */
  96594. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96595. /**
  96596. * Unbind the current render target texture from the webGL context
  96597. * @param texture defines the render target texture to unbind
  96598. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96599. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96600. */
  96601. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96602. /**
  96603. * Force the mipmap generation for the given render target texture
  96604. * @param texture defines the render target texture to use
  96605. */
  96606. generateMipMapsForCubemap(texture: InternalTexture): void;
  96607. /**
  96608. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96609. */
  96610. flushFramebuffer(): void;
  96611. /**
  96612. * Unbind the current render target and bind the default framebuffer
  96613. */
  96614. restoreDefaultFramebuffer(): void;
  96615. /**
  96616. * Create an uniform buffer
  96617. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96618. * @param elements defines the content of the uniform buffer
  96619. * @returns the webGL uniform buffer
  96620. */
  96621. createUniformBuffer(elements: FloatArray): DataBuffer;
  96622. /**
  96623. * Create a dynamic uniform buffer
  96624. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96625. * @param elements defines the content of the uniform buffer
  96626. * @returns the webGL uniform buffer
  96627. */
  96628. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96629. /**
  96630. * Update an existing uniform buffer
  96631. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96632. * @param uniformBuffer defines the target uniform buffer
  96633. * @param elements defines the content to update
  96634. * @param offset defines the offset in the uniform buffer where update should start
  96635. * @param count defines the size of the data to update
  96636. */
  96637. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96638. private _resetVertexBufferBinding;
  96639. /**
  96640. * Creates a vertex buffer
  96641. * @param data the data for the vertex buffer
  96642. * @returns the new WebGL static buffer
  96643. */
  96644. createVertexBuffer(data: DataArray): DataBuffer;
  96645. /**
  96646. * Creates a dynamic vertex buffer
  96647. * @param data the data for the dynamic vertex buffer
  96648. * @returns the new WebGL dynamic buffer
  96649. */
  96650. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96651. /**
  96652. * Update a dynamic index buffer
  96653. * @param indexBuffer defines the target index buffer
  96654. * @param indices defines the data to update
  96655. * @param offset defines the offset in the target index buffer where update should start
  96656. */
  96657. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96658. /**
  96659. * Updates a dynamic vertex buffer.
  96660. * @param vertexBuffer the vertex buffer to update
  96661. * @param data the data used to update the vertex buffer
  96662. * @param byteOffset the byte offset of the data
  96663. * @param byteLength the byte length of the data
  96664. */
  96665. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96666. private _resetIndexBufferBinding;
  96667. /**
  96668. * Creates a new index buffer
  96669. * @param indices defines the content of the index buffer
  96670. * @param updatable defines if the index buffer must be updatable
  96671. * @returns a new webGL buffer
  96672. */
  96673. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96674. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96675. /**
  96676. * Bind a webGL buffer to the webGL context
  96677. * @param buffer defines the buffer to bind
  96678. */
  96679. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96680. /**
  96681. * Bind an uniform buffer to the current webGL context
  96682. * @param buffer defines the buffer to bind
  96683. */
  96684. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96685. /**
  96686. * Bind a buffer to the current webGL context at a given location
  96687. * @param buffer defines the buffer to bind
  96688. * @param location defines the index where to bind the buffer
  96689. */
  96690. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96691. /**
  96692. * Bind a specific block at a given index in a specific shader program
  96693. * @param pipelineContext defines the pipeline context to use
  96694. * @param blockName defines the block name
  96695. * @param index defines the index where to bind the block
  96696. */
  96697. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96698. private bindIndexBuffer;
  96699. private bindBuffer;
  96700. /**
  96701. * update the bound buffer with the given data
  96702. * @param data defines the data to update
  96703. */
  96704. updateArrayBuffer(data: Float32Array): void;
  96705. private _vertexAttribPointer;
  96706. private _bindIndexBufferWithCache;
  96707. private _bindVertexBuffersAttributes;
  96708. /**
  96709. * Records a vertex array object
  96710. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96711. * @param vertexBuffers defines the list of vertex buffers to store
  96712. * @param indexBuffer defines the index buffer to store
  96713. * @param effect defines the effect to store
  96714. * @returns the new vertex array object
  96715. */
  96716. recordVertexArrayObject(vertexBuffers: {
  96717. [key: string]: VertexBuffer;
  96718. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96719. /**
  96720. * Bind a specific vertex array object
  96721. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96722. * @param vertexArrayObject defines the vertex array object to bind
  96723. * @param indexBuffer defines the index buffer to bind
  96724. */
  96725. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96726. /**
  96727. * Bind webGl buffers directly to the webGL context
  96728. * @param vertexBuffer defines the vertex buffer to bind
  96729. * @param indexBuffer defines the index buffer to bind
  96730. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96731. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96732. * @param effect defines the effect associated with the vertex buffer
  96733. */
  96734. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96735. private _unbindVertexArrayObject;
  96736. /**
  96737. * Bind a list of vertex buffers to the webGL context
  96738. * @param vertexBuffers defines the list of vertex buffers to bind
  96739. * @param indexBuffer defines the index buffer to bind
  96740. * @param effect defines the effect associated with the vertex buffers
  96741. */
  96742. bindBuffers(vertexBuffers: {
  96743. [key: string]: Nullable<VertexBuffer>;
  96744. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96745. /**
  96746. * Unbind all instance attributes
  96747. */
  96748. unbindInstanceAttributes(): void;
  96749. /**
  96750. * Release and free the memory of a vertex array object
  96751. * @param vao defines the vertex array object to delete
  96752. */
  96753. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96754. /** @hidden */
  96755. _releaseBuffer(buffer: DataBuffer): boolean;
  96756. protected _deleteBuffer(buffer: DataBuffer): void;
  96757. /**
  96758. * Creates a webGL buffer to use with instanciation
  96759. * @param capacity defines the size of the buffer
  96760. * @returns the webGL buffer
  96761. */
  96762. createInstancesBuffer(capacity: number): DataBuffer;
  96763. /**
  96764. * Delete a webGL buffer used with instanciation
  96765. * @param buffer defines the webGL buffer to delete
  96766. */
  96767. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96768. /**
  96769. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96770. * @param instancesBuffer defines the webGL buffer to update and bind
  96771. * @param data defines the data to store in the buffer
  96772. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96773. */
  96774. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96775. /**
  96776. * Apply all cached states (depth, culling, stencil and alpha)
  96777. */
  96778. applyStates(): void;
  96779. /**
  96780. * Send a draw order
  96781. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96782. * @param indexStart defines the starting index
  96783. * @param indexCount defines the number of index to draw
  96784. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96785. */
  96786. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96787. /**
  96788. * Draw a list of points
  96789. * @param verticesStart defines the index of first vertex to draw
  96790. * @param verticesCount defines the count of vertices to draw
  96791. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96792. */
  96793. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96794. /**
  96795. * Draw a list of unindexed primitives
  96796. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96797. * @param verticesStart defines the index of first vertex to draw
  96798. * @param verticesCount defines the count of vertices to draw
  96799. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96800. */
  96801. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96802. /**
  96803. * Draw a list of indexed primitives
  96804. * @param fillMode defines the primitive to use
  96805. * @param indexStart defines the starting index
  96806. * @param indexCount defines the number of index to draw
  96807. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96808. */
  96809. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96810. /**
  96811. * Draw a list of unindexed primitives
  96812. * @param fillMode defines the primitive to use
  96813. * @param verticesStart defines the index of first vertex to draw
  96814. * @param verticesCount defines the count of vertices to draw
  96815. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96816. */
  96817. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96818. private _drawMode;
  96819. /** @hidden */
  96820. _releaseEffect(effect: Effect): void;
  96821. /** @hidden */
  96822. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96823. /**
  96824. * Create a new effect (used to store vertex/fragment shaders)
  96825. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96826. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96827. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96828. * @param samplers defines an array of string used to represent textures
  96829. * @param defines defines the string containing the defines to use to compile the shaders
  96830. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96831. * @param onCompiled defines a function to call when the effect creation is successful
  96832. * @param onError defines a function to call when the effect creation has failed
  96833. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96834. * @returns the new Effect
  96835. */
  96836. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96837. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96838. private _compileShader;
  96839. private _compileRawShader;
  96840. /**
  96841. * Directly creates a webGL program
  96842. * @param pipelineContext defines the pipeline context to attach to
  96843. * @param vertexCode defines the vertex shader code to use
  96844. * @param fragmentCode defines the fragment shader code to use
  96845. * @param context defines the webGL context to use (if not set, the current one will be used)
  96846. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96847. * @returns the new webGL program
  96848. */
  96849. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96850. /**
  96851. * Creates a webGL program
  96852. * @param pipelineContext defines the pipeline context to attach to
  96853. * @param vertexCode defines the vertex shader code to use
  96854. * @param fragmentCode defines the fragment shader code to use
  96855. * @param defines defines the string containing the defines to use to compile the shaders
  96856. * @param context defines the webGL context to use (if not set, the current one will be used)
  96857. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96858. * @returns the new webGL program
  96859. */
  96860. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96861. /**
  96862. * Creates a new pipeline context
  96863. * @returns the new pipeline
  96864. */
  96865. createPipelineContext(): IPipelineContext;
  96866. private _createShaderProgram;
  96867. private _finalizePipelineContext;
  96868. /** @hidden */
  96869. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96870. /** @hidden */
  96871. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96872. /** @hidden */
  96873. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96874. /**
  96875. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96876. * @param pipelineContext defines the pipeline context to use
  96877. * @param uniformsNames defines the list of uniform names
  96878. * @returns an array of webGL uniform locations
  96879. */
  96880. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96881. /**
  96882. * Gets the lsit of active attributes for a given webGL program
  96883. * @param pipelineContext defines the pipeline context to use
  96884. * @param attributesNames defines the list of attribute names to get
  96885. * @returns an array of indices indicating the offset of each attribute
  96886. */
  96887. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96888. /**
  96889. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96890. * @param effect defines the effect to activate
  96891. */
  96892. enableEffect(effect: Nullable<Effect>): void;
  96893. /**
  96894. * Set the value of an uniform to an array of int32
  96895. * @param uniform defines the webGL uniform location where to store the value
  96896. * @param array defines the array of int32 to store
  96897. */
  96898. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96899. /**
  96900. * Set the value of an uniform to an array of int32 (stored as vec2)
  96901. * @param uniform defines the webGL uniform location where to store the value
  96902. * @param array defines the array of int32 to store
  96903. */
  96904. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96905. /**
  96906. * Set the value of an uniform to an array of int32 (stored as vec3)
  96907. * @param uniform defines the webGL uniform location where to store the value
  96908. * @param array defines the array of int32 to store
  96909. */
  96910. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96911. /**
  96912. * Set the value of an uniform to an array of int32 (stored as vec4)
  96913. * @param uniform defines the webGL uniform location where to store the value
  96914. * @param array defines the array of int32 to store
  96915. */
  96916. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96917. /**
  96918. * Set the value of an uniform to an array of float32
  96919. * @param uniform defines the webGL uniform location where to store the value
  96920. * @param array defines the array of float32 to store
  96921. */
  96922. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96923. /**
  96924. * Set the value of an uniform to an array of float32 (stored as vec2)
  96925. * @param uniform defines the webGL uniform location where to store the value
  96926. * @param array defines the array of float32 to store
  96927. */
  96928. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96929. /**
  96930. * Set the value of an uniform to an array of float32 (stored as vec3)
  96931. * @param uniform defines the webGL uniform location where to store the value
  96932. * @param array defines the array of float32 to store
  96933. */
  96934. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96935. /**
  96936. * Set the value of an uniform to an array of float32 (stored as vec4)
  96937. * @param uniform defines the webGL uniform location where to store the value
  96938. * @param array defines the array of float32 to store
  96939. */
  96940. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96941. /**
  96942. * Set the value of an uniform to an array of number
  96943. * @param uniform defines the webGL uniform location where to store the value
  96944. * @param array defines the array of number to store
  96945. */
  96946. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96947. /**
  96948. * Set the value of an uniform to an array of number (stored as vec2)
  96949. * @param uniform defines the webGL uniform location where to store the value
  96950. * @param array defines the array of number to store
  96951. */
  96952. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96953. /**
  96954. * Set the value of an uniform to an array of number (stored as vec3)
  96955. * @param uniform defines the webGL uniform location where to store the value
  96956. * @param array defines the array of number to store
  96957. */
  96958. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96959. /**
  96960. * Set the value of an uniform to an array of number (stored as vec4)
  96961. * @param uniform defines the webGL uniform location where to store the value
  96962. * @param array defines the array of number to store
  96963. */
  96964. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96965. /**
  96966. * Set the value of an uniform to an array of float32 (stored as matrices)
  96967. * @param uniform defines the webGL uniform location where to store the value
  96968. * @param matrices defines the array of float32 to store
  96969. */
  96970. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96971. /**
  96972. * Set the value of an uniform to a matrix (3x3)
  96973. * @param uniform defines the webGL uniform location where to store the value
  96974. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96975. */
  96976. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96977. /**
  96978. * Set the value of an uniform to a matrix (2x2)
  96979. * @param uniform defines the webGL uniform location where to store the value
  96980. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96981. */
  96982. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96983. /**
  96984. * Set the value of an uniform to a number (int)
  96985. * @param uniform defines the webGL uniform location where to store the value
  96986. * @param value defines the int number to store
  96987. */
  96988. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96989. /**
  96990. * Set the value of an uniform to a number (float)
  96991. * @param uniform defines the webGL uniform location where to store the value
  96992. * @param value defines the float number to store
  96993. */
  96994. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96995. /**
  96996. * Set the value of an uniform to a vec2
  96997. * @param uniform defines the webGL uniform location where to store the value
  96998. * @param x defines the 1st component of the value
  96999. * @param y defines the 2nd component of the value
  97000. */
  97001. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97002. /**
  97003. * Set the value of an uniform to a vec3
  97004. * @param uniform defines the webGL uniform location where to store the value
  97005. * @param x defines the 1st component of the value
  97006. * @param y defines the 2nd component of the value
  97007. * @param z defines the 3rd component of the value
  97008. */
  97009. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97010. /**
  97011. * Set the value of an uniform to a boolean
  97012. * @param uniform defines the webGL uniform location where to store the value
  97013. * @param bool defines the boolean to store
  97014. */
  97015. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  97016. /**
  97017. * Set the value of an uniform to a vec4
  97018. * @param uniform defines the webGL uniform location where to store the value
  97019. * @param x defines the 1st component of the value
  97020. * @param y defines the 2nd component of the value
  97021. * @param z defines the 3rd component of the value
  97022. * @param w defines the 4th component of the value
  97023. */
  97024. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97025. /**
  97026. * Sets a Color4 on a uniform variable
  97027. * @param uniform defines the uniform location
  97028. * @param color4 defines the value to be set
  97029. */
  97030. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  97031. /**
  97032. * Set various states to the webGL context
  97033. * @param culling defines backface culling state
  97034. * @param zOffset defines the value to apply to zOffset (0 by default)
  97035. * @param force defines if states must be applied even if cache is up to date
  97036. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  97037. */
  97038. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97039. /**
  97040. * Set the z offset to apply to current rendering
  97041. * @param value defines the offset to apply
  97042. */
  97043. setZOffset(value: number): void;
  97044. /**
  97045. * Gets the current value of the zOffset
  97046. * @returns the current zOffset state
  97047. */
  97048. getZOffset(): number;
  97049. /**
  97050. * Enable or disable depth buffering
  97051. * @param enable defines the state to set
  97052. */
  97053. setDepthBuffer(enable: boolean): void;
  97054. /**
  97055. * Gets a boolean indicating if depth writing is enabled
  97056. * @returns the current depth writing state
  97057. */
  97058. getDepthWrite(): boolean;
  97059. /**
  97060. * Enable or disable depth writing
  97061. * @param enable defines the state to set
  97062. */
  97063. setDepthWrite(enable: boolean): void;
  97064. /**
  97065. * Enable or disable color writing
  97066. * @param enable defines the state to set
  97067. */
  97068. setColorWrite(enable: boolean): void;
  97069. /**
  97070. * Gets a boolean indicating if color writing is enabled
  97071. * @returns the current color writing state
  97072. */
  97073. getColorWrite(): boolean;
  97074. /**
  97075. * Sets alpha constants used by some alpha blending modes
  97076. * @param r defines the red component
  97077. * @param g defines the green component
  97078. * @param b defines the blue component
  97079. * @param a defines the alpha component
  97080. */
  97081. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  97082. /**
  97083. * Sets the current alpha mode
  97084. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  97085. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  97086. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97087. */
  97088. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97089. /**
  97090. * Gets the current alpha mode
  97091. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97092. * @returns the current alpha mode
  97093. */
  97094. getAlphaMode(): number;
  97095. /**
  97096. * Clears the list of texture accessible through engine.
  97097. * This can help preventing texture load conflict due to name collision.
  97098. */
  97099. clearInternalTexturesCache(): void;
  97100. /**
  97101. * Force the entire cache to be cleared
  97102. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97103. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97104. */
  97105. wipeCaches(bruteForce?: boolean): void;
  97106. /**
  97107. * Set the compressed texture format to use, based on the formats you have, and the formats
  97108. * supported by the hardware / browser.
  97109. *
  97110. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  97111. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  97112. * to API arguments needed to compressed textures. This puts the burden on the container
  97113. * generator to house the arcane code for determining these for current & future formats.
  97114. *
  97115. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  97116. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  97117. *
  97118. * Note: The result of this call is not taken into account when a texture is base64.
  97119. *
  97120. * @param formatsAvailable defines the list of those format families you have created
  97121. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  97122. *
  97123. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  97124. * @returns The extension selected.
  97125. */
  97126. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  97127. /** @hidden */
  97128. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97129. min: number;
  97130. mag: number;
  97131. };
  97132. /** @hidden */
  97133. _createTexture(): WebGLTexture;
  97134. /**
  97135. * Usually called from Texture.ts.
  97136. * Passed information to create a WebGLTexture
  97137. * @param urlArg defines a value which contains one of the following:
  97138. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97139. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97140. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97141. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97142. * @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)
  97143. * @param scene needed for loading to the correct scene
  97144. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97145. * @param onLoad optional callback to be called upon successful completion
  97146. * @param onError optional callback to be called upon failure
  97147. * @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
  97148. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97149. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97150. * @param forcedExtension defines the extension to use to pick the right loader
  97151. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97152. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97153. */
  97154. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  97155. /**
  97156. * @hidden
  97157. * Rescales a texture
  97158. * @param source input texutre
  97159. * @param destination destination texture
  97160. * @param scene scene to use to render the resize
  97161. * @param internalFormat format to use when resizing
  97162. * @param onComplete callback to be called when resize has completed
  97163. */
  97164. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  97165. private _unpackFlipYCached;
  97166. /**
  97167. * In case you are sharing the context with other applications, it might
  97168. * be interested to not cache the unpack flip y state to ensure a consistent
  97169. * value would be set.
  97170. */
  97171. enableUnpackFlipYCached: boolean;
  97172. /** @hidden */
  97173. _unpackFlipY(value: boolean): void;
  97174. /** @hidden */
  97175. _getUnpackAlignement(): number;
  97176. /**
  97177. * Creates a dynamic texture
  97178. * @param width defines the width of the texture
  97179. * @param height defines the height of the texture
  97180. * @param generateMipMaps defines if the engine should generate the mip levels
  97181. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97182. * @returns the dynamic texture inside an InternalTexture
  97183. */
  97184. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  97185. /**
  97186. * Update the sampling mode of a given texture
  97187. * @param samplingMode defines the required sampling mode
  97188. * @param texture defines the texture to update
  97189. */
  97190. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97191. /**
  97192. * Update the content of a dynamic texture
  97193. * @param texture defines the texture to update
  97194. * @param canvas defines the canvas containing the source
  97195. * @param invertY defines if data must be stored with Y axis inverted
  97196. * @param premulAlpha defines if alpha is stored as premultiplied
  97197. * @param format defines the format of the data
  97198. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  97199. */
  97200. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  97201. /**
  97202. * Update a video texture
  97203. * @param texture defines the texture to update
  97204. * @param video defines the video element to use
  97205. * @param invertY defines if data must be stored with Y axis inverted
  97206. */
  97207. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97208. /**
  97209. * Updates a depth texture Comparison Mode and Function.
  97210. * If the comparison Function is equal to 0, the mode will be set to none.
  97211. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97212. * @param texture The texture to set the comparison function for
  97213. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97214. */
  97215. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97216. /** @hidden */
  97217. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97218. width: number;
  97219. height: number;
  97220. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97221. /**
  97222. * Creates a depth stencil texture.
  97223. * This is only available in WebGL 2 or with the depth texture extension available.
  97224. * @param size The size of face edge in the texture.
  97225. * @param options The options defining the texture.
  97226. * @returns The texture
  97227. */
  97228. createDepthStencilTexture(size: number | {
  97229. width: number;
  97230. height: number;
  97231. }, options: DepthTextureCreationOptions): InternalTexture;
  97232. /**
  97233. * Creates a depth stencil texture.
  97234. * This is only available in WebGL 2 or with the depth texture extension available.
  97235. * @param size The size of face edge in the texture.
  97236. * @param options The options defining the texture.
  97237. * @returns The texture
  97238. */
  97239. private _createDepthStencilTexture;
  97240. /**
  97241. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  97242. * @param renderTarget The render target to set the frame buffer for
  97243. */
  97244. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  97245. /**
  97246. * Creates a new render target texture
  97247. * @param size defines the size of the texture
  97248. * @param options defines the options used to create the texture
  97249. * @returns a new render target texture stored in an InternalTexture
  97250. */
  97251. createRenderTargetTexture(size: number | {
  97252. width: number;
  97253. height: number;
  97254. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97255. /** @hidden */
  97256. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97257. /**
  97258. * Updates the sample count of a render target texture
  97259. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  97260. * @param texture defines the texture to update
  97261. * @param samples defines the sample count to set
  97262. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  97263. */
  97264. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  97265. /** @hidden */
  97266. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97267. /** @hidden */
  97268. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97269. /** @hidden */
  97270. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97271. /** @hidden */
  97272. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97273. /**
  97274. * @hidden
  97275. */
  97276. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97277. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97278. private _prepareWebGLTexture;
  97279. /** @hidden */
  97280. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  97281. /** @hidden */
  97282. _releaseFramebufferObjects(texture: InternalTexture): void;
  97283. /** @hidden */
  97284. _releaseTexture(texture: InternalTexture): void;
  97285. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97286. protected _setProgram(program: WebGLProgram): void;
  97287. protected _boundUniforms: {
  97288. [key: number]: WebGLUniformLocation;
  97289. };
  97290. /**
  97291. * Binds an effect to the webGL context
  97292. * @param effect defines the effect to bind
  97293. */
  97294. bindSamplers(effect: Effect): void;
  97295. private _activateCurrentTexture;
  97296. /** @hidden */
  97297. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97298. /** @hidden */
  97299. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97300. /**
  97301. * Sets a texture to the webGL context from a postprocess
  97302. * @param channel defines the channel to use
  97303. * @param postProcess defines the source postprocess
  97304. */
  97305. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  97306. /**
  97307. * Binds the output of the passed in post process to the texture channel specified
  97308. * @param channel The channel the texture should be bound to
  97309. * @param postProcess The post process which's output should be bound
  97310. */
  97311. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  97312. /**
  97313. * Unbind all textures from the webGL context
  97314. */
  97315. unbindAllTextures(): void;
  97316. /**
  97317. * Sets a texture to the according uniform.
  97318. * @param channel The texture channel
  97319. * @param uniform The uniform to set
  97320. * @param texture The texture to apply
  97321. */
  97322. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97323. /**
  97324. * Sets a depth stencil texture from a render target to the according uniform.
  97325. * @param channel The texture channel
  97326. * @param uniform The uniform to set
  97327. * @param texture The render target texture containing the depth stencil texture to apply
  97328. */
  97329. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  97330. private _bindSamplerUniformToChannel;
  97331. private _getTextureWrapMode;
  97332. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97333. /**
  97334. * Sets an array of texture to the webGL context
  97335. * @param channel defines the channel where the texture array must be set
  97336. * @param uniform defines the associated uniform location
  97337. * @param textures defines the array of textures to bind
  97338. */
  97339. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97340. /** @hidden */
  97341. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97342. private _setTextureParameterFloat;
  97343. private _setTextureParameterInteger;
  97344. /**
  97345. * Reads pixels from the current frame buffer. Please note that this function can be slow
  97346. * @param x defines the x coordinate of the rectangle where pixels must be read
  97347. * @param y defines the y coordinate of the rectangle where pixels must be read
  97348. * @param width defines the width of the rectangle where pixels must be read
  97349. * @param height defines the height of the rectangle where pixels must be read
  97350. * @returns a Uint8Array containing RGBA colors
  97351. */
  97352. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  97353. /**
  97354. * Add an externaly attached data from its key.
  97355. * This method call will fail and return false, if such key already exists.
  97356. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97357. * @param key the unique key that identifies the data
  97358. * @param data the data object to associate to the key for this Engine instance
  97359. * @return true if no such key were already present and the data was added successfully, false otherwise
  97360. */
  97361. addExternalData<T>(key: string, data: T): boolean;
  97362. /**
  97363. * Get an externaly attached data from its key
  97364. * @param key the unique key that identifies the data
  97365. * @return the associated data, if present (can be null), or undefined if not present
  97366. */
  97367. getExternalData<T>(key: string): T;
  97368. /**
  97369. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97370. * @param key the unique key that identifies the data
  97371. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97372. * @return the associated data, can be null if the factory returned null.
  97373. */
  97374. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97375. /**
  97376. * Remove an externaly attached data from the Engine instance
  97377. * @param key the unique key that identifies the data
  97378. * @return true if the data was successfully removed, false if it doesn't exist
  97379. */
  97380. removeExternalData(key: string): boolean;
  97381. /**
  97382. * Unbind all vertex attributes from the webGL context
  97383. */
  97384. unbindAllAttributes(): void;
  97385. /**
  97386. * 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
  97387. */
  97388. releaseEffects(): void;
  97389. /**
  97390. * Dispose and release all associated resources
  97391. */
  97392. dispose(): void;
  97393. /**
  97394. * Display the loading screen
  97395. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97396. */
  97397. displayLoadingUI(): void;
  97398. /**
  97399. * Hide the loading screen
  97400. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97401. */
  97402. hideLoadingUI(): void;
  97403. /**
  97404. * Gets the current loading screen object
  97405. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97406. */
  97407. /**
  97408. * Sets the current loading screen object
  97409. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97410. */
  97411. loadingScreen: ILoadingScreen;
  97412. /**
  97413. * Sets the current loading screen text
  97414. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97415. */
  97416. loadingUIText: string;
  97417. /**
  97418. * Sets the current loading screen background color
  97419. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97420. */
  97421. loadingUIBackgroundColor: string;
  97422. /**
  97423. * Attach a new callback raised when context lost event is fired
  97424. * @param callback defines the callback to call
  97425. */
  97426. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97427. /**
  97428. * Attach a new callback raised when context restored event is fired
  97429. * @param callback defines the callback to call
  97430. */
  97431. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97432. /**
  97433. * Gets the source code of the vertex shader associated with a specific webGL program
  97434. * @param program defines the program to use
  97435. * @returns a string containing the source code of the vertex shader associated with the program
  97436. */
  97437. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97438. /**
  97439. * Gets the source code of the fragment shader associated with a specific webGL program
  97440. * @param program defines the program to use
  97441. * @returns a string containing the source code of the fragment shader associated with the program
  97442. */
  97443. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97444. /**
  97445. * Get the current error code of the webGL context
  97446. * @returns the error code
  97447. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97448. */
  97449. getError(): number;
  97450. /**
  97451. * Gets the current framerate
  97452. * @returns a number representing the framerate
  97453. */
  97454. getFps(): number;
  97455. /**
  97456. * Gets the time spent between current and previous frame
  97457. * @returns a number representing the delta time in ms
  97458. */
  97459. getDeltaTime(): number;
  97460. private _measureFps;
  97461. /** @hidden */
  97462. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97463. private _canRenderToFloatFramebuffer;
  97464. private _canRenderToHalfFloatFramebuffer;
  97465. private _canRenderToFramebuffer;
  97466. /** @hidden */
  97467. _getWebGLTextureType(type: number): number;
  97468. /** @hidden */
  97469. _getInternalFormat(format: number): number;
  97470. /** @hidden */
  97471. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97472. /** @hidden */
  97473. _getRGBAMultiSampleBufferFormat(type: number): number;
  97474. /** @hidden */
  97475. _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;
  97476. /** @hidden */
  97477. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97478. /**
  97479. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97480. * @returns true if the engine can be created
  97481. * @ignorenaming
  97482. */
  97483. static isSupported(): boolean;
  97484. /**
  97485. * Find the next highest power of two.
  97486. * @param x Number to start search from.
  97487. * @return Next highest power of two.
  97488. */
  97489. static CeilingPOT(x: number): number;
  97490. /**
  97491. * Find the next lowest power of two.
  97492. * @param x Number to start search from.
  97493. * @return Next lowest power of two.
  97494. */
  97495. static FloorPOT(x: number): number;
  97496. /**
  97497. * Find the nearest power of two.
  97498. * @param x Number to start search from.
  97499. * @return Next nearest power of two.
  97500. */
  97501. static NearestPOT(x: number): number;
  97502. /**
  97503. * Get the closest exponent of two
  97504. * @param value defines the value to approximate
  97505. * @param max defines the maximum value to return
  97506. * @param mode defines how to define the closest value
  97507. * @returns closest exponent of two of the given value
  97508. */
  97509. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97510. /**
  97511. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97512. * @param func - the function to be called
  97513. * @param requester - the object that will request the next frame. Falls back to window.
  97514. * @returns frame number
  97515. */
  97516. static QueueNewFrame(func: () => void, requester?: any): number;
  97517. /**
  97518. * Ask the browser to promote the current element to pointerlock mode
  97519. * @param element defines the DOM element to promote
  97520. */
  97521. static _RequestPointerlock(element: HTMLElement): void;
  97522. /**
  97523. * Asks the browser to exit pointerlock mode
  97524. */
  97525. static _ExitPointerlock(): void;
  97526. /**
  97527. * Ask the browser to promote the current element to fullscreen rendering mode
  97528. * @param element defines the DOM element to promote
  97529. */
  97530. static _RequestFullscreen(element: HTMLElement): void;
  97531. /**
  97532. * Asks the browser to exit fullscreen mode
  97533. */
  97534. static _ExitFullscreen(): void;
  97535. }
  97536. }
  97537. declare module BABYLON {
  97538. /**
  97539. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97540. * during the life time of the application.
  97541. */
  97542. export class EngineStore {
  97543. /** Gets the list of created engines */
  97544. static Instances: Engine[];
  97545. /** @hidden */
  97546. static _LastCreatedScene: Nullable<Scene>;
  97547. /**
  97548. * Gets the latest created engine
  97549. */
  97550. static readonly LastCreatedEngine: Nullable<Engine>;
  97551. /**
  97552. * Gets the latest created scene
  97553. */
  97554. static readonly LastCreatedScene: Nullable<Scene>;
  97555. /**
  97556. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97557. * @ignorenaming
  97558. */
  97559. static UseFallbackTexture: boolean;
  97560. /**
  97561. * Texture content used if a texture cannot loaded
  97562. * @ignorenaming
  97563. */
  97564. static FallbackTexture: string;
  97565. }
  97566. }
  97567. declare module BABYLON {
  97568. /**
  97569. * Helper class that provides a small promise polyfill
  97570. */
  97571. export class PromisePolyfill {
  97572. /**
  97573. * Static function used to check if the polyfill is required
  97574. * If this is the case then the function will inject the polyfill to window.Promise
  97575. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97576. */
  97577. static Apply(force?: boolean): void;
  97578. }
  97579. }
  97580. declare module BABYLON {
  97581. /**
  97582. * Interface for screenshot methods with describe argument called `size` as object with options
  97583. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97584. */
  97585. export interface IScreenshotSize {
  97586. /**
  97587. * number in pixels for canvas height
  97588. */
  97589. height?: number;
  97590. /**
  97591. * multiplier allowing render at a higher or lower resolution
  97592. * If value is defined then height and width will be ignored and taken from camera
  97593. */
  97594. precision?: number;
  97595. /**
  97596. * number in pixels for canvas width
  97597. */
  97598. width?: number;
  97599. }
  97600. }
  97601. declare module BABYLON {
  97602. interface IColor4Like {
  97603. r: float;
  97604. g: float;
  97605. b: float;
  97606. a: float;
  97607. }
  97608. /**
  97609. * Class containing a set of static utilities functions
  97610. */
  97611. export class Tools {
  97612. /**
  97613. * Gets or sets the base URL to use to load assets
  97614. */
  97615. static BaseUrl: string;
  97616. /**
  97617. * Enable/Disable Custom HTTP Request Headers globally.
  97618. * default = false
  97619. * @see CustomRequestHeaders
  97620. */
  97621. static UseCustomRequestHeaders: boolean;
  97622. /**
  97623. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97624. * i.e. when loading files, where the server/service expects an Authorization header
  97625. */
  97626. static CustomRequestHeaders: {
  97627. [key: string]: string;
  97628. };
  97629. /**
  97630. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97631. */
  97632. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97633. /**
  97634. * Default behaviour for cors in the application.
  97635. * It can be a string if the expected behavior is identical in the entire app.
  97636. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97637. */
  97638. static CorsBehavior: string | ((url: string | string[]) => string);
  97639. /**
  97640. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97641. * @ignorenaming
  97642. */
  97643. static UseFallbackTexture: boolean;
  97644. /**
  97645. * Use this object to register external classes like custom textures or material
  97646. * to allow the laoders to instantiate them
  97647. */
  97648. static RegisteredExternalClasses: {
  97649. [key: string]: Object;
  97650. };
  97651. /**
  97652. * Texture content used if a texture cannot loaded
  97653. * @ignorenaming
  97654. */
  97655. static fallbackTexture: string;
  97656. /**
  97657. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97658. * @param u defines the coordinate on X axis
  97659. * @param v defines the coordinate on Y axis
  97660. * @param width defines the width of the source data
  97661. * @param height defines the height of the source data
  97662. * @param pixels defines the source byte array
  97663. * @param color defines the output color
  97664. */
  97665. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97666. /**
  97667. * Interpolates between a and b via alpha
  97668. * @param a The lower value (returned when alpha = 0)
  97669. * @param b The upper value (returned when alpha = 1)
  97670. * @param alpha The interpolation-factor
  97671. * @return The mixed value
  97672. */
  97673. static Mix(a: number, b: number, alpha: number): number;
  97674. /**
  97675. * Tries to instantiate a new object from a given class name
  97676. * @param className defines the class name to instantiate
  97677. * @returns the new object or null if the system was not able to do the instantiation
  97678. */
  97679. static Instantiate(className: string): any;
  97680. /**
  97681. * Provides a slice function that will work even on IE
  97682. * @param data defines the array to slice
  97683. * @param start defines the start of the data (optional)
  97684. * @param end defines the end of the data (optional)
  97685. * @returns the new sliced array
  97686. */
  97687. static Slice<T>(data: T, start?: number, end?: number): T;
  97688. /**
  97689. * Polyfill for setImmediate
  97690. * @param action defines the action to execute after the current execution block
  97691. */
  97692. static SetImmediate(action: () => void): void;
  97693. /**
  97694. * Function indicating if a number is an exponent of 2
  97695. * @param value defines the value to test
  97696. * @returns true if the value is an exponent of 2
  97697. */
  97698. static IsExponentOfTwo(value: number): boolean;
  97699. private static _tmpFloatArray;
  97700. /**
  97701. * Returns the nearest 32-bit single precision float representation of a Number
  97702. * @param value A Number. If the parameter is of a different type, it will get converted
  97703. * to a number or to NaN if it cannot be converted
  97704. * @returns number
  97705. */
  97706. static FloatRound(value: number): number;
  97707. /**
  97708. * Extracts the filename from a path
  97709. * @param path defines the path to use
  97710. * @returns the filename
  97711. */
  97712. static GetFilename(path: string): string;
  97713. /**
  97714. * Extracts the "folder" part of a path (everything before the filename).
  97715. * @param uri The URI to extract the info from
  97716. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97717. * @returns The "folder" part of the path
  97718. */
  97719. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97720. /**
  97721. * Extracts text content from a DOM element hierarchy
  97722. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97723. */
  97724. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97725. /**
  97726. * Convert an angle in radians to degrees
  97727. * @param angle defines the angle to convert
  97728. * @returns the angle in degrees
  97729. */
  97730. static ToDegrees(angle: number): number;
  97731. /**
  97732. * Convert an angle in degrees to radians
  97733. * @param angle defines the angle to convert
  97734. * @returns the angle in radians
  97735. */
  97736. static ToRadians(angle: number): number;
  97737. /**
  97738. * Encode a buffer to a base64 string
  97739. * @param buffer defines the buffer to encode
  97740. * @returns the encoded string
  97741. */
  97742. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97743. /**
  97744. * Returns an array if obj is not an array
  97745. * @param obj defines the object to evaluate as an array
  97746. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97747. * @returns either obj directly if obj is an array or a new array containing obj
  97748. */
  97749. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97750. /**
  97751. * Gets the pointer prefix to use
  97752. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97753. */
  97754. static GetPointerPrefix(): string;
  97755. /**
  97756. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97757. * @param url define the url we are trying
  97758. * @param element define the dom element where to configure the cors policy
  97759. */
  97760. static SetCorsBehavior(url: string | string[], element: {
  97761. crossOrigin: string | null;
  97762. }): void;
  97763. /**
  97764. * Removes unwanted characters from an url
  97765. * @param url defines the url to clean
  97766. * @returns the cleaned url
  97767. */
  97768. static CleanUrl(url: string): string;
  97769. /**
  97770. * Gets or sets a function used to pre-process url before using them to load assets
  97771. */
  97772. static PreprocessUrl: (url: string) => string;
  97773. /**
  97774. * Loads an image as an HTMLImageElement.
  97775. * @param input url string, ArrayBuffer, or Blob to load
  97776. * @param onLoad callback called when the image successfully loads
  97777. * @param onError callback called when the image fails to load
  97778. * @param offlineProvider offline provider for caching
  97779. * @returns the HTMLImageElement of the loaded image
  97780. */
  97781. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97782. /**
  97783. * Loads a file
  97784. * @param url url string, ArrayBuffer, or Blob to load
  97785. * @param onSuccess callback called when the file successfully loads
  97786. * @param onProgress callback called while file is loading (if the server supports this mode)
  97787. * @param offlineProvider defines the offline provider for caching
  97788. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97789. * @param onError callback called when the file fails to load
  97790. * @returns a file request object
  97791. */
  97792. 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;
  97793. /**
  97794. * Loads a file from a url
  97795. * @param url the file url to load
  97796. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97797. */
  97798. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97799. /**
  97800. * Load a script (identified by an url). When the url returns, the
  97801. * content of this file is added into a new script element, attached to the DOM (body element)
  97802. * @param scriptUrl defines the url of the script to laod
  97803. * @param onSuccess defines the callback called when the script is loaded
  97804. * @param onError defines the callback to call if an error occurs
  97805. * @param scriptId defines the id of the script element
  97806. */
  97807. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97808. /**
  97809. * Load an asynchronous script (identified by an url). When the url returns, the
  97810. * content of this file is added into a new script element, attached to the DOM (body element)
  97811. * @param scriptUrl defines the url of the script to laod
  97812. * @param scriptId defines the id of the script element
  97813. * @returns a promise request object
  97814. */
  97815. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97816. /**
  97817. * Loads a file from a blob
  97818. * @param fileToLoad defines the blob to use
  97819. * @param callback defines the callback to call when data is loaded
  97820. * @param progressCallback defines the callback to call during loading process
  97821. * @returns a file request object
  97822. */
  97823. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97824. /**
  97825. * Loads a file
  97826. * @param fileToLoad defines the file to load
  97827. * @param callback defines the callback to call when data is loaded
  97828. * @param progressCallBack defines the callback to call during loading process
  97829. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97830. * @returns a file request object
  97831. */
  97832. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97833. /**
  97834. * Creates a data url from a given string content
  97835. * @param content defines the content to convert
  97836. * @returns the new data url link
  97837. */
  97838. static FileAsURL(content: string): string;
  97839. /**
  97840. * Format the given number to a specific decimal format
  97841. * @param value defines the number to format
  97842. * @param decimals defines the number of decimals to use
  97843. * @returns the formatted string
  97844. */
  97845. static Format(value: number, decimals?: number): string;
  97846. /**
  97847. * Tries to copy an object by duplicating every property
  97848. * @param source defines the source object
  97849. * @param destination defines the target object
  97850. * @param doNotCopyList defines a list of properties to avoid
  97851. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97852. */
  97853. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97854. /**
  97855. * Gets a boolean indicating if the given object has no own property
  97856. * @param obj defines the object to test
  97857. * @returns true if object has no own property
  97858. */
  97859. static IsEmpty(obj: any): boolean;
  97860. /**
  97861. * Function used to register events at window level
  97862. * @param windowElement defines the Window object to use
  97863. * @param events defines the events to register
  97864. */
  97865. static RegisterTopRootEvents(windowElement: Window, events: {
  97866. name: string;
  97867. handler: Nullable<(e: FocusEvent) => any>;
  97868. }[]): void;
  97869. /**
  97870. * Function used to unregister events from window level
  97871. * @param windowElement defines the Window object to use
  97872. * @param events defines the events to unregister
  97873. */
  97874. static UnregisterTopRootEvents(windowElement: Window, events: {
  97875. name: string;
  97876. handler: Nullable<(e: FocusEvent) => any>;
  97877. }[]): void;
  97878. /**
  97879. * @ignore
  97880. */
  97881. static _ScreenshotCanvas: HTMLCanvasElement;
  97882. /**
  97883. * Dumps the current bound framebuffer
  97884. * @param width defines the rendering width
  97885. * @param height defines the rendering height
  97886. * @param engine defines the hosting engine
  97887. * @param successCallback defines the callback triggered once the data are available
  97888. * @param mimeType defines the mime type of the result
  97889. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97890. */
  97891. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97892. /**
  97893. * Converts the canvas data to blob.
  97894. * This acts as a polyfill for browsers not supporting the to blob function.
  97895. * @param canvas Defines the canvas to extract the data from
  97896. * @param successCallback Defines the callback triggered once the data are available
  97897. * @param mimeType Defines the mime type of the result
  97898. */
  97899. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  97900. /**
  97901. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97902. * @param successCallback defines the callback triggered once the data are available
  97903. * @param mimeType defines the mime type of the result
  97904. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97905. */
  97906. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97907. /**
  97908. * Downloads a blob in the browser
  97909. * @param blob defines the blob to download
  97910. * @param fileName defines the name of the downloaded file
  97911. */
  97912. static Download(blob: Blob, fileName: string): void;
  97913. /**
  97914. * Captures a screenshot of the current rendering
  97915. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97916. * @param engine defines the rendering engine
  97917. * @param camera defines the source camera
  97918. * @param size This parameter can be set to a single number or to an object with the
  97919. * following (optional) properties: precision, width, height. If a single number is passed,
  97920. * it will be used for both width and height. If an object is passed, the screenshot size
  97921. * will be derived from the parameters. The precision property is a multiplier allowing
  97922. * rendering at a higher or lower resolution
  97923. * @param successCallback defines the callback receives a single parameter which contains the
  97924. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97925. * src parameter of an <img> to display it
  97926. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97927. * Check your browser for supported MIME types
  97928. */
  97929. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97930. /**
  97931. * Captures a screenshot of the current rendering
  97932. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97933. * @param engine defines the rendering engine
  97934. * @param camera defines the source camera
  97935. * @param size This parameter can be set to a single number or to an object with the
  97936. * following (optional) properties: precision, width, height. If a single number is passed,
  97937. * it will be used for both width and height. If an object is passed, the screenshot size
  97938. * will be derived from the parameters. The precision property is a multiplier allowing
  97939. * rendering at a higher or lower resolution
  97940. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97941. * Check your browser for supported MIME types
  97942. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97943. * to the src parameter of an <img> to display it
  97944. */
  97945. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97946. /**
  97947. * Generates an image screenshot from the specified camera.
  97948. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97949. * @param engine The engine to use for rendering
  97950. * @param camera The camera to use for rendering
  97951. * @param size This parameter can be set to a single number or to an object with the
  97952. * following (optional) properties: precision, width, height. If a single number is passed,
  97953. * it will be used for both width and height. If an object is passed, the screenshot size
  97954. * will be derived from the parameters. The precision property is a multiplier allowing
  97955. * rendering at a higher or lower resolution
  97956. * @param successCallback The callback receives a single parameter which contains the
  97957. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97958. * src parameter of an <img> to display it
  97959. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97960. * Check your browser for supported MIME types
  97961. * @param samples Texture samples (default: 1)
  97962. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97963. * @param fileName A name for for the downloaded file.
  97964. */
  97965. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  97966. /**
  97967. * Generates an image screenshot from the specified camera.
  97968. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97969. * @param engine The engine to use for rendering
  97970. * @param camera The camera to use for rendering
  97971. * @param size This parameter can be set to a single number or to an object with the
  97972. * following (optional) properties: precision, width, height. If a single number is passed,
  97973. * it will be used for both width and height. If an object is passed, the screenshot size
  97974. * will be derived from the parameters. The precision property is a multiplier allowing
  97975. * rendering at a higher or lower resolution
  97976. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97977. * Check your browser for supported MIME types
  97978. * @param samples Texture samples (default: 1)
  97979. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97980. * @param fileName A name for for the downloaded file.
  97981. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97982. * to the src parameter of an <img> to display it
  97983. */
  97984. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  97985. /**
  97986. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97987. * Be aware Math.random() could cause collisions, but:
  97988. * "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"
  97989. * @returns a pseudo random id
  97990. */
  97991. static RandomId(): string;
  97992. /**
  97993. * Test if the given uri is a base64 string
  97994. * @param uri The uri to test
  97995. * @return True if the uri is a base64 string or false otherwise
  97996. */
  97997. static IsBase64(uri: string): boolean;
  97998. /**
  97999. * Decode the given base64 uri.
  98000. * @param uri The uri to decode
  98001. * @return The decoded base64 data.
  98002. */
  98003. static DecodeBase64(uri: string): ArrayBuffer;
  98004. /**
  98005. * Gets the absolute url.
  98006. * @param url the input url
  98007. * @return the absolute url
  98008. */
  98009. static GetAbsoluteUrl(url: string): string;
  98010. /**
  98011. * No log
  98012. */
  98013. static readonly NoneLogLevel: number;
  98014. /**
  98015. * Only message logs
  98016. */
  98017. static readonly MessageLogLevel: number;
  98018. /**
  98019. * Only warning logs
  98020. */
  98021. static readonly WarningLogLevel: number;
  98022. /**
  98023. * Only error logs
  98024. */
  98025. static readonly ErrorLogLevel: number;
  98026. /**
  98027. * All logs
  98028. */
  98029. static readonly AllLogLevel: number;
  98030. /**
  98031. * Gets a value indicating the number of loading errors
  98032. * @ignorenaming
  98033. */
  98034. static readonly errorsCount: number;
  98035. /**
  98036. * Callback called when a new log is added
  98037. */
  98038. static OnNewCacheEntry: (entry: string) => void;
  98039. /**
  98040. * Log a message to the console
  98041. * @param message defines the message to log
  98042. */
  98043. static Log(message: string): void;
  98044. /**
  98045. * Write a warning message to the console
  98046. * @param message defines the message to log
  98047. */
  98048. static Warn(message: string): void;
  98049. /**
  98050. * Write an error message to the console
  98051. * @param message defines the message to log
  98052. */
  98053. static Error(message: string): void;
  98054. /**
  98055. * Gets current log cache (list of logs)
  98056. */
  98057. static readonly LogCache: string;
  98058. /**
  98059. * Clears the log cache
  98060. */
  98061. static ClearLogCache(): void;
  98062. /**
  98063. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98064. */
  98065. static LogLevels: number;
  98066. /**
  98067. * Checks if the window object exists
  98068. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98069. */
  98070. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98071. /**
  98072. * No performance log
  98073. */
  98074. static readonly PerformanceNoneLogLevel: number;
  98075. /**
  98076. * Use user marks to log performance
  98077. */
  98078. static readonly PerformanceUserMarkLogLevel: number;
  98079. /**
  98080. * Log performance to the console
  98081. */
  98082. static readonly PerformanceConsoleLogLevel: number;
  98083. private static _performance;
  98084. /**
  98085. * Sets the current performance log level
  98086. */
  98087. static PerformanceLogLevel: number;
  98088. private static _StartPerformanceCounterDisabled;
  98089. private static _EndPerformanceCounterDisabled;
  98090. private static _StartUserMark;
  98091. private static _EndUserMark;
  98092. private static _StartPerformanceConsole;
  98093. private static _EndPerformanceConsole;
  98094. /**
  98095. * Starts a performance counter
  98096. */
  98097. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98098. /**
  98099. * Ends a specific performance coutner
  98100. */
  98101. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98102. /**
  98103. * Gets either window.performance.now() if supported or Date.now() else
  98104. */
  98105. static readonly Now: number;
  98106. /**
  98107. * This method will return the name of the class used to create the instance of the given object.
  98108. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98109. * @param object the object to get the class name from
  98110. * @param isType defines if the object is actually a type
  98111. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98112. */
  98113. static GetClassName(object: any, isType?: boolean): string;
  98114. /**
  98115. * Gets the first element of an array satisfying a given predicate
  98116. * @param array defines the array to browse
  98117. * @param predicate defines the predicate to use
  98118. * @returns null if not found or the element
  98119. */
  98120. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98121. /**
  98122. * This method will return the name of the full name of the class, including its owning module (if any).
  98123. * 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).
  98124. * @param object the object to get the class name from
  98125. * @param isType defines if the object is actually a type
  98126. * @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.
  98127. * @ignorenaming
  98128. */
  98129. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98130. /**
  98131. * Returns a promise that resolves after the given amount of time.
  98132. * @param delay Number of milliseconds to delay
  98133. * @returns Promise that resolves after the given amount of time
  98134. */
  98135. static DelayAsync(delay: number): Promise<void>;
  98136. }
  98137. /**
  98138. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98139. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98140. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98141. * @param name The name of the class, case should be preserved
  98142. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98143. */
  98144. export function className(name: string, module?: string): (target: Object) => void;
  98145. /**
  98146. * An implementation of a loop for asynchronous functions.
  98147. */
  98148. export class AsyncLoop {
  98149. /**
  98150. * Defines the number of iterations for the loop
  98151. */
  98152. iterations: number;
  98153. /**
  98154. * Defines the current index of the loop.
  98155. */
  98156. index: number;
  98157. private _done;
  98158. private _fn;
  98159. private _successCallback;
  98160. /**
  98161. * Constructor.
  98162. * @param iterations the number of iterations.
  98163. * @param func the function to run each iteration
  98164. * @param successCallback the callback that will be called upon succesful execution
  98165. * @param offset starting offset.
  98166. */
  98167. constructor(
  98168. /**
  98169. * Defines the number of iterations for the loop
  98170. */
  98171. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98172. /**
  98173. * Execute the next iteration. Must be called after the last iteration was finished.
  98174. */
  98175. executeNext(): void;
  98176. /**
  98177. * Break the loop and run the success callback.
  98178. */
  98179. breakLoop(): void;
  98180. /**
  98181. * Create and run an async loop.
  98182. * @param iterations the number of iterations.
  98183. * @param fn the function to run each iteration
  98184. * @param successCallback the callback that will be called upon succesful execution
  98185. * @param offset starting offset.
  98186. * @returns the created async loop object
  98187. */
  98188. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98189. /**
  98190. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98191. * @param iterations total number of iterations
  98192. * @param syncedIterations number of synchronous iterations in each async iteration.
  98193. * @param fn the function to call each iteration.
  98194. * @param callback a success call back that will be called when iterating stops.
  98195. * @param breakFunction a break condition (optional)
  98196. * @param timeout timeout settings for the setTimeout function. default - 0.
  98197. * @returns the created async loop object
  98198. */
  98199. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98200. }
  98201. }
  98202. declare module BABYLON {
  98203. /** @hidden */
  98204. export interface ICollisionCoordinator {
  98205. createCollider(): Collider;
  98206. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98207. init(scene: Scene): void;
  98208. }
  98209. /** @hidden */
  98210. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98211. private _scene;
  98212. private _scaledPosition;
  98213. private _scaledVelocity;
  98214. private _finalPosition;
  98215. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98216. createCollider(): Collider;
  98217. init(scene: Scene): void;
  98218. private _collideWithWorld;
  98219. }
  98220. }
  98221. declare module BABYLON {
  98222. /**
  98223. * Class used to manage all inputs for the scene.
  98224. */
  98225. export class InputManager {
  98226. /** The distance in pixel that you have to move to prevent some events */
  98227. static DragMovementThreshold: number;
  98228. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  98229. static LongPressDelay: number;
  98230. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  98231. static DoubleClickDelay: number;
  98232. /** If you need to check double click without raising a single click at first click, enable this flag */
  98233. static ExclusiveDoubleClickMode: boolean;
  98234. private _wheelEventName;
  98235. private _onPointerMove;
  98236. private _onPointerDown;
  98237. private _onPointerUp;
  98238. private _initClickEvent;
  98239. private _initActionManager;
  98240. private _delayedSimpleClick;
  98241. private _delayedSimpleClickTimeout;
  98242. private _previousDelayedSimpleClickTimeout;
  98243. private _meshPickProceed;
  98244. private _previousButtonPressed;
  98245. private _currentPickResult;
  98246. private _previousPickResult;
  98247. private _totalPointersPressed;
  98248. private _doubleClickOccured;
  98249. private _pointerOverMesh;
  98250. private _pickedDownMesh;
  98251. private _pickedUpMesh;
  98252. private _pointerX;
  98253. private _pointerY;
  98254. private _unTranslatedPointerX;
  98255. private _unTranslatedPointerY;
  98256. private _startingPointerPosition;
  98257. private _previousStartingPointerPosition;
  98258. private _startingPointerTime;
  98259. private _previousStartingPointerTime;
  98260. private _pointerCaptures;
  98261. private _onKeyDown;
  98262. private _onKeyUp;
  98263. private _onCanvasFocusObserver;
  98264. private _onCanvasBlurObserver;
  98265. private _scene;
  98266. /**
  98267. * Creates a new InputManager
  98268. * @param scene defines the hosting scene
  98269. */
  98270. constructor(scene: Scene);
  98271. /**
  98272. * Gets the mesh that is currently under the pointer
  98273. */
  98274. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98275. /**
  98276. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  98277. */
  98278. readonly unTranslatedPointer: Vector2;
  98279. /**
  98280. * Gets or sets the current on-screen X position of the pointer
  98281. */
  98282. pointerX: number;
  98283. /**
  98284. * Gets or sets the current on-screen Y position of the pointer
  98285. */
  98286. pointerY: number;
  98287. private _updatePointerPosition;
  98288. private _processPointerMove;
  98289. private _setRayOnPointerInfo;
  98290. private _checkPrePointerObservable;
  98291. /**
  98292. * Use this method to simulate a pointer move on a mesh
  98293. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98294. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98295. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98296. */
  98297. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98298. /**
  98299. * Use this method to simulate a pointer down on a mesh
  98300. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98301. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98302. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98303. */
  98304. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98305. private _processPointerDown;
  98306. /** @hidden */
  98307. _isPointerSwiping(): boolean;
  98308. /**
  98309. * Use this method to simulate a pointer up on a mesh
  98310. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98311. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98312. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98313. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98314. */
  98315. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  98316. private _processPointerUp;
  98317. /**
  98318. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98319. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98320. * @returns true if the pointer was captured
  98321. */
  98322. isPointerCaptured(pointerId?: number): boolean;
  98323. /**
  98324. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98325. * @param attachUp defines if you want to attach events to pointerup
  98326. * @param attachDown defines if you want to attach events to pointerdown
  98327. * @param attachMove defines if you want to attach events to pointermove
  98328. */
  98329. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98330. /**
  98331. * Detaches all event handlers
  98332. */
  98333. detachControl(): void;
  98334. /**
  98335. * Force the value of meshUnderPointer
  98336. * @param mesh defines the mesh to use
  98337. */
  98338. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98339. /**
  98340. * Gets the mesh under the pointer
  98341. * @returns a Mesh or null if no mesh is under the pointer
  98342. */
  98343. getPointerOverMesh(): Nullable<AbstractMesh>;
  98344. }
  98345. }
  98346. declare module BABYLON {
  98347. /**
  98348. * Helper class used to generate session unique ID
  98349. */
  98350. export class UniqueIdGenerator {
  98351. private static _UniqueIdCounter;
  98352. /**
  98353. * Gets an unique (relatively to the current scene) Id
  98354. */
  98355. static readonly UniqueId: number;
  98356. }
  98357. }
  98358. declare module BABYLON {
  98359. /**
  98360. * This class defines the direct association between an animation and a target
  98361. */
  98362. export class TargetedAnimation {
  98363. /**
  98364. * Animation to perform
  98365. */
  98366. animation: Animation;
  98367. /**
  98368. * Target to animate
  98369. */
  98370. target: any;
  98371. /**
  98372. * Serialize the object
  98373. * @returns the JSON object representing the current entity
  98374. */
  98375. serialize(): any;
  98376. }
  98377. /**
  98378. * Use this class to create coordinated animations on multiple targets
  98379. */
  98380. export class AnimationGroup implements IDisposable {
  98381. /** The name of the animation group */
  98382. name: string;
  98383. private _scene;
  98384. private _targetedAnimations;
  98385. private _animatables;
  98386. private _from;
  98387. private _to;
  98388. private _isStarted;
  98389. private _isPaused;
  98390. private _speedRatio;
  98391. private _loopAnimation;
  98392. /**
  98393. * Gets or sets the unique id of the node
  98394. */
  98395. uniqueId: number;
  98396. /**
  98397. * This observable will notify when one animation have ended
  98398. */
  98399. onAnimationEndObservable: Observable<TargetedAnimation>;
  98400. /**
  98401. * Observer raised when one animation loops
  98402. */
  98403. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98404. /**
  98405. * This observable will notify when all animations have ended.
  98406. */
  98407. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98408. /**
  98409. * This observable will notify when all animations have paused.
  98410. */
  98411. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98412. /**
  98413. * This observable will notify when all animations are playing.
  98414. */
  98415. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98416. /**
  98417. * Gets the first frame
  98418. */
  98419. readonly from: number;
  98420. /**
  98421. * Gets the last frame
  98422. */
  98423. readonly to: number;
  98424. /**
  98425. * Define if the animations are started
  98426. */
  98427. readonly isStarted: boolean;
  98428. /**
  98429. * Gets a value indicating that the current group is playing
  98430. */
  98431. readonly isPlaying: boolean;
  98432. /**
  98433. * Gets or sets the speed ratio to use for all animations
  98434. */
  98435. /**
  98436. * Gets or sets the speed ratio to use for all animations
  98437. */
  98438. speedRatio: number;
  98439. /**
  98440. * Gets or sets if all animations should loop or not
  98441. */
  98442. loopAnimation: boolean;
  98443. /**
  98444. * Gets the targeted animations for this animation group
  98445. */
  98446. readonly targetedAnimations: Array<TargetedAnimation>;
  98447. /**
  98448. * returning the list of animatables controlled by this animation group.
  98449. */
  98450. readonly animatables: Array<Animatable>;
  98451. /**
  98452. * Instantiates a new Animation Group.
  98453. * This helps managing several animations at once.
  98454. * @see http://doc.babylonjs.com/how_to/group
  98455. * @param name Defines the name of the group
  98456. * @param scene Defines the scene the group belongs to
  98457. */
  98458. constructor(
  98459. /** The name of the animation group */
  98460. name: string, scene?: Nullable<Scene>);
  98461. /**
  98462. * Add an animation (with its target) in the group
  98463. * @param animation defines the animation we want to add
  98464. * @param target defines the target of the animation
  98465. * @returns the TargetedAnimation object
  98466. */
  98467. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98468. /**
  98469. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98470. * It can add constant keys at begin or end
  98471. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98472. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98473. * @returns the animation group
  98474. */
  98475. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98476. /**
  98477. * Start all animations on given targets
  98478. * @param loop defines if animations must loop
  98479. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98480. * @param from defines the from key (optional)
  98481. * @param to defines the to key (optional)
  98482. * @returns the current animation group
  98483. */
  98484. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98485. /**
  98486. * Pause all animations
  98487. * @returns the animation group
  98488. */
  98489. pause(): AnimationGroup;
  98490. /**
  98491. * Play all animations to initial state
  98492. * This function will start() the animations if they were not started or will restart() them if they were paused
  98493. * @param loop defines if animations must loop
  98494. * @returns the animation group
  98495. */
  98496. play(loop?: boolean): AnimationGroup;
  98497. /**
  98498. * Reset all animations to initial state
  98499. * @returns the animation group
  98500. */
  98501. reset(): AnimationGroup;
  98502. /**
  98503. * Restart animations from key 0
  98504. * @returns the animation group
  98505. */
  98506. restart(): AnimationGroup;
  98507. /**
  98508. * Stop all animations
  98509. * @returns the animation group
  98510. */
  98511. stop(): AnimationGroup;
  98512. /**
  98513. * Set animation weight for all animatables
  98514. * @param weight defines the weight to use
  98515. * @return the animationGroup
  98516. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98517. */
  98518. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98519. /**
  98520. * Synchronize and normalize all animatables with a source animatable
  98521. * @param root defines the root animatable to synchronize with
  98522. * @return the animationGroup
  98523. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98524. */
  98525. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98526. /**
  98527. * Goes to a specific frame in this animation group
  98528. * @param frame the frame number to go to
  98529. * @return the animationGroup
  98530. */
  98531. goToFrame(frame: number): AnimationGroup;
  98532. /**
  98533. * Dispose all associated resources
  98534. */
  98535. dispose(): void;
  98536. private _checkAnimationGroupEnded;
  98537. /**
  98538. * Clone the current animation group and returns a copy
  98539. * @param newName defines the name of the new group
  98540. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98541. * @returns the new aniamtion group
  98542. */
  98543. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98544. /**
  98545. * Serializes the animationGroup to an object
  98546. * @returns Serialized object
  98547. */
  98548. serialize(): any;
  98549. /**
  98550. * Returns a new AnimationGroup object parsed from the source provided.
  98551. * @param parsedAnimationGroup defines the source
  98552. * @param scene defines the scene that will receive the animationGroup
  98553. * @returns a new AnimationGroup
  98554. */
  98555. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98556. /**
  98557. * Returns the string "AnimationGroup"
  98558. * @returns "AnimationGroup"
  98559. */
  98560. getClassName(): string;
  98561. /**
  98562. * Creates a detailled string about the object
  98563. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98564. * @returns a string representing the object
  98565. */
  98566. toString(fullDetails?: boolean): string;
  98567. }
  98568. }
  98569. declare module BABYLON {
  98570. /**
  98571. * Define an interface for all classes that will hold resources
  98572. */
  98573. export interface IDisposable {
  98574. /**
  98575. * Releases all held resources
  98576. */
  98577. dispose(): void;
  98578. }
  98579. /** Interface defining initialization parameters for Scene class */
  98580. export interface SceneOptions {
  98581. /**
  98582. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98583. * It will improve performance when the number of geometries becomes important.
  98584. */
  98585. useGeometryUniqueIdsMap?: boolean;
  98586. /**
  98587. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98588. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98589. */
  98590. useMaterialMeshMap?: boolean;
  98591. /**
  98592. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98593. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98594. */
  98595. useClonedMeshhMap?: boolean;
  98596. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98597. virtual?: boolean;
  98598. }
  98599. /**
  98600. * Represents a scene to be rendered by the engine.
  98601. * @see http://doc.babylonjs.com/features/scene
  98602. */
  98603. export class Scene extends AbstractScene implements IAnimatable {
  98604. /** The fog is deactivated */
  98605. static readonly FOGMODE_NONE: number;
  98606. /** The fog density is following an exponential function */
  98607. static readonly FOGMODE_EXP: number;
  98608. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98609. static readonly FOGMODE_EXP2: number;
  98610. /** The fog density is following a linear function. */
  98611. static readonly FOGMODE_LINEAR: number;
  98612. /**
  98613. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98614. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98615. */
  98616. static MinDeltaTime: number;
  98617. /**
  98618. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98619. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98620. */
  98621. static MaxDeltaTime: number;
  98622. /**
  98623. * Factory used to create the default material.
  98624. * @param name The name of the material to create
  98625. * @param scene The scene to create the material for
  98626. * @returns The default material
  98627. */
  98628. static DefaultMaterialFactory(scene: Scene): Material;
  98629. /**
  98630. * Factory used to create the a collision coordinator.
  98631. * @returns The collision coordinator
  98632. */
  98633. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98634. /** @hidden */
  98635. _inputManager: InputManager;
  98636. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98637. cameraToUseForPointers: Nullable<Camera>;
  98638. /** @hidden */
  98639. readonly _isScene: boolean;
  98640. /**
  98641. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98642. */
  98643. autoClear: boolean;
  98644. /**
  98645. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98646. */
  98647. autoClearDepthAndStencil: boolean;
  98648. /**
  98649. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98650. */
  98651. clearColor: Color4;
  98652. /**
  98653. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98654. */
  98655. ambientColor: Color3;
  98656. /**
  98657. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98658. * It should only be one of the following (if not the default embedded one):
  98659. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98660. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98661. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98662. * The material properties need to be setup according to the type of texture in use.
  98663. */
  98664. environmentBRDFTexture: BaseTexture;
  98665. /** @hidden */
  98666. protected _environmentTexture: Nullable<BaseTexture>;
  98667. /**
  98668. * Texture used in all pbr material as the reflection texture.
  98669. * As in the majority of the scene they are the same (exception for multi room and so on),
  98670. * this is easier to reference from here than from all the materials.
  98671. */
  98672. /**
  98673. * Texture used in all pbr material as the reflection texture.
  98674. * As in the majority of the scene they are the same (exception for multi room and so on),
  98675. * this is easier to set here than in all the materials.
  98676. */
  98677. environmentTexture: Nullable<BaseTexture>;
  98678. /** @hidden */
  98679. protected _environmentIntensity: number;
  98680. /**
  98681. * Intensity of the environment in all pbr material.
  98682. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98683. * As in the majority of the scene they are the same (exception for multi room and so on),
  98684. * this is easier to reference from here than from all the materials.
  98685. */
  98686. /**
  98687. * Intensity of the environment in all pbr material.
  98688. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98689. * As in the majority of the scene they are the same (exception for multi room and so on),
  98690. * this is easier to set here than in all the materials.
  98691. */
  98692. environmentIntensity: number;
  98693. /** @hidden */
  98694. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98695. /**
  98696. * Default image processing configuration used either in the rendering
  98697. * Forward main pass or through the imageProcessingPostProcess if present.
  98698. * As in the majority of the scene they are the same (exception for multi camera),
  98699. * this is easier to reference from here than from all the materials and post process.
  98700. *
  98701. * No setter as we it is a shared configuration, you can set the values instead.
  98702. */
  98703. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98704. private _forceWireframe;
  98705. /**
  98706. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98707. */
  98708. forceWireframe: boolean;
  98709. private _forcePointsCloud;
  98710. /**
  98711. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98712. */
  98713. forcePointsCloud: boolean;
  98714. /**
  98715. * Gets or sets the active clipplane 1
  98716. */
  98717. clipPlane: Nullable<Plane>;
  98718. /**
  98719. * Gets or sets the active clipplane 2
  98720. */
  98721. clipPlane2: Nullable<Plane>;
  98722. /**
  98723. * Gets or sets the active clipplane 3
  98724. */
  98725. clipPlane3: Nullable<Plane>;
  98726. /**
  98727. * Gets or sets the active clipplane 4
  98728. */
  98729. clipPlane4: Nullable<Plane>;
  98730. /**
  98731. * Gets or sets a boolean indicating if animations are enabled
  98732. */
  98733. animationsEnabled: boolean;
  98734. private _animationPropertiesOverride;
  98735. /**
  98736. * Gets or sets the animation properties override
  98737. */
  98738. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98739. /**
  98740. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98741. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98742. */
  98743. useConstantAnimationDeltaTime: boolean;
  98744. /**
  98745. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98746. * Please note that it requires to run a ray cast through the scene on every frame
  98747. */
  98748. constantlyUpdateMeshUnderPointer: boolean;
  98749. /**
  98750. * Defines the HTML cursor to use when hovering over interactive elements
  98751. */
  98752. hoverCursor: string;
  98753. /**
  98754. * Defines the HTML default cursor to use (empty by default)
  98755. */
  98756. defaultCursor: string;
  98757. /**
  98758. * This is used to call preventDefault() on pointer down
  98759. * in order to block unwanted artifacts like system double clicks
  98760. */
  98761. preventDefaultOnPointerDown: boolean;
  98762. /**
  98763. * This is used to call preventDefault() on pointer up
  98764. * in order to block unwanted artifacts like system double clicks
  98765. */
  98766. preventDefaultOnPointerUp: boolean;
  98767. /**
  98768. * Gets or sets user defined metadata
  98769. */
  98770. metadata: any;
  98771. /**
  98772. * For internal use only. Please do not use.
  98773. */
  98774. reservedDataStore: any;
  98775. /**
  98776. * Gets the name of the plugin used to load this scene (null by default)
  98777. */
  98778. loadingPluginName: string;
  98779. /**
  98780. * Use this array to add regular expressions used to disable offline support for specific urls
  98781. */
  98782. disableOfflineSupportExceptionRules: RegExp[];
  98783. /**
  98784. * An event triggered when the scene is disposed.
  98785. */
  98786. onDisposeObservable: Observable<Scene>;
  98787. private _onDisposeObserver;
  98788. /** Sets a function to be executed when this scene is disposed. */
  98789. onDispose: () => void;
  98790. /**
  98791. * An event triggered before rendering the scene (right after animations and physics)
  98792. */
  98793. onBeforeRenderObservable: Observable<Scene>;
  98794. private _onBeforeRenderObserver;
  98795. /** Sets a function to be executed before rendering this scene */
  98796. beforeRender: Nullable<() => void>;
  98797. /**
  98798. * An event triggered after rendering the scene
  98799. */
  98800. onAfterRenderObservable: Observable<Scene>;
  98801. /**
  98802. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98803. */
  98804. onAfterRenderCameraObservable: Observable<Camera>;
  98805. private _onAfterRenderObserver;
  98806. /** Sets a function to be executed after rendering this scene */
  98807. afterRender: Nullable<() => void>;
  98808. /**
  98809. * An event triggered before animating the scene
  98810. */
  98811. onBeforeAnimationsObservable: Observable<Scene>;
  98812. /**
  98813. * An event triggered after animations processing
  98814. */
  98815. onAfterAnimationsObservable: Observable<Scene>;
  98816. /**
  98817. * An event triggered before draw calls are ready to be sent
  98818. */
  98819. onBeforeDrawPhaseObservable: Observable<Scene>;
  98820. /**
  98821. * An event triggered after draw calls have been sent
  98822. */
  98823. onAfterDrawPhaseObservable: Observable<Scene>;
  98824. /**
  98825. * An event triggered when the scene is ready
  98826. */
  98827. onReadyObservable: Observable<Scene>;
  98828. /**
  98829. * An event triggered before rendering a camera
  98830. */
  98831. onBeforeCameraRenderObservable: Observable<Camera>;
  98832. private _onBeforeCameraRenderObserver;
  98833. /** Sets a function to be executed before rendering a camera*/
  98834. beforeCameraRender: () => void;
  98835. /**
  98836. * An event triggered after rendering a camera
  98837. */
  98838. onAfterCameraRenderObservable: Observable<Camera>;
  98839. private _onAfterCameraRenderObserver;
  98840. /** Sets a function to be executed after rendering a camera*/
  98841. afterCameraRender: () => void;
  98842. /**
  98843. * An event triggered when active meshes evaluation is about to start
  98844. */
  98845. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98846. /**
  98847. * An event triggered when active meshes evaluation is done
  98848. */
  98849. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98850. /**
  98851. * An event triggered when particles rendering is about to start
  98852. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98853. */
  98854. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98855. /**
  98856. * An event triggered when particles rendering is done
  98857. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98858. */
  98859. onAfterParticlesRenderingObservable: Observable<Scene>;
  98860. /**
  98861. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  98862. */
  98863. onDataLoadedObservable: Observable<Scene>;
  98864. /**
  98865. * An event triggered when a camera is created
  98866. */
  98867. onNewCameraAddedObservable: Observable<Camera>;
  98868. /**
  98869. * An event triggered when a camera is removed
  98870. */
  98871. onCameraRemovedObservable: Observable<Camera>;
  98872. /**
  98873. * An event triggered when a light is created
  98874. */
  98875. onNewLightAddedObservable: Observable<Light>;
  98876. /**
  98877. * An event triggered when a light is removed
  98878. */
  98879. onLightRemovedObservable: Observable<Light>;
  98880. /**
  98881. * An event triggered when a geometry is created
  98882. */
  98883. onNewGeometryAddedObservable: Observable<Geometry>;
  98884. /**
  98885. * An event triggered when a geometry is removed
  98886. */
  98887. onGeometryRemovedObservable: Observable<Geometry>;
  98888. /**
  98889. * An event triggered when a transform node is created
  98890. */
  98891. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  98892. /**
  98893. * An event triggered when a transform node is removed
  98894. */
  98895. onTransformNodeRemovedObservable: Observable<TransformNode>;
  98896. /**
  98897. * An event triggered when a mesh is created
  98898. */
  98899. onNewMeshAddedObservable: Observable<AbstractMesh>;
  98900. /**
  98901. * An event triggered when a mesh is removed
  98902. */
  98903. onMeshRemovedObservable: Observable<AbstractMesh>;
  98904. /**
  98905. * An event triggered when a skeleton is created
  98906. */
  98907. onNewSkeletonAddedObservable: Observable<Skeleton>;
  98908. /**
  98909. * An event triggered when a skeleton is removed
  98910. */
  98911. onSkeletonRemovedObservable: Observable<Skeleton>;
  98912. /**
  98913. * An event triggered when a material is created
  98914. */
  98915. onNewMaterialAddedObservable: Observable<Material>;
  98916. /**
  98917. * An event triggered when a material is removed
  98918. */
  98919. onMaterialRemovedObservable: Observable<Material>;
  98920. /**
  98921. * An event triggered when a texture is created
  98922. */
  98923. onNewTextureAddedObservable: Observable<BaseTexture>;
  98924. /**
  98925. * An event triggered when a texture is removed
  98926. */
  98927. onTextureRemovedObservable: Observable<BaseTexture>;
  98928. /**
  98929. * An event triggered when render targets are about to be rendered
  98930. * Can happen multiple times per frame.
  98931. */
  98932. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  98933. /**
  98934. * An event triggered when render targets were rendered.
  98935. * Can happen multiple times per frame.
  98936. */
  98937. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  98938. /**
  98939. * An event triggered before calculating deterministic simulation step
  98940. */
  98941. onBeforeStepObservable: Observable<Scene>;
  98942. /**
  98943. * An event triggered after calculating deterministic simulation step
  98944. */
  98945. onAfterStepObservable: Observable<Scene>;
  98946. /**
  98947. * An event triggered when the activeCamera property is updated
  98948. */
  98949. onActiveCameraChanged: Observable<Scene>;
  98950. /**
  98951. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  98952. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98953. * 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)
  98954. */
  98955. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98956. /**
  98957. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  98958. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98959. * 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)
  98960. */
  98961. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98962. /**
  98963. * This Observable will when a mesh has been imported into the scene.
  98964. */
  98965. onMeshImportedObservable: Observable<AbstractMesh>;
  98966. /**
  98967. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  98968. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  98969. */
  98970. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  98971. /** @hidden */
  98972. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  98973. /**
  98974. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  98975. */
  98976. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  98977. /**
  98978. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  98979. */
  98980. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  98981. /**
  98982. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  98983. */
  98984. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  98985. /** Callback called when a pointer move is detected */
  98986. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98987. /** Callback called when a pointer down is detected */
  98988. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98989. /** Callback called when a pointer up is detected */
  98990. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  98991. /** Callback called when a pointer pick is detected */
  98992. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  98993. /**
  98994. * 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).
  98995. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  98996. */
  98997. onPrePointerObservable: Observable<PointerInfoPre>;
  98998. /**
  98999. * Observable event triggered each time an input event is received from the rendering canvas
  99000. */
  99001. onPointerObservable: Observable<PointerInfo>;
  99002. /**
  99003. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  99004. */
  99005. readonly unTranslatedPointer: Vector2;
  99006. /**
  99007. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99008. */
  99009. static DragMovementThreshold: number;
  99010. /**
  99011. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99012. */
  99013. static LongPressDelay: number;
  99014. /**
  99015. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99016. */
  99017. static DoubleClickDelay: number;
  99018. /** If you need to check double click without raising a single click at first click, enable this flag */
  99019. static ExclusiveDoubleClickMode: boolean;
  99020. /** @hidden */
  99021. _mirroredCameraPosition: Nullable<Vector3>;
  99022. /**
  99023. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99024. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99025. */
  99026. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99027. /**
  99028. * Observable event triggered each time an keyboard event is received from the hosting window
  99029. */
  99030. onKeyboardObservable: Observable<KeyboardInfo>;
  99031. private _useRightHandedSystem;
  99032. /**
  99033. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99034. */
  99035. useRightHandedSystem: boolean;
  99036. private _timeAccumulator;
  99037. private _currentStepId;
  99038. private _currentInternalStep;
  99039. /**
  99040. * Sets the step Id used by deterministic lock step
  99041. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99042. * @param newStepId defines the step Id
  99043. */
  99044. setStepId(newStepId: number): void;
  99045. /**
  99046. * Gets the step Id used by deterministic lock step
  99047. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99048. * @returns the step Id
  99049. */
  99050. getStepId(): number;
  99051. /**
  99052. * Gets the internal step used by deterministic lock step
  99053. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99054. * @returns the internal step
  99055. */
  99056. getInternalStep(): number;
  99057. private _fogEnabled;
  99058. /**
  99059. * Gets or sets a boolean indicating if fog is enabled on this scene
  99060. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99061. * (Default is true)
  99062. */
  99063. fogEnabled: boolean;
  99064. private _fogMode;
  99065. /**
  99066. * Gets or sets the fog mode to use
  99067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99068. * | mode | value |
  99069. * | --- | --- |
  99070. * | FOGMODE_NONE | 0 |
  99071. * | FOGMODE_EXP | 1 |
  99072. * | FOGMODE_EXP2 | 2 |
  99073. * | FOGMODE_LINEAR | 3 |
  99074. */
  99075. fogMode: number;
  99076. /**
  99077. * Gets or sets the fog color to use
  99078. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99079. * (Default is Color3(0.2, 0.2, 0.3))
  99080. */
  99081. fogColor: Color3;
  99082. /**
  99083. * Gets or sets the fog density to use
  99084. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99085. * (Default is 0.1)
  99086. */
  99087. fogDensity: number;
  99088. /**
  99089. * Gets or sets the fog start distance to use
  99090. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99091. * (Default is 0)
  99092. */
  99093. fogStart: number;
  99094. /**
  99095. * Gets or sets the fog end distance to use
  99096. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99097. * (Default is 1000)
  99098. */
  99099. fogEnd: number;
  99100. private _shadowsEnabled;
  99101. /**
  99102. * Gets or sets a boolean indicating if shadows are enabled on this scene
  99103. */
  99104. shadowsEnabled: boolean;
  99105. private _lightsEnabled;
  99106. /**
  99107. * Gets or sets a boolean indicating if lights are enabled on this scene
  99108. */
  99109. lightsEnabled: boolean;
  99110. /** All of the active cameras added to this scene. */
  99111. activeCameras: Camera[];
  99112. /** @hidden */
  99113. _activeCamera: Nullable<Camera>;
  99114. /** Gets or sets the current active camera */
  99115. activeCamera: Nullable<Camera>;
  99116. private _defaultMaterial;
  99117. /** The default material used on meshes when no material is affected */
  99118. /** The default material used on meshes when no material is affected */
  99119. defaultMaterial: Material;
  99120. private _texturesEnabled;
  99121. /**
  99122. * Gets or sets a boolean indicating if textures are enabled on this scene
  99123. */
  99124. texturesEnabled: boolean;
  99125. /**
  99126. * Gets or sets a boolean indicating if particles are enabled on this scene
  99127. */
  99128. particlesEnabled: boolean;
  99129. /**
  99130. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99131. */
  99132. spritesEnabled: boolean;
  99133. private _skeletonsEnabled;
  99134. /**
  99135. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99136. */
  99137. skeletonsEnabled: boolean;
  99138. /**
  99139. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99140. */
  99141. lensFlaresEnabled: boolean;
  99142. /**
  99143. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99145. */
  99146. collisionsEnabled: boolean;
  99147. private _collisionCoordinator;
  99148. /** @hidden */
  99149. readonly collisionCoordinator: ICollisionCoordinator;
  99150. /**
  99151. * Defines the gravity applied to this scene (used only for collisions)
  99152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99153. */
  99154. gravity: Vector3;
  99155. /**
  99156. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99157. */
  99158. postProcessesEnabled: boolean;
  99159. /**
  99160. * The list of postprocesses added to the scene
  99161. */
  99162. postProcesses: PostProcess[];
  99163. /**
  99164. * Gets the current postprocess manager
  99165. */
  99166. postProcessManager: PostProcessManager;
  99167. /**
  99168. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99169. */
  99170. renderTargetsEnabled: boolean;
  99171. /**
  99172. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99173. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99174. */
  99175. dumpNextRenderTargets: boolean;
  99176. /**
  99177. * The list of user defined render targets added to the scene
  99178. */
  99179. customRenderTargets: RenderTargetTexture[];
  99180. /**
  99181. * Defines if texture loading must be delayed
  99182. * If true, textures will only be loaded when they need to be rendered
  99183. */
  99184. useDelayedTextureLoading: boolean;
  99185. /**
  99186. * Gets the list of meshes imported to the scene through SceneLoader
  99187. */
  99188. importedMeshesFiles: String[];
  99189. /**
  99190. * Gets or sets a boolean indicating if probes are enabled on this scene
  99191. */
  99192. probesEnabled: boolean;
  99193. /**
  99194. * Gets or sets the current offline provider to use to store scene data
  99195. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99196. */
  99197. offlineProvider: IOfflineProvider;
  99198. /**
  99199. * Gets or sets the action manager associated with the scene
  99200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99201. */
  99202. actionManager: AbstractActionManager;
  99203. private _meshesForIntersections;
  99204. /**
  99205. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99206. */
  99207. proceduralTexturesEnabled: boolean;
  99208. private _engine;
  99209. private _totalVertices;
  99210. /** @hidden */
  99211. _activeIndices: PerfCounter;
  99212. /** @hidden */
  99213. _activeParticles: PerfCounter;
  99214. /** @hidden */
  99215. _activeBones: PerfCounter;
  99216. private _animationRatio;
  99217. /** @hidden */
  99218. _animationTimeLast: number;
  99219. /** @hidden */
  99220. _animationTime: number;
  99221. /**
  99222. * Gets or sets a general scale for animation speed
  99223. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  99224. */
  99225. animationTimeScale: number;
  99226. /** @hidden */
  99227. _cachedMaterial: Nullable<Material>;
  99228. /** @hidden */
  99229. _cachedEffect: Nullable<Effect>;
  99230. /** @hidden */
  99231. _cachedVisibility: Nullable<number>;
  99232. private _renderId;
  99233. private _frameId;
  99234. private _executeWhenReadyTimeoutId;
  99235. private _intermediateRendering;
  99236. private _viewUpdateFlag;
  99237. private _projectionUpdateFlag;
  99238. /** @hidden */
  99239. _toBeDisposed: Nullable<IDisposable>[];
  99240. private _activeRequests;
  99241. /** @hidden */
  99242. _pendingData: any[];
  99243. private _isDisposed;
  99244. /**
  99245. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  99246. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  99247. */
  99248. dispatchAllSubMeshesOfActiveMeshes: boolean;
  99249. private _activeMeshes;
  99250. private _processedMaterials;
  99251. private _renderTargets;
  99252. /** @hidden */
  99253. _activeParticleSystems: SmartArray<IParticleSystem>;
  99254. private _activeSkeletons;
  99255. private _softwareSkinnedMeshes;
  99256. private _renderingManager;
  99257. /** @hidden */
  99258. _activeAnimatables: Animatable[];
  99259. private _transformMatrix;
  99260. private _sceneUbo;
  99261. /** @hidden */
  99262. _viewMatrix: Matrix;
  99263. private _projectionMatrix;
  99264. /** @hidden */
  99265. _forcedViewPosition: Nullable<Vector3>;
  99266. /** @hidden */
  99267. _frustumPlanes: Plane[];
  99268. /**
  99269. * Gets the list of frustum planes (built from the active camera)
  99270. */
  99271. readonly frustumPlanes: Plane[];
  99272. /**
  99273. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  99274. * This is useful if there are more lights that the maximum simulteanous authorized
  99275. */
  99276. requireLightSorting: boolean;
  99277. /** @hidden */
  99278. readonly useMaterialMeshMap: boolean;
  99279. /** @hidden */
  99280. readonly useClonedMeshhMap: boolean;
  99281. private _externalData;
  99282. private _uid;
  99283. /**
  99284. * @hidden
  99285. * Backing store of defined scene components.
  99286. */
  99287. _components: ISceneComponent[];
  99288. /**
  99289. * @hidden
  99290. * Backing store of defined scene components.
  99291. */
  99292. _serializableComponents: ISceneSerializableComponent[];
  99293. /**
  99294. * List of components to register on the next registration step.
  99295. */
  99296. private _transientComponents;
  99297. /**
  99298. * Registers the transient components if needed.
  99299. */
  99300. private _registerTransientComponents;
  99301. /**
  99302. * @hidden
  99303. * Add a component to the scene.
  99304. * Note that the ccomponent could be registered on th next frame if this is called after
  99305. * the register component stage.
  99306. * @param component Defines the component to add to the scene
  99307. */
  99308. _addComponent(component: ISceneComponent): void;
  99309. /**
  99310. * @hidden
  99311. * Gets a component from the scene.
  99312. * @param name defines the name of the component to retrieve
  99313. * @returns the component or null if not present
  99314. */
  99315. _getComponent(name: string): Nullable<ISceneComponent>;
  99316. /**
  99317. * @hidden
  99318. * Defines the actions happening before camera updates.
  99319. */
  99320. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  99321. /**
  99322. * @hidden
  99323. * Defines the actions happening before clear the canvas.
  99324. */
  99325. _beforeClearStage: Stage<SimpleStageAction>;
  99326. /**
  99327. * @hidden
  99328. * Defines the actions when collecting render targets for the frame.
  99329. */
  99330. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99331. /**
  99332. * @hidden
  99333. * Defines the actions happening for one camera in the frame.
  99334. */
  99335. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99336. /**
  99337. * @hidden
  99338. * Defines the actions happening during the per mesh ready checks.
  99339. */
  99340. _isReadyForMeshStage: Stage<MeshStageAction>;
  99341. /**
  99342. * @hidden
  99343. * Defines the actions happening before evaluate active mesh checks.
  99344. */
  99345. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  99346. /**
  99347. * @hidden
  99348. * Defines the actions happening during the evaluate sub mesh checks.
  99349. */
  99350. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  99351. /**
  99352. * @hidden
  99353. * Defines the actions happening during the active mesh stage.
  99354. */
  99355. _activeMeshStage: Stage<ActiveMeshStageAction>;
  99356. /**
  99357. * @hidden
  99358. * Defines the actions happening during the per camera render target step.
  99359. */
  99360. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  99361. /**
  99362. * @hidden
  99363. * Defines the actions happening just before the active camera is drawing.
  99364. */
  99365. _beforeCameraDrawStage: Stage<CameraStageAction>;
  99366. /**
  99367. * @hidden
  99368. * Defines the actions happening just before a render target is drawing.
  99369. */
  99370. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99371. /**
  99372. * @hidden
  99373. * Defines the actions happening just before a rendering group is drawing.
  99374. */
  99375. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99376. /**
  99377. * @hidden
  99378. * Defines the actions happening just before a mesh is drawing.
  99379. */
  99380. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99381. /**
  99382. * @hidden
  99383. * Defines the actions happening just after a mesh has been drawn.
  99384. */
  99385. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99386. /**
  99387. * @hidden
  99388. * Defines the actions happening just after a rendering group has been drawn.
  99389. */
  99390. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99391. /**
  99392. * @hidden
  99393. * Defines the actions happening just after the active camera has been drawn.
  99394. */
  99395. _afterCameraDrawStage: Stage<CameraStageAction>;
  99396. /**
  99397. * @hidden
  99398. * Defines the actions happening just after a render target has been drawn.
  99399. */
  99400. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99401. /**
  99402. * @hidden
  99403. * Defines the actions happening just after rendering all cameras and computing intersections.
  99404. */
  99405. _afterRenderStage: Stage<SimpleStageAction>;
  99406. /**
  99407. * @hidden
  99408. * Defines the actions happening when a pointer move event happens.
  99409. */
  99410. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99411. /**
  99412. * @hidden
  99413. * Defines the actions happening when a pointer down event happens.
  99414. */
  99415. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99416. /**
  99417. * @hidden
  99418. * Defines the actions happening when a pointer up event happens.
  99419. */
  99420. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99421. /**
  99422. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99423. */
  99424. private geometriesByUniqueId;
  99425. /**
  99426. * Creates a new Scene
  99427. * @param engine defines the engine to use to render this scene
  99428. * @param options defines the scene options
  99429. */
  99430. constructor(engine: Engine, options?: SceneOptions);
  99431. /**
  99432. * Gets a string idenfifying the name of the class
  99433. * @returns "Scene" string
  99434. */
  99435. getClassName(): string;
  99436. private _defaultMeshCandidates;
  99437. /**
  99438. * @hidden
  99439. */
  99440. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99441. private _defaultSubMeshCandidates;
  99442. /**
  99443. * @hidden
  99444. */
  99445. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99446. /**
  99447. * Sets the default candidate providers for the scene.
  99448. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99449. * and getCollidingSubMeshCandidates to their default function
  99450. */
  99451. setDefaultCandidateProviders(): void;
  99452. /**
  99453. * Gets the mesh that is currently under the pointer
  99454. */
  99455. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99456. /**
  99457. * Gets or sets the current on-screen X position of the pointer
  99458. */
  99459. pointerX: number;
  99460. /**
  99461. * Gets or sets the current on-screen Y position of the pointer
  99462. */
  99463. pointerY: number;
  99464. /**
  99465. * Gets the cached material (ie. the latest rendered one)
  99466. * @returns the cached material
  99467. */
  99468. getCachedMaterial(): Nullable<Material>;
  99469. /**
  99470. * Gets the cached effect (ie. the latest rendered one)
  99471. * @returns the cached effect
  99472. */
  99473. getCachedEffect(): Nullable<Effect>;
  99474. /**
  99475. * Gets the cached visibility state (ie. the latest rendered one)
  99476. * @returns the cached visibility state
  99477. */
  99478. getCachedVisibility(): Nullable<number>;
  99479. /**
  99480. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99481. * @param material defines the current material
  99482. * @param effect defines the current effect
  99483. * @param visibility defines the current visibility state
  99484. * @returns true if one parameter is not cached
  99485. */
  99486. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99487. /**
  99488. * Gets the engine associated with the scene
  99489. * @returns an Engine
  99490. */
  99491. getEngine(): Engine;
  99492. /**
  99493. * Gets the total number of vertices rendered per frame
  99494. * @returns the total number of vertices rendered per frame
  99495. */
  99496. getTotalVertices(): number;
  99497. /**
  99498. * Gets the performance counter for total vertices
  99499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99500. */
  99501. readonly totalVerticesPerfCounter: PerfCounter;
  99502. /**
  99503. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99504. * @returns the total number of active indices rendered per frame
  99505. */
  99506. getActiveIndices(): number;
  99507. /**
  99508. * Gets the performance counter for active indices
  99509. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99510. */
  99511. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99512. /**
  99513. * Gets the total number of active particles rendered per frame
  99514. * @returns the total number of active particles rendered per frame
  99515. */
  99516. getActiveParticles(): number;
  99517. /**
  99518. * Gets the performance counter for active particles
  99519. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99520. */
  99521. readonly activeParticlesPerfCounter: PerfCounter;
  99522. /**
  99523. * Gets the total number of active bones rendered per frame
  99524. * @returns the total number of active bones rendered per frame
  99525. */
  99526. getActiveBones(): number;
  99527. /**
  99528. * Gets the performance counter for active bones
  99529. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99530. */
  99531. readonly activeBonesPerfCounter: PerfCounter;
  99532. /**
  99533. * Gets the array of active meshes
  99534. * @returns an array of AbstractMesh
  99535. */
  99536. getActiveMeshes(): SmartArray<AbstractMesh>;
  99537. /**
  99538. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99539. * @returns a number
  99540. */
  99541. getAnimationRatio(): number;
  99542. /**
  99543. * Gets an unique Id for the current render phase
  99544. * @returns a number
  99545. */
  99546. getRenderId(): number;
  99547. /**
  99548. * Gets an unique Id for the current frame
  99549. * @returns a number
  99550. */
  99551. getFrameId(): number;
  99552. /** Call this function if you want to manually increment the render Id*/
  99553. incrementRenderId(): void;
  99554. private _createUbo;
  99555. /**
  99556. * Use this method to simulate a pointer move on a mesh
  99557. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99558. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99559. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99560. * @returns the current scene
  99561. */
  99562. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99563. /**
  99564. * Use this method to simulate a pointer down on a mesh
  99565. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99566. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99567. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99568. * @returns the current scene
  99569. */
  99570. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99571. /**
  99572. * Use this method to simulate a pointer up on a mesh
  99573. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99574. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99575. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99576. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99577. * @returns the current scene
  99578. */
  99579. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99580. /**
  99581. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99582. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99583. * @returns true if the pointer was captured
  99584. */
  99585. isPointerCaptured(pointerId?: number): boolean;
  99586. /**
  99587. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99588. * @param attachUp defines if you want to attach events to pointerup
  99589. * @param attachDown defines if you want to attach events to pointerdown
  99590. * @param attachMove defines if you want to attach events to pointermove
  99591. */
  99592. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99593. /** Detaches all event handlers*/
  99594. detachControl(): void;
  99595. /**
  99596. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99597. * Delay loaded resources are not taking in account
  99598. * @return true if all required resources are ready
  99599. */
  99600. isReady(): boolean;
  99601. /** Resets all cached information relative to material (including effect and visibility) */
  99602. resetCachedMaterial(): void;
  99603. /**
  99604. * Registers a function to be called before every frame render
  99605. * @param func defines the function to register
  99606. */
  99607. registerBeforeRender(func: () => void): void;
  99608. /**
  99609. * Unregisters a function called before every frame render
  99610. * @param func defines the function to unregister
  99611. */
  99612. unregisterBeforeRender(func: () => void): void;
  99613. /**
  99614. * Registers a function to be called after every frame render
  99615. * @param func defines the function to register
  99616. */
  99617. registerAfterRender(func: () => void): void;
  99618. /**
  99619. * Unregisters a function called after every frame render
  99620. * @param func defines the function to unregister
  99621. */
  99622. unregisterAfterRender(func: () => void): void;
  99623. private _executeOnceBeforeRender;
  99624. /**
  99625. * The provided function will run before render once and will be disposed afterwards.
  99626. * A timeout delay can be provided so that the function will be executed in N ms.
  99627. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99628. * @param func The function to be executed.
  99629. * @param timeout optional delay in ms
  99630. */
  99631. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99632. /** @hidden */
  99633. _addPendingData(data: any): void;
  99634. /** @hidden */
  99635. _removePendingData(data: any): void;
  99636. /**
  99637. * Returns the number of items waiting to be loaded
  99638. * @returns the number of items waiting to be loaded
  99639. */
  99640. getWaitingItemsCount(): number;
  99641. /**
  99642. * Returns a boolean indicating if the scene is still loading data
  99643. */
  99644. readonly isLoading: boolean;
  99645. /**
  99646. * Registers a function to be executed when the scene is ready
  99647. * @param {Function} func - the function to be executed
  99648. */
  99649. executeWhenReady(func: () => void): void;
  99650. /**
  99651. * Returns a promise that resolves when the scene is ready
  99652. * @returns A promise that resolves when the scene is ready
  99653. */
  99654. whenReadyAsync(): Promise<void>;
  99655. /** @hidden */
  99656. _checkIsReady(): void;
  99657. /**
  99658. * Gets all animatable attached to the scene
  99659. */
  99660. readonly animatables: Animatable[];
  99661. /**
  99662. * Resets the last animation time frame.
  99663. * Useful to override when animations start running when loading a scene for the first time.
  99664. */
  99665. resetLastAnimationTimeFrame(): void;
  99666. /**
  99667. * Gets the current view matrix
  99668. * @returns a Matrix
  99669. */
  99670. getViewMatrix(): Matrix;
  99671. /**
  99672. * Gets the current projection matrix
  99673. * @returns a Matrix
  99674. */
  99675. getProjectionMatrix(): Matrix;
  99676. /**
  99677. * Gets the current transform matrix
  99678. * @returns a Matrix made of View * Projection
  99679. */
  99680. getTransformMatrix(): Matrix;
  99681. /**
  99682. * Sets the current transform matrix
  99683. * @param viewL defines the View matrix to use
  99684. * @param projectionL defines the Projection matrix to use
  99685. * @param viewR defines the right View matrix to use (if provided)
  99686. * @param projectionR defines the right Projection matrix to use (if provided)
  99687. */
  99688. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99689. /**
  99690. * Gets the uniform buffer used to store scene data
  99691. * @returns a UniformBuffer
  99692. */
  99693. getSceneUniformBuffer(): UniformBuffer;
  99694. /**
  99695. * Gets an unique (relatively to the current scene) Id
  99696. * @returns an unique number for the scene
  99697. */
  99698. getUniqueId(): number;
  99699. /**
  99700. * Add a mesh to the list of scene's meshes
  99701. * @param newMesh defines the mesh to add
  99702. * @param recursive if all child meshes should also be added to the scene
  99703. */
  99704. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99705. /**
  99706. * Remove a mesh for the list of scene's meshes
  99707. * @param toRemove defines the mesh to remove
  99708. * @param recursive if all child meshes should also be removed from the scene
  99709. * @returns the index where the mesh was in the mesh list
  99710. */
  99711. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99712. /**
  99713. * Add a transform node to the list of scene's transform nodes
  99714. * @param newTransformNode defines the transform node to add
  99715. */
  99716. addTransformNode(newTransformNode: TransformNode): void;
  99717. /**
  99718. * Remove a transform node for the list of scene's transform nodes
  99719. * @param toRemove defines the transform node to remove
  99720. * @returns the index where the transform node was in the transform node list
  99721. */
  99722. removeTransformNode(toRemove: TransformNode): number;
  99723. /**
  99724. * Remove a skeleton for the list of scene's skeletons
  99725. * @param toRemove defines the skeleton to remove
  99726. * @returns the index where the skeleton was in the skeleton list
  99727. */
  99728. removeSkeleton(toRemove: Skeleton): number;
  99729. /**
  99730. * Remove a morph target for the list of scene's morph targets
  99731. * @param toRemove defines the morph target to remove
  99732. * @returns the index where the morph target was in the morph target list
  99733. */
  99734. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99735. /**
  99736. * Remove a light for the list of scene's lights
  99737. * @param toRemove defines the light to remove
  99738. * @returns the index where the light was in the light list
  99739. */
  99740. removeLight(toRemove: Light): number;
  99741. /**
  99742. * Remove a camera for the list of scene's cameras
  99743. * @param toRemove defines the camera to remove
  99744. * @returns the index where the camera was in the camera list
  99745. */
  99746. removeCamera(toRemove: Camera): number;
  99747. /**
  99748. * Remove a particle system for the list of scene's particle systems
  99749. * @param toRemove defines the particle system to remove
  99750. * @returns the index where the particle system was in the particle system list
  99751. */
  99752. removeParticleSystem(toRemove: IParticleSystem): number;
  99753. /**
  99754. * Remove a animation for the list of scene's animations
  99755. * @param toRemove defines the animation to remove
  99756. * @returns the index where the animation was in the animation list
  99757. */
  99758. removeAnimation(toRemove: Animation): number;
  99759. /**
  99760. * Will stop the animation of the given target
  99761. * @param target - the target
  99762. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99763. * @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)
  99764. */
  99765. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99766. /**
  99767. * Removes the given animation group from this scene.
  99768. * @param toRemove The animation group to remove
  99769. * @returns The index of the removed animation group
  99770. */
  99771. removeAnimationGroup(toRemove: AnimationGroup): number;
  99772. /**
  99773. * Removes the given multi-material from this scene.
  99774. * @param toRemove The multi-material to remove
  99775. * @returns The index of the removed multi-material
  99776. */
  99777. removeMultiMaterial(toRemove: MultiMaterial): number;
  99778. /**
  99779. * Removes the given material from this scene.
  99780. * @param toRemove The material to remove
  99781. * @returns The index of the removed material
  99782. */
  99783. removeMaterial(toRemove: Material): number;
  99784. /**
  99785. * Removes the given action manager from this scene.
  99786. * @param toRemove The action manager to remove
  99787. * @returns The index of the removed action manager
  99788. */
  99789. removeActionManager(toRemove: AbstractActionManager): number;
  99790. /**
  99791. * Removes the given texture from this scene.
  99792. * @param toRemove The texture to remove
  99793. * @returns The index of the removed texture
  99794. */
  99795. removeTexture(toRemove: BaseTexture): number;
  99796. /**
  99797. * Adds the given light to this scene
  99798. * @param newLight The light to add
  99799. */
  99800. addLight(newLight: Light): void;
  99801. /**
  99802. * Sorts the list list based on light priorities
  99803. */
  99804. sortLightsByPriority(): void;
  99805. /**
  99806. * Adds the given camera to this scene
  99807. * @param newCamera The camera to add
  99808. */
  99809. addCamera(newCamera: Camera): void;
  99810. /**
  99811. * Adds the given skeleton to this scene
  99812. * @param newSkeleton The skeleton to add
  99813. */
  99814. addSkeleton(newSkeleton: Skeleton): void;
  99815. /**
  99816. * Adds the given particle system to this scene
  99817. * @param newParticleSystem The particle system to add
  99818. */
  99819. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99820. /**
  99821. * Adds the given animation to this scene
  99822. * @param newAnimation The animation to add
  99823. */
  99824. addAnimation(newAnimation: Animation): void;
  99825. /**
  99826. * Adds the given animation group to this scene.
  99827. * @param newAnimationGroup The animation group to add
  99828. */
  99829. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99830. /**
  99831. * Adds the given multi-material to this scene
  99832. * @param newMultiMaterial The multi-material to add
  99833. */
  99834. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99835. /**
  99836. * Adds the given material to this scene
  99837. * @param newMaterial The material to add
  99838. */
  99839. addMaterial(newMaterial: Material): void;
  99840. /**
  99841. * Adds the given morph target to this scene
  99842. * @param newMorphTargetManager The morph target to add
  99843. */
  99844. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99845. /**
  99846. * Adds the given geometry to this scene
  99847. * @param newGeometry The geometry to add
  99848. */
  99849. addGeometry(newGeometry: Geometry): void;
  99850. /**
  99851. * Adds the given action manager to this scene
  99852. * @param newActionManager The action manager to add
  99853. */
  99854. addActionManager(newActionManager: AbstractActionManager): void;
  99855. /**
  99856. * Adds the given texture to this scene.
  99857. * @param newTexture The texture to add
  99858. */
  99859. addTexture(newTexture: BaseTexture): void;
  99860. /**
  99861. * Switch active camera
  99862. * @param newCamera defines the new active camera
  99863. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  99864. */
  99865. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  99866. /**
  99867. * sets the active camera of the scene using its ID
  99868. * @param id defines the camera's ID
  99869. * @return the new active camera or null if none found.
  99870. */
  99871. setActiveCameraByID(id: string): Nullable<Camera>;
  99872. /**
  99873. * sets the active camera of the scene using its name
  99874. * @param name defines the camera's name
  99875. * @returns the new active camera or null if none found.
  99876. */
  99877. setActiveCameraByName(name: string): Nullable<Camera>;
  99878. /**
  99879. * get an animation group using its name
  99880. * @param name defines the material's name
  99881. * @return the animation group or null if none found.
  99882. */
  99883. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  99884. /**
  99885. * Get a material using its unique id
  99886. * @param uniqueId defines the material's unique id
  99887. * @return the material or null if none found.
  99888. */
  99889. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  99890. /**
  99891. * get a material using its id
  99892. * @param id defines the material's ID
  99893. * @return the material or null if none found.
  99894. */
  99895. getMaterialByID(id: string): Nullable<Material>;
  99896. /**
  99897. * Gets a the last added material using a given id
  99898. * @param id defines the material's ID
  99899. * @return the last material with the given id or null if none found.
  99900. */
  99901. getLastMaterialByID(id: string): Nullable<Material>;
  99902. /**
  99903. * Gets a material using its name
  99904. * @param name defines the material's name
  99905. * @return the material or null if none found.
  99906. */
  99907. getMaterialByName(name: string): Nullable<Material>;
  99908. /**
  99909. * Get a texture using its unique id
  99910. * @param uniqueId defines the texture's unique id
  99911. * @return the texture or null if none found.
  99912. */
  99913. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  99914. /**
  99915. * Gets a camera using its id
  99916. * @param id defines the id to look for
  99917. * @returns the camera or null if not found
  99918. */
  99919. getCameraByID(id: string): Nullable<Camera>;
  99920. /**
  99921. * Gets a camera using its unique id
  99922. * @param uniqueId defines the unique id to look for
  99923. * @returns the camera or null if not found
  99924. */
  99925. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  99926. /**
  99927. * Gets a camera using its name
  99928. * @param name defines the camera's name
  99929. * @return the camera or null if none found.
  99930. */
  99931. getCameraByName(name: string): Nullable<Camera>;
  99932. /**
  99933. * Gets a bone using its id
  99934. * @param id defines the bone's id
  99935. * @return the bone or null if not found
  99936. */
  99937. getBoneByID(id: string): Nullable<Bone>;
  99938. /**
  99939. * Gets a bone using its id
  99940. * @param name defines the bone's name
  99941. * @return the bone or null if not found
  99942. */
  99943. getBoneByName(name: string): Nullable<Bone>;
  99944. /**
  99945. * Gets a light node using its name
  99946. * @param name defines the the light's name
  99947. * @return the light or null if none found.
  99948. */
  99949. getLightByName(name: string): Nullable<Light>;
  99950. /**
  99951. * Gets a light node using its id
  99952. * @param id defines the light's id
  99953. * @return the light or null if none found.
  99954. */
  99955. getLightByID(id: string): Nullable<Light>;
  99956. /**
  99957. * Gets a light node using its scene-generated unique ID
  99958. * @param uniqueId defines the light's unique id
  99959. * @return the light or null if none found.
  99960. */
  99961. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  99962. /**
  99963. * Gets a particle system by id
  99964. * @param id defines the particle system id
  99965. * @return the corresponding system or null if none found
  99966. */
  99967. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  99968. /**
  99969. * Gets a geometry using its ID
  99970. * @param id defines the geometry's id
  99971. * @return the geometry or null if none found.
  99972. */
  99973. getGeometryByID(id: string): Nullable<Geometry>;
  99974. private _getGeometryByUniqueID;
  99975. /**
  99976. * Add a new geometry to this scene
  99977. * @param geometry defines the geometry to be added to the scene.
  99978. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  99979. * @return a boolean defining if the geometry was added or not
  99980. */
  99981. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  99982. /**
  99983. * Removes an existing geometry
  99984. * @param geometry defines the geometry to be removed from the scene
  99985. * @return a boolean defining if the geometry was removed or not
  99986. */
  99987. removeGeometry(geometry: Geometry): boolean;
  99988. /**
  99989. * Gets the list of geometries attached to the scene
  99990. * @returns an array of Geometry
  99991. */
  99992. getGeometries(): Geometry[];
  99993. /**
  99994. * Gets the first added mesh found of a given ID
  99995. * @param id defines the id to search for
  99996. * @return the mesh found or null if not found at all
  99997. */
  99998. getMeshByID(id: string): Nullable<AbstractMesh>;
  99999. /**
  100000. * Gets a list of meshes using their id
  100001. * @param id defines the id to search for
  100002. * @returns a list of meshes
  100003. */
  100004. getMeshesByID(id: string): Array<AbstractMesh>;
  100005. /**
  100006. * Gets the first added transform node found of a given ID
  100007. * @param id defines the id to search for
  100008. * @return the found transform node or null if not found at all.
  100009. */
  100010. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100011. /**
  100012. * Gets a transform node with its auto-generated unique id
  100013. * @param uniqueId efines the unique id to search for
  100014. * @return the found transform node or null if not found at all.
  100015. */
  100016. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100017. /**
  100018. * Gets a list of transform nodes using their id
  100019. * @param id defines the id to search for
  100020. * @returns a list of transform nodes
  100021. */
  100022. getTransformNodesByID(id: string): Array<TransformNode>;
  100023. /**
  100024. * Gets a mesh with its auto-generated unique id
  100025. * @param uniqueId defines the unique id to search for
  100026. * @return the found mesh or null if not found at all.
  100027. */
  100028. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100029. /**
  100030. * Gets a the last added mesh using a given id
  100031. * @param id defines the id to search for
  100032. * @return the found mesh or null if not found at all.
  100033. */
  100034. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100035. /**
  100036. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100037. * @param id defines the id to search for
  100038. * @return the found node or null if not found at all
  100039. */
  100040. getLastEntryByID(id: string): Nullable<Node>;
  100041. /**
  100042. * Gets a node (Mesh, Camera, Light) using a given id
  100043. * @param id defines the id to search for
  100044. * @return the found node or null if not found at all
  100045. */
  100046. getNodeByID(id: string): Nullable<Node>;
  100047. /**
  100048. * Gets a node (Mesh, Camera, Light) using a given name
  100049. * @param name defines the name to search for
  100050. * @return the found node or null if not found at all.
  100051. */
  100052. getNodeByName(name: string): Nullable<Node>;
  100053. /**
  100054. * Gets a mesh using a given name
  100055. * @param name defines the name to search for
  100056. * @return the found mesh or null if not found at all.
  100057. */
  100058. getMeshByName(name: string): Nullable<AbstractMesh>;
  100059. /**
  100060. * Gets a transform node using a given name
  100061. * @param name defines the name to search for
  100062. * @return the found transform node or null if not found at all.
  100063. */
  100064. getTransformNodeByName(name: string): Nullable<TransformNode>;
  100065. /**
  100066. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  100067. * @param id defines the id to search for
  100068. * @return the found skeleton or null if not found at all.
  100069. */
  100070. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  100071. /**
  100072. * Gets a skeleton using a given auto generated unique id
  100073. * @param uniqueId defines the unique id to search for
  100074. * @return the found skeleton or null if not found at all.
  100075. */
  100076. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  100077. /**
  100078. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  100079. * @param id defines the id to search for
  100080. * @return the found skeleton or null if not found at all.
  100081. */
  100082. getSkeletonById(id: string): Nullable<Skeleton>;
  100083. /**
  100084. * Gets a skeleton using a given name
  100085. * @param name defines the name to search for
  100086. * @return the found skeleton or null if not found at all.
  100087. */
  100088. getSkeletonByName(name: string): Nullable<Skeleton>;
  100089. /**
  100090. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  100091. * @param id defines the id to search for
  100092. * @return the found morph target manager or null if not found at all.
  100093. */
  100094. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  100095. /**
  100096. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  100097. * @param id defines the id to search for
  100098. * @return the found morph target or null if not found at all.
  100099. */
  100100. getMorphTargetById(id: string): Nullable<MorphTarget>;
  100101. /**
  100102. * Gets a boolean indicating if the given mesh is active
  100103. * @param mesh defines the mesh to look for
  100104. * @returns true if the mesh is in the active list
  100105. */
  100106. isActiveMesh(mesh: AbstractMesh): boolean;
  100107. /**
  100108. * Return a unique id as a string which can serve as an identifier for the scene
  100109. */
  100110. readonly uid: string;
  100111. /**
  100112. * Add an externaly attached data from its key.
  100113. * This method call will fail and return false, if such key already exists.
  100114. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100115. * @param key the unique key that identifies the data
  100116. * @param data the data object to associate to the key for this Engine instance
  100117. * @return true if no such key were already present and the data was added successfully, false otherwise
  100118. */
  100119. addExternalData<T>(key: string, data: T): boolean;
  100120. /**
  100121. * Get an externaly attached data from its key
  100122. * @param key the unique key that identifies the data
  100123. * @return the associated data, if present (can be null), or undefined if not present
  100124. */
  100125. getExternalData<T>(key: string): Nullable<T>;
  100126. /**
  100127. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100128. * @param key the unique key that identifies the data
  100129. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100130. * @return the associated data, can be null if the factory returned null.
  100131. */
  100132. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100133. /**
  100134. * Remove an externaly attached data from the Engine instance
  100135. * @param key the unique key that identifies the data
  100136. * @return true if the data was successfully removed, false if it doesn't exist
  100137. */
  100138. removeExternalData(key: string): boolean;
  100139. private _evaluateSubMesh;
  100140. /**
  100141. * Clear the processed materials smart array preventing retention point in material dispose.
  100142. */
  100143. freeProcessedMaterials(): void;
  100144. private _preventFreeActiveMeshesAndRenderingGroups;
  100145. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100146. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100147. * when disposing several meshes in a row or a hierarchy of meshes.
  100148. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100149. */
  100150. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100151. /**
  100152. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100153. */
  100154. freeActiveMeshes(): void;
  100155. /**
  100156. * Clear the info related to rendering groups preventing retention points during dispose.
  100157. */
  100158. freeRenderingGroups(): void;
  100159. /** @hidden */
  100160. _isInIntermediateRendering(): boolean;
  100161. /**
  100162. * Lambda returning the list of potentially active meshes.
  100163. */
  100164. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100165. /**
  100166. * Lambda returning the list of potentially active sub meshes.
  100167. */
  100168. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100169. /**
  100170. * Lambda returning the list of potentially intersecting sub meshes.
  100171. */
  100172. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100173. /**
  100174. * Lambda returning the list of potentially colliding sub meshes.
  100175. */
  100176. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100177. private _activeMeshesFrozen;
  100178. /**
  100179. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100180. * @returns the current scene
  100181. */
  100182. freezeActiveMeshes(): Scene;
  100183. /**
  100184. * Use this function to restart evaluating active meshes on every frame
  100185. * @returns the current scene
  100186. */
  100187. unfreezeActiveMeshes(): Scene;
  100188. private _evaluateActiveMeshes;
  100189. private _activeMesh;
  100190. /**
  100191. * Update the transform matrix to update from the current active camera
  100192. * @param force defines a boolean used to force the update even if cache is up to date
  100193. */
  100194. updateTransformMatrix(force?: boolean): void;
  100195. private _bindFrameBuffer;
  100196. /** @hidden */
  100197. _allowPostProcessClearColor: boolean;
  100198. /** @hidden */
  100199. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100200. private _processSubCameras;
  100201. private _checkIntersections;
  100202. /** @hidden */
  100203. _advancePhysicsEngineStep(step: number): void;
  100204. /**
  100205. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100206. */
  100207. getDeterministicFrameTime: () => number;
  100208. /** @hidden */
  100209. _animate(): void;
  100210. /** Execute all animations (for a frame) */
  100211. animate(): void;
  100212. /**
  100213. * Render the scene
  100214. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100215. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100216. */
  100217. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  100218. /**
  100219. * Freeze all materials
  100220. * A frozen material will not be updatable but should be faster to render
  100221. */
  100222. freezeMaterials(): void;
  100223. /**
  100224. * Unfreeze all materials
  100225. * A frozen material will not be updatable but should be faster to render
  100226. */
  100227. unfreezeMaterials(): void;
  100228. /**
  100229. * Releases all held ressources
  100230. */
  100231. dispose(): void;
  100232. /**
  100233. * Gets if the scene is already disposed
  100234. */
  100235. readonly isDisposed: boolean;
  100236. /**
  100237. * Call this function to reduce memory footprint of the scene.
  100238. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  100239. */
  100240. clearCachedVertexData(): void;
  100241. /**
  100242. * This function will remove the local cached buffer data from texture.
  100243. * It will save memory but will prevent the texture from being rebuilt
  100244. */
  100245. cleanCachedTextureBuffer(): void;
  100246. /**
  100247. * Get the world extend vectors with an optional filter
  100248. *
  100249. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  100250. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  100251. */
  100252. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  100253. min: Vector3;
  100254. max: Vector3;
  100255. };
  100256. /**
  100257. * Creates a ray that can be used to pick in the scene
  100258. * @param x defines the x coordinate of the origin (on-screen)
  100259. * @param y defines the y coordinate of the origin (on-screen)
  100260. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100261. * @param camera defines the camera to use for the picking
  100262. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100263. * @returns a Ray
  100264. */
  100265. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  100266. /**
  100267. * Creates a ray that can be used to pick in the scene
  100268. * @param x defines the x coordinate of the origin (on-screen)
  100269. * @param y defines the y coordinate of the origin (on-screen)
  100270. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100271. * @param result defines the ray where to store the picking ray
  100272. * @param camera defines the camera to use for the picking
  100273. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100274. * @returns the current scene
  100275. */
  100276. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  100277. /**
  100278. * Creates a ray that can be used to pick in the scene
  100279. * @param x defines the x coordinate of the origin (on-screen)
  100280. * @param y defines the y coordinate of the origin (on-screen)
  100281. * @param camera defines the camera to use for the picking
  100282. * @returns a Ray
  100283. */
  100284. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  100285. /**
  100286. * Creates a ray that can be used to pick in the scene
  100287. * @param x defines the x coordinate of the origin (on-screen)
  100288. * @param y defines the y coordinate of the origin (on-screen)
  100289. * @param result defines the ray where to store the picking ray
  100290. * @param camera defines the camera to use for the picking
  100291. * @returns the current scene
  100292. */
  100293. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  100294. /** Launch a ray to try to pick a mesh in the scene
  100295. * @param x position on screen
  100296. * @param y position on screen
  100297. * @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
  100298. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  100299. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100300. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100301. * @returns a PickingInfo
  100302. */
  100303. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100304. /** Use the given ray to pick a mesh in the scene
  100305. * @param ray The ray to use to pick meshes
  100306. * @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
  100307. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  100308. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100309. * @returns a PickingInfo
  100310. */
  100311. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100312. /**
  100313. * Launch a ray to try to pick a mesh in the scene
  100314. * @param x X position on screen
  100315. * @param y Y position on screen
  100316. * @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
  100317. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100318. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100319. * @returns an array of PickingInfo
  100320. */
  100321. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100322. /**
  100323. * Launch a ray to try to pick a mesh in the scene
  100324. * @param ray Ray to use
  100325. * @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
  100326. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100327. * @returns an array of PickingInfo
  100328. */
  100329. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100330. /**
  100331. * Force the value of meshUnderPointer
  100332. * @param mesh defines the mesh to use
  100333. */
  100334. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100335. /**
  100336. * Gets the mesh under the pointer
  100337. * @returns a Mesh or null if no mesh is under the pointer
  100338. */
  100339. getPointerOverMesh(): Nullable<AbstractMesh>;
  100340. /** @hidden */
  100341. _rebuildGeometries(): void;
  100342. /** @hidden */
  100343. _rebuildTextures(): void;
  100344. private _getByTags;
  100345. /**
  100346. * Get a list of meshes by tags
  100347. * @param tagsQuery defines the tags query to use
  100348. * @param forEach defines a predicate used to filter results
  100349. * @returns an array of Mesh
  100350. */
  100351. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  100352. /**
  100353. * Get a list of cameras by tags
  100354. * @param tagsQuery defines the tags query to use
  100355. * @param forEach defines a predicate used to filter results
  100356. * @returns an array of Camera
  100357. */
  100358. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  100359. /**
  100360. * Get a list of lights by tags
  100361. * @param tagsQuery defines the tags query to use
  100362. * @param forEach defines a predicate used to filter results
  100363. * @returns an array of Light
  100364. */
  100365. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  100366. /**
  100367. * Get a list of materials by tags
  100368. * @param tagsQuery defines the tags query to use
  100369. * @param forEach defines a predicate used to filter results
  100370. * @returns an array of Material
  100371. */
  100372. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  100373. /**
  100374. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100375. * This allowed control for front to back rendering or reversly depending of the special needs.
  100376. *
  100377. * @param renderingGroupId The rendering group id corresponding to its index
  100378. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100379. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100380. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100381. */
  100382. 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;
  100383. /**
  100384. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100385. *
  100386. * @param renderingGroupId The rendering group id corresponding to its index
  100387. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100388. * @param depth Automatically clears depth between groups if true and autoClear is true.
  100389. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  100390. */
  100391. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  100392. /**
  100393. * Gets the current auto clear configuration for one rendering group of the rendering
  100394. * manager.
  100395. * @param index the rendering group index to get the information for
  100396. * @returns The auto clear setup for the requested rendering group
  100397. */
  100398. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  100399. private _blockMaterialDirtyMechanism;
  100400. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  100401. blockMaterialDirtyMechanism: boolean;
  100402. /**
  100403. * Will flag all materials as dirty to trigger new shader compilation
  100404. * @param flag defines the flag used to specify which material part must be marked as dirty
  100405. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100406. */
  100407. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100408. /** @hidden */
  100409. _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;
  100410. /** @hidden */
  100411. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100412. }
  100413. }
  100414. declare module BABYLON {
  100415. /**
  100416. * Set of assets to keep when moving a scene into an asset container.
  100417. */
  100418. export class KeepAssets extends AbstractScene {
  100419. }
  100420. /**
  100421. * Container with a set of assets that can be added or removed from a scene.
  100422. */
  100423. export class AssetContainer extends AbstractScene {
  100424. /**
  100425. * The scene the AssetContainer belongs to.
  100426. */
  100427. scene: Scene;
  100428. /**
  100429. * Instantiates an AssetContainer.
  100430. * @param scene The scene the AssetContainer belongs to.
  100431. */
  100432. constructor(scene: Scene);
  100433. /**
  100434. * Adds all the assets from the container to the scene.
  100435. */
  100436. addAllToScene(): void;
  100437. /**
  100438. * Removes all the assets in the container from the scene
  100439. */
  100440. removeAllFromScene(): void;
  100441. /**
  100442. * Disposes all the assets in the container
  100443. */
  100444. dispose(): void;
  100445. private _moveAssets;
  100446. /**
  100447. * Removes all the assets contained in the scene and adds them to the container.
  100448. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100449. */
  100450. moveAllFromScene(keepAssets?: KeepAssets): void;
  100451. /**
  100452. * 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.
  100453. * @returns the root mesh
  100454. */
  100455. createRootMesh(): Mesh;
  100456. }
  100457. }
  100458. declare module BABYLON {
  100459. /**
  100460. * Defines how the parser contract is defined.
  100461. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100462. */
  100463. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100464. /**
  100465. * Defines how the individual parser contract is defined.
  100466. * These parser can parse an individual asset
  100467. */
  100468. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100469. /**
  100470. * Base class of the scene acting as a container for the different elements composing a scene.
  100471. * This class is dynamically extended by the different components of the scene increasing
  100472. * flexibility and reducing coupling
  100473. */
  100474. export abstract class AbstractScene {
  100475. /**
  100476. * Stores the list of available parsers in the application.
  100477. */
  100478. private static _BabylonFileParsers;
  100479. /**
  100480. * Stores the list of available individual parsers in the application.
  100481. */
  100482. private static _IndividualBabylonFileParsers;
  100483. /**
  100484. * Adds a parser in the list of available ones
  100485. * @param name Defines the name of the parser
  100486. * @param parser Defines the parser to add
  100487. */
  100488. static AddParser(name: string, parser: BabylonFileParser): void;
  100489. /**
  100490. * Gets a general parser from the list of avaialble ones
  100491. * @param name Defines the name of the parser
  100492. * @returns the requested parser or null
  100493. */
  100494. static GetParser(name: string): Nullable<BabylonFileParser>;
  100495. /**
  100496. * Adds n individual parser in the list of available ones
  100497. * @param name Defines the name of the parser
  100498. * @param parser Defines the parser to add
  100499. */
  100500. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100501. /**
  100502. * Gets an individual parser from the list of avaialble ones
  100503. * @param name Defines the name of the parser
  100504. * @returns the requested parser or null
  100505. */
  100506. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100507. /**
  100508. * Parser json data and populate both a scene and its associated container object
  100509. * @param jsonData Defines the data to parse
  100510. * @param scene Defines the scene to parse the data for
  100511. * @param container Defines the container attached to the parsing sequence
  100512. * @param rootUrl Defines the root url of the data
  100513. */
  100514. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100515. /**
  100516. * Gets the list of root nodes (ie. nodes with no parent)
  100517. */
  100518. rootNodes: Node[];
  100519. /** All of the cameras added to this scene
  100520. * @see http://doc.babylonjs.com/babylon101/cameras
  100521. */
  100522. cameras: Camera[];
  100523. /**
  100524. * All of the lights added to this scene
  100525. * @see http://doc.babylonjs.com/babylon101/lights
  100526. */
  100527. lights: Light[];
  100528. /**
  100529. * All of the (abstract) meshes added to this scene
  100530. */
  100531. meshes: AbstractMesh[];
  100532. /**
  100533. * The list of skeletons added to the scene
  100534. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100535. */
  100536. skeletons: Skeleton[];
  100537. /**
  100538. * All of the particle systems added to this scene
  100539. * @see http://doc.babylonjs.com/babylon101/particles
  100540. */
  100541. particleSystems: IParticleSystem[];
  100542. /**
  100543. * Gets a list of Animations associated with the scene
  100544. */
  100545. animations: Animation[];
  100546. /**
  100547. * All of the animation groups added to this scene
  100548. * @see http://doc.babylonjs.com/how_to/group
  100549. */
  100550. animationGroups: AnimationGroup[];
  100551. /**
  100552. * All of the multi-materials added to this scene
  100553. * @see http://doc.babylonjs.com/how_to/multi_materials
  100554. */
  100555. multiMaterials: MultiMaterial[];
  100556. /**
  100557. * All of the materials added to this scene
  100558. * In the context of a Scene, it is not supposed to be modified manually.
  100559. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100560. * Note also that the order of the Material wihin the array is not significant and might change.
  100561. * @see http://doc.babylonjs.com/babylon101/materials
  100562. */
  100563. materials: Material[];
  100564. /**
  100565. * The list of morph target managers added to the scene
  100566. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100567. */
  100568. morphTargetManagers: MorphTargetManager[];
  100569. /**
  100570. * The list of geometries used in the scene.
  100571. */
  100572. geometries: Geometry[];
  100573. /**
  100574. * All of the tranform nodes added to this scene
  100575. * In the context of a Scene, it is not supposed to be modified manually.
  100576. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100577. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100578. * @see http://doc.babylonjs.com/how_to/transformnode
  100579. */
  100580. transformNodes: TransformNode[];
  100581. /**
  100582. * ActionManagers available on the scene.
  100583. */
  100584. actionManagers: AbstractActionManager[];
  100585. /**
  100586. * Textures to keep.
  100587. */
  100588. textures: BaseTexture[];
  100589. /**
  100590. * Environment texture for the scene
  100591. */
  100592. environmentTexture: Nullable<BaseTexture>;
  100593. }
  100594. }
  100595. declare module BABYLON {
  100596. /**
  100597. * Interface used to define options for Sound class
  100598. */
  100599. export interface ISoundOptions {
  100600. /**
  100601. * Does the sound autoplay once loaded.
  100602. */
  100603. autoplay?: boolean;
  100604. /**
  100605. * Does the sound loop after it finishes playing once.
  100606. */
  100607. loop?: boolean;
  100608. /**
  100609. * Sound's volume
  100610. */
  100611. volume?: number;
  100612. /**
  100613. * Is it a spatial sound?
  100614. */
  100615. spatialSound?: boolean;
  100616. /**
  100617. * Maximum distance to hear that sound
  100618. */
  100619. maxDistance?: number;
  100620. /**
  100621. * Uses user defined attenuation function
  100622. */
  100623. useCustomAttenuation?: boolean;
  100624. /**
  100625. * Define the roll off factor of spatial sounds.
  100626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100627. */
  100628. rolloffFactor?: number;
  100629. /**
  100630. * Define the reference distance the sound should be heard perfectly.
  100631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100632. */
  100633. refDistance?: number;
  100634. /**
  100635. * Define the distance attenuation model the sound will follow.
  100636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100637. */
  100638. distanceModel?: string;
  100639. /**
  100640. * Defines the playback speed (1 by default)
  100641. */
  100642. playbackRate?: number;
  100643. /**
  100644. * Defines if the sound is from a streaming source
  100645. */
  100646. streaming?: boolean;
  100647. /**
  100648. * Defines an optional length (in seconds) inside the sound file
  100649. */
  100650. length?: number;
  100651. /**
  100652. * Defines an optional offset (in seconds) inside the sound file
  100653. */
  100654. offset?: number;
  100655. /**
  100656. * If true, URLs will not be required to state the audio file codec to use.
  100657. */
  100658. skipCodecCheck?: boolean;
  100659. }
  100660. /**
  100661. * Defines a sound that can be played in the application.
  100662. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100664. */
  100665. export class Sound {
  100666. /**
  100667. * The name of the sound in the scene.
  100668. */
  100669. name: string;
  100670. /**
  100671. * Does the sound autoplay once loaded.
  100672. */
  100673. autoplay: boolean;
  100674. /**
  100675. * Does the sound loop after it finishes playing once.
  100676. */
  100677. loop: boolean;
  100678. /**
  100679. * Does the sound use a custom attenuation curve to simulate the falloff
  100680. * happening when the source gets further away from the camera.
  100681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100682. */
  100683. useCustomAttenuation: boolean;
  100684. /**
  100685. * The sound track id this sound belongs to.
  100686. */
  100687. soundTrackId: number;
  100688. /**
  100689. * Is this sound currently played.
  100690. */
  100691. isPlaying: boolean;
  100692. /**
  100693. * Is this sound currently paused.
  100694. */
  100695. isPaused: boolean;
  100696. /**
  100697. * Does this sound enables spatial sound.
  100698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100699. */
  100700. spatialSound: boolean;
  100701. /**
  100702. * Define the reference distance the sound should be heard perfectly.
  100703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100704. */
  100705. refDistance: number;
  100706. /**
  100707. * Define the roll off factor of spatial sounds.
  100708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100709. */
  100710. rolloffFactor: number;
  100711. /**
  100712. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100714. */
  100715. maxDistance: number;
  100716. /**
  100717. * Define the distance attenuation model the sound will follow.
  100718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100719. */
  100720. distanceModel: string;
  100721. /**
  100722. * @hidden
  100723. * Back Compat
  100724. **/
  100725. onended: () => any;
  100726. /**
  100727. * Observable event when the current playing sound finishes.
  100728. */
  100729. onEndedObservable: Observable<Sound>;
  100730. private _panningModel;
  100731. private _playbackRate;
  100732. private _streaming;
  100733. private _startTime;
  100734. private _startOffset;
  100735. private _position;
  100736. /** @hidden */
  100737. _positionInEmitterSpace: boolean;
  100738. private _localDirection;
  100739. private _volume;
  100740. private _isReadyToPlay;
  100741. private _isDirectional;
  100742. private _readyToPlayCallback;
  100743. private _audioBuffer;
  100744. private _soundSource;
  100745. private _streamingSource;
  100746. private _soundPanner;
  100747. private _soundGain;
  100748. private _inputAudioNode;
  100749. private _outputAudioNode;
  100750. private _coneInnerAngle;
  100751. private _coneOuterAngle;
  100752. private _coneOuterGain;
  100753. private _scene;
  100754. private _connectedTransformNode;
  100755. private _customAttenuationFunction;
  100756. private _registerFunc;
  100757. private _isOutputConnected;
  100758. private _htmlAudioElement;
  100759. private _urlType;
  100760. private _length?;
  100761. private _offset?;
  100762. /** @hidden */
  100763. static _SceneComponentInitialization: (scene: Scene) => void;
  100764. /**
  100765. * Create a sound and attach it to a scene
  100766. * @param name Name of your sound
  100767. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100768. * @param scene defines the scene the sound belongs to
  100769. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100770. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100771. */
  100772. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100773. /**
  100774. * Release the sound and its associated resources
  100775. */
  100776. dispose(): void;
  100777. /**
  100778. * Gets if the sounds is ready to be played or not.
  100779. * @returns true if ready, otherwise false
  100780. */
  100781. isReady(): boolean;
  100782. private _soundLoaded;
  100783. /**
  100784. * Sets the data of the sound from an audiobuffer
  100785. * @param audioBuffer The audioBuffer containing the data
  100786. */
  100787. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100788. /**
  100789. * Updates the current sounds options such as maxdistance, loop...
  100790. * @param options A JSON object containing values named as the object properties
  100791. */
  100792. updateOptions(options: ISoundOptions): void;
  100793. private _createSpatialParameters;
  100794. private _updateSpatialParameters;
  100795. /**
  100796. * Switch the panning model to HRTF:
  100797. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100799. */
  100800. switchPanningModelToHRTF(): void;
  100801. /**
  100802. * Switch the panning model to Equal Power:
  100803. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100805. */
  100806. switchPanningModelToEqualPower(): void;
  100807. private _switchPanningModel;
  100808. /**
  100809. * Connect this sound to a sound track audio node like gain...
  100810. * @param soundTrackAudioNode the sound track audio node to connect to
  100811. */
  100812. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100813. /**
  100814. * Transform this sound into a directional source
  100815. * @param coneInnerAngle Size of the inner cone in degree
  100816. * @param coneOuterAngle Size of the outer cone in degree
  100817. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100818. */
  100819. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100820. /**
  100821. * Gets or sets the inner angle for the directional cone.
  100822. */
  100823. /**
  100824. * Gets or sets the inner angle for the directional cone.
  100825. */
  100826. directionalConeInnerAngle: number;
  100827. /**
  100828. * Gets or sets the outer angle for the directional cone.
  100829. */
  100830. /**
  100831. * Gets or sets the outer angle for the directional cone.
  100832. */
  100833. directionalConeOuterAngle: number;
  100834. /**
  100835. * Sets the position of the emitter if spatial sound is enabled
  100836. * @param newPosition Defines the new posisiton
  100837. */
  100838. setPosition(newPosition: Vector3): void;
  100839. /**
  100840. * Sets the local direction of the emitter if spatial sound is enabled
  100841. * @param newLocalDirection Defines the new local direction
  100842. */
  100843. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100844. private _updateDirection;
  100845. /** @hidden */
  100846. updateDistanceFromListener(): void;
  100847. /**
  100848. * Sets a new custom attenuation function for the sound.
  100849. * @param callback Defines the function used for the attenuation
  100850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100851. */
  100852. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100853. /**
  100854. * Play the sound
  100855. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  100856. * @param offset (optional) Start the sound at a specific time in seconds
  100857. * @param length (optional) Sound duration (in seconds)
  100858. */
  100859. play(time?: number, offset?: number, length?: number): void;
  100860. private _onended;
  100861. /**
  100862. * Stop the sound
  100863. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  100864. */
  100865. stop(time?: number): void;
  100866. /**
  100867. * Put the sound in pause
  100868. */
  100869. pause(): void;
  100870. /**
  100871. * Sets a dedicated volume for this sounds
  100872. * @param newVolume Define the new volume of the sound
  100873. * @param time Define time for gradual change to new volume
  100874. */
  100875. setVolume(newVolume: number, time?: number): void;
  100876. /**
  100877. * Set the sound play back rate
  100878. * @param newPlaybackRate Define the playback rate the sound should be played at
  100879. */
  100880. setPlaybackRate(newPlaybackRate: number): void;
  100881. /**
  100882. * Gets the volume of the sound.
  100883. * @returns the volume of the sound
  100884. */
  100885. getVolume(): number;
  100886. /**
  100887. * Attach the sound to a dedicated mesh
  100888. * @param transformNode The transform node to connect the sound with
  100889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100890. */
  100891. attachToMesh(transformNode: TransformNode): void;
  100892. /**
  100893. * Detach the sound from the previously attached mesh
  100894. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100895. */
  100896. detachFromMesh(): void;
  100897. private _onRegisterAfterWorldMatrixUpdate;
  100898. /**
  100899. * Clone the current sound in the scene.
  100900. * @returns the new sound clone
  100901. */
  100902. clone(): Nullable<Sound>;
  100903. /**
  100904. * Gets the current underlying audio buffer containing the data
  100905. * @returns the audio buffer
  100906. */
  100907. getAudioBuffer(): Nullable<AudioBuffer>;
  100908. /**
  100909. * Serializes the Sound in a JSON representation
  100910. * @returns the JSON representation of the sound
  100911. */
  100912. serialize(): any;
  100913. /**
  100914. * Parse a JSON representation of a sound to innstantiate in a given scene
  100915. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  100916. * @param scene Define the scene the new parsed sound should be created in
  100917. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  100918. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  100919. * @returns the newly parsed sound
  100920. */
  100921. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  100922. }
  100923. }
  100924. declare module BABYLON {
  100925. /**
  100926. * This defines an action helpful to play a defined sound on a triggered action.
  100927. */
  100928. export class PlaySoundAction extends Action {
  100929. private _sound;
  100930. /**
  100931. * Instantiate the action
  100932. * @param triggerOptions defines the trigger options
  100933. * @param sound defines the sound to play
  100934. * @param condition defines the trigger related conditions
  100935. */
  100936. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100937. /** @hidden */
  100938. _prepare(): void;
  100939. /**
  100940. * Execute the action and play the sound.
  100941. */
  100942. execute(): void;
  100943. /**
  100944. * Serializes the actions and its related information.
  100945. * @param parent defines the object to serialize in
  100946. * @returns the serialized object
  100947. */
  100948. serialize(parent: any): any;
  100949. }
  100950. /**
  100951. * This defines an action helpful to stop a defined sound on a triggered action.
  100952. */
  100953. export class StopSoundAction extends Action {
  100954. private _sound;
  100955. /**
  100956. * Instantiate the action
  100957. * @param triggerOptions defines the trigger options
  100958. * @param sound defines the sound to stop
  100959. * @param condition defines the trigger related conditions
  100960. */
  100961. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100962. /** @hidden */
  100963. _prepare(): void;
  100964. /**
  100965. * Execute the action and stop the sound.
  100966. */
  100967. execute(): void;
  100968. /**
  100969. * Serializes the actions and its related information.
  100970. * @param parent defines the object to serialize in
  100971. * @returns the serialized object
  100972. */
  100973. serialize(parent: any): any;
  100974. }
  100975. }
  100976. declare module BABYLON {
  100977. /**
  100978. * This defines an action responsible to change the value of a property
  100979. * by interpolating between its current value and the newly set one once triggered.
  100980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100981. */
  100982. export class InterpolateValueAction extends Action {
  100983. /**
  100984. * Defines the path of the property where the value should be interpolated
  100985. */
  100986. propertyPath: string;
  100987. /**
  100988. * Defines the target value at the end of the interpolation.
  100989. */
  100990. value: any;
  100991. /**
  100992. * Defines the time it will take for the property to interpolate to the value.
  100993. */
  100994. duration: number;
  100995. /**
  100996. * Defines if the other scene animations should be stopped when the action has been triggered
  100997. */
  100998. stopOtherAnimations?: boolean;
  100999. /**
  101000. * Defines a callback raised once the interpolation animation has been done.
  101001. */
  101002. onInterpolationDone?: () => void;
  101003. /**
  101004. * Observable triggered once the interpolation animation has been done.
  101005. */
  101006. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101007. private _target;
  101008. private _effectiveTarget;
  101009. private _property;
  101010. /**
  101011. * Instantiate the action
  101012. * @param triggerOptions defines the trigger options
  101013. * @param target defines the object containing the value to interpolate
  101014. * @param propertyPath defines the path to the property in the target object
  101015. * @param value defines the target value at the end of the interpolation
  101016. * @param duration deines the time it will take for the property to interpolate to the value.
  101017. * @param condition defines the trigger related conditions
  101018. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101019. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101020. */
  101021. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101022. /** @hidden */
  101023. _prepare(): void;
  101024. /**
  101025. * Execute the action starts the value interpolation.
  101026. */
  101027. execute(): void;
  101028. /**
  101029. * Serializes the actions and its related information.
  101030. * @param parent defines the object to serialize in
  101031. * @returns the serialized object
  101032. */
  101033. serialize(parent: any): any;
  101034. }
  101035. }
  101036. declare module BABYLON {
  101037. /**
  101038. * Options allowed during the creation of a sound track.
  101039. */
  101040. export interface ISoundTrackOptions {
  101041. /**
  101042. * The volume the sound track should take during creation
  101043. */
  101044. volume?: number;
  101045. /**
  101046. * Define if the sound track is the main sound track of the scene
  101047. */
  101048. mainTrack?: boolean;
  101049. }
  101050. /**
  101051. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101052. * It will be also used in a future release to apply effects on a specific track.
  101053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101054. */
  101055. export class SoundTrack {
  101056. /**
  101057. * The unique identifier of the sound track in the scene.
  101058. */
  101059. id: number;
  101060. /**
  101061. * The list of sounds included in the sound track.
  101062. */
  101063. soundCollection: Array<Sound>;
  101064. private _outputAudioNode;
  101065. private _scene;
  101066. private _isMainTrack;
  101067. private _connectedAnalyser;
  101068. private _options;
  101069. private _isInitialized;
  101070. /**
  101071. * Creates a new sound track.
  101072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101073. * @param scene Define the scene the sound track belongs to
  101074. * @param options
  101075. */
  101076. constructor(scene: Scene, options?: ISoundTrackOptions);
  101077. private _initializeSoundTrackAudioGraph;
  101078. /**
  101079. * Release the sound track and its associated resources
  101080. */
  101081. dispose(): void;
  101082. /**
  101083. * Adds a sound to this sound track
  101084. * @param sound define the cound to add
  101085. * @ignoreNaming
  101086. */
  101087. AddSound(sound: Sound): void;
  101088. /**
  101089. * Removes a sound to this sound track
  101090. * @param sound define the cound to remove
  101091. * @ignoreNaming
  101092. */
  101093. RemoveSound(sound: Sound): void;
  101094. /**
  101095. * Set a global volume for the full sound track.
  101096. * @param newVolume Define the new volume of the sound track
  101097. */
  101098. setVolume(newVolume: number): void;
  101099. /**
  101100. * Switch the panning model to HRTF:
  101101. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101103. */
  101104. switchPanningModelToHRTF(): void;
  101105. /**
  101106. * Switch the panning model to Equal Power:
  101107. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101109. */
  101110. switchPanningModelToEqualPower(): void;
  101111. /**
  101112. * Connect the sound track to an audio analyser allowing some amazing
  101113. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101115. * @param analyser The analyser to connect to the engine
  101116. */
  101117. connectToAnalyser(analyser: Analyser): void;
  101118. }
  101119. }
  101120. declare module BABYLON {
  101121. interface AbstractScene {
  101122. /**
  101123. * The list of sounds used in the scene.
  101124. */
  101125. sounds: Nullable<Array<Sound>>;
  101126. }
  101127. interface Scene {
  101128. /**
  101129. * @hidden
  101130. * Backing field
  101131. */
  101132. _mainSoundTrack: SoundTrack;
  101133. /**
  101134. * The main sound track played by the scene.
  101135. * It cotains your primary collection of sounds.
  101136. */
  101137. mainSoundTrack: SoundTrack;
  101138. /**
  101139. * The list of sound tracks added to the scene
  101140. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101141. */
  101142. soundTracks: Nullable<Array<SoundTrack>>;
  101143. /**
  101144. * Gets a sound using a given name
  101145. * @param name defines the name to search for
  101146. * @return the found sound or null if not found at all.
  101147. */
  101148. getSoundByName(name: string): Nullable<Sound>;
  101149. /**
  101150. * Gets or sets if audio support is enabled
  101151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101152. */
  101153. audioEnabled: boolean;
  101154. /**
  101155. * Gets or sets if audio will be output to headphones
  101156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101157. */
  101158. headphone: boolean;
  101159. /**
  101160. * Gets or sets custom audio listener position provider
  101161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101162. */
  101163. audioListenerPositionProvider: Nullable<() => Vector3>;
  101164. }
  101165. /**
  101166. * Defines the sound scene component responsible to manage any sounds
  101167. * in a given scene.
  101168. */
  101169. export class AudioSceneComponent implements ISceneSerializableComponent {
  101170. /**
  101171. * The component name helpfull to identify the component in the list of scene components.
  101172. */
  101173. readonly name: string;
  101174. /**
  101175. * The scene the component belongs to.
  101176. */
  101177. scene: Scene;
  101178. private _audioEnabled;
  101179. /**
  101180. * Gets whether audio is enabled or not.
  101181. * Please use related enable/disable method to switch state.
  101182. */
  101183. readonly audioEnabled: boolean;
  101184. private _headphone;
  101185. /**
  101186. * Gets whether audio is outputing to headphone or not.
  101187. * Please use the according Switch methods to change output.
  101188. */
  101189. readonly headphone: boolean;
  101190. private _audioListenerPositionProvider;
  101191. /**
  101192. * Gets the current audio listener position provider
  101193. */
  101194. /**
  101195. * Sets a custom listener position for all sounds in the scene
  101196. * By default, this is the position of the first active camera
  101197. */
  101198. audioListenerPositionProvider: Nullable<() => Vector3>;
  101199. /**
  101200. * Creates a new instance of the component for the given scene
  101201. * @param scene Defines the scene to register the component in
  101202. */
  101203. constructor(scene: Scene);
  101204. /**
  101205. * Registers the component in a given scene
  101206. */
  101207. register(): void;
  101208. /**
  101209. * Rebuilds the elements related to this component in case of
  101210. * context lost for instance.
  101211. */
  101212. rebuild(): void;
  101213. /**
  101214. * Serializes the component data to the specified json object
  101215. * @param serializationObject The object to serialize to
  101216. */
  101217. serialize(serializationObject: any): void;
  101218. /**
  101219. * Adds all the elements from the container to the scene
  101220. * @param container the container holding the elements
  101221. */
  101222. addFromContainer(container: AbstractScene): void;
  101223. /**
  101224. * Removes all the elements in the container from the scene
  101225. * @param container contains the elements to remove
  101226. * @param dispose if the removed element should be disposed (default: false)
  101227. */
  101228. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  101229. /**
  101230. * Disposes the component and the associated ressources.
  101231. */
  101232. dispose(): void;
  101233. /**
  101234. * Disables audio in the associated scene.
  101235. */
  101236. disableAudio(): void;
  101237. /**
  101238. * Enables audio in the associated scene.
  101239. */
  101240. enableAudio(): void;
  101241. /**
  101242. * Switch audio to headphone output.
  101243. */
  101244. switchAudioModeForHeadphones(): void;
  101245. /**
  101246. * Switch audio to normal speakers.
  101247. */
  101248. switchAudioModeForNormalSpeakers(): void;
  101249. private _afterRender;
  101250. }
  101251. }
  101252. declare module BABYLON {
  101253. /**
  101254. * Wraps one or more Sound objects and selects one with random weight for playback.
  101255. */
  101256. export class WeightedSound {
  101257. /** When true a Sound will be selected and played when the current playing Sound completes. */
  101258. loop: boolean;
  101259. private _coneInnerAngle;
  101260. private _coneOuterAngle;
  101261. private _volume;
  101262. /** A Sound is currently playing. */
  101263. isPlaying: boolean;
  101264. /** A Sound is currently paused. */
  101265. isPaused: boolean;
  101266. private _sounds;
  101267. private _weights;
  101268. private _currentIndex?;
  101269. /**
  101270. * Creates a new WeightedSound from the list of sounds given.
  101271. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  101272. * @param sounds Array of Sounds that will be selected from.
  101273. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  101274. */
  101275. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  101276. /**
  101277. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  101278. */
  101279. /**
  101280. * The size of cone in degress for a directional sound in which there will be no attenuation.
  101281. */
  101282. directionalConeInnerAngle: number;
  101283. /**
  101284. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101285. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101286. */
  101287. /**
  101288. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101289. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101290. */
  101291. directionalConeOuterAngle: number;
  101292. /**
  101293. * Playback volume.
  101294. */
  101295. /**
  101296. * Playback volume.
  101297. */
  101298. volume: number;
  101299. private _onended;
  101300. /**
  101301. * Suspend playback
  101302. */
  101303. pause(): void;
  101304. /**
  101305. * Stop playback
  101306. */
  101307. stop(): void;
  101308. /**
  101309. * Start playback.
  101310. * @param startOffset Position the clip head at a specific time in seconds.
  101311. */
  101312. play(startOffset?: number): void;
  101313. }
  101314. }
  101315. declare module BABYLON {
  101316. /**
  101317. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  101318. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101319. */
  101320. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  101321. /**
  101322. * Gets the name of the behavior.
  101323. */
  101324. readonly name: string;
  101325. /**
  101326. * The easing function used by animations
  101327. */
  101328. static EasingFunction: BackEase;
  101329. /**
  101330. * The easing mode used by animations
  101331. */
  101332. static EasingMode: number;
  101333. /**
  101334. * The duration of the animation, in milliseconds
  101335. */
  101336. transitionDuration: number;
  101337. /**
  101338. * Length of the distance animated by the transition when lower radius is reached
  101339. */
  101340. lowerRadiusTransitionRange: number;
  101341. /**
  101342. * Length of the distance animated by the transition when upper radius is reached
  101343. */
  101344. upperRadiusTransitionRange: number;
  101345. private _autoTransitionRange;
  101346. /**
  101347. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101348. */
  101349. /**
  101350. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101351. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  101352. */
  101353. autoTransitionRange: boolean;
  101354. private _attachedCamera;
  101355. private _onAfterCheckInputsObserver;
  101356. private _onMeshTargetChangedObserver;
  101357. /**
  101358. * Initializes the behavior.
  101359. */
  101360. init(): void;
  101361. /**
  101362. * Attaches the behavior to its arc rotate camera.
  101363. * @param camera Defines the camera to attach the behavior to
  101364. */
  101365. attach(camera: ArcRotateCamera): void;
  101366. /**
  101367. * Detaches the behavior from its current arc rotate camera.
  101368. */
  101369. detach(): void;
  101370. private _radiusIsAnimating;
  101371. private _radiusBounceTransition;
  101372. private _animatables;
  101373. private _cachedWheelPrecision;
  101374. /**
  101375. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  101376. * @param radiusLimit The limit to check against.
  101377. * @return Bool to indicate if at limit.
  101378. */
  101379. private _isRadiusAtLimit;
  101380. /**
  101381. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  101382. * @param radiusDelta The delta by which to animate to. Can be negative.
  101383. */
  101384. private _applyBoundRadiusAnimation;
  101385. /**
  101386. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  101387. */
  101388. protected _clearAnimationLocks(): void;
  101389. /**
  101390. * Stops and removes all animations that have been applied to the camera
  101391. */
  101392. stopAllAnimations(): void;
  101393. }
  101394. }
  101395. declare module BABYLON {
  101396. /**
  101397. * 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.
  101398. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101399. */
  101400. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  101401. /**
  101402. * Gets the name of the behavior.
  101403. */
  101404. readonly name: string;
  101405. private _mode;
  101406. private _radiusScale;
  101407. private _positionScale;
  101408. private _defaultElevation;
  101409. private _elevationReturnTime;
  101410. private _elevationReturnWaitTime;
  101411. private _zoomStopsAnimation;
  101412. private _framingTime;
  101413. /**
  101414. * The easing function used by animations
  101415. */
  101416. static EasingFunction: ExponentialEase;
  101417. /**
  101418. * The easing mode used by animations
  101419. */
  101420. static EasingMode: number;
  101421. /**
  101422. * Sets the current mode used by the behavior
  101423. */
  101424. /**
  101425. * Gets current mode used by the behavior.
  101426. */
  101427. mode: number;
  101428. /**
  101429. * Sets the scale applied to the radius (1 by default)
  101430. */
  101431. /**
  101432. * Gets the scale applied to the radius
  101433. */
  101434. radiusScale: number;
  101435. /**
  101436. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101437. */
  101438. /**
  101439. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101440. */
  101441. positionScale: number;
  101442. /**
  101443. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101444. * behaviour is triggered, in radians.
  101445. */
  101446. /**
  101447. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101448. * behaviour is triggered, in radians.
  101449. */
  101450. defaultElevation: number;
  101451. /**
  101452. * Sets the time (in milliseconds) taken to return to the default beta position.
  101453. * Negative value indicates camera should not return to default.
  101454. */
  101455. /**
  101456. * Gets the time (in milliseconds) taken to return to the default beta position.
  101457. * Negative value indicates camera should not return to default.
  101458. */
  101459. elevationReturnTime: number;
  101460. /**
  101461. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101462. */
  101463. /**
  101464. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101465. */
  101466. elevationReturnWaitTime: number;
  101467. /**
  101468. * Sets the flag that indicates if user zooming should stop animation.
  101469. */
  101470. /**
  101471. * Gets the flag that indicates if user zooming should stop animation.
  101472. */
  101473. zoomStopsAnimation: boolean;
  101474. /**
  101475. * Sets the transition time when framing the mesh, in milliseconds
  101476. */
  101477. /**
  101478. * Gets the transition time when framing the mesh, in milliseconds
  101479. */
  101480. framingTime: number;
  101481. /**
  101482. * Define if the behavior should automatically change the configured
  101483. * camera limits and sensibilities.
  101484. */
  101485. autoCorrectCameraLimitsAndSensibility: boolean;
  101486. private _onPrePointerObservableObserver;
  101487. private _onAfterCheckInputsObserver;
  101488. private _onMeshTargetChangedObserver;
  101489. private _attachedCamera;
  101490. private _isPointerDown;
  101491. private _lastInteractionTime;
  101492. /**
  101493. * Initializes the behavior.
  101494. */
  101495. init(): void;
  101496. /**
  101497. * Attaches the behavior to its arc rotate camera.
  101498. * @param camera Defines the camera to attach the behavior to
  101499. */
  101500. attach(camera: ArcRotateCamera): void;
  101501. /**
  101502. * Detaches the behavior from its current arc rotate camera.
  101503. */
  101504. detach(): void;
  101505. private _animatables;
  101506. private _betaIsAnimating;
  101507. private _betaTransition;
  101508. private _radiusTransition;
  101509. private _vectorTransition;
  101510. /**
  101511. * Targets the given mesh and updates zoom level accordingly.
  101512. * @param mesh The mesh to target.
  101513. * @param radius Optional. If a cached radius position already exists, overrides default.
  101514. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101515. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101516. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101517. */
  101518. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101519. /**
  101520. * Targets the given mesh with its children and updates zoom level accordingly.
  101521. * @param mesh The mesh to target.
  101522. * @param radius Optional. If a cached radius position already exists, overrides default.
  101523. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101524. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101525. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101526. */
  101527. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101528. /**
  101529. * Targets the given meshes with their children and updates zoom level accordingly.
  101530. * @param meshes The mesh to target.
  101531. * @param radius Optional. If a cached radius position already exists, overrides default.
  101532. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101533. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101534. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101535. */
  101536. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101537. /**
  101538. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101539. * @param minimumWorld Determines the smaller position of the bounding box extend
  101540. * @param maximumWorld Determines the bigger position of the bounding box extend
  101541. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101542. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101543. */
  101544. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101545. /**
  101546. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101547. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101548. * frustum width.
  101549. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101550. * to fully enclose the mesh in the viewing frustum.
  101551. */
  101552. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101553. /**
  101554. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101555. * is automatically returned to its default position (expected to be above ground plane).
  101556. */
  101557. private _maintainCameraAboveGround;
  101558. /**
  101559. * Returns the frustum slope based on the canvas ratio and camera FOV
  101560. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101561. */
  101562. private _getFrustumSlope;
  101563. /**
  101564. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101565. */
  101566. private _clearAnimationLocks;
  101567. /**
  101568. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101569. */
  101570. private _applyUserInteraction;
  101571. /**
  101572. * Stops and removes all animations that have been applied to the camera
  101573. */
  101574. stopAllAnimations(): void;
  101575. /**
  101576. * Gets a value indicating if the user is moving the camera
  101577. */
  101578. readonly isUserIsMoving: boolean;
  101579. /**
  101580. * The camera can move all the way towards the mesh.
  101581. */
  101582. static IgnoreBoundsSizeMode: number;
  101583. /**
  101584. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101585. */
  101586. static FitFrustumSidesMode: number;
  101587. }
  101588. }
  101589. declare module BABYLON {
  101590. /**
  101591. * Base class for Camera Pointer Inputs.
  101592. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101593. * for example usage.
  101594. */
  101595. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101596. /**
  101597. * Defines the camera the input is attached to.
  101598. */
  101599. abstract camera: Camera;
  101600. /**
  101601. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101602. */
  101603. protected _altKey: boolean;
  101604. protected _ctrlKey: boolean;
  101605. protected _metaKey: boolean;
  101606. protected _shiftKey: boolean;
  101607. /**
  101608. * Which mouse buttons were pressed at time of last mouse event.
  101609. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101610. */
  101611. protected _buttonsPressed: number;
  101612. /**
  101613. * Defines the buttons associated with the input to handle camera move.
  101614. */
  101615. buttons: number[];
  101616. /**
  101617. * Attach the input controls to a specific dom element to get the input from.
  101618. * @param element Defines the element the controls should be listened from
  101619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101620. */
  101621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101622. /**
  101623. * Detach the current controls from the specified dom element.
  101624. * @param element Defines the element to stop listening the inputs from
  101625. */
  101626. detachControl(element: Nullable<HTMLElement>): void;
  101627. /**
  101628. * Gets the class name of the current input.
  101629. * @returns the class name
  101630. */
  101631. getClassName(): string;
  101632. /**
  101633. * Get the friendly name associated with the input class.
  101634. * @returns the input friendly name
  101635. */
  101636. getSimpleName(): string;
  101637. /**
  101638. * Called on pointer POINTERDOUBLETAP event.
  101639. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101640. */
  101641. protected onDoubleTap(type: string): void;
  101642. /**
  101643. * Called on pointer POINTERMOVE event if only a single touch is active.
  101644. * Override this method to provide functionality.
  101645. */
  101646. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101647. /**
  101648. * Called on pointer POINTERMOVE event if multiple touches are active.
  101649. * Override this method to provide functionality.
  101650. */
  101651. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101652. /**
  101653. * Called on JS contextmenu event.
  101654. * Override this method to provide functionality.
  101655. */
  101656. protected onContextMenu(evt: PointerEvent): void;
  101657. /**
  101658. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101659. * press.
  101660. * Override this method to provide functionality.
  101661. */
  101662. protected onButtonDown(evt: PointerEvent): void;
  101663. /**
  101664. * Called each time a new POINTERUP event occurs. Ie, for each button
  101665. * release.
  101666. * Override this method to provide functionality.
  101667. */
  101668. protected onButtonUp(evt: PointerEvent): void;
  101669. /**
  101670. * Called when window becomes inactive.
  101671. * Override this method to provide functionality.
  101672. */
  101673. protected onLostFocus(): void;
  101674. private _pointerInput;
  101675. private _observer;
  101676. private _onLostFocus;
  101677. private pointA;
  101678. private pointB;
  101679. }
  101680. }
  101681. declare module BABYLON {
  101682. /**
  101683. * Manage the pointers inputs to control an arc rotate camera.
  101684. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101685. */
  101686. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101687. /**
  101688. * Defines the camera the input is attached to.
  101689. */
  101690. camera: ArcRotateCamera;
  101691. /**
  101692. * Gets the class name of the current input.
  101693. * @returns the class name
  101694. */
  101695. getClassName(): string;
  101696. /**
  101697. * Defines the buttons associated with the input to handle camera move.
  101698. */
  101699. buttons: number[];
  101700. /**
  101701. * Defines the pointer angular sensibility along the X axis or how fast is
  101702. * the camera rotating.
  101703. */
  101704. angularSensibilityX: number;
  101705. /**
  101706. * Defines the pointer angular sensibility along the Y axis or how fast is
  101707. * the camera rotating.
  101708. */
  101709. angularSensibilityY: number;
  101710. /**
  101711. * Defines the pointer pinch precision or how fast is the camera zooming.
  101712. */
  101713. pinchPrecision: number;
  101714. /**
  101715. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101716. * from 0.
  101717. * It defines the percentage of current camera.radius to use as delta when
  101718. * pinch zoom is used.
  101719. */
  101720. pinchDeltaPercentage: number;
  101721. /**
  101722. * Defines the pointer panning sensibility or how fast is the camera moving.
  101723. */
  101724. panningSensibility: number;
  101725. /**
  101726. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101727. */
  101728. multiTouchPanning: boolean;
  101729. /**
  101730. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101731. * zoom (pinch) through multitouch.
  101732. */
  101733. multiTouchPanAndZoom: boolean;
  101734. /**
  101735. * Revers pinch action direction.
  101736. */
  101737. pinchInwards: boolean;
  101738. private _isPanClick;
  101739. private _twoFingerActivityCount;
  101740. private _isPinching;
  101741. /**
  101742. * Called on pointer POINTERMOVE event if only a single touch is active.
  101743. */
  101744. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101745. /**
  101746. * Called on pointer POINTERDOUBLETAP event.
  101747. */
  101748. protected onDoubleTap(type: string): void;
  101749. /**
  101750. * Called on pointer POINTERMOVE event if multiple touches are active.
  101751. */
  101752. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101753. /**
  101754. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101755. * press.
  101756. */
  101757. protected onButtonDown(evt: PointerEvent): void;
  101758. /**
  101759. * Called each time a new POINTERUP event occurs. Ie, for each button
  101760. * release.
  101761. */
  101762. protected onButtonUp(evt: PointerEvent): void;
  101763. /**
  101764. * Called when window becomes inactive.
  101765. */
  101766. protected onLostFocus(): void;
  101767. }
  101768. }
  101769. declare module BABYLON {
  101770. /**
  101771. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101773. */
  101774. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101775. /**
  101776. * Defines the camera the input is attached to.
  101777. */
  101778. camera: ArcRotateCamera;
  101779. /**
  101780. * Defines the list of key codes associated with the up action (increase alpha)
  101781. */
  101782. keysUp: number[];
  101783. /**
  101784. * Defines the list of key codes associated with the down action (decrease alpha)
  101785. */
  101786. keysDown: number[];
  101787. /**
  101788. * Defines the list of key codes associated with the left action (increase beta)
  101789. */
  101790. keysLeft: number[];
  101791. /**
  101792. * Defines the list of key codes associated with the right action (decrease beta)
  101793. */
  101794. keysRight: number[];
  101795. /**
  101796. * Defines the list of key codes associated with the reset action.
  101797. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101798. */
  101799. keysReset: number[];
  101800. /**
  101801. * Defines the panning sensibility of the inputs.
  101802. * (How fast is the camera paning)
  101803. */
  101804. panningSensibility: number;
  101805. /**
  101806. * Defines the zooming sensibility of the inputs.
  101807. * (How fast is the camera zooming)
  101808. */
  101809. zoomingSensibility: number;
  101810. /**
  101811. * Defines wether maintaining the alt key down switch the movement mode from
  101812. * orientation to zoom.
  101813. */
  101814. useAltToZoom: boolean;
  101815. /**
  101816. * Rotation speed of the camera
  101817. */
  101818. angularSpeed: number;
  101819. private _keys;
  101820. private _ctrlPressed;
  101821. private _altPressed;
  101822. private _onCanvasBlurObserver;
  101823. private _onKeyboardObserver;
  101824. private _engine;
  101825. private _scene;
  101826. /**
  101827. * Attach the input controls to a specific dom element to get the input from.
  101828. * @param element Defines the element the controls should be listened from
  101829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101830. */
  101831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101832. /**
  101833. * Detach the current controls from the specified dom element.
  101834. * @param element Defines the element to stop listening the inputs from
  101835. */
  101836. detachControl(element: Nullable<HTMLElement>): void;
  101837. /**
  101838. * Update the current camera state depending on the inputs that have been used this frame.
  101839. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101840. */
  101841. checkInputs(): void;
  101842. /**
  101843. * Gets the class name of the current intput.
  101844. * @returns the class name
  101845. */
  101846. getClassName(): string;
  101847. /**
  101848. * Get the friendly name associated with the input class.
  101849. * @returns the input friendly name
  101850. */
  101851. getSimpleName(): string;
  101852. }
  101853. }
  101854. declare module BABYLON {
  101855. /**
  101856. * Manage the mouse wheel inputs to control an arc rotate camera.
  101857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101858. */
  101859. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  101860. /**
  101861. * Defines the camera the input is attached to.
  101862. */
  101863. camera: ArcRotateCamera;
  101864. /**
  101865. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101866. */
  101867. wheelPrecision: number;
  101868. /**
  101869. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101870. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101871. */
  101872. wheelDeltaPercentage: number;
  101873. private _wheel;
  101874. private _observer;
  101875. private computeDeltaFromMouseWheelLegacyEvent;
  101876. /**
  101877. * Attach the input controls to a specific dom element to get the input from.
  101878. * @param element Defines the element the controls should be listened from
  101879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101880. */
  101881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101882. /**
  101883. * Detach the current controls from the specified dom element.
  101884. * @param element Defines the element to stop listening the inputs from
  101885. */
  101886. detachControl(element: Nullable<HTMLElement>): void;
  101887. /**
  101888. * Gets the class name of the current intput.
  101889. * @returns the class name
  101890. */
  101891. getClassName(): string;
  101892. /**
  101893. * Get the friendly name associated with the input class.
  101894. * @returns the input friendly name
  101895. */
  101896. getSimpleName(): string;
  101897. }
  101898. }
  101899. declare module BABYLON {
  101900. /**
  101901. * Default Inputs manager for the ArcRotateCamera.
  101902. * It groups all the default supported inputs for ease of use.
  101903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101904. */
  101905. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  101906. /**
  101907. * Instantiates a new ArcRotateCameraInputsManager.
  101908. * @param camera Defines the camera the inputs belong to
  101909. */
  101910. constructor(camera: ArcRotateCamera);
  101911. /**
  101912. * Add mouse wheel input support to the input manager.
  101913. * @returns the current input manager
  101914. */
  101915. addMouseWheel(): ArcRotateCameraInputsManager;
  101916. /**
  101917. * Add pointers input support to the input manager.
  101918. * @returns the current input manager
  101919. */
  101920. addPointers(): ArcRotateCameraInputsManager;
  101921. /**
  101922. * Add keyboard input support to the input manager.
  101923. * @returns the current input manager
  101924. */
  101925. addKeyboard(): ArcRotateCameraInputsManager;
  101926. }
  101927. }
  101928. declare module BABYLON {
  101929. /**
  101930. * This represents an orbital type of camera.
  101931. *
  101932. * 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.
  101933. * 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.
  101934. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  101935. */
  101936. export class ArcRotateCamera extends TargetCamera {
  101937. /**
  101938. * Defines the rotation angle of the camera along the longitudinal axis.
  101939. */
  101940. alpha: number;
  101941. /**
  101942. * Defines the rotation angle of the camera along the latitudinal axis.
  101943. */
  101944. beta: number;
  101945. /**
  101946. * Defines the radius of the camera from it s target point.
  101947. */
  101948. radius: number;
  101949. protected _target: Vector3;
  101950. protected _targetHost: Nullable<AbstractMesh>;
  101951. /**
  101952. * Defines the target point of the camera.
  101953. * The camera looks towards it form the radius distance.
  101954. */
  101955. target: Vector3;
  101956. /**
  101957. * Define the current local position of the camera in the scene
  101958. */
  101959. position: Vector3;
  101960. protected _upVector: Vector3;
  101961. protected _upToYMatrix: Matrix;
  101962. protected _YToUpMatrix: Matrix;
  101963. /**
  101964. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  101965. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  101966. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  101967. */
  101968. upVector: Vector3;
  101969. /**
  101970. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  101971. */
  101972. setMatUp(): void;
  101973. /**
  101974. * Current inertia value on the longitudinal axis.
  101975. * The bigger this number the longer it will take for the camera to stop.
  101976. */
  101977. inertialAlphaOffset: number;
  101978. /**
  101979. * Current inertia value on the latitudinal axis.
  101980. * The bigger this number the longer it will take for the camera to stop.
  101981. */
  101982. inertialBetaOffset: number;
  101983. /**
  101984. * Current inertia value on the radius axis.
  101985. * The bigger this number the longer it will take for the camera to stop.
  101986. */
  101987. inertialRadiusOffset: number;
  101988. /**
  101989. * Minimum allowed angle on the longitudinal axis.
  101990. * This can help limiting how the Camera is able to move in the scene.
  101991. */
  101992. lowerAlphaLimit: Nullable<number>;
  101993. /**
  101994. * Maximum allowed angle on the longitudinal axis.
  101995. * This can help limiting how the Camera is able to move in the scene.
  101996. */
  101997. upperAlphaLimit: Nullable<number>;
  101998. /**
  101999. * Minimum allowed angle on the latitudinal axis.
  102000. * This can help limiting how the Camera is able to move in the scene.
  102001. */
  102002. lowerBetaLimit: number;
  102003. /**
  102004. * Maximum allowed angle on the latitudinal axis.
  102005. * This can help limiting how the Camera is able to move in the scene.
  102006. */
  102007. upperBetaLimit: number;
  102008. /**
  102009. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102010. * This can help limiting how the Camera is able to move in the scene.
  102011. */
  102012. lowerRadiusLimit: Nullable<number>;
  102013. /**
  102014. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102015. * This can help limiting how the Camera is able to move in the scene.
  102016. */
  102017. upperRadiusLimit: Nullable<number>;
  102018. /**
  102019. * Defines the current inertia value used during panning of the camera along the X axis.
  102020. */
  102021. inertialPanningX: number;
  102022. /**
  102023. * Defines the current inertia value used during panning of the camera along the Y axis.
  102024. */
  102025. inertialPanningY: number;
  102026. /**
  102027. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102028. * Basically if your fingers moves away from more than this distance you will be considered
  102029. * in pinch mode.
  102030. */
  102031. pinchToPanMaxDistance: number;
  102032. /**
  102033. * Defines the maximum distance the camera can pan.
  102034. * This could help keeping the cammera always in your scene.
  102035. */
  102036. panningDistanceLimit: Nullable<number>;
  102037. /**
  102038. * Defines the target of the camera before paning.
  102039. */
  102040. panningOriginTarget: Vector3;
  102041. /**
  102042. * Defines the value of the inertia used during panning.
  102043. * 0 would mean stop inertia and one would mean no decelleration at all.
  102044. */
  102045. panningInertia: number;
  102046. /**
  102047. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102048. */
  102049. angularSensibilityX: number;
  102050. /**
  102051. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102052. */
  102053. angularSensibilityY: number;
  102054. /**
  102055. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  102056. */
  102057. pinchPrecision: number;
  102058. /**
  102059. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  102060. * It will be used instead of pinchDeltaPrecision if different from 0.
  102061. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102062. */
  102063. pinchDeltaPercentage: number;
  102064. /**
  102065. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  102066. */
  102067. panningSensibility: number;
  102068. /**
  102069. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  102070. */
  102071. keysUp: number[];
  102072. /**
  102073. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  102074. */
  102075. keysDown: number[];
  102076. /**
  102077. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  102078. */
  102079. keysLeft: number[];
  102080. /**
  102081. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  102082. */
  102083. keysRight: number[];
  102084. /**
  102085. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102086. */
  102087. wheelPrecision: number;
  102088. /**
  102089. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  102090. * It will be used instead of pinchDeltaPrecision if different from 0.
  102091. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102092. */
  102093. wheelDeltaPercentage: number;
  102094. /**
  102095. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  102096. */
  102097. zoomOnFactor: number;
  102098. /**
  102099. * Defines a screen offset for the camera position.
  102100. */
  102101. targetScreenOffset: Vector2;
  102102. /**
  102103. * Allows the camera to be completely reversed.
  102104. * If false the camera can not arrive upside down.
  102105. */
  102106. allowUpsideDown: boolean;
  102107. /**
  102108. * Define if double tap/click is used to restore the previously saved state of the camera.
  102109. */
  102110. useInputToRestoreState: boolean;
  102111. /** @hidden */
  102112. _viewMatrix: Matrix;
  102113. /** @hidden */
  102114. _useCtrlForPanning: boolean;
  102115. /** @hidden */
  102116. _panningMouseButton: number;
  102117. /**
  102118. * Defines the input associated to the camera.
  102119. */
  102120. inputs: ArcRotateCameraInputsManager;
  102121. /** @hidden */
  102122. _reset: () => void;
  102123. /**
  102124. * Defines the allowed panning axis.
  102125. */
  102126. panningAxis: Vector3;
  102127. protected _localDirection: Vector3;
  102128. protected _transformedDirection: Vector3;
  102129. private _bouncingBehavior;
  102130. /**
  102131. * Gets the bouncing behavior of the camera if it has been enabled.
  102132. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102133. */
  102134. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102135. /**
  102136. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102137. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102138. */
  102139. useBouncingBehavior: boolean;
  102140. private _framingBehavior;
  102141. /**
  102142. * Gets the framing behavior of the camera if it has been enabled.
  102143. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102144. */
  102145. readonly framingBehavior: Nullable<FramingBehavior>;
  102146. /**
  102147. * Defines if the framing behavior of the camera is enabled on the camera.
  102148. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102149. */
  102150. useFramingBehavior: boolean;
  102151. private _autoRotationBehavior;
  102152. /**
  102153. * Gets the auto rotation behavior of the camera if it has been enabled.
  102154. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102155. */
  102156. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102157. /**
  102158. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102159. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102160. */
  102161. useAutoRotationBehavior: boolean;
  102162. /**
  102163. * Observable triggered when the mesh target has been changed on the camera.
  102164. */
  102165. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102166. /**
  102167. * Event raised when the camera is colliding with a mesh.
  102168. */
  102169. onCollide: (collidedMesh: AbstractMesh) => void;
  102170. /**
  102171. * Defines whether the camera should check collision with the objects oh the scene.
  102172. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102173. */
  102174. checkCollisions: boolean;
  102175. /**
  102176. * Defines the collision radius of the camera.
  102177. * This simulates a sphere around the camera.
  102178. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102179. */
  102180. collisionRadius: Vector3;
  102181. protected _collider: Collider;
  102182. protected _previousPosition: Vector3;
  102183. protected _collisionVelocity: Vector3;
  102184. protected _newPosition: Vector3;
  102185. protected _previousAlpha: number;
  102186. protected _previousBeta: number;
  102187. protected _previousRadius: number;
  102188. protected _collisionTriggered: boolean;
  102189. protected _targetBoundingCenter: Nullable<Vector3>;
  102190. private _computationVector;
  102191. /**
  102192. * Instantiates a new ArcRotateCamera in a given scene
  102193. * @param name Defines the name of the camera
  102194. * @param alpha Defines the camera rotation along the logitudinal axis
  102195. * @param beta Defines the camera rotation along the latitudinal axis
  102196. * @param radius Defines the camera distance from its target
  102197. * @param target Defines the camera target
  102198. * @param scene Defines the scene the camera belongs to
  102199. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102200. */
  102201. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102202. /** @hidden */
  102203. _initCache(): void;
  102204. /** @hidden */
  102205. _updateCache(ignoreParentClass?: boolean): void;
  102206. protected _getTargetPosition(): Vector3;
  102207. private _storedAlpha;
  102208. private _storedBeta;
  102209. private _storedRadius;
  102210. private _storedTarget;
  102211. private _storedTargetScreenOffset;
  102212. /**
  102213. * Stores the current state of the camera (alpha, beta, radius and target)
  102214. * @returns the camera itself
  102215. */
  102216. storeState(): Camera;
  102217. /**
  102218. * @hidden
  102219. * Restored camera state. You must call storeState() first
  102220. */
  102221. _restoreStateValues(): boolean;
  102222. /** @hidden */
  102223. _isSynchronizedViewMatrix(): boolean;
  102224. /**
  102225. * Attached controls to the current camera.
  102226. * @param element Defines the element the controls should be listened from
  102227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102228. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  102229. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  102230. */
  102231. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  102232. /**
  102233. * Detach the current controls from the camera.
  102234. * The camera will stop reacting to inputs.
  102235. * @param element Defines the element to stop listening the inputs from
  102236. */
  102237. detachControl(element: HTMLElement): void;
  102238. /** @hidden */
  102239. _checkInputs(): void;
  102240. protected _checkLimits(): void;
  102241. /**
  102242. * Rebuilds angles (alpha, beta) and radius from the give position and target
  102243. */
  102244. rebuildAnglesAndRadius(): void;
  102245. /**
  102246. * Use a position to define the current camera related information like aplha, beta and radius
  102247. * @param position Defines the position to set the camera at
  102248. */
  102249. setPosition(position: Vector3): void;
  102250. /**
  102251. * Defines the target the camera should look at.
  102252. * This will automatically adapt alpha beta and radius to fit within the new target.
  102253. * @param target Defines the new target as a Vector or a mesh
  102254. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  102255. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  102256. */
  102257. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  102258. /** @hidden */
  102259. _getViewMatrix(): Matrix;
  102260. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  102261. /**
  102262. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  102263. * @param meshes Defines the mesh to zoom on
  102264. * @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)
  102265. */
  102266. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  102267. /**
  102268. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  102269. * The target will be changed but the radius
  102270. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  102271. * @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)
  102272. */
  102273. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  102274. min: Vector3;
  102275. max: Vector3;
  102276. distance: number;
  102277. }, doNotUpdateMaxZ?: boolean): void;
  102278. /**
  102279. * @override
  102280. * Override Camera.createRigCamera
  102281. */
  102282. createRigCamera(name: string, cameraIndex: number): Camera;
  102283. /**
  102284. * @hidden
  102285. * @override
  102286. * Override Camera._updateRigCameras
  102287. */
  102288. _updateRigCameras(): void;
  102289. /**
  102290. * Destroy the camera and release the current resources hold by it.
  102291. */
  102292. dispose(): void;
  102293. /**
  102294. * Gets the current object class name.
  102295. * @return the class name
  102296. */
  102297. getClassName(): string;
  102298. }
  102299. }
  102300. declare module BABYLON {
  102301. /**
  102302. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  102303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102304. */
  102305. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  102306. /**
  102307. * Gets the name of the behavior.
  102308. */
  102309. readonly name: string;
  102310. private _zoomStopsAnimation;
  102311. private _idleRotationSpeed;
  102312. private _idleRotationWaitTime;
  102313. private _idleRotationSpinupTime;
  102314. /**
  102315. * Sets the flag that indicates if user zooming should stop animation.
  102316. */
  102317. /**
  102318. * Gets the flag that indicates if user zooming should stop animation.
  102319. */
  102320. zoomStopsAnimation: boolean;
  102321. /**
  102322. * Sets the default speed at which the camera rotates around the model.
  102323. */
  102324. /**
  102325. * Gets the default speed at which the camera rotates around the model.
  102326. */
  102327. idleRotationSpeed: number;
  102328. /**
  102329. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  102330. */
  102331. /**
  102332. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  102333. */
  102334. idleRotationWaitTime: number;
  102335. /**
  102336. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102337. */
  102338. /**
  102339. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102340. */
  102341. idleRotationSpinupTime: number;
  102342. /**
  102343. * Gets a value indicating if the camera is currently rotating because of this behavior
  102344. */
  102345. readonly rotationInProgress: boolean;
  102346. private _onPrePointerObservableObserver;
  102347. private _onAfterCheckInputsObserver;
  102348. private _attachedCamera;
  102349. private _isPointerDown;
  102350. private _lastFrameTime;
  102351. private _lastInteractionTime;
  102352. private _cameraRotationSpeed;
  102353. /**
  102354. * Initializes the behavior.
  102355. */
  102356. init(): void;
  102357. /**
  102358. * Attaches the behavior to its arc rotate camera.
  102359. * @param camera Defines the camera to attach the behavior to
  102360. */
  102361. attach(camera: ArcRotateCamera): void;
  102362. /**
  102363. * Detaches the behavior from its current arc rotate camera.
  102364. */
  102365. detach(): void;
  102366. /**
  102367. * Returns true if user is scrolling.
  102368. * @return true if user is scrolling.
  102369. */
  102370. private _userIsZooming;
  102371. private _lastFrameRadius;
  102372. private _shouldAnimationStopForInteraction;
  102373. /**
  102374. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102375. */
  102376. private _applyUserInteraction;
  102377. private _userIsMoving;
  102378. }
  102379. }
  102380. declare module BABYLON {
  102381. /**
  102382. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  102383. */
  102384. export class AttachToBoxBehavior implements Behavior<Mesh> {
  102385. private ui;
  102386. /**
  102387. * The name of the behavior
  102388. */
  102389. name: string;
  102390. /**
  102391. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  102392. */
  102393. distanceAwayFromFace: number;
  102394. /**
  102395. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  102396. */
  102397. distanceAwayFromBottomOfFace: number;
  102398. private _faceVectors;
  102399. private _target;
  102400. private _scene;
  102401. private _onRenderObserver;
  102402. private _tmpMatrix;
  102403. private _tmpVector;
  102404. /**
  102405. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102406. * @param ui The transform node that should be attched to the mesh
  102407. */
  102408. constructor(ui: TransformNode);
  102409. /**
  102410. * Initializes the behavior
  102411. */
  102412. init(): void;
  102413. private _closestFace;
  102414. private _zeroVector;
  102415. private _lookAtTmpMatrix;
  102416. private _lookAtToRef;
  102417. /**
  102418. * Attaches the AttachToBoxBehavior to the passed in mesh
  102419. * @param target The mesh that the specified node will be attached to
  102420. */
  102421. attach(target: Mesh): void;
  102422. /**
  102423. * Detaches the behavior from the mesh
  102424. */
  102425. detach(): void;
  102426. }
  102427. }
  102428. declare module BABYLON {
  102429. /**
  102430. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102431. */
  102432. export class FadeInOutBehavior implements Behavior<Mesh> {
  102433. /**
  102434. * Time in milliseconds to delay before fading in (Default: 0)
  102435. */
  102436. delay: number;
  102437. /**
  102438. * Time in milliseconds for the mesh to fade in (Default: 300)
  102439. */
  102440. fadeInTime: number;
  102441. private _millisecondsPerFrame;
  102442. private _hovered;
  102443. private _hoverValue;
  102444. private _ownerNode;
  102445. /**
  102446. * Instatiates the FadeInOutBehavior
  102447. */
  102448. constructor();
  102449. /**
  102450. * The name of the behavior
  102451. */
  102452. readonly name: string;
  102453. /**
  102454. * Initializes the behavior
  102455. */
  102456. init(): void;
  102457. /**
  102458. * Attaches the fade behavior on the passed in mesh
  102459. * @param ownerNode The mesh that will be faded in/out once attached
  102460. */
  102461. attach(ownerNode: Mesh): void;
  102462. /**
  102463. * Detaches the behavior from the mesh
  102464. */
  102465. detach(): void;
  102466. /**
  102467. * Triggers the mesh to begin fading in or out
  102468. * @param value if the object should fade in or out (true to fade in)
  102469. */
  102470. fadeIn(value: boolean): void;
  102471. private _update;
  102472. private _setAllVisibility;
  102473. }
  102474. }
  102475. declare module BABYLON {
  102476. /**
  102477. * Class containing a set of static utilities functions for managing Pivots
  102478. * @hidden
  102479. */
  102480. export class PivotTools {
  102481. private static _PivotCached;
  102482. private static _OldPivotPoint;
  102483. private static _PivotTranslation;
  102484. private static _PivotTmpVector;
  102485. /** @hidden */
  102486. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102487. /** @hidden */
  102488. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102489. }
  102490. }
  102491. declare module BABYLON {
  102492. /**
  102493. * Class containing static functions to help procedurally build meshes
  102494. */
  102495. export class PlaneBuilder {
  102496. /**
  102497. * Creates a plane mesh
  102498. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102499. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102500. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102504. * @param name defines the name of the mesh
  102505. * @param options defines the options used to create the mesh
  102506. * @param scene defines the hosting scene
  102507. * @returns the plane mesh
  102508. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102509. */
  102510. static CreatePlane(name: string, options: {
  102511. size?: number;
  102512. width?: number;
  102513. height?: number;
  102514. sideOrientation?: number;
  102515. frontUVs?: Vector4;
  102516. backUVs?: Vector4;
  102517. updatable?: boolean;
  102518. sourcePlane?: Plane;
  102519. }, scene?: Nullable<Scene>): Mesh;
  102520. }
  102521. }
  102522. declare module BABYLON {
  102523. /**
  102524. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102525. */
  102526. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102527. private static _AnyMouseID;
  102528. /**
  102529. * Abstract mesh the behavior is set on
  102530. */
  102531. attachedNode: AbstractMesh;
  102532. private _dragPlane;
  102533. private _scene;
  102534. private _pointerObserver;
  102535. private _beforeRenderObserver;
  102536. private static _planeScene;
  102537. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102538. /**
  102539. * 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)
  102540. */
  102541. maxDragAngle: number;
  102542. /**
  102543. * @hidden
  102544. */
  102545. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102546. /**
  102547. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102548. */
  102549. currentDraggingPointerID: number;
  102550. /**
  102551. * The last position where the pointer hit the drag plane in world space
  102552. */
  102553. lastDragPosition: Vector3;
  102554. /**
  102555. * If the behavior is currently in a dragging state
  102556. */
  102557. dragging: boolean;
  102558. /**
  102559. * 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)
  102560. */
  102561. dragDeltaRatio: number;
  102562. /**
  102563. * If the drag plane orientation should be updated during the dragging (Default: true)
  102564. */
  102565. updateDragPlane: boolean;
  102566. private _debugMode;
  102567. private _moving;
  102568. /**
  102569. * Fires each time the attached mesh is dragged with the pointer
  102570. * * delta between last drag position and current drag position in world space
  102571. * * dragDistance along the drag axis
  102572. * * dragPlaneNormal normal of the current drag plane used during the drag
  102573. * * dragPlanePoint in world space where the drag intersects the drag plane
  102574. */
  102575. onDragObservable: Observable<{
  102576. delta: Vector3;
  102577. dragPlanePoint: Vector3;
  102578. dragPlaneNormal: Vector3;
  102579. dragDistance: number;
  102580. pointerId: number;
  102581. }>;
  102582. /**
  102583. * Fires each time a drag begins (eg. mouse down on mesh)
  102584. */
  102585. onDragStartObservable: Observable<{
  102586. dragPlanePoint: Vector3;
  102587. pointerId: number;
  102588. }>;
  102589. /**
  102590. * Fires each time a drag ends (eg. mouse release after drag)
  102591. */
  102592. onDragEndObservable: Observable<{
  102593. dragPlanePoint: Vector3;
  102594. pointerId: number;
  102595. }>;
  102596. /**
  102597. * If the attached mesh should be moved when dragged
  102598. */
  102599. moveAttached: boolean;
  102600. /**
  102601. * If the drag behavior will react to drag events (Default: true)
  102602. */
  102603. enabled: boolean;
  102604. /**
  102605. * If pointer events should start and release the drag (Default: true)
  102606. */
  102607. startAndReleaseDragOnPointerEvents: boolean;
  102608. /**
  102609. * If camera controls should be detached during the drag
  102610. */
  102611. detachCameraControls: boolean;
  102612. /**
  102613. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102614. */
  102615. useObjectOrienationForDragging: boolean;
  102616. private _options;
  102617. /**
  102618. * Creates a pointer drag behavior that can be attached to a mesh
  102619. * @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)
  102620. */
  102621. constructor(options?: {
  102622. dragAxis?: Vector3;
  102623. dragPlaneNormal?: Vector3;
  102624. });
  102625. /**
  102626. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102627. */
  102628. validateDrag: (targetPosition: Vector3) => boolean;
  102629. /**
  102630. * The name of the behavior
  102631. */
  102632. readonly name: string;
  102633. /**
  102634. * Initializes the behavior
  102635. */
  102636. init(): void;
  102637. private _tmpVector;
  102638. private _alternatePickedPoint;
  102639. private _worldDragAxis;
  102640. private _targetPosition;
  102641. private _attachedElement;
  102642. /**
  102643. * Attaches the drag behavior the passed in mesh
  102644. * @param ownerNode The mesh that will be dragged around once attached
  102645. * @param predicate Predicate to use for pick filtering
  102646. */
  102647. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  102648. /**
  102649. * Force relase the drag action by code.
  102650. */
  102651. releaseDrag(): void;
  102652. private _startDragRay;
  102653. private _lastPointerRay;
  102654. /**
  102655. * Simulates the start of a pointer drag event on the behavior
  102656. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102657. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102658. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102659. */
  102660. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102661. private _startDrag;
  102662. private _dragDelta;
  102663. private _moveDrag;
  102664. private _pickWithRayOnDragPlane;
  102665. private _pointA;
  102666. private _pointB;
  102667. private _pointC;
  102668. private _lineA;
  102669. private _lineB;
  102670. private _localAxis;
  102671. private _lookAt;
  102672. private _updateDragPlanePosition;
  102673. /**
  102674. * Detaches the behavior from the mesh
  102675. */
  102676. detach(): void;
  102677. }
  102678. }
  102679. declare module BABYLON {
  102680. /**
  102681. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102682. */
  102683. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102684. private _dragBehaviorA;
  102685. private _dragBehaviorB;
  102686. private _startDistance;
  102687. private _initialScale;
  102688. private _targetScale;
  102689. private _ownerNode;
  102690. private _sceneRenderObserver;
  102691. /**
  102692. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102693. */
  102694. constructor();
  102695. /**
  102696. * The name of the behavior
  102697. */
  102698. readonly name: string;
  102699. /**
  102700. * Initializes the behavior
  102701. */
  102702. init(): void;
  102703. private _getCurrentDistance;
  102704. /**
  102705. * Attaches the scale behavior the passed in mesh
  102706. * @param ownerNode The mesh that will be scaled around once attached
  102707. */
  102708. attach(ownerNode: Mesh): void;
  102709. /**
  102710. * Detaches the behavior from the mesh
  102711. */
  102712. detach(): void;
  102713. }
  102714. }
  102715. declare module BABYLON {
  102716. /**
  102717. * 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
  102718. */
  102719. export class SixDofDragBehavior implements Behavior<Mesh> {
  102720. private static _virtualScene;
  102721. private _ownerNode;
  102722. private _sceneRenderObserver;
  102723. private _scene;
  102724. private _targetPosition;
  102725. private _virtualOriginMesh;
  102726. private _virtualDragMesh;
  102727. private _pointerObserver;
  102728. private _moving;
  102729. private _startingOrientation;
  102730. /**
  102731. * 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)
  102732. */
  102733. private zDragFactor;
  102734. /**
  102735. * If the object should rotate to face the drag origin
  102736. */
  102737. rotateDraggedObject: boolean;
  102738. /**
  102739. * If the behavior is currently in a dragging state
  102740. */
  102741. dragging: boolean;
  102742. /**
  102743. * 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)
  102744. */
  102745. dragDeltaRatio: number;
  102746. /**
  102747. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102748. */
  102749. currentDraggingPointerID: number;
  102750. /**
  102751. * If camera controls should be detached during the drag
  102752. */
  102753. detachCameraControls: boolean;
  102754. /**
  102755. * Fires each time a drag starts
  102756. */
  102757. onDragStartObservable: Observable<{}>;
  102758. /**
  102759. * Fires each time a drag ends (eg. mouse release after drag)
  102760. */
  102761. onDragEndObservable: Observable<{}>;
  102762. /**
  102763. * 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
  102764. */
  102765. constructor();
  102766. /**
  102767. * The name of the behavior
  102768. */
  102769. readonly name: string;
  102770. /**
  102771. * Initializes the behavior
  102772. */
  102773. init(): void;
  102774. /**
  102775. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102776. */
  102777. private readonly _pointerCamera;
  102778. /**
  102779. * Attaches the scale behavior the passed in mesh
  102780. * @param ownerNode The mesh that will be scaled around once attached
  102781. */
  102782. attach(ownerNode: Mesh): void;
  102783. /**
  102784. * Detaches the behavior from the mesh
  102785. */
  102786. detach(): void;
  102787. }
  102788. }
  102789. declare module BABYLON {
  102790. /**
  102791. * Class used to apply inverse kinematics to bones
  102792. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102793. */
  102794. export class BoneIKController {
  102795. private static _tmpVecs;
  102796. private static _tmpQuat;
  102797. private static _tmpMats;
  102798. /**
  102799. * Gets or sets the target mesh
  102800. */
  102801. targetMesh: AbstractMesh;
  102802. /** Gets or sets the mesh used as pole */
  102803. poleTargetMesh: AbstractMesh;
  102804. /**
  102805. * Gets or sets the bone used as pole
  102806. */
  102807. poleTargetBone: Nullable<Bone>;
  102808. /**
  102809. * Gets or sets the target position
  102810. */
  102811. targetPosition: Vector3;
  102812. /**
  102813. * Gets or sets the pole target position
  102814. */
  102815. poleTargetPosition: Vector3;
  102816. /**
  102817. * Gets or sets the pole target local offset
  102818. */
  102819. poleTargetLocalOffset: Vector3;
  102820. /**
  102821. * Gets or sets the pole angle
  102822. */
  102823. poleAngle: number;
  102824. /**
  102825. * Gets or sets the mesh associated with the controller
  102826. */
  102827. mesh: AbstractMesh;
  102828. /**
  102829. * 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)
  102830. */
  102831. slerpAmount: number;
  102832. private _bone1Quat;
  102833. private _bone1Mat;
  102834. private _bone2Ang;
  102835. private _bone1;
  102836. private _bone2;
  102837. private _bone1Length;
  102838. private _bone2Length;
  102839. private _maxAngle;
  102840. private _maxReach;
  102841. private _rightHandedSystem;
  102842. private _bendAxis;
  102843. private _slerping;
  102844. private _adjustRoll;
  102845. /**
  102846. * Gets or sets maximum allowed angle
  102847. */
  102848. maxAngle: number;
  102849. /**
  102850. * Creates a new BoneIKController
  102851. * @param mesh defines the mesh to control
  102852. * @param bone defines the bone to control
  102853. * @param options defines options to set up the controller
  102854. */
  102855. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  102856. targetMesh?: AbstractMesh;
  102857. poleTargetMesh?: AbstractMesh;
  102858. poleTargetBone?: Bone;
  102859. poleTargetLocalOffset?: Vector3;
  102860. poleAngle?: number;
  102861. bendAxis?: Vector3;
  102862. maxAngle?: number;
  102863. slerpAmount?: number;
  102864. });
  102865. private _setMaxAngle;
  102866. /**
  102867. * Force the controller to update the bones
  102868. */
  102869. update(): void;
  102870. }
  102871. }
  102872. declare module BABYLON {
  102873. /**
  102874. * Class used to make a bone look toward a point in space
  102875. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  102876. */
  102877. export class BoneLookController {
  102878. private static _tmpVecs;
  102879. private static _tmpQuat;
  102880. private static _tmpMats;
  102881. /**
  102882. * The target Vector3 that the bone will look at
  102883. */
  102884. target: Vector3;
  102885. /**
  102886. * The mesh that the bone is attached to
  102887. */
  102888. mesh: AbstractMesh;
  102889. /**
  102890. * The bone that will be looking to the target
  102891. */
  102892. bone: Bone;
  102893. /**
  102894. * The up axis of the coordinate system that is used when the bone is rotated
  102895. */
  102896. upAxis: Vector3;
  102897. /**
  102898. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  102899. */
  102900. upAxisSpace: Space;
  102901. /**
  102902. * Used to make an adjustment to the yaw of the bone
  102903. */
  102904. adjustYaw: number;
  102905. /**
  102906. * Used to make an adjustment to the pitch of the bone
  102907. */
  102908. adjustPitch: number;
  102909. /**
  102910. * Used to make an adjustment to the roll of the bone
  102911. */
  102912. adjustRoll: number;
  102913. /**
  102914. * 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)
  102915. */
  102916. slerpAmount: number;
  102917. private _minYaw;
  102918. private _maxYaw;
  102919. private _minPitch;
  102920. private _maxPitch;
  102921. private _minYawSin;
  102922. private _minYawCos;
  102923. private _maxYawSin;
  102924. private _maxYawCos;
  102925. private _midYawConstraint;
  102926. private _minPitchTan;
  102927. private _maxPitchTan;
  102928. private _boneQuat;
  102929. private _slerping;
  102930. private _transformYawPitch;
  102931. private _transformYawPitchInv;
  102932. private _firstFrameSkipped;
  102933. private _yawRange;
  102934. private _fowardAxis;
  102935. /**
  102936. * Gets or sets the minimum yaw angle that the bone can look to
  102937. */
  102938. minYaw: number;
  102939. /**
  102940. * Gets or sets the maximum yaw angle that the bone can look to
  102941. */
  102942. maxYaw: number;
  102943. /**
  102944. * Gets or sets the minimum pitch angle that the bone can look to
  102945. */
  102946. minPitch: number;
  102947. /**
  102948. * Gets or sets the maximum pitch angle that the bone can look to
  102949. */
  102950. maxPitch: number;
  102951. /**
  102952. * Create a BoneLookController
  102953. * @param mesh the mesh that the bone belongs to
  102954. * @param bone the bone that will be looking to the target
  102955. * @param target the target Vector3 to look at
  102956. * @param options optional settings:
  102957. * * maxYaw: the maximum angle the bone will yaw to
  102958. * * minYaw: the minimum angle the bone will yaw to
  102959. * * maxPitch: the maximum angle the bone will pitch to
  102960. * * minPitch: the minimum angle the bone will yaw to
  102961. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  102962. * * upAxis: the up axis of the coordinate system
  102963. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  102964. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  102965. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  102966. * * adjustYaw: used to make an adjustment to the yaw of the bone
  102967. * * adjustPitch: used to make an adjustment to the pitch of the bone
  102968. * * adjustRoll: used to make an adjustment to the roll of the bone
  102969. **/
  102970. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  102971. maxYaw?: number;
  102972. minYaw?: number;
  102973. maxPitch?: number;
  102974. minPitch?: number;
  102975. slerpAmount?: number;
  102976. upAxis?: Vector3;
  102977. upAxisSpace?: Space;
  102978. yawAxis?: Vector3;
  102979. pitchAxis?: Vector3;
  102980. adjustYaw?: number;
  102981. adjustPitch?: number;
  102982. adjustRoll?: number;
  102983. });
  102984. /**
  102985. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  102986. */
  102987. update(): void;
  102988. private _getAngleDiff;
  102989. private _getAngleBetween;
  102990. private _isAngleBetween;
  102991. }
  102992. }
  102993. declare module BABYLON {
  102994. /**
  102995. * Manage the gamepad inputs to control an arc rotate camera.
  102996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102997. */
  102998. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  102999. /**
  103000. * Defines the camera the input is attached to.
  103001. */
  103002. camera: ArcRotateCamera;
  103003. /**
  103004. * Defines the gamepad the input is gathering event from.
  103005. */
  103006. gamepad: Nullable<Gamepad>;
  103007. /**
  103008. * Defines the gamepad rotation sensiblity.
  103009. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103010. */
  103011. gamepadRotationSensibility: number;
  103012. /**
  103013. * Defines the gamepad move sensiblity.
  103014. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103015. */
  103016. gamepadMoveSensibility: number;
  103017. private _onGamepadConnectedObserver;
  103018. private _onGamepadDisconnectedObserver;
  103019. /**
  103020. * Attach the input controls to a specific dom element to get the input from.
  103021. * @param element Defines the element the controls should be listened from
  103022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103023. */
  103024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103025. /**
  103026. * Detach the current controls from the specified dom element.
  103027. * @param element Defines the element to stop listening the inputs from
  103028. */
  103029. detachControl(element: Nullable<HTMLElement>): void;
  103030. /**
  103031. * Update the current camera state depending on the inputs that have been used this frame.
  103032. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103033. */
  103034. checkInputs(): void;
  103035. /**
  103036. * Gets the class name of the current intput.
  103037. * @returns the class name
  103038. */
  103039. getClassName(): string;
  103040. /**
  103041. * Get the friendly name associated with the input class.
  103042. * @returns the input friendly name
  103043. */
  103044. getSimpleName(): string;
  103045. }
  103046. }
  103047. declare module BABYLON {
  103048. interface ArcRotateCameraInputsManager {
  103049. /**
  103050. * Add orientation input support to the input manager.
  103051. * @returns the current input manager
  103052. */
  103053. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  103054. }
  103055. /**
  103056. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  103057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103058. */
  103059. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  103060. /**
  103061. * Defines the camera the input is attached to.
  103062. */
  103063. camera: ArcRotateCamera;
  103064. /**
  103065. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  103066. */
  103067. alphaCorrection: number;
  103068. /**
  103069. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  103070. */
  103071. gammaCorrection: number;
  103072. private _alpha;
  103073. private _gamma;
  103074. private _dirty;
  103075. private _deviceOrientationHandler;
  103076. /**
  103077. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  103078. */
  103079. constructor();
  103080. /**
  103081. * Attach the input controls to a specific dom element to get the input from.
  103082. * @param element Defines the element the controls should be listened from
  103083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103084. */
  103085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103086. /** @hidden */
  103087. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  103088. /**
  103089. * Update the current camera state depending on the inputs that have been used this frame.
  103090. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103091. */
  103092. checkInputs(): void;
  103093. /**
  103094. * Detach the current controls from the specified dom element.
  103095. * @param element Defines the element to stop listening the inputs from
  103096. */
  103097. detachControl(element: Nullable<HTMLElement>): void;
  103098. /**
  103099. * Gets the class name of the current intput.
  103100. * @returns the class name
  103101. */
  103102. getClassName(): string;
  103103. /**
  103104. * Get the friendly name associated with the input class.
  103105. * @returns the input friendly name
  103106. */
  103107. getSimpleName(): string;
  103108. }
  103109. }
  103110. declare module BABYLON {
  103111. /**
  103112. * Listen to mouse events to control the camera.
  103113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103114. */
  103115. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103116. /**
  103117. * Defines the camera the input is attached to.
  103118. */
  103119. camera: FlyCamera;
  103120. /**
  103121. * Defines if touch is enabled. (Default is true.)
  103122. */
  103123. touchEnabled: boolean;
  103124. /**
  103125. * Defines the buttons associated with the input to handle camera rotation.
  103126. */
  103127. buttons: number[];
  103128. /**
  103129. * Assign buttons for Yaw control.
  103130. */
  103131. buttonsYaw: number[];
  103132. /**
  103133. * Assign buttons for Pitch control.
  103134. */
  103135. buttonsPitch: number[];
  103136. /**
  103137. * Assign buttons for Roll control.
  103138. */
  103139. buttonsRoll: number[];
  103140. /**
  103141. * Detect if any button is being pressed while mouse is moved.
  103142. * -1 = Mouse locked.
  103143. * 0 = Left button.
  103144. * 1 = Middle Button.
  103145. * 2 = Right Button.
  103146. */
  103147. activeButton: number;
  103148. /**
  103149. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103150. * Higher values reduce its sensitivity.
  103151. */
  103152. angularSensibility: number;
  103153. private _mousemoveCallback;
  103154. private _observer;
  103155. private _rollObserver;
  103156. private previousPosition;
  103157. private noPreventDefault;
  103158. private element;
  103159. /**
  103160. * Listen to mouse events to control the camera.
  103161. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103163. */
  103164. constructor(touchEnabled?: boolean);
  103165. /**
  103166. * Attach the mouse control to the HTML DOM element.
  103167. * @param element Defines the element that listens to the input events.
  103168. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103169. */
  103170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103171. /**
  103172. * Detach the current controls from the specified dom element.
  103173. * @param element Defines the element to stop listening the inputs from
  103174. */
  103175. detachControl(element: Nullable<HTMLElement>): void;
  103176. /**
  103177. * Gets the class name of the current input.
  103178. * @returns the class name.
  103179. */
  103180. getClassName(): string;
  103181. /**
  103182. * Get the friendly name associated with the input class.
  103183. * @returns the input's friendly name.
  103184. */
  103185. getSimpleName(): string;
  103186. private _pointerInput;
  103187. private _onMouseMove;
  103188. /**
  103189. * Rotate camera by mouse offset.
  103190. */
  103191. private rotateCamera;
  103192. }
  103193. }
  103194. declare module BABYLON {
  103195. /**
  103196. * Default Inputs manager for the FlyCamera.
  103197. * It groups all the default supported inputs for ease of use.
  103198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103199. */
  103200. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103201. /**
  103202. * Instantiates a new FlyCameraInputsManager.
  103203. * @param camera Defines the camera the inputs belong to.
  103204. */
  103205. constructor(camera: FlyCamera);
  103206. /**
  103207. * Add keyboard input support to the input manager.
  103208. * @returns the new FlyCameraKeyboardMoveInput().
  103209. */
  103210. addKeyboard(): FlyCameraInputsManager;
  103211. /**
  103212. * Add mouse input support to the input manager.
  103213. * @param touchEnabled Enable touch screen support.
  103214. * @returns the new FlyCameraMouseInput().
  103215. */
  103216. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103217. }
  103218. }
  103219. declare module BABYLON {
  103220. /**
  103221. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103222. * such as in a 3D Space Shooter or a Flight Simulator.
  103223. */
  103224. export class FlyCamera extends TargetCamera {
  103225. /**
  103226. * Define the collision ellipsoid of the camera.
  103227. * This is helpful for simulating a camera body, like a player's body.
  103228. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103229. */
  103230. ellipsoid: Vector3;
  103231. /**
  103232. * Define an offset for the position of the ellipsoid around the camera.
  103233. * This can be helpful if the camera is attached away from the player's body center,
  103234. * such as at its head.
  103235. */
  103236. ellipsoidOffset: Vector3;
  103237. /**
  103238. * Enable or disable collisions of the camera with the rest of the scene objects.
  103239. */
  103240. checkCollisions: boolean;
  103241. /**
  103242. * Enable or disable gravity on the camera.
  103243. */
  103244. applyGravity: boolean;
  103245. /**
  103246. * Define the current direction the camera is moving to.
  103247. */
  103248. cameraDirection: Vector3;
  103249. /**
  103250. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  103251. * This overrides and empties cameraRotation.
  103252. */
  103253. rotationQuaternion: Quaternion;
  103254. /**
  103255. * Track Roll to maintain the wanted Rolling when looking around.
  103256. */
  103257. _trackRoll: number;
  103258. /**
  103259. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  103260. */
  103261. rollCorrect: number;
  103262. /**
  103263. * Mimic a banked turn, Rolling the camera when Yawing.
  103264. * It's recommended to use rollCorrect = 10 for faster banking correction.
  103265. */
  103266. bankedTurn: boolean;
  103267. /**
  103268. * Limit in radians for how much Roll banking will add. (Default: 90°)
  103269. */
  103270. bankedTurnLimit: number;
  103271. /**
  103272. * Value of 0 disables the banked Roll.
  103273. * Value of 1 is equal to the Yaw angle in radians.
  103274. */
  103275. bankedTurnMultiplier: number;
  103276. /**
  103277. * The inputs manager loads all the input sources, such as keyboard and mouse.
  103278. */
  103279. inputs: FlyCameraInputsManager;
  103280. /**
  103281. * Gets the input sensibility for mouse input.
  103282. * Higher values reduce sensitivity.
  103283. */
  103284. /**
  103285. * Sets the input sensibility for a mouse input.
  103286. * Higher values reduce sensitivity.
  103287. */
  103288. angularSensibility: number;
  103289. /**
  103290. * Get the keys for camera movement forward.
  103291. */
  103292. /**
  103293. * Set the keys for camera movement forward.
  103294. */
  103295. keysForward: number[];
  103296. /**
  103297. * Get the keys for camera movement backward.
  103298. */
  103299. keysBackward: number[];
  103300. /**
  103301. * Get the keys for camera movement up.
  103302. */
  103303. /**
  103304. * Set the keys for camera movement up.
  103305. */
  103306. keysUp: number[];
  103307. /**
  103308. * Get the keys for camera movement down.
  103309. */
  103310. /**
  103311. * Set the keys for camera movement down.
  103312. */
  103313. keysDown: number[];
  103314. /**
  103315. * Get the keys for camera movement left.
  103316. */
  103317. /**
  103318. * Set the keys for camera movement left.
  103319. */
  103320. keysLeft: number[];
  103321. /**
  103322. * Set the keys for camera movement right.
  103323. */
  103324. /**
  103325. * Set the keys for camera movement right.
  103326. */
  103327. keysRight: number[];
  103328. /**
  103329. * Event raised when the camera collides with a mesh in the scene.
  103330. */
  103331. onCollide: (collidedMesh: AbstractMesh) => void;
  103332. private _collider;
  103333. private _needMoveForGravity;
  103334. private _oldPosition;
  103335. private _diffPosition;
  103336. private _newPosition;
  103337. /** @hidden */
  103338. _localDirection: Vector3;
  103339. /** @hidden */
  103340. _transformedDirection: Vector3;
  103341. /**
  103342. * Instantiates a FlyCamera.
  103343. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103344. * such as in a 3D Space Shooter or a Flight Simulator.
  103345. * @param name Define the name of the camera in the scene.
  103346. * @param position Define the starting position of the camera in the scene.
  103347. * @param scene Define the scene the camera belongs to.
  103348. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  103349. */
  103350. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103351. /**
  103352. * Attach a control to the HTML DOM element.
  103353. * @param element Defines the element that listens to the input events.
  103354. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  103355. */
  103356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103357. /**
  103358. * Detach a control from the HTML DOM element.
  103359. * The camera will stop reacting to that input.
  103360. * @param element Defines the element that listens to the input events.
  103361. */
  103362. detachControl(element: HTMLElement): void;
  103363. private _collisionMask;
  103364. /**
  103365. * Get the mask that the camera ignores in collision events.
  103366. */
  103367. /**
  103368. * Set the mask that the camera ignores in collision events.
  103369. */
  103370. collisionMask: number;
  103371. /** @hidden */
  103372. _collideWithWorld(displacement: Vector3): void;
  103373. /** @hidden */
  103374. private _onCollisionPositionChange;
  103375. /** @hidden */
  103376. _checkInputs(): void;
  103377. /** @hidden */
  103378. _decideIfNeedsToMove(): boolean;
  103379. /** @hidden */
  103380. _updatePosition(): void;
  103381. /**
  103382. * Restore the Roll to its target value at the rate specified.
  103383. * @param rate - Higher means slower restoring.
  103384. * @hidden
  103385. */
  103386. restoreRoll(rate: number): void;
  103387. /**
  103388. * Destroy the camera and release the current resources held by it.
  103389. */
  103390. dispose(): void;
  103391. /**
  103392. * Get the current object class name.
  103393. * @returns the class name.
  103394. */
  103395. getClassName(): string;
  103396. }
  103397. }
  103398. declare module BABYLON {
  103399. /**
  103400. * Listen to keyboard events to control the camera.
  103401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103402. */
  103403. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103404. /**
  103405. * Defines the camera the input is attached to.
  103406. */
  103407. camera: FlyCamera;
  103408. /**
  103409. * The list of keyboard keys used to control the forward move of the camera.
  103410. */
  103411. keysForward: number[];
  103412. /**
  103413. * The list of keyboard keys used to control the backward move of the camera.
  103414. */
  103415. keysBackward: number[];
  103416. /**
  103417. * The list of keyboard keys used to control the forward move of the camera.
  103418. */
  103419. keysUp: number[];
  103420. /**
  103421. * The list of keyboard keys used to control the backward move of the camera.
  103422. */
  103423. keysDown: number[];
  103424. /**
  103425. * The list of keyboard keys used to control the right strafe move of the camera.
  103426. */
  103427. keysRight: number[];
  103428. /**
  103429. * The list of keyboard keys used to control the left strafe move of the camera.
  103430. */
  103431. keysLeft: number[];
  103432. private _keys;
  103433. private _onCanvasBlurObserver;
  103434. private _onKeyboardObserver;
  103435. private _engine;
  103436. private _scene;
  103437. /**
  103438. * Attach the input controls to a specific dom element to get the input from.
  103439. * @param element Defines the element the controls should be listened from
  103440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103441. */
  103442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103443. /**
  103444. * Detach the current controls from the specified dom element.
  103445. * @param element Defines the element to stop listening the inputs from
  103446. */
  103447. detachControl(element: Nullable<HTMLElement>): void;
  103448. /**
  103449. * Gets the class name of the current intput.
  103450. * @returns the class name
  103451. */
  103452. getClassName(): string;
  103453. /** @hidden */
  103454. _onLostFocus(e: FocusEvent): void;
  103455. /**
  103456. * Get the friendly name associated with the input class.
  103457. * @returns the input friendly name
  103458. */
  103459. getSimpleName(): string;
  103460. /**
  103461. * Update the current camera state depending on the inputs that have been used this frame.
  103462. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103463. */
  103464. checkInputs(): void;
  103465. }
  103466. }
  103467. declare module BABYLON {
  103468. /**
  103469. * Manage the mouse wheel inputs to control a follow camera.
  103470. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103471. */
  103472. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103473. /**
  103474. * Defines the camera the input is attached to.
  103475. */
  103476. camera: FollowCamera;
  103477. /**
  103478. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103479. */
  103480. axisControlRadius: boolean;
  103481. /**
  103482. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103483. */
  103484. axisControlHeight: boolean;
  103485. /**
  103486. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103487. */
  103488. axisControlRotation: boolean;
  103489. /**
  103490. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103491. * relation to mouseWheel events.
  103492. */
  103493. wheelPrecision: number;
  103494. /**
  103495. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103496. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103497. */
  103498. wheelDeltaPercentage: number;
  103499. private _wheel;
  103500. private _observer;
  103501. /**
  103502. * Attach the input controls to a specific dom element to get the input from.
  103503. * @param element Defines the element the controls should be listened from
  103504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103505. */
  103506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103507. /**
  103508. * Detach the current controls from the specified dom element.
  103509. * @param element Defines the element to stop listening the inputs from
  103510. */
  103511. detachControl(element: Nullable<HTMLElement>): void;
  103512. /**
  103513. * Gets the class name of the current intput.
  103514. * @returns the class name
  103515. */
  103516. getClassName(): string;
  103517. /**
  103518. * Get the friendly name associated with the input class.
  103519. * @returns the input friendly name
  103520. */
  103521. getSimpleName(): string;
  103522. }
  103523. }
  103524. declare module BABYLON {
  103525. /**
  103526. * Manage the pointers inputs to control an follow camera.
  103527. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103528. */
  103529. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103530. /**
  103531. * Defines the camera the input is attached to.
  103532. */
  103533. camera: FollowCamera;
  103534. /**
  103535. * Gets the class name of the current input.
  103536. * @returns the class name
  103537. */
  103538. getClassName(): string;
  103539. /**
  103540. * Defines the pointer angular sensibility along the X axis or how fast is
  103541. * the camera rotating.
  103542. * A negative number will reverse the axis direction.
  103543. */
  103544. angularSensibilityX: number;
  103545. /**
  103546. * Defines the pointer angular sensibility along the Y axis or how fast is
  103547. * the camera rotating.
  103548. * A negative number will reverse the axis direction.
  103549. */
  103550. angularSensibilityY: number;
  103551. /**
  103552. * Defines the pointer pinch precision or how fast is the camera zooming.
  103553. * A negative number will reverse the axis direction.
  103554. */
  103555. pinchPrecision: number;
  103556. /**
  103557. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103558. * from 0.
  103559. * It defines the percentage of current camera.radius to use as delta when
  103560. * pinch zoom is used.
  103561. */
  103562. pinchDeltaPercentage: number;
  103563. /**
  103564. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103565. */
  103566. axisXControlRadius: boolean;
  103567. /**
  103568. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103569. */
  103570. axisXControlHeight: boolean;
  103571. /**
  103572. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103573. */
  103574. axisXControlRotation: boolean;
  103575. /**
  103576. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103577. */
  103578. axisYControlRadius: boolean;
  103579. /**
  103580. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103581. */
  103582. axisYControlHeight: boolean;
  103583. /**
  103584. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103585. */
  103586. axisYControlRotation: boolean;
  103587. /**
  103588. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103589. */
  103590. axisPinchControlRadius: boolean;
  103591. /**
  103592. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103593. */
  103594. axisPinchControlHeight: boolean;
  103595. /**
  103596. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103597. */
  103598. axisPinchControlRotation: boolean;
  103599. /**
  103600. * Log error messages if basic misconfiguration has occurred.
  103601. */
  103602. warningEnable: boolean;
  103603. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103604. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103605. private _warningCounter;
  103606. private _warning;
  103607. }
  103608. }
  103609. declare module BABYLON {
  103610. /**
  103611. * Default Inputs manager for the FollowCamera.
  103612. * It groups all the default supported inputs for ease of use.
  103613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103614. */
  103615. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103616. /**
  103617. * Instantiates a new FollowCameraInputsManager.
  103618. * @param camera Defines the camera the inputs belong to
  103619. */
  103620. constructor(camera: FollowCamera);
  103621. /**
  103622. * Add keyboard input support to the input manager.
  103623. * @returns the current input manager
  103624. */
  103625. addKeyboard(): FollowCameraInputsManager;
  103626. /**
  103627. * Add mouse wheel input support to the input manager.
  103628. * @returns the current input manager
  103629. */
  103630. addMouseWheel(): FollowCameraInputsManager;
  103631. /**
  103632. * Add pointers input support to the input manager.
  103633. * @returns the current input manager
  103634. */
  103635. addPointers(): FollowCameraInputsManager;
  103636. /**
  103637. * Add orientation input support to the input manager.
  103638. * @returns the current input manager
  103639. */
  103640. addVRDeviceOrientation(): FollowCameraInputsManager;
  103641. }
  103642. }
  103643. declare module BABYLON {
  103644. /**
  103645. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103646. * an arc rotate version arcFollowCamera are available.
  103647. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103648. */
  103649. export class FollowCamera extends TargetCamera {
  103650. /**
  103651. * Distance the follow camera should follow an object at
  103652. */
  103653. radius: number;
  103654. /**
  103655. * Minimum allowed distance of the camera to the axis of rotation
  103656. * (The camera can not get closer).
  103657. * This can help limiting how the Camera is able to move in the scene.
  103658. */
  103659. lowerRadiusLimit: Nullable<number>;
  103660. /**
  103661. * Maximum allowed distance of the camera to the axis of rotation
  103662. * (The camera can not get further).
  103663. * This can help limiting how the Camera is able to move in the scene.
  103664. */
  103665. upperRadiusLimit: Nullable<number>;
  103666. /**
  103667. * Define a rotation offset between the camera and the object it follows
  103668. */
  103669. rotationOffset: number;
  103670. /**
  103671. * Minimum allowed angle to camera position relative to target object.
  103672. * This can help limiting how the Camera is able to move in the scene.
  103673. */
  103674. lowerRotationOffsetLimit: Nullable<number>;
  103675. /**
  103676. * Maximum allowed angle to camera position relative to target object.
  103677. * This can help limiting how the Camera is able to move in the scene.
  103678. */
  103679. upperRotationOffsetLimit: Nullable<number>;
  103680. /**
  103681. * Define a height offset between the camera and the object it follows.
  103682. * It can help following an object from the top (like a car chaing a plane)
  103683. */
  103684. heightOffset: number;
  103685. /**
  103686. * Minimum allowed height of camera position relative to target object.
  103687. * This can help limiting how the Camera is able to move in the scene.
  103688. */
  103689. lowerHeightOffsetLimit: Nullable<number>;
  103690. /**
  103691. * Maximum allowed height of camera position relative to target object.
  103692. * This can help limiting how the Camera is able to move in the scene.
  103693. */
  103694. upperHeightOffsetLimit: Nullable<number>;
  103695. /**
  103696. * Define how fast the camera can accelerate to follow it s target.
  103697. */
  103698. cameraAcceleration: number;
  103699. /**
  103700. * Define the speed limit of the camera following an object.
  103701. */
  103702. maxCameraSpeed: number;
  103703. /**
  103704. * Define the target of the camera.
  103705. */
  103706. lockedTarget: Nullable<AbstractMesh>;
  103707. /**
  103708. * Defines the input associated with the camera.
  103709. */
  103710. inputs: FollowCameraInputsManager;
  103711. /**
  103712. * Instantiates the follow camera.
  103713. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103714. * @param name Define the name of the camera in the scene
  103715. * @param position Define the position of the camera
  103716. * @param scene Define the scene the camera belong to
  103717. * @param lockedTarget Define the target of the camera
  103718. */
  103719. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103720. private _follow;
  103721. /**
  103722. * Attached controls to the current camera.
  103723. * @param element Defines the element the controls should be listened from
  103724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103725. */
  103726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103727. /**
  103728. * Detach the current controls from the camera.
  103729. * The camera will stop reacting to inputs.
  103730. * @param element Defines the element to stop listening the inputs from
  103731. */
  103732. detachControl(element: HTMLElement): void;
  103733. /** @hidden */
  103734. _checkInputs(): void;
  103735. private _checkLimits;
  103736. /**
  103737. * Gets the camera class name.
  103738. * @returns the class name
  103739. */
  103740. getClassName(): string;
  103741. }
  103742. /**
  103743. * Arc Rotate version of the follow camera.
  103744. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103745. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103746. */
  103747. export class ArcFollowCamera extends TargetCamera {
  103748. /** The longitudinal angle of the camera */
  103749. alpha: number;
  103750. /** The latitudinal angle of the camera */
  103751. beta: number;
  103752. /** The radius of the camera from its target */
  103753. radius: number;
  103754. /** Define the camera target (the messh it should follow) */
  103755. target: Nullable<AbstractMesh>;
  103756. private _cartesianCoordinates;
  103757. /**
  103758. * Instantiates a new ArcFollowCamera
  103759. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103760. * @param name Define the name of the camera
  103761. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103762. * @param beta Define the rotation angle of the camera around the elevation axis
  103763. * @param radius Define the radius of the camera from its target point
  103764. * @param target Define the target of the camera
  103765. * @param scene Define the scene the camera belongs to
  103766. */
  103767. constructor(name: string,
  103768. /** The longitudinal angle of the camera */
  103769. alpha: number,
  103770. /** The latitudinal angle of the camera */
  103771. beta: number,
  103772. /** The radius of the camera from its target */
  103773. radius: number,
  103774. /** Define the camera target (the messh it should follow) */
  103775. target: Nullable<AbstractMesh>, scene: Scene);
  103776. private _follow;
  103777. /** @hidden */
  103778. _checkInputs(): void;
  103779. /**
  103780. * Returns the class name of the object.
  103781. * It is mostly used internally for serialization purposes.
  103782. */
  103783. getClassName(): string;
  103784. }
  103785. }
  103786. declare module BABYLON {
  103787. /**
  103788. * Manage the keyboard inputs to control the movement of a follow camera.
  103789. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103790. */
  103791. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103792. /**
  103793. * Defines the camera the input is attached to.
  103794. */
  103795. camera: FollowCamera;
  103796. /**
  103797. * Defines the list of key codes associated with the up action (increase heightOffset)
  103798. */
  103799. keysHeightOffsetIncr: number[];
  103800. /**
  103801. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103802. */
  103803. keysHeightOffsetDecr: number[];
  103804. /**
  103805. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103806. */
  103807. keysHeightOffsetModifierAlt: boolean;
  103808. /**
  103809. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103810. */
  103811. keysHeightOffsetModifierCtrl: boolean;
  103812. /**
  103813. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103814. */
  103815. keysHeightOffsetModifierShift: boolean;
  103816. /**
  103817. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103818. */
  103819. keysRotationOffsetIncr: number[];
  103820. /**
  103821. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103822. */
  103823. keysRotationOffsetDecr: number[];
  103824. /**
  103825. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103826. */
  103827. keysRotationOffsetModifierAlt: boolean;
  103828. /**
  103829. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103830. */
  103831. keysRotationOffsetModifierCtrl: boolean;
  103832. /**
  103833. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103834. */
  103835. keysRotationOffsetModifierShift: boolean;
  103836. /**
  103837. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103838. */
  103839. keysRadiusIncr: number[];
  103840. /**
  103841. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103842. */
  103843. keysRadiusDecr: number[];
  103844. /**
  103845. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103846. */
  103847. keysRadiusModifierAlt: boolean;
  103848. /**
  103849. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103850. */
  103851. keysRadiusModifierCtrl: boolean;
  103852. /**
  103853. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103854. */
  103855. keysRadiusModifierShift: boolean;
  103856. /**
  103857. * Defines the rate of change of heightOffset.
  103858. */
  103859. heightSensibility: number;
  103860. /**
  103861. * Defines the rate of change of rotationOffset.
  103862. */
  103863. rotationSensibility: number;
  103864. /**
  103865. * Defines the rate of change of radius.
  103866. */
  103867. radiusSensibility: number;
  103868. private _keys;
  103869. private _ctrlPressed;
  103870. private _altPressed;
  103871. private _shiftPressed;
  103872. private _onCanvasBlurObserver;
  103873. private _onKeyboardObserver;
  103874. private _engine;
  103875. private _scene;
  103876. /**
  103877. * Attach the input controls to a specific dom element to get the input from.
  103878. * @param element Defines the element the controls should be listened from
  103879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103880. */
  103881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103882. /**
  103883. * Detach the current controls from the specified dom element.
  103884. * @param element Defines the element to stop listening the inputs from
  103885. */
  103886. detachControl(element: Nullable<HTMLElement>): void;
  103887. /**
  103888. * Update the current camera state depending on the inputs that have been used this frame.
  103889. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103890. */
  103891. checkInputs(): void;
  103892. /**
  103893. * Gets the class name of the current input.
  103894. * @returns the class name
  103895. */
  103896. getClassName(): string;
  103897. /**
  103898. * Get the friendly name associated with the input class.
  103899. * @returns the input friendly name
  103900. */
  103901. getSimpleName(): string;
  103902. /**
  103903. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103904. * allow modification of the heightOffset value.
  103905. */
  103906. private _modifierHeightOffset;
  103907. /**
  103908. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103909. * allow modification of the rotationOffset value.
  103910. */
  103911. private _modifierRotationOffset;
  103912. /**
  103913. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103914. * allow modification of the radius value.
  103915. */
  103916. private _modifierRadius;
  103917. }
  103918. }
  103919. declare module BABYLON {
  103920. interface FreeCameraInputsManager {
  103921. /**
  103922. * @hidden
  103923. */
  103924. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  103925. /**
  103926. * Add orientation input support to the input manager.
  103927. * @returns the current input manager
  103928. */
  103929. addDeviceOrientation(): FreeCameraInputsManager;
  103930. }
  103931. /**
  103932. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  103933. * Screen rotation is taken into account.
  103934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103935. */
  103936. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  103937. private _camera;
  103938. private _screenOrientationAngle;
  103939. private _constantTranform;
  103940. private _screenQuaternion;
  103941. private _alpha;
  103942. private _beta;
  103943. private _gamma;
  103944. /**
  103945. * Can be used to detect if a device orientation sensor is availible on a device
  103946. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  103947. * @returns a promise that will resolve on orientation change
  103948. */
  103949. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  103950. /**
  103951. * @hidden
  103952. */
  103953. _onDeviceOrientationChangedObservable: Observable<void>;
  103954. /**
  103955. * Instantiates a new input
  103956. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103957. */
  103958. constructor();
  103959. /**
  103960. * Define the camera controlled by the input.
  103961. */
  103962. camera: FreeCamera;
  103963. /**
  103964. * Attach the input controls to a specific dom element to get the input from.
  103965. * @param element Defines the element the controls should be listened from
  103966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103967. */
  103968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103969. private _orientationChanged;
  103970. private _deviceOrientation;
  103971. /**
  103972. * Detach the current controls from the specified dom element.
  103973. * @param element Defines the element to stop listening the inputs from
  103974. */
  103975. detachControl(element: Nullable<HTMLElement>): void;
  103976. /**
  103977. * Update the current camera state depending on the inputs that have been used this frame.
  103978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103979. */
  103980. checkInputs(): void;
  103981. /**
  103982. * Gets the class name of the current intput.
  103983. * @returns the class name
  103984. */
  103985. getClassName(): string;
  103986. /**
  103987. * Get the friendly name associated with the input class.
  103988. * @returns the input friendly name
  103989. */
  103990. getSimpleName(): string;
  103991. }
  103992. }
  103993. declare module BABYLON {
  103994. /**
  103995. * Manage the gamepad inputs to control a free camera.
  103996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103997. */
  103998. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  103999. /**
  104000. * Define the camera the input is attached to.
  104001. */
  104002. camera: FreeCamera;
  104003. /**
  104004. * Define the Gamepad controlling the input
  104005. */
  104006. gamepad: Nullable<Gamepad>;
  104007. /**
  104008. * Defines the gamepad rotation sensiblity.
  104009. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104010. */
  104011. gamepadAngularSensibility: number;
  104012. /**
  104013. * Defines the gamepad move sensiblity.
  104014. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104015. */
  104016. gamepadMoveSensibility: number;
  104017. private _onGamepadConnectedObserver;
  104018. private _onGamepadDisconnectedObserver;
  104019. private _cameraTransform;
  104020. private _deltaTransform;
  104021. private _vector3;
  104022. private _vector2;
  104023. /**
  104024. * Attach the input controls to a specific dom element to get the input from.
  104025. * @param element Defines the element the controls should be listened from
  104026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104027. */
  104028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104029. /**
  104030. * Detach the current controls from the specified dom element.
  104031. * @param element Defines the element to stop listening the inputs from
  104032. */
  104033. detachControl(element: Nullable<HTMLElement>): void;
  104034. /**
  104035. * Update the current camera state depending on the inputs that have been used this frame.
  104036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104037. */
  104038. checkInputs(): void;
  104039. /**
  104040. * Gets the class name of the current intput.
  104041. * @returns the class name
  104042. */
  104043. getClassName(): string;
  104044. /**
  104045. * Get the friendly name associated with the input class.
  104046. * @returns the input friendly name
  104047. */
  104048. getSimpleName(): string;
  104049. }
  104050. }
  104051. declare module BABYLON {
  104052. /**
  104053. * Defines the potential axis of a Joystick
  104054. */
  104055. export enum JoystickAxis {
  104056. /** X axis */
  104057. X = 0,
  104058. /** Y axis */
  104059. Y = 1,
  104060. /** Z axis */
  104061. Z = 2
  104062. }
  104063. /**
  104064. * Class used to define virtual joystick (used in touch mode)
  104065. */
  104066. export class VirtualJoystick {
  104067. /**
  104068. * Gets or sets a boolean indicating that left and right values must be inverted
  104069. */
  104070. reverseLeftRight: boolean;
  104071. /**
  104072. * Gets or sets a boolean indicating that up and down values must be inverted
  104073. */
  104074. reverseUpDown: boolean;
  104075. /**
  104076. * Gets the offset value for the position (ie. the change of the position value)
  104077. */
  104078. deltaPosition: Vector3;
  104079. /**
  104080. * Gets a boolean indicating if the virtual joystick was pressed
  104081. */
  104082. pressed: boolean;
  104083. /**
  104084. * Canvas the virtual joystick will render onto, default z-index of this is 5
  104085. */
  104086. static Canvas: Nullable<HTMLCanvasElement>;
  104087. private static _globalJoystickIndex;
  104088. private static vjCanvasContext;
  104089. private static vjCanvasWidth;
  104090. private static vjCanvasHeight;
  104091. private static halfWidth;
  104092. private _action;
  104093. private _axisTargetedByLeftAndRight;
  104094. private _axisTargetedByUpAndDown;
  104095. private _joystickSensibility;
  104096. private _inversedSensibility;
  104097. private _joystickPointerID;
  104098. private _joystickColor;
  104099. private _joystickPointerPos;
  104100. private _joystickPreviousPointerPos;
  104101. private _joystickPointerStartPos;
  104102. private _deltaJoystickVector;
  104103. private _leftJoystick;
  104104. private _touches;
  104105. private _onPointerDownHandlerRef;
  104106. private _onPointerMoveHandlerRef;
  104107. private _onPointerUpHandlerRef;
  104108. private _onResize;
  104109. /**
  104110. * Creates a new virtual joystick
  104111. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104112. */
  104113. constructor(leftJoystick?: boolean);
  104114. /**
  104115. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104116. * @param newJoystickSensibility defines the new sensibility
  104117. */
  104118. setJoystickSensibility(newJoystickSensibility: number): void;
  104119. private _onPointerDown;
  104120. private _onPointerMove;
  104121. private _onPointerUp;
  104122. /**
  104123. * Change the color of the virtual joystick
  104124. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104125. */
  104126. setJoystickColor(newColor: string): void;
  104127. /**
  104128. * Defines a callback to call when the joystick is touched
  104129. * @param action defines the callback
  104130. */
  104131. setActionOnTouch(action: () => any): void;
  104132. /**
  104133. * Defines which axis you'd like to control for left & right
  104134. * @param axis defines the axis to use
  104135. */
  104136. setAxisForLeftRight(axis: JoystickAxis): void;
  104137. /**
  104138. * Defines which axis you'd like to control for up & down
  104139. * @param axis defines the axis to use
  104140. */
  104141. setAxisForUpDown(axis: JoystickAxis): void;
  104142. private _drawVirtualJoystick;
  104143. /**
  104144. * Release internal HTML canvas
  104145. */
  104146. releaseCanvas(): void;
  104147. }
  104148. }
  104149. declare module BABYLON {
  104150. interface FreeCameraInputsManager {
  104151. /**
  104152. * Add virtual joystick input support to the input manager.
  104153. * @returns the current input manager
  104154. */
  104155. addVirtualJoystick(): FreeCameraInputsManager;
  104156. }
  104157. /**
  104158. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104160. */
  104161. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104162. /**
  104163. * Defines the camera the input is attached to.
  104164. */
  104165. camera: FreeCamera;
  104166. private _leftjoystick;
  104167. private _rightjoystick;
  104168. /**
  104169. * Gets the left stick of the virtual joystick.
  104170. * @returns The virtual Joystick
  104171. */
  104172. getLeftJoystick(): VirtualJoystick;
  104173. /**
  104174. * Gets the right stick of the virtual joystick.
  104175. * @returns The virtual Joystick
  104176. */
  104177. getRightJoystick(): VirtualJoystick;
  104178. /**
  104179. * Update the current camera state depending on the inputs that have been used this frame.
  104180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104181. */
  104182. checkInputs(): void;
  104183. /**
  104184. * Attach the input controls to a specific dom element to get the input from.
  104185. * @param element Defines the element the controls should be listened from
  104186. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104187. */
  104188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104189. /**
  104190. * Detach the current controls from the specified dom element.
  104191. * @param element Defines the element to stop listening the inputs from
  104192. */
  104193. detachControl(element: Nullable<HTMLElement>): void;
  104194. /**
  104195. * Gets the class name of the current intput.
  104196. * @returns the class name
  104197. */
  104198. getClassName(): string;
  104199. /**
  104200. * Get the friendly name associated with the input class.
  104201. * @returns the input friendly name
  104202. */
  104203. getSimpleName(): string;
  104204. }
  104205. }
  104206. declare module BABYLON {
  104207. /**
  104208. * This represents a FPS type of camera controlled by touch.
  104209. * This is like a universal camera minus the Gamepad controls.
  104210. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104211. */
  104212. export class TouchCamera extends FreeCamera {
  104213. /**
  104214. * Defines the touch sensibility for rotation.
  104215. * The higher the faster.
  104216. */
  104217. touchAngularSensibility: number;
  104218. /**
  104219. * Defines the touch sensibility for move.
  104220. * The higher the faster.
  104221. */
  104222. touchMoveSensibility: number;
  104223. /**
  104224. * Instantiates a new touch camera.
  104225. * This represents a FPS type of camera controlled by touch.
  104226. * This is like a universal camera minus the Gamepad controls.
  104227. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104228. * @param name Define the name of the camera in the scene
  104229. * @param position Define the start position of the camera in the scene
  104230. * @param scene Define the scene the camera belongs to
  104231. */
  104232. constructor(name: string, position: Vector3, scene: Scene);
  104233. /**
  104234. * Gets the current object class name.
  104235. * @return the class name
  104236. */
  104237. getClassName(): string;
  104238. /** @hidden */
  104239. _setupInputs(): void;
  104240. }
  104241. }
  104242. declare module BABYLON {
  104243. /**
  104244. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  104245. * being tilted forward or back and left or right.
  104246. */
  104247. export class DeviceOrientationCamera extends FreeCamera {
  104248. private _initialQuaternion;
  104249. private _quaternionCache;
  104250. private _tmpDragQuaternion;
  104251. private _disablePointerInputWhenUsingDeviceOrientation;
  104252. /**
  104253. * Creates a new device orientation camera
  104254. * @param name The name of the camera
  104255. * @param position The start position camera
  104256. * @param scene The scene the camera belongs to
  104257. */
  104258. constructor(name: string, position: Vector3, scene: Scene);
  104259. /**
  104260. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  104261. */
  104262. disablePointerInputWhenUsingDeviceOrientation: boolean;
  104263. private _dragFactor;
  104264. /**
  104265. * Enabled turning on the y axis when the orientation sensor is active
  104266. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  104267. */
  104268. enableHorizontalDragging(dragFactor?: number): void;
  104269. /**
  104270. * Gets the current instance class name ("DeviceOrientationCamera").
  104271. * This helps avoiding instanceof at run time.
  104272. * @returns the class name
  104273. */
  104274. getClassName(): string;
  104275. /**
  104276. * @hidden
  104277. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  104278. */
  104279. _checkInputs(): void;
  104280. /**
  104281. * Reset the camera to its default orientation on the specified axis only.
  104282. * @param axis The axis to reset
  104283. */
  104284. resetToCurrentRotation(axis?: Axis): void;
  104285. }
  104286. }
  104287. declare module BABYLON {
  104288. /**
  104289. * Defines supported buttons for XBox360 compatible gamepads
  104290. */
  104291. export enum Xbox360Button {
  104292. /** A */
  104293. A = 0,
  104294. /** B */
  104295. B = 1,
  104296. /** X */
  104297. X = 2,
  104298. /** Y */
  104299. Y = 3,
  104300. /** Start */
  104301. Start = 4,
  104302. /** Back */
  104303. Back = 5,
  104304. /** Left button */
  104305. LB = 6,
  104306. /** Right button */
  104307. RB = 7,
  104308. /** Left stick */
  104309. LeftStick = 8,
  104310. /** Right stick */
  104311. RightStick = 9
  104312. }
  104313. /** Defines values for XBox360 DPad */
  104314. export enum Xbox360Dpad {
  104315. /** Up */
  104316. Up = 0,
  104317. /** Down */
  104318. Down = 1,
  104319. /** Left */
  104320. Left = 2,
  104321. /** Right */
  104322. Right = 3
  104323. }
  104324. /**
  104325. * Defines a XBox360 gamepad
  104326. */
  104327. export class Xbox360Pad extends Gamepad {
  104328. private _leftTrigger;
  104329. private _rightTrigger;
  104330. private _onlefttriggerchanged;
  104331. private _onrighttriggerchanged;
  104332. private _onbuttondown;
  104333. private _onbuttonup;
  104334. private _ondpaddown;
  104335. private _ondpadup;
  104336. /** Observable raised when a button is pressed */
  104337. onButtonDownObservable: Observable<Xbox360Button>;
  104338. /** Observable raised when a button is released */
  104339. onButtonUpObservable: Observable<Xbox360Button>;
  104340. /** Observable raised when a pad is pressed */
  104341. onPadDownObservable: Observable<Xbox360Dpad>;
  104342. /** Observable raised when a pad is released */
  104343. onPadUpObservable: Observable<Xbox360Dpad>;
  104344. private _buttonA;
  104345. private _buttonB;
  104346. private _buttonX;
  104347. private _buttonY;
  104348. private _buttonBack;
  104349. private _buttonStart;
  104350. private _buttonLB;
  104351. private _buttonRB;
  104352. private _buttonLeftStick;
  104353. private _buttonRightStick;
  104354. private _dPadUp;
  104355. private _dPadDown;
  104356. private _dPadLeft;
  104357. private _dPadRight;
  104358. private _isXboxOnePad;
  104359. /**
  104360. * Creates a new XBox360 gamepad object
  104361. * @param id defines the id of this gamepad
  104362. * @param index defines its index
  104363. * @param gamepad defines the internal HTML gamepad object
  104364. * @param xboxOne defines if it is a XBox One gamepad
  104365. */
  104366. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  104367. /**
  104368. * Defines the callback to call when left trigger is pressed
  104369. * @param callback defines the callback to use
  104370. */
  104371. onlefttriggerchanged(callback: (value: number) => void): void;
  104372. /**
  104373. * Defines the callback to call when right trigger is pressed
  104374. * @param callback defines the callback to use
  104375. */
  104376. onrighttriggerchanged(callback: (value: number) => void): void;
  104377. /**
  104378. * Gets the left trigger value
  104379. */
  104380. /**
  104381. * Sets the left trigger value
  104382. */
  104383. leftTrigger: number;
  104384. /**
  104385. * Gets the right trigger value
  104386. */
  104387. /**
  104388. * Sets the right trigger value
  104389. */
  104390. rightTrigger: number;
  104391. /**
  104392. * Defines the callback to call when a button is pressed
  104393. * @param callback defines the callback to use
  104394. */
  104395. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  104396. /**
  104397. * Defines the callback to call when a button is released
  104398. * @param callback defines the callback to use
  104399. */
  104400. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  104401. /**
  104402. * Defines the callback to call when a pad is pressed
  104403. * @param callback defines the callback to use
  104404. */
  104405. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104406. /**
  104407. * Defines the callback to call when a pad is released
  104408. * @param callback defines the callback to use
  104409. */
  104410. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104411. private _setButtonValue;
  104412. private _setDPadValue;
  104413. /**
  104414. * Gets the value of the `A` button
  104415. */
  104416. /**
  104417. * Sets the value of the `A` button
  104418. */
  104419. buttonA: number;
  104420. /**
  104421. * Gets the value of the `B` button
  104422. */
  104423. /**
  104424. * Sets the value of the `B` button
  104425. */
  104426. buttonB: number;
  104427. /**
  104428. * Gets the value of the `X` button
  104429. */
  104430. /**
  104431. * Sets the value of the `X` button
  104432. */
  104433. buttonX: number;
  104434. /**
  104435. * Gets the value of the `Y` button
  104436. */
  104437. /**
  104438. * Sets the value of the `Y` button
  104439. */
  104440. buttonY: number;
  104441. /**
  104442. * Gets the value of the `Start` button
  104443. */
  104444. /**
  104445. * Sets the value of the `Start` button
  104446. */
  104447. buttonStart: number;
  104448. /**
  104449. * Gets the value of the `Back` button
  104450. */
  104451. /**
  104452. * Sets the value of the `Back` button
  104453. */
  104454. buttonBack: number;
  104455. /**
  104456. * Gets the value of the `Left` button
  104457. */
  104458. /**
  104459. * Sets the value of the `Left` button
  104460. */
  104461. buttonLB: number;
  104462. /**
  104463. * Gets the value of the `Right` button
  104464. */
  104465. /**
  104466. * Sets the value of the `Right` button
  104467. */
  104468. buttonRB: number;
  104469. /**
  104470. * Gets the value of the Left joystick
  104471. */
  104472. /**
  104473. * Sets the value of the Left joystick
  104474. */
  104475. buttonLeftStick: number;
  104476. /**
  104477. * Gets the value of the Right joystick
  104478. */
  104479. /**
  104480. * Sets the value of the Right joystick
  104481. */
  104482. buttonRightStick: number;
  104483. /**
  104484. * Gets the value of D-pad up
  104485. */
  104486. /**
  104487. * Sets the value of D-pad up
  104488. */
  104489. dPadUp: number;
  104490. /**
  104491. * Gets the value of D-pad down
  104492. */
  104493. /**
  104494. * Sets the value of D-pad down
  104495. */
  104496. dPadDown: number;
  104497. /**
  104498. * Gets the value of D-pad left
  104499. */
  104500. /**
  104501. * Sets the value of D-pad left
  104502. */
  104503. dPadLeft: number;
  104504. /**
  104505. * Gets the value of D-pad right
  104506. */
  104507. /**
  104508. * Sets the value of D-pad right
  104509. */
  104510. dPadRight: number;
  104511. /**
  104512. * Force the gamepad to synchronize with device values
  104513. */
  104514. update(): void;
  104515. /**
  104516. * Disposes the gamepad
  104517. */
  104518. dispose(): void;
  104519. }
  104520. }
  104521. declare module BABYLON {
  104522. /**
  104523. * Defines supported buttons for DualShock compatible gamepads
  104524. */
  104525. export enum DualShockButton {
  104526. /** Cross */
  104527. Cross = 0,
  104528. /** Circle */
  104529. Circle = 1,
  104530. /** Square */
  104531. Square = 2,
  104532. /** Triangle */
  104533. Triangle = 3,
  104534. /** Options */
  104535. Options = 4,
  104536. /** Share */
  104537. Share = 5,
  104538. /** L1 */
  104539. L1 = 6,
  104540. /** R1 */
  104541. R1 = 7,
  104542. /** Left stick */
  104543. LeftStick = 8,
  104544. /** Right stick */
  104545. RightStick = 9
  104546. }
  104547. /** Defines values for DualShock DPad */
  104548. export enum DualShockDpad {
  104549. /** Up */
  104550. Up = 0,
  104551. /** Down */
  104552. Down = 1,
  104553. /** Left */
  104554. Left = 2,
  104555. /** Right */
  104556. Right = 3
  104557. }
  104558. /**
  104559. * Defines a DualShock gamepad
  104560. */
  104561. export class DualShockPad extends Gamepad {
  104562. private _leftTrigger;
  104563. private _rightTrigger;
  104564. private _onlefttriggerchanged;
  104565. private _onrighttriggerchanged;
  104566. private _onbuttondown;
  104567. private _onbuttonup;
  104568. private _ondpaddown;
  104569. private _ondpadup;
  104570. /** Observable raised when a button is pressed */
  104571. onButtonDownObservable: Observable<DualShockButton>;
  104572. /** Observable raised when a button is released */
  104573. onButtonUpObservable: Observable<DualShockButton>;
  104574. /** Observable raised when a pad is pressed */
  104575. onPadDownObservable: Observable<DualShockDpad>;
  104576. /** Observable raised when a pad is released */
  104577. onPadUpObservable: Observable<DualShockDpad>;
  104578. private _buttonCross;
  104579. private _buttonCircle;
  104580. private _buttonSquare;
  104581. private _buttonTriangle;
  104582. private _buttonShare;
  104583. private _buttonOptions;
  104584. private _buttonL1;
  104585. private _buttonR1;
  104586. private _buttonLeftStick;
  104587. private _buttonRightStick;
  104588. private _dPadUp;
  104589. private _dPadDown;
  104590. private _dPadLeft;
  104591. private _dPadRight;
  104592. /**
  104593. * Creates a new DualShock gamepad object
  104594. * @param id defines the id of this gamepad
  104595. * @param index defines its index
  104596. * @param gamepad defines the internal HTML gamepad object
  104597. */
  104598. constructor(id: string, index: number, gamepad: any);
  104599. /**
  104600. * Defines the callback to call when left trigger is pressed
  104601. * @param callback defines the callback to use
  104602. */
  104603. onlefttriggerchanged(callback: (value: number) => void): void;
  104604. /**
  104605. * Defines the callback to call when right trigger is pressed
  104606. * @param callback defines the callback to use
  104607. */
  104608. onrighttriggerchanged(callback: (value: number) => void): void;
  104609. /**
  104610. * Gets the left trigger value
  104611. */
  104612. /**
  104613. * Sets the left trigger value
  104614. */
  104615. leftTrigger: number;
  104616. /**
  104617. * Gets the right trigger value
  104618. */
  104619. /**
  104620. * Sets the right trigger value
  104621. */
  104622. rightTrigger: number;
  104623. /**
  104624. * Defines the callback to call when a button is pressed
  104625. * @param callback defines the callback to use
  104626. */
  104627. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104628. /**
  104629. * Defines the callback to call when a button is released
  104630. * @param callback defines the callback to use
  104631. */
  104632. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104633. /**
  104634. * Defines the callback to call when a pad is pressed
  104635. * @param callback defines the callback to use
  104636. */
  104637. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104638. /**
  104639. * Defines the callback to call when a pad is released
  104640. * @param callback defines the callback to use
  104641. */
  104642. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104643. private _setButtonValue;
  104644. private _setDPadValue;
  104645. /**
  104646. * Gets the value of the `Cross` button
  104647. */
  104648. /**
  104649. * Sets the value of the `Cross` button
  104650. */
  104651. buttonCross: number;
  104652. /**
  104653. * Gets the value of the `Circle` button
  104654. */
  104655. /**
  104656. * Sets the value of the `Circle` button
  104657. */
  104658. buttonCircle: number;
  104659. /**
  104660. * Gets the value of the `Square` button
  104661. */
  104662. /**
  104663. * Sets the value of the `Square` button
  104664. */
  104665. buttonSquare: number;
  104666. /**
  104667. * Gets the value of the `Triangle` button
  104668. */
  104669. /**
  104670. * Sets the value of the `Triangle` button
  104671. */
  104672. buttonTriangle: number;
  104673. /**
  104674. * Gets the value of the `Options` button
  104675. */
  104676. /**
  104677. * Sets the value of the `Options` button
  104678. */
  104679. buttonOptions: number;
  104680. /**
  104681. * Gets the value of the `Share` button
  104682. */
  104683. /**
  104684. * Sets the value of the `Share` button
  104685. */
  104686. buttonShare: number;
  104687. /**
  104688. * Gets the value of the `L1` button
  104689. */
  104690. /**
  104691. * Sets the value of the `L1` button
  104692. */
  104693. buttonL1: number;
  104694. /**
  104695. * Gets the value of the `R1` button
  104696. */
  104697. /**
  104698. * Sets the value of the `R1` button
  104699. */
  104700. buttonR1: number;
  104701. /**
  104702. * Gets the value of the Left joystick
  104703. */
  104704. /**
  104705. * Sets the value of the Left joystick
  104706. */
  104707. buttonLeftStick: number;
  104708. /**
  104709. * Gets the value of the Right joystick
  104710. */
  104711. /**
  104712. * Sets the value of the Right joystick
  104713. */
  104714. buttonRightStick: number;
  104715. /**
  104716. * Gets the value of D-pad up
  104717. */
  104718. /**
  104719. * Sets the value of D-pad up
  104720. */
  104721. dPadUp: number;
  104722. /**
  104723. * Gets the value of D-pad down
  104724. */
  104725. /**
  104726. * Sets the value of D-pad down
  104727. */
  104728. dPadDown: number;
  104729. /**
  104730. * Gets the value of D-pad left
  104731. */
  104732. /**
  104733. * Sets the value of D-pad left
  104734. */
  104735. dPadLeft: number;
  104736. /**
  104737. * Gets the value of D-pad right
  104738. */
  104739. /**
  104740. * Sets the value of D-pad right
  104741. */
  104742. dPadRight: number;
  104743. /**
  104744. * Force the gamepad to synchronize with device values
  104745. */
  104746. update(): void;
  104747. /**
  104748. * Disposes the gamepad
  104749. */
  104750. dispose(): void;
  104751. }
  104752. }
  104753. declare module BABYLON {
  104754. /**
  104755. * Manager for handling gamepads
  104756. */
  104757. export class GamepadManager {
  104758. private _scene?;
  104759. private _babylonGamepads;
  104760. private _oneGamepadConnected;
  104761. /** @hidden */
  104762. _isMonitoring: boolean;
  104763. private _gamepadEventSupported;
  104764. private _gamepadSupport;
  104765. /**
  104766. * observable to be triggered when the gamepad controller has been connected
  104767. */
  104768. onGamepadConnectedObservable: Observable<Gamepad>;
  104769. /**
  104770. * observable to be triggered when the gamepad controller has been disconnected
  104771. */
  104772. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104773. private _onGamepadConnectedEvent;
  104774. private _onGamepadDisconnectedEvent;
  104775. /**
  104776. * Initializes the gamepad manager
  104777. * @param _scene BabylonJS scene
  104778. */
  104779. constructor(_scene?: Scene | undefined);
  104780. /**
  104781. * The gamepads in the game pad manager
  104782. */
  104783. readonly gamepads: Gamepad[];
  104784. /**
  104785. * Get the gamepad controllers based on type
  104786. * @param type The type of gamepad controller
  104787. * @returns Nullable gamepad
  104788. */
  104789. getGamepadByType(type?: number): Nullable<Gamepad>;
  104790. /**
  104791. * Disposes the gamepad manager
  104792. */
  104793. dispose(): void;
  104794. private _addNewGamepad;
  104795. private _startMonitoringGamepads;
  104796. private _stopMonitoringGamepads;
  104797. /** @hidden */
  104798. _checkGamepadsStatus(): void;
  104799. private _updateGamepadObjects;
  104800. }
  104801. }
  104802. declare module BABYLON {
  104803. interface Scene {
  104804. /** @hidden */
  104805. _gamepadManager: Nullable<GamepadManager>;
  104806. /**
  104807. * Gets the gamepad manager associated with the scene
  104808. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104809. */
  104810. gamepadManager: GamepadManager;
  104811. }
  104812. /**
  104813. * Interface representing a free camera inputs manager
  104814. */
  104815. interface FreeCameraInputsManager {
  104816. /**
  104817. * Adds gamepad input support to the FreeCameraInputsManager.
  104818. * @returns the FreeCameraInputsManager
  104819. */
  104820. addGamepad(): FreeCameraInputsManager;
  104821. }
  104822. /**
  104823. * Interface representing an arc rotate camera inputs manager
  104824. */
  104825. interface ArcRotateCameraInputsManager {
  104826. /**
  104827. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104828. * @returns the camera inputs manager
  104829. */
  104830. addGamepad(): ArcRotateCameraInputsManager;
  104831. }
  104832. /**
  104833. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104834. */
  104835. export class GamepadSystemSceneComponent implements ISceneComponent {
  104836. /**
  104837. * The component name helpfull to identify the component in the list of scene components.
  104838. */
  104839. readonly name: string;
  104840. /**
  104841. * The scene the component belongs to.
  104842. */
  104843. scene: Scene;
  104844. /**
  104845. * Creates a new instance of the component for the given scene
  104846. * @param scene Defines the scene to register the component in
  104847. */
  104848. constructor(scene: Scene);
  104849. /**
  104850. * Registers the component in a given scene
  104851. */
  104852. register(): void;
  104853. /**
  104854. * Rebuilds the elements related to this component in case of
  104855. * context lost for instance.
  104856. */
  104857. rebuild(): void;
  104858. /**
  104859. * Disposes the component and the associated ressources
  104860. */
  104861. dispose(): void;
  104862. private _beforeCameraUpdate;
  104863. }
  104864. }
  104865. declare module BABYLON {
  104866. /**
  104867. * 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,
  104868. * which still works and will still be found in many Playgrounds.
  104869. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104870. */
  104871. export class UniversalCamera extends TouchCamera {
  104872. /**
  104873. * Defines the gamepad rotation sensiblity.
  104874. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104875. */
  104876. gamepadAngularSensibility: number;
  104877. /**
  104878. * Defines the gamepad move sensiblity.
  104879. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104880. */
  104881. gamepadMoveSensibility: number;
  104882. /**
  104883. * 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,
  104884. * which still works and will still be found in many Playgrounds.
  104885. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104886. * @param name Define the name of the camera in the scene
  104887. * @param position Define the start position of the camera in the scene
  104888. * @param scene Define the scene the camera belongs to
  104889. */
  104890. constructor(name: string, position: Vector3, scene: Scene);
  104891. /**
  104892. * Gets the current object class name.
  104893. * @return the class name
  104894. */
  104895. getClassName(): string;
  104896. }
  104897. }
  104898. declare module BABYLON {
  104899. /**
  104900. * This represents a FPS type of camera. This is only here for back compat purpose.
  104901. * Please use the UniversalCamera instead as both are identical.
  104902. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104903. */
  104904. export class GamepadCamera extends UniversalCamera {
  104905. /**
  104906. * Instantiates a new Gamepad Camera
  104907. * This represents a FPS type of camera. This is only here for back compat purpose.
  104908. * Please use the UniversalCamera instead as both are identical.
  104909. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104910. * @param name Define the name of the camera in the scene
  104911. * @param position Define the start position of the camera in the scene
  104912. * @param scene Define the scene the camera belongs to
  104913. */
  104914. constructor(name: string, position: Vector3, scene: Scene);
  104915. /**
  104916. * Gets the current object class name.
  104917. * @return the class name
  104918. */
  104919. getClassName(): string;
  104920. }
  104921. }
  104922. declare module BABYLON {
  104923. /** @hidden */
  104924. export var passPixelShader: {
  104925. name: string;
  104926. shader: string;
  104927. };
  104928. }
  104929. declare module BABYLON {
  104930. /** @hidden */
  104931. export var passCubePixelShader: {
  104932. name: string;
  104933. shader: string;
  104934. };
  104935. }
  104936. declare module BABYLON {
  104937. /**
  104938. * PassPostProcess which produces an output the same as it's input
  104939. */
  104940. export class PassPostProcess extends PostProcess {
  104941. /**
  104942. * Creates the PassPostProcess
  104943. * @param name The name of the effect.
  104944. * @param options The required width/height ratio to downsize to before computing the render pass.
  104945. * @param camera The camera to apply the render pass to.
  104946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104947. * @param engine The engine which the post process will be applied. (default: current engine)
  104948. * @param reusable If the post process can be reused on the same frame. (default: false)
  104949. * @param textureType The type of texture to be used when performing the post processing.
  104950. * @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)
  104951. */
  104952. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104953. }
  104954. /**
  104955. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104956. */
  104957. export class PassCubePostProcess extends PostProcess {
  104958. private _face;
  104959. /**
  104960. * Gets or sets the cube face to display.
  104961. * * 0 is +X
  104962. * * 1 is -X
  104963. * * 2 is +Y
  104964. * * 3 is -Y
  104965. * * 4 is +Z
  104966. * * 5 is -Z
  104967. */
  104968. face: number;
  104969. /**
  104970. * Creates the PassCubePostProcess
  104971. * @param name The name of the effect.
  104972. * @param options The required width/height ratio to downsize to before computing the render pass.
  104973. * @param camera The camera to apply the render pass to.
  104974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104975. * @param engine The engine which the post process will be applied. (default: current engine)
  104976. * @param reusable If the post process can be reused on the same frame. (default: false)
  104977. * @param textureType The type of texture to be used when performing the post processing.
  104978. * @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)
  104979. */
  104980. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104981. }
  104982. }
  104983. declare module BABYLON {
  104984. /** @hidden */
  104985. export var anaglyphPixelShader: {
  104986. name: string;
  104987. shader: string;
  104988. };
  104989. }
  104990. declare module BABYLON {
  104991. /**
  104992. * Postprocess used to generate anaglyphic rendering
  104993. */
  104994. export class AnaglyphPostProcess extends PostProcess {
  104995. private _passedProcess;
  104996. /**
  104997. * Creates a new AnaglyphPostProcess
  104998. * @param name defines postprocess name
  104999. * @param options defines creation options or target ratio scale
  105000. * @param rigCameras defines cameras using this postprocess
  105001. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  105002. * @param engine defines hosting engine
  105003. * @param reusable defines if the postprocess will be reused multiple times per frame
  105004. */
  105005. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105006. }
  105007. }
  105008. declare module BABYLON {
  105009. /**
  105010. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105011. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105012. */
  105013. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105014. /**
  105015. * Creates a new AnaglyphArcRotateCamera
  105016. * @param name defines camera name
  105017. * @param alpha defines alpha angle (in radians)
  105018. * @param beta defines beta angle (in radians)
  105019. * @param radius defines radius
  105020. * @param target defines camera target
  105021. * @param interaxialDistance defines distance between each color axis
  105022. * @param scene defines the hosting scene
  105023. */
  105024. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105025. /**
  105026. * Gets camera class name
  105027. * @returns AnaglyphArcRotateCamera
  105028. */
  105029. getClassName(): string;
  105030. }
  105031. }
  105032. declare module BABYLON {
  105033. /**
  105034. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105035. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105036. */
  105037. export class AnaglyphFreeCamera extends FreeCamera {
  105038. /**
  105039. * Creates a new AnaglyphFreeCamera
  105040. * @param name defines camera name
  105041. * @param position defines initial position
  105042. * @param interaxialDistance defines distance between each color axis
  105043. * @param scene defines the hosting scene
  105044. */
  105045. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105046. /**
  105047. * Gets camera class name
  105048. * @returns AnaglyphFreeCamera
  105049. */
  105050. getClassName(): string;
  105051. }
  105052. }
  105053. declare module BABYLON {
  105054. /**
  105055. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  105056. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105057. */
  105058. export class AnaglyphGamepadCamera extends GamepadCamera {
  105059. /**
  105060. * Creates a new AnaglyphGamepadCamera
  105061. * @param name defines camera name
  105062. * @param position defines initial position
  105063. * @param interaxialDistance defines distance between each color axis
  105064. * @param scene defines the hosting scene
  105065. */
  105066. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105067. /**
  105068. * Gets camera class name
  105069. * @returns AnaglyphGamepadCamera
  105070. */
  105071. getClassName(): string;
  105072. }
  105073. }
  105074. declare module BABYLON {
  105075. /**
  105076. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  105077. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105078. */
  105079. export class AnaglyphUniversalCamera extends UniversalCamera {
  105080. /**
  105081. * Creates a new AnaglyphUniversalCamera
  105082. * @param name defines camera name
  105083. * @param position defines initial position
  105084. * @param interaxialDistance defines distance between each color axis
  105085. * @param scene defines the hosting scene
  105086. */
  105087. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105088. /**
  105089. * Gets camera class name
  105090. * @returns AnaglyphUniversalCamera
  105091. */
  105092. getClassName(): string;
  105093. }
  105094. }
  105095. declare module BABYLON {
  105096. /** @hidden */
  105097. export var stereoscopicInterlacePixelShader: {
  105098. name: string;
  105099. shader: string;
  105100. };
  105101. }
  105102. declare module BABYLON {
  105103. /**
  105104. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  105105. */
  105106. export class StereoscopicInterlacePostProcess extends PostProcess {
  105107. private _stepSize;
  105108. private _passedProcess;
  105109. /**
  105110. * Initializes a StereoscopicInterlacePostProcess
  105111. * @param name The name of the effect.
  105112. * @param rigCameras The rig cameras to be appled to the post process
  105113. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105115. * @param engine The engine which the post process will be applied. (default: current engine)
  105116. * @param reusable If the post process can be reused on the same frame. (default: false)
  105117. */
  105118. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105119. }
  105120. }
  105121. declare module BABYLON {
  105122. /**
  105123. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105124. * @see http://doc.babylonjs.com/features/cameras
  105125. */
  105126. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105127. /**
  105128. * Creates a new StereoscopicArcRotateCamera
  105129. * @param name defines camera name
  105130. * @param alpha defines alpha angle (in radians)
  105131. * @param beta defines beta angle (in radians)
  105132. * @param radius defines radius
  105133. * @param target defines camera target
  105134. * @param interaxialDistance defines distance between each color axis
  105135. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105136. * @param scene defines the hosting scene
  105137. */
  105138. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105139. /**
  105140. * Gets camera class name
  105141. * @returns StereoscopicArcRotateCamera
  105142. */
  105143. getClassName(): string;
  105144. }
  105145. }
  105146. declare module BABYLON {
  105147. /**
  105148. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105149. * @see http://doc.babylonjs.com/features/cameras
  105150. */
  105151. export class StereoscopicFreeCamera extends FreeCamera {
  105152. /**
  105153. * Creates a new StereoscopicFreeCamera
  105154. * @param name defines camera name
  105155. * @param position defines initial position
  105156. * @param interaxialDistance defines distance between each color axis
  105157. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105158. * @param scene defines the hosting scene
  105159. */
  105160. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105161. /**
  105162. * Gets camera class name
  105163. * @returns StereoscopicFreeCamera
  105164. */
  105165. getClassName(): string;
  105166. }
  105167. }
  105168. declare module BABYLON {
  105169. /**
  105170. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105171. * @see http://doc.babylonjs.com/features/cameras
  105172. */
  105173. export class StereoscopicGamepadCamera extends GamepadCamera {
  105174. /**
  105175. * Creates a new StereoscopicGamepadCamera
  105176. * @param name defines camera name
  105177. * @param position defines initial position
  105178. * @param interaxialDistance defines distance between each color axis
  105179. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105180. * @param scene defines the hosting scene
  105181. */
  105182. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105183. /**
  105184. * Gets camera class name
  105185. * @returns StereoscopicGamepadCamera
  105186. */
  105187. getClassName(): string;
  105188. }
  105189. }
  105190. declare module BABYLON {
  105191. /**
  105192. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105193. * @see http://doc.babylonjs.com/features/cameras
  105194. */
  105195. export class StereoscopicUniversalCamera extends UniversalCamera {
  105196. /**
  105197. * Creates a new StereoscopicUniversalCamera
  105198. * @param name defines camera name
  105199. * @param position defines initial position
  105200. * @param interaxialDistance defines distance between each color axis
  105201. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105202. * @param scene defines the hosting scene
  105203. */
  105204. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105205. /**
  105206. * Gets camera class name
  105207. * @returns StereoscopicUniversalCamera
  105208. */
  105209. getClassName(): string;
  105210. }
  105211. }
  105212. declare module BABYLON {
  105213. /**
  105214. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105215. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105216. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105217. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105218. */
  105219. export class VirtualJoysticksCamera extends FreeCamera {
  105220. /**
  105221. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  105222. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105223. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105224. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105225. * @param name Define the name of the camera in the scene
  105226. * @param position Define the start position of the camera in the scene
  105227. * @param scene Define the scene the camera belongs to
  105228. */
  105229. constructor(name: string, position: Vector3, scene: Scene);
  105230. /**
  105231. * Gets the current object class name.
  105232. * @return the class name
  105233. */
  105234. getClassName(): string;
  105235. }
  105236. }
  105237. declare module BABYLON {
  105238. /**
  105239. * This represents all the required metrics to create a VR camera.
  105240. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  105241. */
  105242. export class VRCameraMetrics {
  105243. /**
  105244. * Define the horizontal resolution off the screen.
  105245. */
  105246. hResolution: number;
  105247. /**
  105248. * Define the vertical resolution off the screen.
  105249. */
  105250. vResolution: number;
  105251. /**
  105252. * Define the horizontal screen size.
  105253. */
  105254. hScreenSize: number;
  105255. /**
  105256. * Define the vertical screen size.
  105257. */
  105258. vScreenSize: number;
  105259. /**
  105260. * Define the vertical screen center position.
  105261. */
  105262. vScreenCenter: number;
  105263. /**
  105264. * Define the distance of the eyes to the screen.
  105265. */
  105266. eyeToScreenDistance: number;
  105267. /**
  105268. * Define the distance between both lenses
  105269. */
  105270. lensSeparationDistance: number;
  105271. /**
  105272. * Define the distance between both viewer's eyes.
  105273. */
  105274. interpupillaryDistance: number;
  105275. /**
  105276. * Define the distortion factor of the VR postprocess.
  105277. * Please, touch with care.
  105278. */
  105279. distortionK: number[];
  105280. /**
  105281. * Define the chromatic aberration correction factors for the VR post process.
  105282. */
  105283. chromaAbCorrection: number[];
  105284. /**
  105285. * Define the scale factor of the post process.
  105286. * The smaller the better but the slower.
  105287. */
  105288. postProcessScaleFactor: number;
  105289. /**
  105290. * Define an offset for the lens center.
  105291. */
  105292. lensCenterOffset: number;
  105293. /**
  105294. * Define if the current vr camera should compensate the distortion of the lense or not.
  105295. */
  105296. compensateDistortion: boolean;
  105297. /**
  105298. * Defines if multiview should be enabled when rendering (Default: false)
  105299. */
  105300. multiviewEnabled: boolean;
  105301. /**
  105302. * Gets the rendering aspect ratio based on the provided resolutions.
  105303. */
  105304. readonly aspectRatio: number;
  105305. /**
  105306. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  105307. */
  105308. readonly aspectRatioFov: number;
  105309. /**
  105310. * @hidden
  105311. */
  105312. readonly leftHMatrix: Matrix;
  105313. /**
  105314. * @hidden
  105315. */
  105316. readonly rightHMatrix: Matrix;
  105317. /**
  105318. * @hidden
  105319. */
  105320. readonly leftPreViewMatrix: Matrix;
  105321. /**
  105322. * @hidden
  105323. */
  105324. readonly rightPreViewMatrix: Matrix;
  105325. /**
  105326. * Get the default VRMetrics based on the most generic setup.
  105327. * @returns the default vr metrics
  105328. */
  105329. static GetDefault(): VRCameraMetrics;
  105330. }
  105331. }
  105332. declare module BABYLON {
  105333. /** @hidden */
  105334. export var vrDistortionCorrectionPixelShader: {
  105335. name: string;
  105336. shader: string;
  105337. };
  105338. }
  105339. declare module BABYLON {
  105340. /**
  105341. * VRDistortionCorrectionPostProcess used for mobile VR
  105342. */
  105343. export class VRDistortionCorrectionPostProcess extends PostProcess {
  105344. private _isRightEye;
  105345. private _distortionFactors;
  105346. private _postProcessScaleFactor;
  105347. private _lensCenterOffset;
  105348. private _scaleIn;
  105349. private _scaleFactor;
  105350. private _lensCenter;
  105351. /**
  105352. * Initializes the VRDistortionCorrectionPostProcess
  105353. * @param name The name of the effect.
  105354. * @param camera The camera to apply the render pass to.
  105355. * @param isRightEye If this is for the right eye distortion
  105356. * @param vrMetrics All the required metrics for the VR camera
  105357. */
  105358. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  105359. }
  105360. }
  105361. declare module BABYLON {
  105362. /**
  105363. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  105364. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105365. */
  105366. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  105367. /**
  105368. * Creates a new VRDeviceOrientationArcRotateCamera
  105369. * @param name defines camera name
  105370. * @param alpha defines the camera rotation along the logitudinal axis
  105371. * @param beta defines the camera rotation along the latitudinal axis
  105372. * @param radius defines the camera distance from its target
  105373. * @param target defines the camera target
  105374. * @param scene defines the scene the camera belongs to
  105375. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105376. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105377. */
  105378. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105379. /**
  105380. * Gets camera class name
  105381. * @returns VRDeviceOrientationArcRotateCamera
  105382. */
  105383. getClassName(): string;
  105384. }
  105385. }
  105386. declare module BABYLON {
  105387. /**
  105388. * Camera used to simulate VR rendering (based on FreeCamera)
  105389. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105390. */
  105391. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  105392. /**
  105393. * Creates a new VRDeviceOrientationFreeCamera
  105394. * @param name defines camera name
  105395. * @param position defines the start position of the camera
  105396. * @param scene defines the scene the camera belongs to
  105397. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105398. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105399. */
  105400. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105401. /**
  105402. * Gets camera class name
  105403. * @returns VRDeviceOrientationFreeCamera
  105404. */
  105405. getClassName(): string;
  105406. }
  105407. }
  105408. declare module BABYLON {
  105409. /**
  105410. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105411. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105412. */
  105413. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105414. /**
  105415. * Creates a new VRDeviceOrientationGamepadCamera
  105416. * @param name defines camera name
  105417. * @param position defines the start position of the camera
  105418. * @param scene defines the scene the camera belongs to
  105419. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105420. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105421. */
  105422. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105423. /**
  105424. * Gets camera class name
  105425. * @returns VRDeviceOrientationGamepadCamera
  105426. */
  105427. getClassName(): string;
  105428. }
  105429. }
  105430. declare module BABYLON {
  105431. /**
  105432. * Base class of materials working in push mode in babylon JS
  105433. * @hidden
  105434. */
  105435. export class PushMaterial extends Material {
  105436. protected _activeEffect: Effect;
  105437. protected _normalMatrix: Matrix;
  105438. /**
  105439. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105440. * This means that the material can keep using a previous shader while a new one is being compiled.
  105441. * This is mostly used when shader parallel compilation is supported (true by default)
  105442. */
  105443. allowShaderHotSwapping: boolean;
  105444. constructor(name: string, scene: Scene);
  105445. getEffect(): Effect;
  105446. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105447. /**
  105448. * Binds the given world matrix to the active effect
  105449. *
  105450. * @param world the matrix to bind
  105451. */
  105452. bindOnlyWorldMatrix(world: Matrix): void;
  105453. /**
  105454. * Binds the given normal matrix to the active effect
  105455. *
  105456. * @param normalMatrix the matrix to bind
  105457. */
  105458. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105459. bind(world: Matrix, mesh?: Mesh): void;
  105460. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105461. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105462. }
  105463. }
  105464. declare module BABYLON {
  105465. /**
  105466. * This groups all the flags used to control the materials channel.
  105467. */
  105468. export class MaterialFlags {
  105469. private static _DiffuseTextureEnabled;
  105470. /**
  105471. * Are diffuse textures enabled in the application.
  105472. */
  105473. static DiffuseTextureEnabled: boolean;
  105474. private static _AmbientTextureEnabled;
  105475. /**
  105476. * Are ambient textures enabled in the application.
  105477. */
  105478. static AmbientTextureEnabled: boolean;
  105479. private static _OpacityTextureEnabled;
  105480. /**
  105481. * Are opacity textures enabled in the application.
  105482. */
  105483. static OpacityTextureEnabled: boolean;
  105484. private static _ReflectionTextureEnabled;
  105485. /**
  105486. * Are reflection textures enabled in the application.
  105487. */
  105488. static ReflectionTextureEnabled: boolean;
  105489. private static _EmissiveTextureEnabled;
  105490. /**
  105491. * Are emissive textures enabled in the application.
  105492. */
  105493. static EmissiveTextureEnabled: boolean;
  105494. private static _SpecularTextureEnabled;
  105495. /**
  105496. * Are specular textures enabled in the application.
  105497. */
  105498. static SpecularTextureEnabled: boolean;
  105499. private static _BumpTextureEnabled;
  105500. /**
  105501. * Are bump textures enabled in the application.
  105502. */
  105503. static BumpTextureEnabled: boolean;
  105504. private static _LightmapTextureEnabled;
  105505. /**
  105506. * Are lightmap textures enabled in the application.
  105507. */
  105508. static LightmapTextureEnabled: boolean;
  105509. private static _RefractionTextureEnabled;
  105510. /**
  105511. * Are refraction textures enabled in the application.
  105512. */
  105513. static RefractionTextureEnabled: boolean;
  105514. private static _ColorGradingTextureEnabled;
  105515. /**
  105516. * Are color grading textures enabled in the application.
  105517. */
  105518. static ColorGradingTextureEnabled: boolean;
  105519. private static _FresnelEnabled;
  105520. /**
  105521. * Are fresnels enabled in the application.
  105522. */
  105523. static FresnelEnabled: boolean;
  105524. private static _ClearCoatTextureEnabled;
  105525. /**
  105526. * Are clear coat textures enabled in the application.
  105527. */
  105528. static ClearCoatTextureEnabled: boolean;
  105529. private static _ClearCoatBumpTextureEnabled;
  105530. /**
  105531. * Are clear coat bump textures enabled in the application.
  105532. */
  105533. static ClearCoatBumpTextureEnabled: boolean;
  105534. private static _ClearCoatTintTextureEnabled;
  105535. /**
  105536. * Are clear coat tint textures enabled in the application.
  105537. */
  105538. static ClearCoatTintTextureEnabled: boolean;
  105539. private static _SheenTextureEnabled;
  105540. /**
  105541. * Are sheen textures enabled in the application.
  105542. */
  105543. static SheenTextureEnabled: boolean;
  105544. private static _AnisotropicTextureEnabled;
  105545. /**
  105546. * Are anisotropic textures enabled in the application.
  105547. */
  105548. static AnisotropicTextureEnabled: boolean;
  105549. private static _ThicknessTextureEnabled;
  105550. /**
  105551. * Are thickness textures enabled in the application.
  105552. */
  105553. static ThicknessTextureEnabled: boolean;
  105554. }
  105555. }
  105556. declare module BABYLON {
  105557. /** @hidden */
  105558. export var defaultFragmentDeclaration: {
  105559. name: string;
  105560. shader: string;
  105561. };
  105562. }
  105563. declare module BABYLON {
  105564. /** @hidden */
  105565. export var defaultUboDeclaration: {
  105566. name: string;
  105567. shader: string;
  105568. };
  105569. }
  105570. declare module BABYLON {
  105571. /** @hidden */
  105572. export var lightFragmentDeclaration: {
  105573. name: string;
  105574. shader: string;
  105575. };
  105576. }
  105577. declare module BABYLON {
  105578. /** @hidden */
  105579. export var lightUboDeclaration: {
  105580. name: string;
  105581. shader: string;
  105582. };
  105583. }
  105584. declare module BABYLON {
  105585. /** @hidden */
  105586. export var lightsFragmentFunctions: {
  105587. name: string;
  105588. shader: string;
  105589. };
  105590. }
  105591. declare module BABYLON {
  105592. /** @hidden */
  105593. export var shadowsFragmentFunctions: {
  105594. name: string;
  105595. shader: string;
  105596. };
  105597. }
  105598. declare module BABYLON {
  105599. /** @hidden */
  105600. export var fresnelFunction: {
  105601. name: string;
  105602. shader: string;
  105603. };
  105604. }
  105605. declare module BABYLON {
  105606. /** @hidden */
  105607. export var reflectionFunction: {
  105608. name: string;
  105609. shader: string;
  105610. };
  105611. }
  105612. declare module BABYLON {
  105613. /** @hidden */
  105614. export var bumpFragmentFunctions: {
  105615. name: string;
  105616. shader: string;
  105617. };
  105618. }
  105619. declare module BABYLON {
  105620. /** @hidden */
  105621. export var logDepthDeclaration: {
  105622. name: string;
  105623. shader: string;
  105624. };
  105625. }
  105626. declare module BABYLON {
  105627. /** @hidden */
  105628. export var bumpFragment: {
  105629. name: string;
  105630. shader: string;
  105631. };
  105632. }
  105633. declare module BABYLON {
  105634. /** @hidden */
  105635. export var depthPrePass: {
  105636. name: string;
  105637. shader: string;
  105638. };
  105639. }
  105640. declare module BABYLON {
  105641. /** @hidden */
  105642. export var lightFragment: {
  105643. name: string;
  105644. shader: string;
  105645. };
  105646. }
  105647. declare module BABYLON {
  105648. /** @hidden */
  105649. export var logDepthFragment: {
  105650. name: string;
  105651. shader: string;
  105652. };
  105653. }
  105654. declare module BABYLON {
  105655. /** @hidden */
  105656. export var defaultPixelShader: {
  105657. name: string;
  105658. shader: string;
  105659. };
  105660. }
  105661. declare module BABYLON {
  105662. /** @hidden */
  105663. export var defaultVertexDeclaration: {
  105664. name: string;
  105665. shader: string;
  105666. };
  105667. }
  105668. declare module BABYLON {
  105669. /** @hidden */
  105670. export var bumpVertexDeclaration: {
  105671. name: string;
  105672. shader: string;
  105673. };
  105674. }
  105675. declare module BABYLON {
  105676. /** @hidden */
  105677. export var bumpVertex: {
  105678. name: string;
  105679. shader: string;
  105680. };
  105681. }
  105682. declare module BABYLON {
  105683. /** @hidden */
  105684. export var fogVertex: {
  105685. name: string;
  105686. shader: string;
  105687. };
  105688. }
  105689. declare module BABYLON {
  105690. /** @hidden */
  105691. export var shadowsVertex: {
  105692. name: string;
  105693. shader: string;
  105694. };
  105695. }
  105696. declare module BABYLON {
  105697. /** @hidden */
  105698. export var pointCloudVertex: {
  105699. name: string;
  105700. shader: string;
  105701. };
  105702. }
  105703. declare module BABYLON {
  105704. /** @hidden */
  105705. export var logDepthVertex: {
  105706. name: string;
  105707. shader: string;
  105708. };
  105709. }
  105710. declare module BABYLON {
  105711. /** @hidden */
  105712. export var defaultVertexShader: {
  105713. name: string;
  105714. shader: string;
  105715. };
  105716. }
  105717. declare module BABYLON {
  105718. /** @hidden */
  105719. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105720. MAINUV1: boolean;
  105721. MAINUV2: boolean;
  105722. DIFFUSE: boolean;
  105723. DIFFUSEDIRECTUV: number;
  105724. AMBIENT: boolean;
  105725. AMBIENTDIRECTUV: number;
  105726. OPACITY: boolean;
  105727. OPACITYDIRECTUV: number;
  105728. OPACITYRGB: boolean;
  105729. REFLECTION: boolean;
  105730. EMISSIVE: boolean;
  105731. EMISSIVEDIRECTUV: number;
  105732. SPECULAR: boolean;
  105733. SPECULARDIRECTUV: number;
  105734. BUMP: boolean;
  105735. BUMPDIRECTUV: number;
  105736. PARALLAX: boolean;
  105737. PARALLAXOCCLUSION: boolean;
  105738. SPECULAROVERALPHA: boolean;
  105739. CLIPPLANE: boolean;
  105740. CLIPPLANE2: boolean;
  105741. CLIPPLANE3: boolean;
  105742. CLIPPLANE4: boolean;
  105743. ALPHATEST: boolean;
  105744. DEPTHPREPASS: boolean;
  105745. ALPHAFROMDIFFUSE: boolean;
  105746. POINTSIZE: boolean;
  105747. FOG: boolean;
  105748. SPECULARTERM: boolean;
  105749. DIFFUSEFRESNEL: boolean;
  105750. OPACITYFRESNEL: boolean;
  105751. REFLECTIONFRESNEL: boolean;
  105752. REFRACTIONFRESNEL: boolean;
  105753. EMISSIVEFRESNEL: boolean;
  105754. FRESNEL: boolean;
  105755. NORMAL: boolean;
  105756. UV1: boolean;
  105757. UV2: boolean;
  105758. VERTEXCOLOR: boolean;
  105759. VERTEXALPHA: boolean;
  105760. NUM_BONE_INFLUENCERS: number;
  105761. BonesPerMesh: number;
  105762. BONETEXTURE: boolean;
  105763. INSTANCES: boolean;
  105764. GLOSSINESS: boolean;
  105765. ROUGHNESS: boolean;
  105766. EMISSIVEASILLUMINATION: boolean;
  105767. LINKEMISSIVEWITHDIFFUSE: boolean;
  105768. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105769. LIGHTMAP: boolean;
  105770. LIGHTMAPDIRECTUV: number;
  105771. OBJECTSPACE_NORMALMAP: boolean;
  105772. USELIGHTMAPASSHADOWMAP: boolean;
  105773. REFLECTIONMAP_3D: boolean;
  105774. REFLECTIONMAP_SPHERICAL: boolean;
  105775. REFLECTIONMAP_PLANAR: boolean;
  105776. REFLECTIONMAP_CUBIC: boolean;
  105777. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105778. REFLECTIONMAP_PROJECTION: boolean;
  105779. REFLECTIONMAP_SKYBOX: boolean;
  105780. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105781. REFLECTIONMAP_EXPLICIT: boolean;
  105782. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105783. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105784. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105785. INVERTCUBICMAP: boolean;
  105786. LOGARITHMICDEPTH: boolean;
  105787. REFRACTION: boolean;
  105788. REFRACTIONMAP_3D: boolean;
  105789. REFLECTIONOVERALPHA: boolean;
  105790. TWOSIDEDLIGHTING: boolean;
  105791. SHADOWFLOAT: boolean;
  105792. MORPHTARGETS: boolean;
  105793. MORPHTARGETS_NORMAL: boolean;
  105794. MORPHTARGETS_TANGENT: boolean;
  105795. MORPHTARGETS_UV: boolean;
  105796. NUM_MORPH_INFLUENCERS: number;
  105797. NONUNIFORMSCALING: boolean;
  105798. PREMULTIPLYALPHA: boolean;
  105799. IMAGEPROCESSING: boolean;
  105800. VIGNETTE: boolean;
  105801. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105802. VIGNETTEBLENDMODEOPAQUE: boolean;
  105803. TONEMAPPING: boolean;
  105804. TONEMAPPING_ACES: boolean;
  105805. CONTRAST: boolean;
  105806. COLORCURVES: boolean;
  105807. COLORGRADING: boolean;
  105808. COLORGRADING3D: boolean;
  105809. SAMPLER3DGREENDEPTH: boolean;
  105810. SAMPLER3DBGRMAP: boolean;
  105811. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105812. MULTIVIEW: boolean;
  105813. /**
  105814. * If the reflection texture on this material is in linear color space
  105815. * @hidden
  105816. */
  105817. IS_REFLECTION_LINEAR: boolean;
  105818. /**
  105819. * If the refraction texture on this material is in linear color space
  105820. * @hidden
  105821. */
  105822. IS_REFRACTION_LINEAR: boolean;
  105823. EXPOSURE: boolean;
  105824. constructor();
  105825. setReflectionMode(modeToEnable: string): void;
  105826. }
  105827. /**
  105828. * This is the default material used in Babylon. It is the best trade off between quality
  105829. * and performances.
  105830. * @see http://doc.babylonjs.com/babylon101/materials
  105831. */
  105832. export class StandardMaterial extends PushMaterial {
  105833. private _diffuseTexture;
  105834. /**
  105835. * The basic texture of the material as viewed under a light.
  105836. */
  105837. diffuseTexture: Nullable<BaseTexture>;
  105838. private _ambientTexture;
  105839. /**
  105840. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105841. */
  105842. ambientTexture: Nullable<BaseTexture>;
  105843. private _opacityTexture;
  105844. /**
  105845. * Define the transparency of the material from a texture.
  105846. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105847. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105848. */
  105849. opacityTexture: Nullable<BaseTexture>;
  105850. private _reflectionTexture;
  105851. /**
  105852. * Define the texture used to display the reflection.
  105853. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105854. */
  105855. reflectionTexture: Nullable<BaseTexture>;
  105856. private _emissiveTexture;
  105857. /**
  105858. * Define texture of the material as if self lit.
  105859. * This will be mixed in the final result even in the absence of light.
  105860. */
  105861. emissiveTexture: Nullable<BaseTexture>;
  105862. private _specularTexture;
  105863. /**
  105864. * Define how the color and intensity of the highlight given by the light in the material.
  105865. */
  105866. specularTexture: Nullable<BaseTexture>;
  105867. private _bumpTexture;
  105868. /**
  105869. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105870. * 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.
  105871. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  105872. */
  105873. bumpTexture: Nullable<BaseTexture>;
  105874. private _lightmapTexture;
  105875. /**
  105876. * Complex lighting can be computationally expensive to compute at runtime.
  105877. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105878. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  105879. */
  105880. lightmapTexture: Nullable<BaseTexture>;
  105881. private _refractionTexture;
  105882. /**
  105883. * Define the texture used to display the refraction.
  105884. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105885. */
  105886. refractionTexture: Nullable<BaseTexture>;
  105887. /**
  105888. * The color of the material lit by the environmental background lighting.
  105889. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105890. */
  105891. ambientColor: Color3;
  105892. /**
  105893. * The basic color of the material as viewed under a light.
  105894. */
  105895. diffuseColor: Color3;
  105896. /**
  105897. * Define how the color and intensity of the highlight given by the light in the material.
  105898. */
  105899. specularColor: Color3;
  105900. /**
  105901. * Define the color of the material as if self lit.
  105902. * This will be mixed in the final result even in the absence of light.
  105903. */
  105904. emissiveColor: Color3;
  105905. /**
  105906. * Defines how sharp are the highlights in the material.
  105907. * The bigger the value the sharper giving a more glossy feeling to the result.
  105908. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105909. */
  105910. specularPower: number;
  105911. private _useAlphaFromDiffuseTexture;
  105912. /**
  105913. * Does the transparency come from the diffuse texture alpha channel.
  105914. */
  105915. useAlphaFromDiffuseTexture: boolean;
  105916. private _useEmissiveAsIllumination;
  105917. /**
  105918. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105919. */
  105920. useEmissiveAsIllumination: boolean;
  105921. private _linkEmissiveWithDiffuse;
  105922. /**
  105923. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105924. * the emissive level when the final color is close to one.
  105925. */
  105926. linkEmissiveWithDiffuse: boolean;
  105927. private _useSpecularOverAlpha;
  105928. /**
  105929. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105930. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105931. */
  105932. useSpecularOverAlpha: boolean;
  105933. private _useReflectionOverAlpha;
  105934. /**
  105935. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105936. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105937. */
  105938. useReflectionOverAlpha: boolean;
  105939. private _disableLighting;
  105940. /**
  105941. * Does lights from the scene impacts this material.
  105942. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105943. */
  105944. disableLighting: boolean;
  105945. private _useObjectSpaceNormalMap;
  105946. /**
  105947. * Allows using an object space normal map (instead of tangent space).
  105948. */
  105949. useObjectSpaceNormalMap: boolean;
  105950. private _useParallax;
  105951. /**
  105952. * Is parallax enabled or not.
  105953. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105954. */
  105955. useParallax: boolean;
  105956. private _useParallaxOcclusion;
  105957. /**
  105958. * Is parallax occlusion enabled or not.
  105959. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105960. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105961. */
  105962. useParallaxOcclusion: boolean;
  105963. /**
  105964. * 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.
  105965. */
  105966. parallaxScaleBias: number;
  105967. private _roughness;
  105968. /**
  105969. * Helps to define how blurry the reflections should appears in the material.
  105970. */
  105971. roughness: number;
  105972. /**
  105973. * In case of refraction, define the value of the index of refraction.
  105974. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105975. */
  105976. indexOfRefraction: number;
  105977. /**
  105978. * Invert the refraction texture alongside the y axis.
  105979. * It can be useful with procedural textures or probe for instance.
  105980. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105981. */
  105982. invertRefractionY: boolean;
  105983. /**
  105984. * Defines the alpha limits in alpha test mode.
  105985. */
  105986. alphaCutOff: number;
  105987. private _useLightmapAsShadowmap;
  105988. /**
  105989. * In case of light mapping, define whether the map contains light or shadow informations.
  105990. */
  105991. useLightmapAsShadowmap: boolean;
  105992. private _diffuseFresnelParameters;
  105993. /**
  105994. * Define the diffuse fresnel parameters of the material.
  105995. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105996. */
  105997. diffuseFresnelParameters: FresnelParameters;
  105998. private _opacityFresnelParameters;
  105999. /**
  106000. * Define the opacity fresnel parameters of the material.
  106001. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106002. */
  106003. opacityFresnelParameters: FresnelParameters;
  106004. private _reflectionFresnelParameters;
  106005. /**
  106006. * Define the reflection fresnel parameters of the material.
  106007. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106008. */
  106009. reflectionFresnelParameters: FresnelParameters;
  106010. private _refractionFresnelParameters;
  106011. /**
  106012. * Define the refraction fresnel parameters of the material.
  106013. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106014. */
  106015. refractionFresnelParameters: FresnelParameters;
  106016. private _emissiveFresnelParameters;
  106017. /**
  106018. * Define the emissive fresnel parameters of the material.
  106019. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106020. */
  106021. emissiveFresnelParameters: FresnelParameters;
  106022. private _useReflectionFresnelFromSpecular;
  106023. /**
  106024. * If true automatically deducts the fresnels values from the material specularity.
  106025. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106026. */
  106027. useReflectionFresnelFromSpecular: boolean;
  106028. private _useGlossinessFromSpecularMapAlpha;
  106029. /**
  106030. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106031. */
  106032. useGlossinessFromSpecularMapAlpha: boolean;
  106033. private _maxSimultaneousLights;
  106034. /**
  106035. * Defines the maximum number of lights that can be used in the material
  106036. */
  106037. maxSimultaneousLights: number;
  106038. private _invertNormalMapX;
  106039. /**
  106040. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106041. */
  106042. invertNormalMapX: boolean;
  106043. private _invertNormalMapY;
  106044. /**
  106045. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106046. */
  106047. invertNormalMapY: boolean;
  106048. private _twoSidedLighting;
  106049. /**
  106050. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106051. */
  106052. twoSidedLighting: boolean;
  106053. /**
  106054. * Default configuration related to image processing available in the standard Material.
  106055. */
  106056. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106057. /**
  106058. * Gets the image processing configuration used either in this material.
  106059. */
  106060. /**
  106061. * Sets the Default image processing configuration used either in the this material.
  106062. *
  106063. * If sets to null, the scene one is in use.
  106064. */
  106065. imageProcessingConfiguration: ImageProcessingConfiguration;
  106066. /**
  106067. * Keep track of the image processing observer to allow dispose and replace.
  106068. */
  106069. private _imageProcessingObserver;
  106070. /**
  106071. * Attaches a new image processing configuration to the Standard Material.
  106072. * @param configuration
  106073. */
  106074. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106075. /**
  106076. * Gets wether the color curves effect is enabled.
  106077. */
  106078. /**
  106079. * Sets wether the color curves effect is enabled.
  106080. */
  106081. cameraColorCurvesEnabled: boolean;
  106082. /**
  106083. * Gets wether the color grading effect is enabled.
  106084. */
  106085. /**
  106086. * Gets wether the color grading effect is enabled.
  106087. */
  106088. cameraColorGradingEnabled: boolean;
  106089. /**
  106090. * Gets wether tonemapping is enabled or not.
  106091. */
  106092. /**
  106093. * Sets wether tonemapping is enabled or not
  106094. */
  106095. cameraToneMappingEnabled: boolean;
  106096. /**
  106097. * The camera exposure used on this material.
  106098. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106099. * This corresponds to a photographic exposure.
  106100. */
  106101. /**
  106102. * The camera exposure used on this material.
  106103. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106104. * This corresponds to a photographic exposure.
  106105. */
  106106. cameraExposure: number;
  106107. /**
  106108. * Gets The camera contrast used on this material.
  106109. */
  106110. /**
  106111. * Sets The camera contrast used on this material.
  106112. */
  106113. cameraContrast: number;
  106114. /**
  106115. * Gets the Color Grading 2D Lookup Texture.
  106116. */
  106117. /**
  106118. * Sets the Color Grading 2D Lookup Texture.
  106119. */
  106120. cameraColorGradingTexture: Nullable<BaseTexture>;
  106121. /**
  106122. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106123. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106124. * 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;
  106125. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106126. */
  106127. /**
  106128. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106129. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106130. * 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;
  106131. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106132. */
  106133. cameraColorCurves: Nullable<ColorCurves>;
  106134. /**
  106135. * Custom callback helping to override the default shader used in the material.
  106136. */
  106137. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106138. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106139. protected _worldViewProjectionMatrix: Matrix;
  106140. protected _globalAmbientColor: Color3;
  106141. protected _useLogarithmicDepth: boolean;
  106142. protected _rebuildInParallel: boolean;
  106143. /**
  106144. * Instantiates a new standard material.
  106145. * This is the default material used in Babylon. It is the best trade off between quality
  106146. * and performances.
  106147. * @see http://doc.babylonjs.com/babylon101/materials
  106148. * @param name Define the name of the material in the scene
  106149. * @param scene Define the scene the material belong to
  106150. */
  106151. constructor(name: string, scene: Scene);
  106152. /**
  106153. * Gets a boolean indicating that current material needs to register RTT
  106154. */
  106155. readonly hasRenderTargetTextures: boolean;
  106156. /**
  106157. * Gets the current class name of the material e.g. "StandardMaterial"
  106158. * Mainly use in serialization.
  106159. * @returns the class name
  106160. */
  106161. getClassName(): string;
  106162. /**
  106163. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106164. * You can try switching to logarithmic depth.
  106165. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106166. */
  106167. useLogarithmicDepth: boolean;
  106168. /**
  106169. * Specifies if the material will require alpha blending
  106170. * @returns a boolean specifying if alpha blending is needed
  106171. */
  106172. needAlphaBlending(): boolean;
  106173. /**
  106174. * Specifies if this material should be rendered in alpha test mode
  106175. * @returns a boolean specifying if an alpha test is needed.
  106176. */
  106177. needAlphaTesting(): boolean;
  106178. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106179. /**
  106180. * Get the texture used for alpha test purpose.
  106181. * @returns the diffuse texture in case of the standard material.
  106182. */
  106183. getAlphaTestTexture(): Nullable<BaseTexture>;
  106184. /**
  106185. * Get if the submesh is ready to be used and all its information available.
  106186. * Child classes can use it to update shaders
  106187. * @param mesh defines the mesh to check
  106188. * @param subMesh defines which submesh to check
  106189. * @param useInstances specifies that instances should be used
  106190. * @returns a boolean indicating that the submesh is ready or not
  106191. */
  106192. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106193. /**
  106194. * Builds the material UBO layouts.
  106195. * Used internally during the effect preparation.
  106196. */
  106197. buildUniformLayout(): void;
  106198. /**
  106199. * Unbinds the material from the mesh
  106200. */
  106201. unbind(): void;
  106202. /**
  106203. * Binds the submesh to this material by preparing the effect and shader to draw
  106204. * @param world defines the world transformation matrix
  106205. * @param mesh defines the mesh containing the submesh
  106206. * @param subMesh defines the submesh to bind the material to
  106207. */
  106208. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106209. /**
  106210. * Get the list of animatables in the material.
  106211. * @returns the list of animatables object used in the material
  106212. */
  106213. getAnimatables(): IAnimatable[];
  106214. /**
  106215. * Gets the active textures from the material
  106216. * @returns an array of textures
  106217. */
  106218. getActiveTextures(): BaseTexture[];
  106219. /**
  106220. * Specifies if the material uses a texture
  106221. * @param texture defines the texture to check against the material
  106222. * @returns a boolean specifying if the material uses the texture
  106223. */
  106224. hasTexture(texture: BaseTexture): boolean;
  106225. /**
  106226. * Disposes the material
  106227. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106228. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106229. */
  106230. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106231. /**
  106232. * Makes a duplicate of the material, and gives it a new name
  106233. * @param name defines the new name for the duplicated material
  106234. * @returns the cloned material
  106235. */
  106236. clone(name: string): StandardMaterial;
  106237. /**
  106238. * Serializes this material in a JSON representation
  106239. * @returns the serialized material object
  106240. */
  106241. serialize(): any;
  106242. /**
  106243. * Creates a standard material from parsed material data
  106244. * @param source defines the JSON representation of the material
  106245. * @param scene defines the hosting scene
  106246. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106247. * @returns a new standard material
  106248. */
  106249. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106250. /**
  106251. * Are diffuse textures enabled in the application.
  106252. */
  106253. static DiffuseTextureEnabled: boolean;
  106254. /**
  106255. * Are ambient textures enabled in the application.
  106256. */
  106257. static AmbientTextureEnabled: boolean;
  106258. /**
  106259. * Are opacity textures enabled in the application.
  106260. */
  106261. static OpacityTextureEnabled: boolean;
  106262. /**
  106263. * Are reflection textures enabled in the application.
  106264. */
  106265. static ReflectionTextureEnabled: boolean;
  106266. /**
  106267. * Are emissive textures enabled in the application.
  106268. */
  106269. static EmissiveTextureEnabled: boolean;
  106270. /**
  106271. * Are specular textures enabled in the application.
  106272. */
  106273. static SpecularTextureEnabled: boolean;
  106274. /**
  106275. * Are bump textures enabled in the application.
  106276. */
  106277. static BumpTextureEnabled: boolean;
  106278. /**
  106279. * Are lightmap textures enabled in the application.
  106280. */
  106281. static LightmapTextureEnabled: boolean;
  106282. /**
  106283. * Are refraction textures enabled in the application.
  106284. */
  106285. static RefractionTextureEnabled: boolean;
  106286. /**
  106287. * Are color grading textures enabled in the application.
  106288. */
  106289. static ColorGradingTextureEnabled: boolean;
  106290. /**
  106291. * Are fresnels enabled in the application.
  106292. */
  106293. static FresnelEnabled: boolean;
  106294. }
  106295. }
  106296. declare module BABYLON {
  106297. /** @hidden */
  106298. export var imageProcessingPixelShader: {
  106299. name: string;
  106300. shader: string;
  106301. };
  106302. }
  106303. declare module BABYLON {
  106304. /**
  106305. * ImageProcessingPostProcess
  106306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  106307. */
  106308. export class ImageProcessingPostProcess extends PostProcess {
  106309. /**
  106310. * Default configuration related to image processing available in the PBR Material.
  106311. */
  106312. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106313. /**
  106314. * Gets the image processing configuration used either in this material.
  106315. */
  106316. /**
  106317. * Sets the Default image processing configuration used either in the this material.
  106318. *
  106319. * If sets to null, the scene one is in use.
  106320. */
  106321. imageProcessingConfiguration: ImageProcessingConfiguration;
  106322. /**
  106323. * Keep track of the image processing observer to allow dispose and replace.
  106324. */
  106325. private _imageProcessingObserver;
  106326. /**
  106327. * Attaches a new image processing configuration to the PBR Material.
  106328. * @param configuration
  106329. */
  106330. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106331. /**
  106332. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106333. */
  106334. /**
  106335. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106336. */
  106337. colorCurves: Nullable<ColorCurves>;
  106338. /**
  106339. * Gets wether the color curves effect is enabled.
  106340. */
  106341. /**
  106342. * Sets wether the color curves effect is enabled.
  106343. */
  106344. colorCurvesEnabled: boolean;
  106345. /**
  106346. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106347. */
  106348. /**
  106349. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106350. */
  106351. colorGradingTexture: Nullable<BaseTexture>;
  106352. /**
  106353. * Gets wether the color grading effect is enabled.
  106354. */
  106355. /**
  106356. * Gets wether the color grading effect is enabled.
  106357. */
  106358. colorGradingEnabled: boolean;
  106359. /**
  106360. * Gets exposure used in the effect.
  106361. */
  106362. /**
  106363. * Sets exposure used in the effect.
  106364. */
  106365. exposure: number;
  106366. /**
  106367. * Gets wether tonemapping is enabled or not.
  106368. */
  106369. /**
  106370. * Sets wether tonemapping is enabled or not
  106371. */
  106372. toneMappingEnabled: boolean;
  106373. /**
  106374. * Gets the type of tone mapping effect.
  106375. */
  106376. /**
  106377. * Sets the type of tone mapping effect.
  106378. */
  106379. toneMappingType: number;
  106380. /**
  106381. * Gets contrast used in the effect.
  106382. */
  106383. /**
  106384. * Sets contrast used in the effect.
  106385. */
  106386. contrast: number;
  106387. /**
  106388. * Gets Vignette stretch size.
  106389. */
  106390. /**
  106391. * Sets Vignette stretch size.
  106392. */
  106393. vignetteStretch: number;
  106394. /**
  106395. * Gets Vignette centre X Offset.
  106396. */
  106397. /**
  106398. * Sets Vignette centre X Offset.
  106399. */
  106400. vignetteCentreX: number;
  106401. /**
  106402. * Gets Vignette centre Y Offset.
  106403. */
  106404. /**
  106405. * Sets Vignette centre Y Offset.
  106406. */
  106407. vignetteCentreY: number;
  106408. /**
  106409. * Gets Vignette weight or intensity of the vignette effect.
  106410. */
  106411. /**
  106412. * Sets Vignette weight or intensity of the vignette effect.
  106413. */
  106414. vignetteWeight: number;
  106415. /**
  106416. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106417. * if vignetteEnabled is set to true.
  106418. */
  106419. /**
  106420. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106421. * if vignetteEnabled is set to true.
  106422. */
  106423. vignetteColor: Color4;
  106424. /**
  106425. * Gets Camera field of view used by the Vignette effect.
  106426. */
  106427. /**
  106428. * Sets Camera field of view used by the Vignette effect.
  106429. */
  106430. vignetteCameraFov: number;
  106431. /**
  106432. * Gets the vignette blend mode allowing different kind of effect.
  106433. */
  106434. /**
  106435. * Sets the vignette blend mode allowing different kind of effect.
  106436. */
  106437. vignetteBlendMode: number;
  106438. /**
  106439. * Gets wether the vignette effect is enabled.
  106440. */
  106441. /**
  106442. * Sets wether the vignette effect is enabled.
  106443. */
  106444. vignetteEnabled: boolean;
  106445. private _fromLinearSpace;
  106446. /**
  106447. * Gets wether the input of the processing is in Gamma or Linear Space.
  106448. */
  106449. /**
  106450. * Sets wether the input of the processing is in Gamma or Linear Space.
  106451. */
  106452. fromLinearSpace: boolean;
  106453. /**
  106454. * Defines cache preventing GC.
  106455. */
  106456. private _defines;
  106457. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106458. /**
  106459. * "ImageProcessingPostProcess"
  106460. * @returns "ImageProcessingPostProcess"
  106461. */
  106462. getClassName(): string;
  106463. protected _updateParameters(): void;
  106464. dispose(camera?: Camera): void;
  106465. }
  106466. }
  106467. declare module BABYLON {
  106468. /**
  106469. * Class containing static functions to help procedurally build meshes
  106470. */
  106471. export class GroundBuilder {
  106472. /**
  106473. * Creates a ground mesh
  106474. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106475. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106477. * @param name defines the name of the mesh
  106478. * @param options defines the options used to create the mesh
  106479. * @param scene defines the hosting scene
  106480. * @returns the ground mesh
  106481. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106482. */
  106483. static CreateGround(name: string, options: {
  106484. width?: number;
  106485. height?: number;
  106486. subdivisions?: number;
  106487. subdivisionsX?: number;
  106488. subdivisionsY?: number;
  106489. updatable?: boolean;
  106490. }, scene: any): Mesh;
  106491. /**
  106492. * Creates a tiled ground mesh
  106493. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106494. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106495. * * 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
  106496. * * 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
  106497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106498. * @param name defines the name of the mesh
  106499. * @param options defines the options used to create the mesh
  106500. * @param scene defines the hosting scene
  106501. * @returns the tiled ground mesh
  106502. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106503. */
  106504. static CreateTiledGround(name: string, options: {
  106505. xmin: number;
  106506. zmin: number;
  106507. xmax: number;
  106508. zmax: number;
  106509. subdivisions?: {
  106510. w: number;
  106511. h: number;
  106512. };
  106513. precision?: {
  106514. w: number;
  106515. h: number;
  106516. };
  106517. updatable?: boolean;
  106518. }, scene?: Nullable<Scene>): Mesh;
  106519. /**
  106520. * Creates a ground mesh from a height map
  106521. * * The parameter `url` sets the URL of the height map image resource.
  106522. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106523. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106524. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106525. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106526. * * 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.
  106527. * * 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).
  106528. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106530. * @param name defines the name of the mesh
  106531. * @param url defines the url to the height map
  106532. * @param options defines the options used to create the mesh
  106533. * @param scene defines the hosting scene
  106534. * @returns the ground mesh
  106535. * @see https://doc.babylonjs.com/babylon101/height_map
  106536. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106537. */
  106538. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106539. width?: number;
  106540. height?: number;
  106541. subdivisions?: number;
  106542. minHeight?: number;
  106543. maxHeight?: number;
  106544. colorFilter?: Color3;
  106545. alphaFilter?: number;
  106546. updatable?: boolean;
  106547. onReady?: (mesh: GroundMesh) => void;
  106548. }, scene?: Nullable<Scene>): GroundMesh;
  106549. }
  106550. }
  106551. declare module BABYLON {
  106552. /**
  106553. * Class containing static functions to help procedurally build meshes
  106554. */
  106555. export class TorusBuilder {
  106556. /**
  106557. * Creates a torus mesh
  106558. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106559. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106560. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106564. * @param name defines the name of the mesh
  106565. * @param options defines the options used to create the mesh
  106566. * @param scene defines the hosting scene
  106567. * @returns the torus mesh
  106568. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106569. */
  106570. static CreateTorus(name: string, options: {
  106571. diameter?: number;
  106572. thickness?: number;
  106573. tessellation?: number;
  106574. updatable?: boolean;
  106575. sideOrientation?: number;
  106576. frontUVs?: Vector4;
  106577. backUVs?: Vector4;
  106578. }, scene: any): Mesh;
  106579. }
  106580. }
  106581. declare module BABYLON {
  106582. /**
  106583. * Class containing static functions to help procedurally build meshes
  106584. */
  106585. export class CylinderBuilder {
  106586. /**
  106587. * Creates a cylinder or a cone mesh
  106588. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106589. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106590. * * 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.
  106591. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106592. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106593. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106594. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106595. * * 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).
  106596. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106597. * * 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).
  106598. * * 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
  106599. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106600. * * 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
  106601. * * 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.
  106602. * * If `enclose` is false, a ring surface is one element.
  106603. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106604. * * 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
  106605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106608. * @param name defines the name of the mesh
  106609. * @param options defines the options used to create the mesh
  106610. * @param scene defines the hosting scene
  106611. * @returns the cylinder mesh
  106612. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106613. */
  106614. static CreateCylinder(name: string, options: {
  106615. height?: number;
  106616. diameterTop?: number;
  106617. diameterBottom?: number;
  106618. diameter?: number;
  106619. tessellation?: number;
  106620. subdivisions?: number;
  106621. arc?: number;
  106622. faceColors?: Color4[];
  106623. faceUV?: Vector4[];
  106624. updatable?: boolean;
  106625. hasRings?: boolean;
  106626. enclose?: boolean;
  106627. cap?: number;
  106628. sideOrientation?: number;
  106629. frontUVs?: Vector4;
  106630. backUVs?: Vector4;
  106631. }, scene: any): Mesh;
  106632. }
  106633. }
  106634. declare module BABYLON {
  106635. /**
  106636. * Options to modify the vr teleportation behavior.
  106637. */
  106638. export interface VRTeleportationOptions {
  106639. /**
  106640. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106641. */
  106642. floorMeshName?: string;
  106643. /**
  106644. * A list of meshes to be used as the teleportation floor. (default: empty)
  106645. */
  106646. floorMeshes?: Mesh[];
  106647. }
  106648. /**
  106649. * Options to modify the vr experience helper's behavior.
  106650. */
  106651. export interface VRExperienceHelperOptions extends WebVROptions {
  106652. /**
  106653. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106654. */
  106655. createDeviceOrientationCamera?: boolean;
  106656. /**
  106657. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106658. */
  106659. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106660. /**
  106661. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106662. */
  106663. laserToggle?: boolean;
  106664. /**
  106665. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106666. */
  106667. floorMeshes?: Mesh[];
  106668. /**
  106669. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106670. */
  106671. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106672. }
  106673. /**
  106674. * Event containing information after VR has been entered
  106675. */
  106676. export class OnAfterEnteringVRObservableEvent {
  106677. /**
  106678. * If entering vr was successful
  106679. */
  106680. success: boolean;
  106681. }
  106682. /**
  106683. * Helps to quickly add VR support to an existing scene.
  106684. * See http://doc.babylonjs.com/how_to/webvr_helper
  106685. */
  106686. export class VRExperienceHelper {
  106687. /** Options to modify the vr experience helper's behavior. */
  106688. webVROptions: VRExperienceHelperOptions;
  106689. private _scene;
  106690. private _position;
  106691. private _btnVR;
  106692. private _btnVRDisplayed;
  106693. private _webVRsupported;
  106694. private _webVRready;
  106695. private _webVRrequesting;
  106696. private _webVRpresenting;
  106697. private _hasEnteredVR;
  106698. private _fullscreenVRpresenting;
  106699. private _canvas;
  106700. private _webVRCamera;
  106701. private _vrDeviceOrientationCamera;
  106702. private _deviceOrientationCamera;
  106703. private _existingCamera;
  106704. private _onKeyDown;
  106705. private _onVrDisplayPresentChange;
  106706. private _onVRDisplayChanged;
  106707. private _onVRRequestPresentStart;
  106708. private _onVRRequestPresentComplete;
  106709. /**
  106710. * 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)
  106711. */
  106712. enableGazeEvenWhenNoPointerLock: boolean;
  106713. /**
  106714. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106715. */
  106716. exitVROnDoubleTap: boolean;
  106717. /**
  106718. * Observable raised right before entering VR.
  106719. */
  106720. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106721. /**
  106722. * Observable raised when entering VR has completed.
  106723. */
  106724. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106725. /**
  106726. * Observable raised when exiting VR.
  106727. */
  106728. onExitingVRObservable: Observable<VRExperienceHelper>;
  106729. /**
  106730. * Observable raised when controller mesh is loaded.
  106731. */
  106732. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106733. /** Return this.onEnteringVRObservable
  106734. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106735. */
  106736. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106737. /** Return this.onExitingVRObservable
  106738. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106739. */
  106740. readonly onExitingVR: Observable<VRExperienceHelper>;
  106741. /** Return this.onControllerMeshLoadedObservable
  106742. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106743. */
  106744. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106745. private _rayLength;
  106746. private _useCustomVRButton;
  106747. private _teleportationRequested;
  106748. private _teleportActive;
  106749. private _floorMeshName;
  106750. private _floorMeshesCollection;
  106751. private _rotationAllowed;
  106752. private _teleportBackwardsVector;
  106753. private _teleportationTarget;
  106754. private _isDefaultTeleportationTarget;
  106755. private _postProcessMove;
  106756. private _teleportationFillColor;
  106757. private _teleportationBorderColor;
  106758. private _rotationAngle;
  106759. private _haloCenter;
  106760. private _cameraGazer;
  106761. private _padSensibilityUp;
  106762. private _padSensibilityDown;
  106763. private _leftController;
  106764. private _rightController;
  106765. /**
  106766. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106767. */
  106768. onNewMeshSelected: Observable<AbstractMesh>;
  106769. /**
  106770. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106771. * This observable will provide the mesh and the controller used to select the mesh
  106772. */
  106773. onMeshSelectedWithController: Observable<{
  106774. mesh: AbstractMesh;
  106775. controller: WebVRController;
  106776. }>;
  106777. /**
  106778. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106779. */
  106780. onNewMeshPicked: Observable<PickingInfo>;
  106781. private _circleEase;
  106782. /**
  106783. * Observable raised before camera teleportation
  106784. */
  106785. onBeforeCameraTeleport: Observable<Vector3>;
  106786. /**
  106787. * Observable raised after camera teleportation
  106788. */
  106789. onAfterCameraTeleport: Observable<Vector3>;
  106790. /**
  106791. * Observable raised when current selected mesh gets unselected
  106792. */
  106793. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106794. private _raySelectionPredicate;
  106795. /**
  106796. * To be optionaly changed by user to define custom ray selection
  106797. */
  106798. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106799. /**
  106800. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106801. */
  106802. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106803. /**
  106804. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106805. */
  106806. teleportationEnabled: boolean;
  106807. private _defaultHeight;
  106808. private _teleportationInitialized;
  106809. private _interactionsEnabled;
  106810. private _interactionsRequested;
  106811. private _displayGaze;
  106812. private _displayLaserPointer;
  106813. /**
  106814. * The mesh used to display where the user is going to teleport.
  106815. */
  106816. /**
  106817. * Sets the mesh to be used to display where the user is going to teleport.
  106818. */
  106819. teleportationTarget: Mesh;
  106820. /**
  106821. * 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
  106822. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106823. * See http://doc.babylonjs.com/resources/baking_transformations
  106824. */
  106825. gazeTrackerMesh: Mesh;
  106826. /**
  106827. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106828. */
  106829. updateGazeTrackerScale: boolean;
  106830. /**
  106831. * If the gaze trackers color should be updated when selecting meshes
  106832. */
  106833. updateGazeTrackerColor: boolean;
  106834. /**
  106835. * If the controller laser color should be updated when selecting meshes
  106836. */
  106837. updateControllerLaserColor: boolean;
  106838. /**
  106839. * The gaze tracking mesh corresponding to the left controller
  106840. */
  106841. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106842. /**
  106843. * The gaze tracking mesh corresponding to the right controller
  106844. */
  106845. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106846. /**
  106847. * If the ray of the gaze should be displayed.
  106848. */
  106849. /**
  106850. * Sets if the ray of the gaze should be displayed.
  106851. */
  106852. displayGaze: boolean;
  106853. /**
  106854. * If the ray of the LaserPointer should be displayed.
  106855. */
  106856. /**
  106857. * Sets if the ray of the LaserPointer should be displayed.
  106858. */
  106859. displayLaserPointer: boolean;
  106860. /**
  106861. * The deviceOrientationCamera used as the camera when not in VR.
  106862. */
  106863. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106864. /**
  106865. * Based on the current WebVR support, returns the current VR camera used.
  106866. */
  106867. readonly currentVRCamera: Nullable<Camera>;
  106868. /**
  106869. * The webVRCamera which is used when in VR.
  106870. */
  106871. readonly webVRCamera: WebVRFreeCamera;
  106872. /**
  106873. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106874. */
  106875. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106876. /**
  106877. * The html button that is used to trigger entering into VR.
  106878. */
  106879. readonly vrButton: Nullable<HTMLButtonElement>;
  106880. private readonly _teleportationRequestInitiated;
  106881. /**
  106882. * Defines wether or not Pointer lock should be requested when switching to
  106883. * full screen.
  106884. */
  106885. requestPointerLockOnFullScreen: boolean;
  106886. /**
  106887. * Instantiates a VRExperienceHelper.
  106888. * Helps to quickly add VR support to an existing scene.
  106889. * @param scene The scene the VRExperienceHelper belongs to.
  106890. * @param webVROptions Options to modify the vr experience helper's behavior.
  106891. */
  106892. constructor(scene: Scene,
  106893. /** Options to modify the vr experience helper's behavior. */
  106894. webVROptions?: VRExperienceHelperOptions);
  106895. private _onDefaultMeshLoaded;
  106896. private _onResize;
  106897. private _onFullscreenChange;
  106898. /**
  106899. * Gets a value indicating if we are currently in VR mode.
  106900. */
  106901. readonly isInVRMode: boolean;
  106902. private onVrDisplayPresentChange;
  106903. private onVRDisplayChanged;
  106904. private moveButtonToBottomRight;
  106905. private displayVRButton;
  106906. private updateButtonVisibility;
  106907. private _cachedAngularSensibility;
  106908. /**
  106909. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  106910. * Otherwise, will use the fullscreen API.
  106911. */
  106912. enterVR(): void;
  106913. /**
  106914. * Attempt to exit VR, or fullscreen.
  106915. */
  106916. exitVR(): void;
  106917. /**
  106918. * The position of the vr experience helper.
  106919. */
  106920. /**
  106921. * Sets the position of the vr experience helper.
  106922. */
  106923. position: Vector3;
  106924. /**
  106925. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  106926. */
  106927. enableInteractions(): void;
  106928. private readonly _noControllerIsActive;
  106929. private beforeRender;
  106930. private _isTeleportationFloor;
  106931. /**
  106932. * Adds a floor mesh to be used for teleportation.
  106933. * @param floorMesh the mesh to be used for teleportation.
  106934. */
  106935. addFloorMesh(floorMesh: Mesh): void;
  106936. /**
  106937. * Removes a floor mesh from being used for teleportation.
  106938. * @param floorMesh the mesh to be removed.
  106939. */
  106940. removeFloorMesh(floorMesh: Mesh): void;
  106941. /**
  106942. * Enables interactions and teleportation using the VR controllers and gaze.
  106943. * @param vrTeleportationOptions options to modify teleportation behavior.
  106944. */
  106945. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106946. private _onNewGamepadConnected;
  106947. private _tryEnableInteractionOnController;
  106948. private _onNewGamepadDisconnected;
  106949. private _enableInteractionOnController;
  106950. private _checkTeleportWithRay;
  106951. private _checkRotate;
  106952. private _checkTeleportBackwards;
  106953. private _enableTeleportationOnController;
  106954. private _createTeleportationCircles;
  106955. private _displayTeleportationTarget;
  106956. private _hideTeleportationTarget;
  106957. private _rotateCamera;
  106958. private _moveTeleportationSelectorTo;
  106959. private _workingVector;
  106960. private _workingQuaternion;
  106961. private _workingMatrix;
  106962. /**
  106963. * Teleports the users feet to the desired location
  106964. * @param location The location where the user's feet should be placed
  106965. */
  106966. teleportCamera(location: Vector3): void;
  106967. private _convertNormalToDirectionOfRay;
  106968. private _castRayAndSelectObject;
  106969. private _notifySelectedMeshUnselected;
  106970. /**
  106971. * Sets the color of the laser ray from the vr controllers.
  106972. * @param color new color for the ray.
  106973. */
  106974. changeLaserColor(color: Color3): void;
  106975. /**
  106976. * Sets the color of the ray from the vr headsets gaze.
  106977. * @param color new color for the ray.
  106978. */
  106979. changeGazeColor(color: Color3): void;
  106980. /**
  106981. * Exits VR and disposes of the vr experience helper
  106982. */
  106983. dispose(): void;
  106984. /**
  106985. * Gets the name of the VRExperienceHelper class
  106986. * @returns "VRExperienceHelper"
  106987. */
  106988. getClassName(): string;
  106989. }
  106990. }
  106991. declare module BABYLON {
  106992. /**
  106993. * Manages an XRSession to work with Babylon's engine
  106994. * @see https://doc.babylonjs.com/how_to/webxr
  106995. */
  106996. export class WebXRSessionManager implements IDisposable {
  106997. private scene;
  106998. /**
  106999. * Fires every time a new xrFrame arrives which can be used to update the camera
  107000. */
  107001. onXRFrameObservable: Observable<any>;
  107002. /**
  107003. * Fires when the xr session is ended either by the device or manually done
  107004. */
  107005. onXRSessionEnded: Observable<any>;
  107006. /**
  107007. * Underlying xr session
  107008. */
  107009. session: XRSession;
  107010. /**
  107011. * Type of reference space used when creating the session
  107012. */
  107013. referenceSpace: XRReferenceSpace;
  107014. /** @hidden */
  107015. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107016. /**
  107017. * Current XR frame
  107018. */
  107019. currentFrame: Nullable<XRFrame>;
  107020. private _xrNavigator;
  107021. private baseLayer;
  107022. /**
  107023. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107024. * @param scene The scene which the session should be created for
  107025. */
  107026. constructor(scene: Scene);
  107027. /**
  107028. * Initializes the manager
  107029. * After initialization enterXR can be called to start an XR session
  107030. * @returns Promise which resolves after it is initialized
  107031. */
  107032. initializeAsync(): Promise<void>;
  107033. /**
  107034. * Initializes an xr session
  107035. * @param xrSessionMode mode to initialize
  107036. * @returns a promise which will resolve once the session has been initialized
  107037. */
  107038. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107039. /**
  107040. * Sets the reference space on the xr session
  107041. * @param referenceSpace space to set
  107042. * @returns a promise that will resolve once the reference space has been set
  107043. */
  107044. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107045. /**
  107046. * Updates the render state of the session
  107047. * @param state state to set
  107048. * @returns a promise that resolves once the render state has been updated
  107049. */
  107050. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107051. /**
  107052. * Starts rendering to the xr layer
  107053. * @returns a promise that will resolve once rendering has started
  107054. */
  107055. startRenderingToXRAsync(): Promise<void>;
  107056. /**
  107057. * Stops the xrSession and restores the renderloop
  107058. * @returns Promise which resolves after it exits XR
  107059. */
  107060. exitXRAsync(): Promise<unknown>;
  107061. /**
  107062. * Checks if a session would be supported for the creation options specified
  107063. * @param sessionMode session mode to check if supported eg. immersive-vr
  107064. * @returns true if supported
  107065. */
  107066. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107067. /**
  107068. * @hidden
  107069. * Converts the render layer of xrSession to a render target
  107070. * @param session session to create render target for
  107071. * @param scene scene the new render target should be created for
  107072. */
  107073. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107074. /**
  107075. * Disposes of the session manager
  107076. */
  107077. dispose(): void;
  107078. }
  107079. }
  107080. declare module BABYLON {
  107081. /**
  107082. * WebXR Camera which holds the views for the xrSession
  107083. * @see https://doc.babylonjs.com/how_to/webxr
  107084. */
  107085. export class WebXRCamera extends FreeCamera {
  107086. private static _TmpMatrix;
  107087. /**
  107088. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107089. * @param name the name of the camera
  107090. * @param scene the scene to add the camera to
  107091. */
  107092. constructor(name: string, scene: Scene);
  107093. private _updateNumberOfRigCameras;
  107094. /** @hidden */
  107095. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107096. /**
  107097. * Updates the cameras position from the current pose information of the XR session
  107098. * @param xrSessionManager the session containing pose information
  107099. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107100. */
  107101. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107102. }
  107103. }
  107104. declare module BABYLON {
  107105. /**
  107106. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107107. */
  107108. export class WebXRManagedOutputCanvas implements IDisposable {
  107109. private helper;
  107110. private _canvas;
  107111. /**
  107112. * xrpresent context of the canvas which can be used to display/mirror xr content
  107113. */
  107114. canvasContext: WebGLRenderingContext;
  107115. /**
  107116. * xr layer for the canvas
  107117. */
  107118. xrLayer: Nullable<XRWebGLLayer>;
  107119. /**
  107120. * Initializes the xr layer for the session
  107121. * @param xrSession xr session
  107122. * @returns a promise that will resolve once the XR Layer has been created
  107123. */
  107124. initializeXRLayerAsync(xrSession: any): any;
  107125. /**
  107126. * Initializes the canvas to be added/removed upon entering/exiting xr
  107127. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107128. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107129. */
  107130. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107131. /**
  107132. * Disposes of the object
  107133. */
  107134. dispose(): void;
  107135. private _setManagedOutputCanvas;
  107136. private _addCanvas;
  107137. private _removeCanvas;
  107138. }
  107139. }
  107140. declare module BABYLON {
  107141. /**
  107142. * States of the webXR experience
  107143. */
  107144. export enum WebXRState {
  107145. /**
  107146. * Transitioning to being in XR mode
  107147. */
  107148. ENTERING_XR = 0,
  107149. /**
  107150. * Transitioning to non XR mode
  107151. */
  107152. EXITING_XR = 1,
  107153. /**
  107154. * In XR mode and presenting
  107155. */
  107156. IN_XR = 2,
  107157. /**
  107158. * Not entered XR mode
  107159. */
  107160. NOT_IN_XR = 3
  107161. }
  107162. /**
  107163. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107164. * @see https://doc.babylonjs.com/how_to/webxr
  107165. */
  107166. export class WebXRExperienceHelper implements IDisposable {
  107167. private scene;
  107168. /**
  107169. * 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
  107170. */
  107171. container: AbstractMesh;
  107172. /**
  107173. * Camera used to render xr content
  107174. */
  107175. camera: WebXRCamera;
  107176. /**
  107177. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107178. */
  107179. state: WebXRState;
  107180. private _setState;
  107181. private static _TmpVector;
  107182. /**
  107183. * Fires when the state of the experience helper has changed
  107184. */
  107185. onStateChangedObservable: Observable<WebXRState>;
  107186. /** Session manager used to keep track of xr session */
  107187. sessionManager: WebXRSessionManager;
  107188. private _nonVRCamera;
  107189. private _originalSceneAutoClear;
  107190. private _supported;
  107191. /**
  107192. * Creates the experience helper
  107193. * @param scene the scene to attach the experience helper to
  107194. * @returns a promise for the experience helper
  107195. */
  107196. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107197. /**
  107198. * Creates a WebXRExperienceHelper
  107199. * @param scene The scene the helper should be created in
  107200. */
  107201. private constructor();
  107202. /**
  107203. * Exits XR mode and returns the scene to its original state
  107204. * @returns promise that resolves after xr mode has exited
  107205. */
  107206. exitXRAsync(): Promise<unknown>;
  107207. /**
  107208. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107209. * @param sessionCreationOptions options for the XR session
  107210. * @param referenceSpaceType frame of reference of the XR session
  107211. * @param outputCanvas the output canvas that will be used to enter XR mode
  107212. * @returns promise that resolves after xr mode has entered
  107213. */
  107214. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107215. /**
  107216. * Updates the global position of the camera by moving the camera's container
  107217. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107218. * @param position The desired global position of the camera
  107219. */
  107220. setPositionOfCameraUsingContainer(position: Vector3): void;
  107221. /**
  107222. * Rotates the xr camera by rotating the camera's container around the camera's position
  107223. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107224. * @param rotation the desired quaternion rotation to apply to the camera
  107225. */
  107226. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107227. /**
  107228. * Disposes of the experience helper
  107229. */
  107230. dispose(): void;
  107231. }
  107232. }
  107233. declare module BABYLON {
  107234. /**
  107235. * Button which can be used to enter a different mode of XR
  107236. */
  107237. export class WebXREnterExitUIButton {
  107238. /** button element */
  107239. element: HTMLElement;
  107240. /** XR initialization options for the button */
  107241. sessionMode: XRSessionMode;
  107242. /** Reference space type */
  107243. referenceSpaceType: XRReferenceSpaceType;
  107244. /**
  107245. * Creates a WebXREnterExitUIButton
  107246. * @param element button element
  107247. * @param sessionMode XR initialization session mode
  107248. * @param referenceSpaceType the type of reference space to be used
  107249. */
  107250. constructor(
  107251. /** button element */
  107252. element: HTMLElement,
  107253. /** XR initialization options for the button */
  107254. sessionMode: XRSessionMode,
  107255. /** Reference space type */
  107256. referenceSpaceType: XRReferenceSpaceType);
  107257. /**
  107258. * Overwritable function which can be used to update the button's visuals when the state changes
  107259. * @param activeButton the current active button in the UI
  107260. */
  107261. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  107262. }
  107263. /**
  107264. * Options to create the webXR UI
  107265. */
  107266. export class WebXREnterExitUIOptions {
  107267. /**
  107268. * Context to enter xr with
  107269. */
  107270. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  107271. /**
  107272. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  107273. */
  107274. customButtons?: Array<WebXREnterExitUIButton>;
  107275. }
  107276. /**
  107277. * UI to allow the user to enter/exit XR mode
  107278. */
  107279. export class WebXREnterExitUI implements IDisposable {
  107280. private scene;
  107281. private _overlay;
  107282. private _buttons;
  107283. private _activeButton;
  107284. /**
  107285. * Fired every time the active button is changed.
  107286. *
  107287. * When xr is entered via a button that launches xr that button will be the callback parameter
  107288. *
  107289. * When exiting xr the callback parameter will be null)
  107290. */
  107291. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  107292. /**
  107293. * Creates UI to allow the user to enter/exit XR mode
  107294. * @param scene the scene to add the ui to
  107295. * @param helper the xr experience helper to enter/exit xr with
  107296. * @param options options to configure the UI
  107297. * @returns the created ui
  107298. */
  107299. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  107300. private constructor();
  107301. private _updateButtons;
  107302. /**
  107303. * Disposes of the object
  107304. */
  107305. dispose(): void;
  107306. }
  107307. }
  107308. declare module BABYLON {
  107309. /**
  107310. * Represents an XR input
  107311. */
  107312. export class WebXRController {
  107313. private scene;
  107314. /** The underlying input source for the controller */
  107315. inputSource: XRInputSource;
  107316. private parentContainer;
  107317. /**
  107318. * 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
  107319. */
  107320. grip?: AbstractMesh;
  107321. /**
  107322. * Pointer which can be used to select objects or attach a visible laser to
  107323. */
  107324. pointer: AbstractMesh;
  107325. /**
  107326. * Event that fires when the controller is removed/disposed
  107327. */
  107328. onDisposeObservable: Observable<{}>;
  107329. private _tmpMatrix;
  107330. private _tmpQuaternion;
  107331. private _tmpVector;
  107332. /**
  107333. * Creates the controller
  107334. * @see https://doc.babylonjs.com/how_to/webxr
  107335. * @param scene the scene which the controller should be associated to
  107336. * @param inputSource the underlying input source for the controller
  107337. * @param parentContainer parent that the controller meshes should be children of
  107338. */
  107339. constructor(scene: Scene,
  107340. /** The underlying input source for the controller */
  107341. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107342. /**
  107343. * Updates the controller pose based on the given XRFrame
  107344. * @param xrFrame xr frame to update the pose with
  107345. * @param referenceSpace reference space to use
  107346. */
  107347. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107348. /**
  107349. * Gets a world space ray coming from the controller
  107350. * @param result the resulting ray
  107351. */
  107352. getWorldPointerRayToRef(result: Ray): void;
  107353. /**
  107354. * Disposes of the object
  107355. */
  107356. dispose(): void;
  107357. }
  107358. }
  107359. declare module BABYLON {
  107360. /**
  107361. * XR input used to track XR inputs such as controllers/rays
  107362. */
  107363. export class WebXRInput implements IDisposable {
  107364. /**
  107365. * Base experience the input listens to
  107366. */
  107367. baseExperience: WebXRExperienceHelper;
  107368. /**
  107369. * XR controllers being tracked
  107370. */
  107371. controllers: Array<WebXRController>;
  107372. private _frameObserver;
  107373. private _stateObserver;
  107374. /**
  107375. * Event when a controller has been connected/added
  107376. */
  107377. onControllerAddedObservable: Observable<WebXRController>;
  107378. /**
  107379. * Event when a controller has been removed/disconnected
  107380. */
  107381. onControllerRemovedObservable: Observable<WebXRController>;
  107382. /**
  107383. * Initializes the WebXRInput
  107384. * @param baseExperience experience helper which the input should be created for
  107385. */
  107386. constructor(
  107387. /**
  107388. * Base experience the input listens to
  107389. */
  107390. baseExperience: WebXRExperienceHelper);
  107391. private _onInputSourcesChange;
  107392. private _addAndRemoveControllers;
  107393. /**
  107394. * Disposes of the object
  107395. */
  107396. dispose(): void;
  107397. }
  107398. }
  107399. declare module BABYLON {
  107400. /**
  107401. * Enables teleportation
  107402. */
  107403. export class WebXRControllerTeleportation {
  107404. private _teleportationFillColor;
  107405. private _teleportationBorderColor;
  107406. private _tmpRay;
  107407. private _tmpVector;
  107408. /**
  107409. * Creates a WebXRControllerTeleportation
  107410. * @param input input manager to add teleportation to
  107411. * @param floorMeshes floormeshes which can be teleported to
  107412. */
  107413. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107414. }
  107415. }
  107416. declare module BABYLON {
  107417. /**
  107418. * Handles pointer input automatically for the pointer of XR controllers
  107419. */
  107420. export class WebXRControllerPointerSelection {
  107421. private static _idCounter;
  107422. private _tmpRay;
  107423. /**
  107424. * Creates a WebXRControllerPointerSelection
  107425. * @param input input manager to setup pointer selection
  107426. */
  107427. constructor(input: WebXRInput);
  107428. private _convertNormalToDirectionOfRay;
  107429. private _updatePointerDistance;
  107430. }
  107431. }
  107432. declare module BABYLON {
  107433. /**
  107434. * Class used to represent data loading progression
  107435. */
  107436. export class SceneLoaderProgressEvent {
  107437. /** defines if data length to load can be evaluated */
  107438. readonly lengthComputable: boolean;
  107439. /** defines the loaded data length */
  107440. readonly loaded: number;
  107441. /** defines the data length to load */
  107442. readonly total: number;
  107443. /**
  107444. * Create a new progress event
  107445. * @param lengthComputable defines if data length to load can be evaluated
  107446. * @param loaded defines the loaded data length
  107447. * @param total defines the data length to load
  107448. */
  107449. constructor(
  107450. /** defines if data length to load can be evaluated */
  107451. lengthComputable: boolean,
  107452. /** defines the loaded data length */
  107453. loaded: number,
  107454. /** defines the data length to load */
  107455. total: number);
  107456. /**
  107457. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107458. * @param event defines the source event
  107459. * @returns a new SceneLoaderProgressEvent
  107460. */
  107461. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107462. }
  107463. /**
  107464. * Interface used by SceneLoader plugins to define supported file extensions
  107465. */
  107466. export interface ISceneLoaderPluginExtensions {
  107467. /**
  107468. * Defines the list of supported extensions
  107469. */
  107470. [extension: string]: {
  107471. isBinary: boolean;
  107472. };
  107473. }
  107474. /**
  107475. * Interface used by SceneLoader plugin factory
  107476. */
  107477. export interface ISceneLoaderPluginFactory {
  107478. /**
  107479. * Defines the name of the factory
  107480. */
  107481. name: string;
  107482. /**
  107483. * Function called to create a new plugin
  107484. * @return the new plugin
  107485. */
  107486. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107487. /**
  107488. * Boolean indicating if the plugin can direct load specific data
  107489. */
  107490. canDirectLoad?: (data: string) => boolean;
  107491. }
  107492. /**
  107493. * Interface used to define a SceneLoader plugin
  107494. */
  107495. export interface ISceneLoaderPlugin {
  107496. /**
  107497. * The friendly name of this plugin.
  107498. */
  107499. name: string;
  107500. /**
  107501. * The file extensions supported by this plugin.
  107502. */
  107503. extensions: string | ISceneLoaderPluginExtensions;
  107504. /**
  107505. * Import meshes into a scene.
  107506. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107507. * @param scene The scene to import into
  107508. * @param data The data to import
  107509. * @param rootUrl The root url for scene and resources
  107510. * @param meshes The meshes array to import into
  107511. * @param particleSystems The particle systems array to import into
  107512. * @param skeletons The skeletons array to import into
  107513. * @param onError The callback when import fails
  107514. * @returns True if successful or false otherwise
  107515. */
  107516. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107517. /**
  107518. * Load into a scene.
  107519. * @param scene The scene to load into
  107520. * @param data The data to import
  107521. * @param rootUrl The root url for scene and resources
  107522. * @param onError The callback when import fails
  107523. * @returns true if successful or false otherwise
  107524. */
  107525. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107526. /**
  107527. * The callback that returns true if the data can be directly loaded.
  107528. */
  107529. canDirectLoad?: (data: string) => boolean;
  107530. /**
  107531. * The callback that allows custom handling of the root url based on the response url.
  107532. */
  107533. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107534. /**
  107535. * Load into an asset container.
  107536. * @param scene The scene to load into
  107537. * @param data The data to import
  107538. * @param rootUrl The root url for scene and resources
  107539. * @param onError The callback when import fails
  107540. * @returns The loaded asset container
  107541. */
  107542. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107543. }
  107544. /**
  107545. * Interface used to define an async SceneLoader plugin
  107546. */
  107547. export interface ISceneLoaderPluginAsync {
  107548. /**
  107549. * The friendly name of this plugin.
  107550. */
  107551. name: string;
  107552. /**
  107553. * The file extensions supported by this plugin.
  107554. */
  107555. extensions: string | ISceneLoaderPluginExtensions;
  107556. /**
  107557. * Import meshes into a scene.
  107558. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107559. * @param scene The scene to import into
  107560. * @param data The data to import
  107561. * @param rootUrl The root url for scene and resources
  107562. * @param onProgress The callback when the load progresses
  107563. * @param fileName Defines the name of the file to load
  107564. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107565. */
  107566. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107567. meshes: AbstractMesh[];
  107568. particleSystems: IParticleSystem[];
  107569. skeletons: Skeleton[];
  107570. animationGroups: AnimationGroup[];
  107571. }>;
  107572. /**
  107573. * Load into a scene.
  107574. * @param scene The scene to load into
  107575. * @param data The data to import
  107576. * @param rootUrl The root url for scene and resources
  107577. * @param onProgress The callback when the load progresses
  107578. * @param fileName Defines the name of the file to load
  107579. * @returns Nothing
  107580. */
  107581. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107582. /**
  107583. * The callback that returns true if the data can be directly loaded.
  107584. */
  107585. canDirectLoad?: (data: string) => boolean;
  107586. /**
  107587. * The callback that allows custom handling of the root url based on the response url.
  107588. */
  107589. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107590. /**
  107591. * Load into an asset container.
  107592. * @param scene The scene to load into
  107593. * @param data The data to import
  107594. * @param rootUrl The root url for scene and resources
  107595. * @param onProgress The callback when the load progresses
  107596. * @param fileName Defines the name of the file to load
  107597. * @returns The loaded asset container
  107598. */
  107599. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107600. }
  107601. /**
  107602. * Class used to load scene from various file formats using registered plugins
  107603. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107604. */
  107605. export class SceneLoader {
  107606. /**
  107607. * No logging while loading
  107608. */
  107609. static readonly NO_LOGGING: number;
  107610. /**
  107611. * Minimal logging while loading
  107612. */
  107613. static readonly MINIMAL_LOGGING: number;
  107614. /**
  107615. * Summary logging while loading
  107616. */
  107617. static readonly SUMMARY_LOGGING: number;
  107618. /**
  107619. * Detailled logging while loading
  107620. */
  107621. static readonly DETAILED_LOGGING: number;
  107622. /**
  107623. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107624. */
  107625. static ForceFullSceneLoadingForIncremental: boolean;
  107626. /**
  107627. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107628. */
  107629. static ShowLoadingScreen: boolean;
  107630. /**
  107631. * Defines the current logging level (while loading the scene)
  107632. * @ignorenaming
  107633. */
  107634. static loggingLevel: number;
  107635. /**
  107636. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107637. */
  107638. static CleanBoneMatrixWeights: boolean;
  107639. /**
  107640. * Event raised when a plugin is used to load a scene
  107641. */
  107642. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107643. private static _registeredPlugins;
  107644. private static _getDefaultPlugin;
  107645. private static _getPluginForExtension;
  107646. private static _getPluginForDirectLoad;
  107647. private static _getPluginForFilename;
  107648. private static _getDirectLoad;
  107649. private static _loadData;
  107650. private static _getFileInfo;
  107651. /**
  107652. * Gets a plugin that can load the given extension
  107653. * @param extension defines the extension to load
  107654. * @returns a plugin or null if none works
  107655. */
  107656. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107657. /**
  107658. * Gets a boolean indicating that the given extension can be loaded
  107659. * @param extension defines the extension to load
  107660. * @returns true if the extension is supported
  107661. */
  107662. static IsPluginForExtensionAvailable(extension: string): boolean;
  107663. /**
  107664. * Adds a new plugin to the list of registered plugins
  107665. * @param plugin defines the plugin to add
  107666. */
  107667. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107668. /**
  107669. * Import meshes into a scene
  107670. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107671. * @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)
  107672. * @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)
  107673. * @param scene the instance of BABYLON.Scene to append to
  107674. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107675. * @param onProgress a callback with a progress event for each file being loaded
  107676. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107677. * @param pluginExtension the extension used to determine the plugin
  107678. * @returns The loaded plugin
  107679. */
  107680. 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>;
  107681. /**
  107682. * Import meshes into a scene
  107683. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107684. * @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)
  107685. * @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)
  107686. * @param scene the instance of BABYLON.Scene to append to
  107687. * @param onProgress a callback with a progress event for each file being loaded
  107688. * @param pluginExtension the extension used to determine the plugin
  107689. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107690. */
  107691. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107692. meshes: AbstractMesh[];
  107693. particleSystems: IParticleSystem[];
  107694. skeletons: Skeleton[];
  107695. animationGroups: AnimationGroup[];
  107696. }>;
  107697. /**
  107698. * Load a scene
  107699. * @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)
  107700. * @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)
  107701. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107702. * @param onSuccess a callback with the scene when import succeeds
  107703. * @param onProgress a callback with a progress event for each file being loaded
  107704. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107705. * @param pluginExtension the extension used to determine the plugin
  107706. * @returns The loaded plugin
  107707. */
  107708. 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>;
  107709. /**
  107710. * Load a scene
  107711. * @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)
  107712. * @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)
  107713. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107714. * @param onProgress a callback with a progress event for each file being loaded
  107715. * @param pluginExtension the extension used to determine the plugin
  107716. * @returns The loaded scene
  107717. */
  107718. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107719. /**
  107720. * Append a scene
  107721. * @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)
  107722. * @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)
  107723. * @param scene is the instance of BABYLON.Scene to append to
  107724. * @param onSuccess a callback with the scene when import succeeds
  107725. * @param onProgress a callback with a progress event for each file being loaded
  107726. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107727. * @param pluginExtension the extension used to determine the plugin
  107728. * @returns The loaded plugin
  107729. */
  107730. 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>;
  107731. /**
  107732. * Append a scene
  107733. * @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)
  107734. * @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)
  107735. * @param scene is the instance of BABYLON.Scene to append to
  107736. * @param onProgress a callback with a progress event for each file being loaded
  107737. * @param pluginExtension the extension used to determine the plugin
  107738. * @returns The given scene
  107739. */
  107740. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107741. /**
  107742. * Load a scene into an asset container
  107743. * @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)
  107744. * @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)
  107745. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107746. * @param onSuccess a callback with the scene when import succeeds
  107747. * @param onProgress a callback with a progress event for each file being loaded
  107748. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107749. * @param pluginExtension the extension used to determine the plugin
  107750. * @returns The loaded plugin
  107751. */
  107752. 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>;
  107753. /**
  107754. * Load a scene into an asset container
  107755. * @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)
  107756. * @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)
  107757. * @param scene is the instance of Scene to append to
  107758. * @param onProgress a callback with a progress event for each file being loaded
  107759. * @param pluginExtension the extension used to determine the plugin
  107760. * @returns The loaded asset container
  107761. */
  107762. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107763. }
  107764. }
  107765. declare module BABYLON {
  107766. /**
  107767. * Generic Controller
  107768. */
  107769. export class GenericController extends WebVRController {
  107770. /**
  107771. * Base Url for the controller model.
  107772. */
  107773. static readonly MODEL_BASE_URL: string;
  107774. /**
  107775. * File name for the controller model.
  107776. */
  107777. static readonly MODEL_FILENAME: string;
  107778. /**
  107779. * Creates a new GenericController from a gamepad
  107780. * @param vrGamepad the gamepad that the controller should be created from
  107781. */
  107782. constructor(vrGamepad: any);
  107783. /**
  107784. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107785. * @param scene scene in which to add meshes
  107786. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107787. */
  107788. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107789. /**
  107790. * Called once for each button that changed state since the last frame
  107791. * @param buttonIdx Which button index changed
  107792. * @param state New state of the button
  107793. * @param changes Which properties on the state changed since last frame
  107794. */
  107795. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107796. }
  107797. }
  107798. declare module BABYLON {
  107799. /**
  107800. * Defines the WindowsMotionController object that the state of the windows motion controller
  107801. */
  107802. export class WindowsMotionController extends WebVRController {
  107803. /**
  107804. * The base url used to load the left and right controller models
  107805. */
  107806. static MODEL_BASE_URL: string;
  107807. /**
  107808. * The name of the left controller model file
  107809. */
  107810. static MODEL_LEFT_FILENAME: string;
  107811. /**
  107812. * The name of the right controller model file
  107813. */
  107814. static MODEL_RIGHT_FILENAME: string;
  107815. /**
  107816. * The controller name prefix for this controller type
  107817. */
  107818. static readonly GAMEPAD_ID_PREFIX: string;
  107819. /**
  107820. * The controller id pattern for this controller type
  107821. */
  107822. private static readonly GAMEPAD_ID_PATTERN;
  107823. private _loadedMeshInfo;
  107824. private readonly _mapping;
  107825. /**
  107826. * Fired when the trackpad on this controller is clicked
  107827. */
  107828. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107829. /**
  107830. * Fired when the trackpad on this controller is modified
  107831. */
  107832. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107833. /**
  107834. * The current x and y values of this controller's trackpad
  107835. */
  107836. trackpad: StickValues;
  107837. /**
  107838. * Creates a new WindowsMotionController from a gamepad
  107839. * @param vrGamepad the gamepad that the controller should be created from
  107840. */
  107841. constructor(vrGamepad: any);
  107842. /**
  107843. * Fired when the trigger on this controller is modified
  107844. */
  107845. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107846. /**
  107847. * Fired when the menu button on this controller is modified
  107848. */
  107849. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107850. /**
  107851. * Fired when the grip button on this controller is modified
  107852. */
  107853. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107854. /**
  107855. * Fired when the thumbstick button on this controller is modified
  107856. */
  107857. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107858. /**
  107859. * Fired when the touchpad button on this controller is modified
  107860. */
  107861. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107862. /**
  107863. * Fired when the touchpad values on this controller are modified
  107864. */
  107865. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107866. private _updateTrackpad;
  107867. /**
  107868. * Called once per frame by the engine.
  107869. */
  107870. update(): void;
  107871. /**
  107872. * Called once for each button that changed state since the last frame
  107873. * @param buttonIdx Which button index changed
  107874. * @param state New state of the button
  107875. * @param changes Which properties on the state changed since last frame
  107876. */
  107877. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107878. /**
  107879. * Moves the buttons on the controller mesh based on their current state
  107880. * @param buttonName the name of the button to move
  107881. * @param buttonValue the value of the button which determines the buttons new position
  107882. */
  107883. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  107884. /**
  107885. * Moves the axis on the controller mesh based on its current state
  107886. * @param axis the index of the axis
  107887. * @param axisValue the value of the axis which determines the meshes new position
  107888. * @hidden
  107889. */
  107890. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  107891. /**
  107892. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107893. * @param scene scene in which to add meshes
  107894. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107895. */
  107896. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  107897. /**
  107898. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  107899. * can be transformed by button presses and axes values, based on this._mapping.
  107900. *
  107901. * @param scene scene in which the meshes exist
  107902. * @param meshes list of meshes that make up the controller model to process
  107903. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  107904. */
  107905. private processModel;
  107906. private createMeshInfo;
  107907. /**
  107908. * Gets the ray of the controller in the direction the controller is pointing
  107909. * @param length the length the resulting ray should be
  107910. * @returns a ray in the direction the controller is pointing
  107911. */
  107912. getForwardRay(length?: number): Ray;
  107913. /**
  107914. * Disposes of the controller
  107915. */
  107916. dispose(): void;
  107917. }
  107918. }
  107919. declare module BABYLON {
  107920. /**
  107921. * Oculus Touch Controller
  107922. */
  107923. export class OculusTouchController extends WebVRController {
  107924. /**
  107925. * Base Url for the controller model.
  107926. */
  107927. static MODEL_BASE_URL: string;
  107928. /**
  107929. * File name for the left controller model.
  107930. */
  107931. static MODEL_LEFT_FILENAME: string;
  107932. /**
  107933. * File name for the right controller model.
  107934. */
  107935. static MODEL_RIGHT_FILENAME: string;
  107936. /**
  107937. * Base Url for the Quest controller model.
  107938. */
  107939. static QUEST_MODEL_BASE_URL: string;
  107940. /**
  107941. * @hidden
  107942. * If the controllers are running on a device that needs the updated Quest controller models
  107943. */
  107944. static _IsQuest: boolean;
  107945. /**
  107946. * Fired when the secondary trigger on this controller is modified
  107947. */
  107948. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107949. /**
  107950. * Fired when the thumb rest on this controller is modified
  107951. */
  107952. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107953. /**
  107954. * Creates a new OculusTouchController from a gamepad
  107955. * @param vrGamepad the gamepad that the controller should be created from
  107956. */
  107957. constructor(vrGamepad: any);
  107958. /**
  107959. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107960. * @param scene scene in which to add meshes
  107961. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107962. */
  107963. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107964. /**
  107965. * Fired when the A button on this controller is modified
  107966. */
  107967. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107968. /**
  107969. * Fired when the B button on this controller is modified
  107970. */
  107971. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107972. /**
  107973. * Fired when the X button on this controller is modified
  107974. */
  107975. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107976. /**
  107977. * Fired when the Y button on this controller is modified
  107978. */
  107979. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107980. /**
  107981. * Called once for each button that changed state since the last frame
  107982. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107983. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107984. * 2) secondary trigger (same)
  107985. * 3) A (right) X (left), touch, pressed = value
  107986. * 4) B / Y
  107987. * 5) thumb rest
  107988. * @param buttonIdx Which button index changed
  107989. * @param state New state of the button
  107990. * @param changes Which properties on the state changed since last frame
  107991. */
  107992. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107993. }
  107994. }
  107995. declare module BABYLON {
  107996. /**
  107997. * Vive Controller
  107998. */
  107999. export class ViveController extends WebVRController {
  108000. /**
  108001. * Base Url for the controller model.
  108002. */
  108003. static MODEL_BASE_URL: string;
  108004. /**
  108005. * File name for the controller model.
  108006. */
  108007. static MODEL_FILENAME: string;
  108008. /**
  108009. * Creates a new ViveController from a gamepad
  108010. * @param vrGamepad the gamepad that the controller should be created from
  108011. */
  108012. constructor(vrGamepad: any);
  108013. /**
  108014. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108015. * @param scene scene in which to add meshes
  108016. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108017. */
  108018. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108019. /**
  108020. * Fired when the left button on this controller is modified
  108021. */
  108022. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108023. /**
  108024. * Fired when the right button on this controller is modified
  108025. */
  108026. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108027. /**
  108028. * Fired when the menu button on this controller is modified
  108029. */
  108030. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108031. /**
  108032. * Called once for each button that changed state since the last frame
  108033. * Vive mapping:
  108034. * 0: touchpad
  108035. * 1: trigger
  108036. * 2: left AND right buttons
  108037. * 3: menu button
  108038. * @param buttonIdx Which button index changed
  108039. * @param state New state of the button
  108040. * @param changes Which properties on the state changed since last frame
  108041. */
  108042. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108043. }
  108044. }
  108045. declare module BABYLON {
  108046. /**
  108047. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108048. */
  108049. export class WebXRControllerModelLoader {
  108050. /**
  108051. * Creates the WebXRControllerModelLoader
  108052. * @param input xr input that creates the controllers
  108053. */
  108054. constructor(input: WebXRInput);
  108055. }
  108056. }
  108057. declare module BABYLON {
  108058. /**
  108059. * Contains an array of blocks representing the octree
  108060. */
  108061. export interface IOctreeContainer<T> {
  108062. /**
  108063. * Blocks within the octree
  108064. */
  108065. blocks: Array<OctreeBlock<T>>;
  108066. }
  108067. /**
  108068. * Class used to store a cell in an octree
  108069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108070. */
  108071. export class OctreeBlock<T> {
  108072. /**
  108073. * Gets the content of the current block
  108074. */
  108075. entries: T[];
  108076. /**
  108077. * Gets the list of block children
  108078. */
  108079. blocks: Array<OctreeBlock<T>>;
  108080. private _depth;
  108081. private _maxDepth;
  108082. private _capacity;
  108083. private _minPoint;
  108084. private _maxPoint;
  108085. private _boundingVectors;
  108086. private _creationFunc;
  108087. /**
  108088. * Creates a new block
  108089. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108090. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108091. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108092. * @param depth defines the current depth of this block in the octree
  108093. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108094. * @param creationFunc defines a callback to call when an element is added to the block
  108095. */
  108096. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108097. /**
  108098. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108099. */
  108100. readonly capacity: number;
  108101. /**
  108102. * Gets the minimum vector (in world space) of the block's bounding box
  108103. */
  108104. readonly minPoint: Vector3;
  108105. /**
  108106. * Gets the maximum vector (in world space) of the block's bounding box
  108107. */
  108108. readonly maxPoint: Vector3;
  108109. /**
  108110. * Add a new element to this block
  108111. * @param entry defines the element to add
  108112. */
  108113. addEntry(entry: T): void;
  108114. /**
  108115. * Remove an element from this block
  108116. * @param entry defines the element to remove
  108117. */
  108118. removeEntry(entry: T): void;
  108119. /**
  108120. * Add an array of elements to this block
  108121. * @param entries defines the array of elements to add
  108122. */
  108123. addEntries(entries: T[]): void;
  108124. /**
  108125. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108126. * @param frustumPlanes defines the frustum planes to test
  108127. * @param selection defines the array to store current content if selection is positive
  108128. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108129. */
  108130. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108131. /**
  108132. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108133. * @param sphereCenter defines the bounding sphere center
  108134. * @param sphereRadius defines the bounding sphere radius
  108135. * @param selection defines the array to store current content if selection is positive
  108136. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108137. */
  108138. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108139. /**
  108140. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108141. * @param ray defines the ray to test with
  108142. * @param selection defines the array to store current content if selection is positive
  108143. */
  108144. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108145. /**
  108146. * Subdivide the content into child blocks (this block will then be empty)
  108147. */
  108148. createInnerBlocks(): void;
  108149. /**
  108150. * @hidden
  108151. */
  108152. 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;
  108153. }
  108154. }
  108155. declare module BABYLON {
  108156. /**
  108157. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108158. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108159. */
  108160. export class Octree<T> {
  108161. /** 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.) */
  108162. maxDepth: number;
  108163. /**
  108164. * Blocks within the octree containing objects
  108165. */
  108166. blocks: Array<OctreeBlock<T>>;
  108167. /**
  108168. * Content stored in the octree
  108169. */
  108170. dynamicContent: T[];
  108171. private _maxBlockCapacity;
  108172. private _selectionContent;
  108173. private _creationFunc;
  108174. /**
  108175. * Creates a octree
  108176. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108177. * @param creationFunc function to be used to instatiate the octree
  108178. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108179. * @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.)
  108180. */
  108181. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108182. /** 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.) */
  108183. maxDepth?: number);
  108184. /**
  108185. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108186. * @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);
  108187. * @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);
  108188. * @param entries meshes to be added to the octree blocks
  108189. */
  108190. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108191. /**
  108192. * Adds a mesh to the octree
  108193. * @param entry Mesh to add to the octree
  108194. */
  108195. addMesh(entry: T): void;
  108196. /**
  108197. * Remove an element from the octree
  108198. * @param entry defines the element to remove
  108199. */
  108200. removeMesh(entry: T): void;
  108201. /**
  108202. * Selects an array of meshes within the frustum
  108203. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108204. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108205. * @returns array of meshes within the frustum
  108206. */
  108207. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108208. /**
  108209. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108210. * @param sphereCenter defines the bounding sphere center
  108211. * @param sphereRadius defines the bounding sphere radius
  108212. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108213. * @returns an array of objects that intersect the sphere
  108214. */
  108215. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108216. /**
  108217. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108218. * @param ray defines the ray to test with
  108219. * @returns array of intersected objects
  108220. */
  108221. intersectsRay(ray: Ray): SmartArray<T>;
  108222. /**
  108223. * Adds a mesh into the octree block if it intersects the block
  108224. */
  108225. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108226. /**
  108227. * Adds a submesh into the octree block if it intersects the block
  108228. */
  108229. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108230. }
  108231. }
  108232. declare module BABYLON {
  108233. interface Scene {
  108234. /**
  108235. * @hidden
  108236. * Backing Filed
  108237. */
  108238. _selectionOctree: Octree<AbstractMesh>;
  108239. /**
  108240. * Gets the octree used to boost mesh selection (picking)
  108241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108242. */
  108243. selectionOctree: Octree<AbstractMesh>;
  108244. /**
  108245. * Creates or updates the octree used to boost selection (picking)
  108246. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108247. * @param maxCapacity defines the maximum capacity per leaf
  108248. * @param maxDepth defines the maximum depth of the octree
  108249. * @returns an octree of AbstractMesh
  108250. */
  108251. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  108252. }
  108253. interface AbstractMesh {
  108254. /**
  108255. * @hidden
  108256. * Backing Field
  108257. */
  108258. _submeshesOctree: Octree<SubMesh>;
  108259. /**
  108260. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  108261. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  108262. * @param maxCapacity defines the maximum size of each block (64 by default)
  108263. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  108264. * @returns the new octree
  108265. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  108266. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108267. */
  108268. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  108269. }
  108270. /**
  108271. * Defines the octree scene component responsible to manage any octrees
  108272. * in a given scene.
  108273. */
  108274. export class OctreeSceneComponent {
  108275. /**
  108276. * The component name help to identify the component in the list of scene components.
  108277. */
  108278. readonly name: string;
  108279. /**
  108280. * The scene the component belongs to.
  108281. */
  108282. scene: Scene;
  108283. /**
  108284. * Indicates if the meshes have been checked to make sure they are isEnabled()
  108285. */
  108286. readonly checksIsEnabled: boolean;
  108287. /**
  108288. * Creates a new instance of the component for the given scene
  108289. * @param scene Defines the scene to register the component in
  108290. */
  108291. constructor(scene: Scene);
  108292. /**
  108293. * Registers the component in a given scene
  108294. */
  108295. register(): void;
  108296. /**
  108297. * Return the list of active meshes
  108298. * @returns the list of active meshes
  108299. */
  108300. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108301. /**
  108302. * Return the list of active sub meshes
  108303. * @param mesh The mesh to get the candidates sub meshes from
  108304. * @returns the list of active sub meshes
  108305. */
  108306. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108307. private _tempRay;
  108308. /**
  108309. * Return the list of sub meshes intersecting with a given local ray
  108310. * @param mesh defines the mesh to find the submesh for
  108311. * @param localRay defines the ray in local space
  108312. * @returns the list of intersecting sub meshes
  108313. */
  108314. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  108315. /**
  108316. * Return the list of sub meshes colliding with a collider
  108317. * @param mesh defines the mesh to find the submesh for
  108318. * @param collider defines the collider to evaluate the collision against
  108319. * @returns the list of colliding sub meshes
  108320. */
  108321. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  108322. /**
  108323. * Rebuilds the elements related to this component in case of
  108324. * context lost for instance.
  108325. */
  108326. rebuild(): void;
  108327. /**
  108328. * Disposes the component and the associated ressources.
  108329. */
  108330. dispose(): void;
  108331. }
  108332. }
  108333. declare module BABYLON {
  108334. /**
  108335. * Renders a layer on top of an existing scene
  108336. */
  108337. export class UtilityLayerRenderer implements IDisposable {
  108338. /** the original scene that will be rendered on top of */
  108339. originalScene: Scene;
  108340. private _pointerCaptures;
  108341. private _lastPointerEvents;
  108342. private static _DefaultUtilityLayer;
  108343. private static _DefaultKeepDepthUtilityLayer;
  108344. private _sharedGizmoLight;
  108345. private _renderCamera;
  108346. /**
  108347. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108348. * @returns the camera that is used when rendering the utility layer
  108349. */
  108350. getRenderCamera(): Nullable<Camera>;
  108351. /**
  108352. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108353. * @param cam the camera that should be used when rendering the utility layer
  108354. */
  108355. setRenderCamera(cam: Nullable<Camera>): void;
  108356. /**
  108357. * @hidden
  108358. * Light which used by gizmos to get light shading
  108359. */
  108360. _getSharedGizmoLight(): HemisphericLight;
  108361. /**
  108362. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108363. */
  108364. pickUtilitySceneFirst: boolean;
  108365. /**
  108366. * 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)
  108367. */
  108368. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108369. /**
  108370. * 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)
  108371. */
  108372. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108373. /**
  108374. * The scene that is rendered on top of the original scene
  108375. */
  108376. utilityLayerScene: Scene;
  108377. /**
  108378. * If the utility layer should automatically be rendered on top of existing scene
  108379. */
  108380. shouldRender: boolean;
  108381. /**
  108382. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108383. */
  108384. onlyCheckPointerDownEvents: boolean;
  108385. /**
  108386. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108387. */
  108388. processAllEvents: boolean;
  108389. /**
  108390. * Observable raised when the pointer move from the utility layer scene to the main scene
  108391. */
  108392. onPointerOutObservable: Observable<number>;
  108393. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108394. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108395. private _afterRenderObserver;
  108396. private _sceneDisposeObserver;
  108397. private _originalPointerObserver;
  108398. /**
  108399. * Instantiates a UtilityLayerRenderer
  108400. * @param originalScene the original scene that will be rendered on top of
  108401. * @param handleEvents boolean indicating if the utility layer should handle events
  108402. */
  108403. constructor(
  108404. /** the original scene that will be rendered on top of */
  108405. originalScene: Scene, handleEvents?: boolean);
  108406. private _notifyObservers;
  108407. /**
  108408. * Renders the utility layers scene on top of the original scene
  108409. */
  108410. render(): void;
  108411. /**
  108412. * Disposes of the renderer
  108413. */
  108414. dispose(): void;
  108415. private _updateCamera;
  108416. }
  108417. }
  108418. declare module BABYLON {
  108419. /**
  108420. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108421. */
  108422. export class Gizmo implements IDisposable {
  108423. /** The utility layer the gizmo will be added to */
  108424. gizmoLayer: UtilityLayerRenderer;
  108425. /**
  108426. * The root mesh of the gizmo
  108427. */
  108428. _rootMesh: Mesh;
  108429. private _attachedMesh;
  108430. /**
  108431. * Ratio for the scale of the gizmo (Default: 1)
  108432. */
  108433. scaleRatio: number;
  108434. /**
  108435. * If a custom mesh has been set (Default: false)
  108436. */
  108437. protected _customMeshSet: boolean;
  108438. /**
  108439. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108440. * * When set, interactions will be enabled
  108441. */
  108442. attachedMesh: Nullable<AbstractMesh>;
  108443. /**
  108444. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108445. * @param mesh The mesh to replace the default mesh of the gizmo
  108446. */
  108447. setCustomMesh(mesh: Mesh): void;
  108448. /**
  108449. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108450. */
  108451. updateGizmoRotationToMatchAttachedMesh: boolean;
  108452. /**
  108453. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108454. */
  108455. updateGizmoPositionToMatchAttachedMesh: boolean;
  108456. /**
  108457. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108458. */
  108459. updateScale: boolean;
  108460. protected _interactionsEnabled: boolean;
  108461. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108462. private _beforeRenderObserver;
  108463. private _tempVector;
  108464. /**
  108465. * Creates a gizmo
  108466. * @param gizmoLayer The utility layer the gizmo will be added to
  108467. */
  108468. constructor(
  108469. /** The utility layer the gizmo will be added to */
  108470. gizmoLayer?: UtilityLayerRenderer);
  108471. /**
  108472. * Updates the gizmo to match the attached mesh's position/rotation
  108473. */
  108474. protected _update(): void;
  108475. /**
  108476. * Disposes of the gizmo
  108477. */
  108478. dispose(): void;
  108479. }
  108480. }
  108481. declare module BABYLON {
  108482. /**
  108483. * Single plane drag gizmo
  108484. */
  108485. export class PlaneDragGizmo extends Gizmo {
  108486. /**
  108487. * Drag behavior responsible for the gizmos dragging interactions
  108488. */
  108489. dragBehavior: PointerDragBehavior;
  108490. private _pointerObserver;
  108491. /**
  108492. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108493. */
  108494. snapDistance: number;
  108495. /**
  108496. * Event that fires each time the gizmo snaps to a new location.
  108497. * * snapDistance is the the change in distance
  108498. */
  108499. onSnapObservable: Observable<{
  108500. snapDistance: number;
  108501. }>;
  108502. private _plane;
  108503. private _coloredMaterial;
  108504. private _hoverMaterial;
  108505. private _isEnabled;
  108506. private _parent;
  108507. /** @hidden */
  108508. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108509. /** @hidden */
  108510. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108511. /**
  108512. * Creates a PlaneDragGizmo
  108513. * @param gizmoLayer The utility layer the gizmo will be added to
  108514. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108515. * @param color The color of the gizmo
  108516. */
  108517. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108518. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108519. /**
  108520. * If the gizmo is enabled
  108521. */
  108522. isEnabled: boolean;
  108523. /**
  108524. * Disposes of the gizmo
  108525. */
  108526. dispose(): void;
  108527. }
  108528. }
  108529. declare module BABYLON {
  108530. /**
  108531. * Gizmo that enables dragging a mesh along 3 axis
  108532. */
  108533. export class PositionGizmo extends Gizmo {
  108534. /**
  108535. * Internal gizmo used for interactions on the x axis
  108536. */
  108537. xGizmo: AxisDragGizmo;
  108538. /**
  108539. * Internal gizmo used for interactions on the y axis
  108540. */
  108541. yGizmo: AxisDragGizmo;
  108542. /**
  108543. * Internal gizmo used for interactions on the z axis
  108544. */
  108545. zGizmo: AxisDragGizmo;
  108546. /**
  108547. * Internal gizmo used for interactions on the yz plane
  108548. */
  108549. xPlaneGizmo: PlaneDragGizmo;
  108550. /**
  108551. * Internal gizmo used for interactions on the xz plane
  108552. */
  108553. yPlaneGizmo: PlaneDragGizmo;
  108554. /**
  108555. * Internal gizmo used for interactions on the xy plane
  108556. */
  108557. zPlaneGizmo: PlaneDragGizmo;
  108558. /**
  108559. * private variables
  108560. */
  108561. private _meshAttached;
  108562. private _updateGizmoRotationToMatchAttachedMesh;
  108563. private _snapDistance;
  108564. private _scaleRatio;
  108565. /** Fires an event when any of it's sub gizmos are dragged */
  108566. onDragStartObservable: Observable<unknown>;
  108567. /** Fires an event when any of it's sub gizmos are released from dragging */
  108568. onDragEndObservable: Observable<unknown>;
  108569. /**
  108570. * If set to true, planar drag is enabled
  108571. */
  108572. private _planarGizmoEnabled;
  108573. attachedMesh: Nullable<AbstractMesh>;
  108574. /**
  108575. * Creates a PositionGizmo
  108576. * @param gizmoLayer The utility layer the gizmo will be added to
  108577. */
  108578. constructor(gizmoLayer?: UtilityLayerRenderer);
  108579. /**
  108580. * If the planar drag gizmo is enabled
  108581. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108582. */
  108583. planarGizmoEnabled: boolean;
  108584. updateGizmoRotationToMatchAttachedMesh: boolean;
  108585. /**
  108586. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108587. */
  108588. snapDistance: number;
  108589. /**
  108590. * Ratio for the scale of the gizmo (Default: 1)
  108591. */
  108592. scaleRatio: number;
  108593. /**
  108594. * Disposes of the gizmo
  108595. */
  108596. dispose(): void;
  108597. /**
  108598. * CustomMeshes are not supported by this gizmo
  108599. * @param mesh The mesh to replace the default mesh of the gizmo
  108600. */
  108601. setCustomMesh(mesh: Mesh): void;
  108602. }
  108603. }
  108604. declare module BABYLON {
  108605. /**
  108606. * Single axis drag gizmo
  108607. */
  108608. export class AxisDragGizmo extends Gizmo {
  108609. /**
  108610. * Drag behavior responsible for the gizmos dragging interactions
  108611. */
  108612. dragBehavior: PointerDragBehavior;
  108613. private _pointerObserver;
  108614. /**
  108615. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108616. */
  108617. snapDistance: number;
  108618. /**
  108619. * Event that fires each time the gizmo snaps to a new location.
  108620. * * snapDistance is the the change in distance
  108621. */
  108622. onSnapObservable: Observable<{
  108623. snapDistance: number;
  108624. }>;
  108625. private _isEnabled;
  108626. private _parent;
  108627. private _arrow;
  108628. private _coloredMaterial;
  108629. private _hoverMaterial;
  108630. /** @hidden */
  108631. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108632. /** @hidden */
  108633. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108634. /**
  108635. * Creates an AxisDragGizmo
  108636. * @param gizmoLayer The utility layer the gizmo will be added to
  108637. * @param dragAxis The axis which the gizmo will be able to drag on
  108638. * @param color The color of the gizmo
  108639. */
  108640. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108641. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108642. /**
  108643. * If the gizmo is enabled
  108644. */
  108645. isEnabled: boolean;
  108646. /**
  108647. * Disposes of the gizmo
  108648. */
  108649. dispose(): void;
  108650. }
  108651. }
  108652. declare module BABYLON.Debug {
  108653. /**
  108654. * The Axes viewer will show 3 axes in a specific point in space
  108655. */
  108656. export class AxesViewer {
  108657. private _xAxis;
  108658. private _yAxis;
  108659. private _zAxis;
  108660. private _scaleLinesFactor;
  108661. private _instanced;
  108662. /**
  108663. * Gets the hosting scene
  108664. */
  108665. scene: Scene;
  108666. /**
  108667. * Gets or sets a number used to scale line length
  108668. */
  108669. scaleLines: number;
  108670. /** Gets the node hierarchy used to render x-axis */
  108671. readonly xAxis: TransformNode;
  108672. /** Gets the node hierarchy used to render y-axis */
  108673. readonly yAxis: TransformNode;
  108674. /** Gets the node hierarchy used to render z-axis */
  108675. readonly zAxis: TransformNode;
  108676. /**
  108677. * Creates a new AxesViewer
  108678. * @param scene defines the hosting scene
  108679. * @param scaleLines defines a number used to scale line length (1 by default)
  108680. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108681. * @param xAxis defines the node hierarchy used to render the x-axis
  108682. * @param yAxis defines the node hierarchy used to render the y-axis
  108683. * @param zAxis defines the node hierarchy used to render the z-axis
  108684. */
  108685. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108686. /**
  108687. * Force the viewer to update
  108688. * @param position defines the position of the viewer
  108689. * @param xaxis defines the x axis of the viewer
  108690. * @param yaxis defines the y axis of the viewer
  108691. * @param zaxis defines the z axis of the viewer
  108692. */
  108693. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108694. /**
  108695. * Creates an instance of this axes viewer.
  108696. * @returns a new axes viewer with instanced meshes
  108697. */
  108698. createInstance(): AxesViewer;
  108699. /** Releases resources */
  108700. dispose(): void;
  108701. private static _SetRenderingGroupId;
  108702. }
  108703. }
  108704. declare module BABYLON.Debug {
  108705. /**
  108706. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108707. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108708. */
  108709. export class BoneAxesViewer extends AxesViewer {
  108710. /**
  108711. * Gets or sets the target mesh where to display the axes viewer
  108712. */
  108713. mesh: Nullable<Mesh>;
  108714. /**
  108715. * Gets or sets the target bone where to display the axes viewer
  108716. */
  108717. bone: Nullable<Bone>;
  108718. /** Gets current position */
  108719. pos: Vector3;
  108720. /** Gets direction of X axis */
  108721. xaxis: Vector3;
  108722. /** Gets direction of Y axis */
  108723. yaxis: Vector3;
  108724. /** Gets direction of Z axis */
  108725. zaxis: Vector3;
  108726. /**
  108727. * Creates a new BoneAxesViewer
  108728. * @param scene defines the hosting scene
  108729. * @param bone defines the target bone
  108730. * @param mesh defines the target mesh
  108731. * @param scaleLines defines a scaling factor for line length (1 by default)
  108732. */
  108733. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108734. /**
  108735. * Force the viewer to update
  108736. */
  108737. update(): void;
  108738. /** Releases resources */
  108739. dispose(): void;
  108740. }
  108741. }
  108742. declare module BABYLON {
  108743. /**
  108744. * Interface used to define scene explorer extensibility option
  108745. */
  108746. export interface IExplorerExtensibilityOption {
  108747. /**
  108748. * Define the option label
  108749. */
  108750. label: string;
  108751. /**
  108752. * Defines the action to execute on click
  108753. */
  108754. action: (entity: any) => void;
  108755. }
  108756. /**
  108757. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108758. */
  108759. export interface IExplorerExtensibilityGroup {
  108760. /**
  108761. * Defines a predicate to test if a given type mut be extended
  108762. */
  108763. predicate: (entity: any) => boolean;
  108764. /**
  108765. * Gets the list of options added to a type
  108766. */
  108767. entries: IExplorerExtensibilityOption[];
  108768. }
  108769. /**
  108770. * Interface used to define the options to use to create the Inspector
  108771. */
  108772. export interface IInspectorOptions {
  108773. /**
  108774. * Display in overlay mode (default: false)
  108775. */
  108776. overlay?: boolean;
  108777. /**
  108778. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108779. */
  108780. globalRoot?: HTMLElement;
  108781. /**
  108782. * Display the Scene explorer
  108783. */
  108784. showExplorer?: boolean;
  108785. /**
  108786. * Display the property inspector
  108787. */
  108788. showInspector?: boolean;
  108789. /**
  108790. * Display in embed mode (both panes on the right)
  108791. */
  108792. embedMode?: boolean;
  108793. /**
  108794. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108795. */
  108796. handleResize?: boolean;
  108797. /**
  108798. * Allow the panes to popup (default: true)
  108799. */
  108800. enablePopup?: boolean;
  108801. /**
  108802. * Allow the panes to be closed by users (default: true)
  108803. */
  108804. enableClose?: boolean;
  108805. /**
  108806. * Optional list of extensibility entries
  108807. */
  108808. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108809. /**
  108810. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108811. */
  108812. inspectorURL?: string;
  108813. }
  108814. interface Scene {
  108815. /**
  108816. * @hidden
  108817. * Backing field
  108818. */
  108819. _debugLayer: DebugLayer;
  108820. /**
  108821. * Gets the debug layer (aka Inspector) associated with the scene
  108822. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108823. */
  108824. debugLayer: DebugLayer;
  108825. }
  108826. /**
  108827. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108828. * what is happening in your scene
  108829. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108830. */
  108831. export class DebugLayer {
  108832. /**
  108833. * Define the url to get the inspector script from.
  108834. * By default it uses the babylonjs CDN.
  108835. * @ignoreNaming
  108836. */
  108837. static InspectorURL: string;
  108838. private _scene;
  108839. private BJSINSPECTOR;
  108840. private _onPropertyChangedObservable?;
  108841. /**
  108842. * Observable triggered when a property is changed through the inspector.
  108843. */
  108844. readonly onPropertyChangedObservable: any;
  108845. /**
  108846. * Instantiates a new debug layer.
  108847. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108848. * what is happening in your scene
  108849. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108850. * @param scene Defines the scene to inspect
  108851. */
  108852. constructor(scene: Scene);
  108853. /** Creates the inspector window. */
  108854. private _createInspector;
  108855. /**
  108856. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108857. * @param entity defines the entity to select
  108858. * @param lineContainerTitle defines the specific block to highlight
  108859. */
  108860. select(entity: any, lineContainerTitle?: string): void;
  108861. /** Get the inspector from bundle or global */
  108862. private _getGlobalInspector;
  108863. /**
  108864. * Get if the inspector is visible or not.
  108865. * @returns true if visible otherwise, false
  108866. */
  108867. isVisible(): boolean;
  108868. /**
  108869. * Hide the inspector and close its window.
  108870. */
  108871. hide(): void;
  108872. /**
  108873. * Launch the debugLayer.
  108874. * @param config Define the configuration of the inspector
  108875. * @return a promise fulfilled when the debug layer is visible
  108876. */
  108877. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108878. }
  108879. }
  108880. declare module BABYLON {
  108881. /**
  108882. * Class containing static functions to help procedurally build meshes
  108883. */
  108884. export class BoxBuilder {
  108885. /**
  108886. * Creates a box mesh
  108887. * * The parameter `size` sets the size (float) of each box side (default 1)
  108888. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108889. * * 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)
  108890. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108892. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108894. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108895. * @param name defines the name of the mesh
  108896. * @param options defines the options used to create the mesh
  108897. * @param scene defines the hosting scene
  108898. * @returns the box mesh
  108899. */
  108900. static CreateBox(name: string, options: {
  108901. size?: number;
  108902. width?: number;
  108903. height?: number;
  108904. depth?: number;
  108905. faceUV?: Vector4[];
  108906. faceColors?: Color4[];
  108907. sideOrientation?: number;
  108908. frontUVs?: Vector4;
  108909. backUVs?: Vector4;
  108910. wrap?: boolean;
  108911. topBaseAt?: number;
  108912. bottomBaseAt?: number;
  108913. updatable?: boolean;
  108914. }, scene?: Nullable<Scene>): Mesh;
  108915. }
  108916. }
  108917. declare module BABYLON {
  108918. /**
  108919. * Class containing static functions to help procedurally build meshes
  108920. */
  108921. export class SphereBuilder {
  108922. /**
  108923. * Creates a sphere mesh
  108924. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108925. * * 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`)
  108926. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108927. * * 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
  108928. * * 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)
  108929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108932. * @param name defines the name of the mesh
  108933. * @param options defines the options used to create the mesh
  108934. * @param scene defines the hosting scene
  108935. * @returns the sphere mesh
  108936. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108937. */
  108938. static CreateSphere(name: string, options: {
  108939. segments?: number;
  108940. diameter?: number;
  108941. diameterX?: number;
  108942. diameterY?: number;
  108943. diameterZ?: number;
  108944. arc?: number;
  108945. slice?: number;
  108946. sideOrientation?: number;
  108947. frontUVs?: Vector4;
  108948. backUVs?: Vector4;
  108949. updatable?: boolean;
  108950. }, scene?: Nullable<Scene>): Mesh;
  108951. }
  108952. }
  108953. declare module BABYLON.Debug {
  108954. /**
  108955. * Used to show the physics impostor around the specific mesh
  108956. */
  108957. export class PhysicsViewer {
  108958. /** @hidden */
  108959. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108960. /** @hidden */
  108961. protected _meshes: Array<Nullable<AbstractMesh>>;
  108962. /** @hidden */
  108963. protected _scene: Nullable<Scene>;
  108964. /** @hidden */
  108965. protected _numMeshes: number;
  108966. /** @hidden */
  108967. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108968. private _renderFunction;
  108969. private _utilityLayer;
  108970. private _debugBoxMesh;
  108971. private _debugSphereMesh;
  108972. private _debugCylinderMesh;
  108973. private _debugMaterial;
  108974. private _debugMeshMeshes;
  108975. /**
  108976. * Creates a new PhysicsViewer
  108977. * @param scene defines the hosting scene
  108978. */
  108979. constructor(scene: Scene);
  108980. /** @hidden */
  108981. protected _updateDebugMeshes(): void;
  108982. /**
  108983. * Renders a specified physic impostor
  108984. * @param impostor defines the impostor to render
  108985. * @param targetMesh defines the mesh represented by the impostor
  108986. * @returns the new debug mesh used to render the impostor
  108987. */
  108988. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  108989. /**
  108990. * Hides a specified physic impostor
  108991. * @param impostor defines the impostor to hide
  108992. */
  108993. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  108994. private _getDebugMaterial;
  108995. private _getDebugBoxMesh;
  108996. private _getDebugSphereMesh;
  108997. private _getDebugCylinderMesh;
  108998. private _getDebugMeshMesh;
  108999. private _getDebugMesh;
  109000. /** Releases all resources */
  109001. dispose(): void;
  109002. }
  109003. }
  109004. declare module BABYLON {
  109005. /**
  109006. * Class containing static functions to help procedurally build meshes
  109007. */
  109008. export class LinesBuilder {
  109009. /**
  109010. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109011. * * 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
  109012. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109013. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109014. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109015. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109016. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109017. * * 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
  109018. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109020. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109021. * @param name defines the name of the new line system
  109022. * @param options defines the options used to create the line system
  109023. * @param scene defines the hosting scene
  109024. * @returns a new line system mesh
  109025. */
  109026. static CreateLineSystem(name: string, options: {
  109027. lines: Vector3[][];
  109028. updatable?: boolean;
  109029. instance?: Nullable<LinesMesh>;
  109030. colors?: Nullable<Color4[][]>;
  109031. useVertexAlpha?: boolean;
  109032. }, scene: Nullable<Scene>): LinesMesh;
  109033. /**
  109034. * Creates a line mesh
  109035. * 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
  109036. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109037. * * The parameter `points` is an array successive Vector3
  109038. * * 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
  109039. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109040. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109041. * * When updating an instance, remember that only point positions can change, not the number of points
  109042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109044. * @param name defines the name of the new line system
  109045. * @param options defines the options used to create the line system
  109046. * @param scene defines the hosting scene
  109047. * @returns a new line mesh
  109048. */
  109049. static CreateLines(name: string, options: {
  109050. points: Vector3[];
  109051. updatable?: boolean;
  109052. instance?: Nullable<LinesMesh>;
  109053. colors?: Color4[];
  109054. useVertexAlpha?: boolean;
  109055. }, scene?: Nullable<Scene>): LinesMesh;
  109056. /**
  109057. * Creates a dashed line mesh
  109058. * * 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
  109059. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109060. * * The parameter `points` is an array successive Vector3
  109061. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109062. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109063. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109064. * * 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
  109065. * * When updating an instance, remember that only point positions can change, not the number of points
  109066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109067. * @param name defines the name of the mesh
  109068. * @param options defines the options used to create the mesh
  109069. * @param scene defines the hosting scene
  109070. * @returns the dashed line mesh
  109071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109072. */
  109073. static CreateDashedLines(name: string, options: {
  109074. points: Vector3[];
  109075. dashSize?: number;
  109076. gapSize?: number;
  109077. dashNb?: number;
  109078. updatable?: boolean;
  109079. instance?: LinesMesh;
  109080. }, scene?: Nullable<Scene>): LinesMesh;
  109081. }
  109082. }
  109083. declare module BABYLON {
  109084. /**
  109085. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109086. * in order to better appreciate the issue one might have.
  109087. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109088. */
  109089. export class RayHelper {
  109090. /**
  109091. * Defines the ray we are currently tryin to visualize.
  109092. */
  109093. ray: Nullable<Ray>;
  109094. private _renderPoints;
  109095. private _renderLine;
  109096. private _renderFunction;
  109097. private _scene;
  109098. private _updateToMeshFunction;
  109099. private _attachedToMesh;
  109100. private _meshSpaceDirection;
  109101. private _meshSpaceOrigin;
  109102. /**
  109103. * Helper function to create a colored helper in a scene in one line.
  109104. * @param ray Defines the ray we are currently tryin to visualize
  109105. * @param scene Defines the scene the ray is used in
  109106. * @param color Defines the color we want to see the ray in
  109107. * @returns The newly created ray helper.
  109108. */
  109109. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109110. /**
  109111. * Instantiate a new ray helper.
  109112. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109113. * in order to better appreciate the issue one might have.
  109114. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109115. * @param ray Defines the ray we are currently tryin to visualize
  109116. */
  109117. constructor(ray: Ray);
  109118. /**
  109119. * Shows the ray we are willing to debug.
  109120. * @param scene Defines the scene the ray needs to be rendered in
  109121. * @param color Defines the color the ray needs to be rendered in
  109122. */
  109123. show(scene: Scene, color?: Color3): void;
  109124. /**
  109125. * Hides the ray we are debugging.
  109126. */
  109127. hide(): void;
  109128. private _render;
  109129. /**
  109130. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109131. * @param mesh Defines the mesh we want the helper attached to
  109132. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109133. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109134. * @param length Defines the length of the ray
  109135. */
  109136. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109137. /**
  109138. * Detach the ray helper from the mesh it has previously been attached to.
  109139. */
  109140. detachFromMesh(): void;
  109141. private _updateToMesh;
  109142. /**
  109143. * Dispose the helper and release its associated resources.
  109144. */
  109145. dispose(): void;
  109146. }
  109147. }
  109148. declare module BABYLON.Debug {
  109149. /**
  109150. * Class used to render a debug view of a given skeleton
  109151. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109152. */
  109153. export class SkeletonViewer {
  109154. /** defines the skeleton to render */
  109155. skeleton: Skeleton;
  109156. /** defines the mesh attached to the skeleton */
  109157. mesh: AbstractMesh;
  109158. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109159. autoUpdateBonesMatrices: boolean;
  109160. /** defines the rendering group id to use with the viewer */
  109161. renderingGroupId: number;
  109162. /** Gets or sets the color used to render the skeleton */
  109163. color: Color3;
  109164. private _scene;
  109165. private _debugLines;
  109166. private _debugMesh;
  109167. private _isEnabled;
  109168. private _renderFunction;
  109169. private _utilityLayer;
  109170. /**
  109171. * Returns the mesh used to render the bones
  109172. */
  109173. readonly debugMesh: Nullable<LinesMesh>;
  109174. /**
  109175. * Creates a new SkeletonViewer
  109176. * @param skeleton defines the skeleton to render
  109177. * @param mesh defines the mesh attached to the skeleton
  109178. * @param scene defines the hosting scene
  109179. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109180. * @param renderingGroupId defines the rendering group id to use with the viewer
  109181. */
  109182. constructor(
  109183. /** defines the skeleton to render */
  109184. skeleton: Skeleton,
  109185. /** defines the mesh attached to the skeleton */
  109186. mesh: AbstractMesh, scene: Scene,
  109187. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109188. autoUpdateBonesMatrices?: boolean,
  109189. /** defines the rendering group id to use with the viewer */
  109190. renderingGroupId?: number);
  109191. /** Gets or sets a boolean indicating if the viewer is enabled */
  109192. isEnabled: boolean;
  109193. private _getBonePosition;
  109194. private _getLinesForBonesWithLength;
  109195. private _getLinesForBonesNoLength;
  109196. /** Update the viewer to sync with current skeleton state */
  109197. update(): void;
  109198. /** Release associated resources */
  109199. dispose(): void;
  109200. }
  109201. }
  109202. declare module BABYLON {
  109203. /**
  109204. * Options to create the null engine
  109205. */
  109206. export class NullEngineOptions {
  109207. /**
  109208. * Render width (Default: 512)
  109209. */
  109210. renderWidth: number;
  109211. /**
  109212. * Render height (Default: 256)
  109213. */
  109214. renderHeight: number;
  109215. /**
  109216. * Texture size (Default: 512)
  109217. */
  109218. textureSize: number;
  109219. /**
  109220. * If delta time between frames should be constant
  109221. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109222. */
  109223. deterministicLockstep: boolean;
  109224. /**
  109225. * Maximum about of steps between frames (Default: 4)
  109226. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109227. */
  109228. lockstepMaxSteps: number;
  109229. }
  109230. /**
  109231. * The null engine class provides support for headless version of babylon.js.
  109232. * This can be used in server side scenario or for testing purposes
  109233. */
  109234. export class NullEngine extends Engine {
  109235. private _options;
  109236. /**
  109237. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109238. */
  109239. isDeterministicLockStep(): boolean;
  109240. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  109241. getLockstepMaxSteps(): number;
  109242. /**
  109243. * Sets hardware scaling, used to save performance if needed
  109244. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109245. */
  109246. getHardwareScalingLevel(): number;
  109247. constructor(options?: NullEngineOptions);
  109248. createVertexBuffer(vertices: FloatArray): DataBuffer;
  109249. createIndexBuffer(indices: IndicesArray): DataBuffer;
  109250. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109251. getRenderWidth(useScreen?: boolean): number;
  109252. getRenderHeight(useScreen?: boolean): number;
  109253. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  109254. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  109255. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  109256. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109257. bindSamplers(effect: Effect): void;
  109258. enableEffect(effect: Effect): void;
  109259. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109260. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109261. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109262. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109263. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109264. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109265. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109266. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109267. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109268. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109269. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109270. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109271. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109272. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109273. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109274. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109275. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109276. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109277. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109278. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109279. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109280. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109281. bindBuffers(vertexBuffers: {
  109282. [key: string]: VertexBuffer;
  109283. }, indexBuffer: DataBuffer, effect: Effect): void;
  109284. wipeCaches(bruteForce?: boolean): void;
  109285. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  109286. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109287. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109288. /** @hidden */
  109289. _createTexture(): WebGLTexture;
  109290. /** @hidden */
  109291. _releaseTexture(texture: InternalTexture): void;
  109292. 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;
  109293. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109294. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109295. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109296. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109297. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  109298. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  109299. areAllEffectsReady(): boolean;
  109300. /**
  109301. * @hidden
  109302. * Get the current error code of the webGL context
  109303. * @returns the error code
  109304. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  109305. */
  109306. getError(): number;
  109307. /** @hidden */
  109308. _getUnpackAlignement(): number;
  109309. /** @hidden */
  109310. _unpackFlipY(value: boolean): void;
  109311. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  109312. /**
  109313. * Updates a dynamic vertex buffer.
  109314. * @param vertexBuffer the vertex buffer to update
  109315. * @param data the data used to update the vertex buffer
  109316. * @param byteOffset the byte offset of the data (optional)
  109317. * @param byteLength the byte length of the data (optional)
  109318. */
  109319. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  109320. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  109321. /** @hidden */
  109322. _bindTexture(channel: number, texture: InternalTexture): void;
  109323. protected _deleteBuffer(buffer: WebGLBuffer): void;
  109324. releaseEffects(): void;
  109325. displayLoadingUI(): void;
  109326. hideLoadingUI(): void;
  109327. /** @hidden */
  109328. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109329. /** @hidden */
  109330. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109331. /** @hidden */
  109332. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109333. /** @hidden */
  109334. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109335. }
  109336. }
  109337. declare module BABYLON {
  109338. /** @hidden */
  109339. export class _OcclusionDataStorage {
  109340. /** @hidden */
  109341. occlusionInternalRetryCounter: number;
  109342. /** @hidden */
  109343. isOcclusionQueryInProgress: boolean;
  109344. /** @hidden */
  109345. isOccluded: boolean;
  109346. /** @hidden */
  109347. occlusionRetryCount: number;
  109348. /** @hidden */
  109349. occlusionType: number;
  109350. /** @hidden */
  109351. occlusionQueryAlgorithmType: number;
  109352. }
  109353. interface Engine {
  109354. /**
  109355. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109356. * @return the new query
  109357. */
  109358. createQuery(): WebGLQuery;
  109359. /**
  109360. * Delete and release a webGL query
  109361. * @param query defines the query to delete
  109362. * @return the current engine
  109363. */
  109364. deleteQuery(query: WebGLQuery): Engine;
  109365. /**
  109366. * Check if a given query has resolved and got its value
  109367. * @param query defines the query to check
  109368. * @returns true if the query got its value
  109369. */
  109370. isQueryResultAvailable(query: WebGLQuery): boolean;
  109371. /**
  109372. * Gets the value of a given query
  109373. * @param query defines the query to check
  109374. * @returns the value of the query
  109375. */
  109376. getQueryResult(query: WebGLQuery): number;
  109377. /**
  109378. * Initiates an occlusion query
  109379. * @param algorithmType defines the algorithm to use
  109380. * @param query defines the query to use
  109381. * @returns the current engine
  109382. * @see http://doc.babylonjs.com/features/occlusionquery
  109383. */
  109384. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109385. /**
  109386. * Ends an occlusion query
  109387. * @see http://doc.babylonjs.com/features/occlusionquery
  109388. * @param algorithmType defines the algorithm to use
  109389. * @returns the current engine
  109390. */
  109391. endOcclusionQuery(algorithmType: number): Engine;
  109392. /**
  109393. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109394. * Please note that only one query can be issued at a time
  109395. * @returns a time token used to track the time span
  109396. */
  109397. startTimeQuery(): Nullable<_TimeToken>;
  109398. /**
  109399. * Ends a time query
  109400. * @param token defines the token used to measure the time span
  109401. * @returns the time spent (in ns)
  109402. */
  109403. endTimeQuery(token: _TimeToken): int;
  109404. /** @hidden */
  109405. _currentNonTimestampToken: Nullable<_TimeToken>;
  109406. /** @hidden */
  109407. _createTimeQuery(): WebGLQuery;
  109408. /** @hidden */
  109409. _deleteTimeQuery(query: WebGLQuery): void;
  109410. /** @hidden */
  109411. _getGlAlgorithmType(algorithmType: number): number;
  109412. /** @hidden */
  109413. _getTimeQueryResult(query: WebGLQuery): any;
  109414. /** @hidden */
  109415. _getTimeQueryAvailability(query: WebGLQuery): any;
  109416. }
  109417. interface AbstractMesh {
  109418. /**
  109419. * Backing filed
  109420. * @hidden
  109421. */
  109422. __occlusionDataStorage: _OcclusionDataStorage;
  109423. /**
  109424. * Access property
  109425. * @hidden
  109426. */
  109427. _occlusionDataStorage: _OcclusionDataStorage;
  109428. /**
  109429. * 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.
  109430. * The default value is -1 which means don't break the query and wait till the result
  109431. * @see http://doc.babylonjs.com/features/occlusionquery
  109432. */
  109433. occlusionRetryCount: number;
  109434. /**
  109435. * 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:
  109436. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109437. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109438. * * 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.
  109439. * @see http://doc.babylonjs.com/features/occlusionquery
  109440. */
  109441. occlusionType: number;
  109442. /**
  109443. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109444. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109445. * * 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.
  109446. * @see http://doc.babylonjs.com/features/occlusionquery
  109447. */
  109448. occlusionQueryAlgorithmType: number;
  109449. /**
  109450. * 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
  109451. * @see http://doc.babylonjs.com/features/occlusionquery
  109452. */
  109453. isOccluded: boolean;
  109454. /**
  109455. * Flag to check the progress status of the query
  109456. * @see http://doc.babylonjs.com/features/occlusionquery
  109457. */
  109458. isOcclusionQueryInProgress: boolean;
  109459. }
  109460. }
  109461. declare module BABYLON {
  109462. /** @hidden */
  109463. export var _forceTransformFeedbackToBundle: boolean;
  109464. interface Engine {
  109465. /**
  109466. * Creates a webGL transform feedback object
  109467. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109468. * @returns the webGL transform feedback object
  109469. */
  109470. createTransformFeedback(): WebGLTransformFeedback;
  109471. /**
  109472. * Delete a webGL transform feedback object
  109473. * @param value defines the webGL transform feedback object to delete
  109474. */
  109475. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109476. /**
  109477. * Bind a webGL transform feedback object to the webgl context
  109478. * @param value defines the webGL transform feedback object to bind
  109479. */
  109480. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109481. /**
  109482. * Begins a transform feedback operation
  109483. * @param usePoints defines if points or triangles must be used
  109484. */
  109485. beginTransformFeedback(usePoints: boolean): void;
  109486. /**
  109487. * Ends a transform feedback operation
  109488. */
  109489. endTransformFeedback(): void;
  109490. /**
  109491. * Specify the varyings to use with transform feedback
  109492. * @param program defines the associated webGL program
  109493. * @param value defines the list of strings representing the varying names
  109494. */
  109495. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109496. /**
  109497. * Bind a webGL buffer for a transform feedback operation
  109498. * @param value defines the webGL buffer to bind
  109499. */
  109500. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109501. }
  109502. }
  109503. declare module BABYLON {
  109504. /**
  109505. * Creation options of the multi render target texture.
  109506. */
  109507. export interface IMultiRenderTargetOptions {
  109508. /**
  109509. * Define if the texture needs to create mip maps after render.
  109510. */
  109511. generateMipMaps?: boolean;
  109512. /**
  109513. * Define the types of all the draw buffers we want to create
  109514. */
  109515. types?: number[];
  109516. /**
  109517. * Define the sampling modes of all the draw buffers we want to create
  109518. */
  109519. samplingModes?: number[];
  109520. /**
  109521. * Define if a depth buffer is required
  109522. */
  109523. generateDepthBuffer?: boolean;
  109524. /**
  109525. * Define if a stencil buffer is required
  109526. */
  109527. generateStencilBuffer?: boolean;
  109528. /**
  109529. * Define if a depth texture is required instead of a depth buffer
  109530. */
  109531. generateDepthTexture?: boolean;
  109532. /**
  109533. * Define the number of desired draw buffers
  109534. */
  109535. textureCount?: number;
  109536. /**
  109537. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109538. */
  109539. doNotChangeAspectRatio?: boolean;
  109540. /**
  109541. * Define the default type of the buffers we are creating
  109542. */
  109543. defaultType?: number;
  109544. }
  109545. /**
  109546. * A multi render target, like a render target provides the ability to render to a texture.
  109547. * Unlike the render target, it can render to several draw buffers in one draw.
  109548. * This is specially interesting in deferred rendering or for any effects requiring more than
  109549. * just one color from a single pass.
  109550. */
  109551. export class MultiRenderTarget extends RenderTargetTexture {
  109552. private _internalTextures;
  109553. private _textures;
  109554. private _multiRenderTargetOptions;
  109555. /**
  109556. * Get if draw buffers are currently supported by the used hardware and browser.
  109557. */
  109558. readonly isSupported: boolean;
  109559. /**
  109560. * Get the list of textures generated by the multi render target.
  109561. */
  109562. readonly textures: Texture[];
  109563. /**
  109564. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109565. */
  109566. readonly depthTexture: Texture;
  109567. /**
  109568. * Set the wrapping mode on U of all the textures we are rendering to.
  109569. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109570. */
  109571. wrapU: number;
  109572. /**
  109573. * Set the wrapping mode on V of all the textures we are rendering to.
  109574. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109575. */
  109576. wrapV: number;
  109577. /**
  109578. * Instantiate a new multi render target texture.
  109579. * A multi render target, like a render target provides the ability to render to a texture.
  109580. * Unlike the render target, it can render to several draw buffers in one draw.
  109581. * This is specially interesting in deferred rendering or for any effects requiring more than
  109582. * just one color from a single pass.
  109583. * @param name Define the name of the texture
  109584. * @param size Define the size of the buffers to render to
  109585. * @param count Define the number of target we are rendering into
  109586. * @param scene Define the scene the texture belongs to
  109587. * @param options Define the options used to create the multi render target
  109588. */
  109589. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109590. /** @hidden */
  109591. _rebuild(): void;
  109592. private _createInternalTextures;
  109593. private _createTextures;
  109594. /**
  109595. * Define the number of samples used if MSAA is enabled.
  109596. */
  109597. samples: number;
  109598. /**
  109599. * Resize all the textures in the multi render target.
  109600. * Be carrefull as it will recreate all the data in the new texture.
  109601. * @param size Define the new size
  109602. */
  109603. resize(size: any): void;
  109604. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109605. /**
  109606. * Dispose the render targets and their associated resources
  109607. */
  109608. dispose(): void;
  109609. /**
  109610. * Release all the underlying texture used as draw buffers.
  109611. */
  109612. releaseInternalTextures(): void;
  109613. }
  109614. }
  109615. declare module BABYLON {
  109616. interface Engine {
  109617. /**
  109618. * Unbind a list of render target textures from the webGL context
  109619. * This is used only when drawBuffer extension or webGL2 are active
  109620. * @param textures defines the render target textures to unbind
  109621. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109622. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109623. */
  109624. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109625. /**
  109626. * Create a multi render target texture
  109627. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109628. * @param size defines the size of the texture
  109629. * @param options defines the creation options
  109630. * @returns the cube texture as an InternalTexture
  109631. */
  109632. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109633. /**
  109634. * Update the sample count for a given multiple render target texture
  109635. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109636. * @param textures defines the textures to update
  109637. * @param samples defines the sample count to set
  109638. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109639. */
  109640. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109641. }
  109642. }
  109643. declare module BABYLON {
  109644. /** @hidden */
  109645. export var rgbdEncodePixelShader: {
  109646. name: string;
  109647. shader: string;
  109648. };
  109649. }
  109650. declare module BABYLON {
  109651. /** @hidden */
  109652. export var rgbdDecodePixelShader: {
  109653. name: string;
  109654. shader: string;
  109655. };
  109656. }
  109657. declare module BABYLON {
  109658. /**
  109659. * Raw texture data and descriptor sufficient for WebGL texture upload
  109660. */
  109661. export interface EnvironmentTextureInfo {
  109662. /**
  109663. * Version of the environment map
  109664. */
  109665. version: number;
  109666. /**
  109667. * Width of image
  109668. */
  109669. width: number;
  109670. /**
  109671. * Irradiance information stored in the file.
  109672. */
  109673. irradiance: any;
  109674. /**
  109675. * Specular information stored in the file.
  109676. */
  109677. specular: any;
  109678. }
  109679. /**
  109680. * Defines One Image in the file. It requires only the position in the file
  109681. * as well as the length.
  109682. */
  109683. interface BufferImageData {
  109684. /**
  109685. * Length of the image data.
  109686. */
  109687. length: number;
  109688. /**
  109689. * Position of the data from the null terminator delimiting the end of the JSON.
  109690. */
  109691. position: number;
  109692. }
  109693. /**
  109694. * Defines the specular data enclosed in the file.
  109695. * This corresponds to the version 1 of the data.
  109696. */
  109697. export interface EnvironmentTextureSpecularInfoV1 {
  109698. /**
  109699. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109700. */
  109701. specularDataPosition?: number;
  109702. /**
  109703. * This contains all the images data needed to reconstruct the cubemap.
  109704. */
  109705. mipmaps: Array<BufferImageData>;
  109706. /**
  109707. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109708. */
  109709. lodGenerationScale: number;
  109710. }
  109711. /**
  109712. * Sets of helpers addressing the serialization and deserialization of environment texture
  109713. * stored in a BabylonJS env file.
  109714. * Those files are usually stored as .env files.
  109715. */
  109716. export class EnvironmentTextureTools {
  109717. /**
  109718. * Magic number identifying the env file.
  109719. */
  109720. private static _MagicBytes;
  109721. /**
  109722. * Gets the environment info from an env file.
  109723. * @param data The array buffer containing the .env bytes.
  109724. * @returns the environment file info (the json header) if successfully parsed.
  109725. */
  109726. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109727. /**
  109728. * Creates an environment texture from a loaded cube texture.
  109729. * @param texture defines the cube texture to convert in env file
  109730. * @return a promise containing the environment data if succesfull.
  109731. */
  109732. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109733. /**
  109734. * Creates a JSON representation of the spherical data.
  109735. * @param texture defines the texture containing the polynomials
  109736. * @return the JSON representation of the spherical info
  109737. */
  109738. private static _CreateEnvTextureIrradiance;
  109739. /**
  109740. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109741. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109742. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109743. * @return the views described by info providing access to the underlying buffer
  109744. */
  109745. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109746. /**
  109747. * Uploads the texture info contained in the env file to the GPU.
  109748. * @param texture defines the internal texture to upload to
  109749. * @param arrayBuffer defines the buffer cotaining the data to load
  109750. * @param info defines the texture info retrieved through the GetEnvInfo method
  109751. * @returns a promise
  109752. */
  109753. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109754. /**
  109755. * Uploads the levels of image data to the GPU.
  109756. * @param texture defines the internal texture to upload to
  109757. * @param imageData defines the array buffer views of image data [mipmap][face]
  109758. * @returns a promise
  109759. */
  109760. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109761. /**
  109762. * Uploads spherical polynomials information to the texture.
  109763. * @param texture defines the texture we are trying to upload the information to
  109764. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109765. */
  109766. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109767. /** @hidden */
  109768. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109769. }
  109770. }
  109771. declare module BABYLON {
  109772. /**
  109773. * Contains position and normal vectors for a vertex
  109774. */
  109775. export class PositionNormalVertex {
  109776. /** the position of the vertex (defaut: 0,0,0) */
  109777. position: Vector3;
  109778. /** the normal of the vertex (defaut: 0,1,0) */
  109779. normal: Vector3;
  109780. /**
  109781. * Creates a PositionNormalVertex
  109782. * @param position the position of the vertex (defaut: 0,0,0)
  109783. * @param normal the normal of the vertex (defaut: 0,1,0)
  109784. */
  109785. constructor(
  109786. /** the position of the vertex (defaut: 0,0,0) */
  109787. position?: Vector3,
  109788. /** the normal of the vertex (defaut: 0,1,0) */
  109789. normal?: Vector3);
  109790. /**
  109791. * Clones the PositionNormalVertex
  109792. * @returns the cloned PositionNormalVertex
  109793. */
  109794. clone(): PositionNormalVertex;
  109795. }
  109796. /**
  109797. * Contains position, normal and uv vectors for a vertex
  109798. */
  109799. export class PositionNormalTextureVertex {
  109800. /** the position of the vertex (defaut: 0,0,0) */
  109801. position: Vector3;
  109802. /** the normal of the vertex (defaut: 0,1,0) */
  109803. normal: Vector3;
  109804. /** the uv of the vertex (default: 0,0) */
  109805. uv: Vector2;
  109806. /**
  109807. * Creates a PositionNormalTextureVertex
  109808. * @param position the position of the vertex (defaut: 0,0,0)
  109809. * @param normal the normal of the vertex (defaut: 0,1,0)
  109810. * @param uv the uv of the vertex (default: 0,0)
  109811. */
  109812. constructor(
  109813. /** the position of the vertex (defaut: 0,0,0) */
  109814. position?: Vector3,
  109815. /** the normal of the vertex (defaut: 0,1,0) */
  109816. normal?: Vector3,
  109817. /** the uv of the vertex (default: 0,0) */
  109818. uv?: Vector2);
  109819. /**
  109820. * Clones the PositionNormalTextureVertex
  109821. * @returns the cloned PositionNormalTextureVertex
  109822. */
  109823. clone(): PositionNormalTextureVertex;
  109824. }
  109825. }
  109826. declare module BABYLON {
  109827. /** @hidden */
  109828. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109829. private _genericAttributeLocation;
  109830. private _varyingLocationCount;
  109831. private _varyingLocationMap;
  109832. private _replacements;
  109833. private _textureCount;
  109834. private _uniforms;
  109835. lineProcessor(line: string): string;
  109836. attributeProcessor(attribute: string): string;
  109837. varyingProcessor(varying: string, isFragment: boolean): string;
  109838. uniformProcessor(uniform: string): string;
  109839. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109840. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109841. }
  109842. }
  109843. declare module BABYLON {
  109844. /**
  109845. * Container for accessors for natively-stored mesh data buffers.
  109846. */
  109847. class NativeDataBuffer extends DataBuffer {
  109848. /**
  109849. * Accessor value used to identify/retrieve a natively-stored index buffer.
  109850. */
  109851. nativeIndexBuffer?: any;
  109852. /**
  109853. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  109854. */
  109855. nativeVertexBuffer?: any;
  109856. }
  109857. /** @hidden */
  109858. export class NativeEngine extends Engine {
  109859. private readonly _native;
  109860. getHardwareScalingLevel(): number;
  109861. constructor();
  109862. /**
  109863. * Can be used to override the current requestAnimationFrame requester.
  109864. * @hidden
  109865. */
  109866. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  109867. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109868. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  109869. createVertexBuffer(data: DataArray): NativeDataBuffer;
  109870. recordVertexArrayObject(vertexBuffers: {
  109871. [key: string]: VertexBuffer;
  109872. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  109873. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109874. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109875. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109876. /**
  109877. * Draw a list of indexed primitives
  109878. * @param fillMode defines the primitive to use
  109879. * @param indexStart defines the starting index
  109880. * @param indexCount defines the number of index to draw
  109881. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109882. */
  109883. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109884. /**
  109885. * Draw a list of unindexed primitives
  109886. * @param fillMode defines the primitive to use
  109887. * @param verticesStart defines the index of first vertex to draw
  109888. * @param verticesCount defines the count of vertices to draw
  109889. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109890. */
  109891. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109892. createPipelineContext(): IPipelineContext;
  109893. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  109894. /** @hidden */
  109895. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  109896. /** @hidden */
  109897. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  109898. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109899. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109900. protected _setProgram(program: WebGLProgram): void;
  109901. _releaseEffect(effect: Effect): void;
  109902. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  109903. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  109904. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  109905. bindSamplers(effect: Effect): void;
  109906. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  109907. getRenderWidth(useScreen?: boolean): number;
  109908. getRenderHeight(useScreen?: boolean): number;
  109909. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  109910. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109911. /**
  109912. * Set the z offset to apply to current rendering
  109913. * @param value defines the offset to apply
  109914. */
  109915. setZOffset(value: number): void;
  109916. /**
  109917. * Gets the current value of the zOffset
  109918. * @returns the current zOffset state
  109919. */
  109920. getZOffset(): number;
  109921. /**
  109922. * Enable or disable depth buffering
  109923. * @param enable defines the state to set
  109924. */
  109925. setDepthBuffer(enable: boolean): void;
  109926. /**
  109927. * Gets a boolean indicating if depth writing is enabled
  109928. * @returns the current depth writing state
  109929. */
  109930. getDepthWrite(): boolean;
  109931. /**
  109932. * Enable or disable depth writing
  109933. * @param enable defines the state to set
  109934. */
  109935. setDepthWrite(enable: boolean): void;
  109936. /**
  109937. * Enable or disable color writing
  109938. * @param enable defines the state to set
  109939. */
  109940. setColorWrite(enable: boolean): void;
  109941. /**
  109942. * Gets a boolean indicating if color writing is enabled
  109943. * @returns the current color writing state
  109944. */
  109945. getColorWrite(): boolean;
  109946. /**
  109947. * Sets alpha constants used by some alpha blending modes
  109948. * @param r defines the red component
  109949. * @param g defines the green component
  109950. * @param b defines the blue component
  109951. * @param a defines the alpha component
  109952. */
  109953. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109954. /**
  109955. * Sets the current alpha mode
  109956. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  109957. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109958. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109959. */
  109960. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109961. /**
  109962. * Gets the current alpha mode
  109963. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109964. * @returns the current alpha mode
  109965. */
  109966. getAlphaMode(): number;
  109967. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109968. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109969. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109970. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109971. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109972. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109973. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109974. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109975. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109976. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109977. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109978. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109979. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109980. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109981. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109982. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109983. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109984. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109985. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109986. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109987. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  109988. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  109989. wipeCaches(bruteForce?: boolean): void;
  109990. _createTexture(): WebGLTexture;
  109991. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  109992. /**
  109993. * Usually called from BABYLON.Texture.ts.
  109994. * Passed information to create a WebGLTexture
  109995. * @param urlArg defines a value which contains one of the following:
  109996. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  109997. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  109998. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  109999. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110000. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  110001. * @param scene needed for loading to the correct scene
  110002. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  110003. * @param onLoad optional callback to be called upon successful completion
  110004. * @param onError optional callback to be called upon failure
  110005. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  110006. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110007. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110008. * @param forcedExtension defines the extension to use to pick the right loader
  110009. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110010. */
  110011. 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;
  110012. /**
  110013. * Creates a cube texture
  110014. * @param rootUrl defines the url where the files to load is located
  110015. * @param scene defines the current scene
  110016. * @param files defines the list of files to load (1 per face)
  110017. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  110018. * @param onLoad defines an optional callback raised when the texture is loaded
  110019. * @param onError defines an optional callback raised if there is an issue to load the texture
  110020. * @param format defines the format of the data
  110021. * @param forcedExtension defines the extension to use to pick the right loader
  110022. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  110023. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  110024. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  110025. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  110026. * @returns the cube texture as an InternalTexture
  110027. */
  110028. 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;
  110029. private _getSamplingFilter;
  110030. private static _GetNativeTextureFormat;
  110031. createRenderTargetTexture(size: number | {
  110032. width: number;
  110033. height: number;
  110034. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110035. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110036. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110037. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110038. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  110039. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110040. /**
  110041. * Updates a dynamic vertex buffer.
  110042. * @param vertexBuffer the vertex buffer to update
  110043. * @param data the data used to update the vertex buffer
  110044. * @param byteOffset the byte offset of the data (optional)
  110045. * @param byteLength the byte length of the data (optional)
  110046. */
  110047. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110048. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  110049. private _updateAnisotropicLevel;
  110050. private _getAddressMode;
  110051. /** @hidden */
  110052. _bindTexture(channel: number, texture: InternalTexture): void;
  110053. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  110054. releaseEffects(): void;
  110055. /** @hidden */
  110056. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110057. /** @hidden */
  110058. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110059. /** @hidden */
  110060. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110061. /** @hidden */
  110062. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110063. }
  110064. }
  110065. declare module BABYLON {
  110066. /**
  110067. * Gather the list of clipboard event types as constants.
  110068. */
  110069. export class ClipboardEventTypes {
  110070. /**
  110071. * The clipboard event is fired when a copy command is active (pressed).
  110072. */
  110073. static readonly COPY: number;
  110074. /**
  110075. * The clipboard event is fired when a cut command is active (pressed).
  110076. */
  110077. static readonly CUT: number;
  110078. /**
  110079. * The clipboard event is fired when a paste command is active (pressed).
  110080. */
  110081. static readonly PASTE: number;
  110082. }
  110083. /**
  110084. * This class is used to store clipboard related info for the onClipboardObservable event.
  110085. */
  110086. export class ClipboardInfo {
  110087. /**
  110088. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110089. */
  110090. type: number;
  110091. /**
  110092. * Defines the related dom event
  110093. */
  110094. event: ClipboardEvent;
  110095. /**
  110096. *Creates an instance of ClipboardInfo.
  110097. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  110098. * @param event Defines the related dom event
  110099. */
  110100. constructor(
  110101. /**
  110102. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110103. */
  110104. type: number,
  110105. /**
  110106. * Defines the related dom event
  110107. */
  110108. event: ClipboardEvent);
  110109. /**
  110110. * Get the clipboard event's type from the keycode.
  110111. * @param keyCode Defines the keyCode for the current keyboard event.
  110112. * @return {number}
  110113. */
  110114. static GetTypeFromCharacter(keyCode: number): number;
  110115. }
  110116. }
  110117. declare module BABYLON {
  110118. /**
  110119. * Google Daydream controller
  110120. */
  110121. export class DaydreamController extends WebVRController {
  110122. /**
  110123. * Base Url for the controller model.
  110124. */
  110125. static MODEL_BASE_URL: string;
  110126. /**
  110127. * File name for the controller model.
  110128. */
  110129. static MODEL_FILENAME: string;
  110130. /**
  110131. * Gamepad Id prefix used to identify Daydream Controller.
  110132. */
  110133. static readonly GAMEPAD_ID_PREFIX: string;
  110134. /**
  110135. * Creates a new DaydreamController from a gamepad
  110136. * @param vrGamepad the gamepad that the controller should be created from
  110137. */
  110138. constructor(vrGamepad: any);
  110139. /**
  110140. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110141. * @param scene scene in which to add meshes
  110142. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110143. */
  110144. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110145. /**
  110146. * Called once for each button that changed state since the last frame
  110147. * @param buttonIdx Which button index changed
  110148. * @param state New state of the button
  110149. * @param changes Which properties on the state changed since last frame
  110150. */
  110151. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110152. }
  110153. }
  110154. declare module BABYLON {
  110155. /**
  110156. * Gear VR Controller
  110157. */
  110158. export class GearVRController extends WebVRController {
  110159. /**
  110160. * Base Url for the controller model.
  110161. */
  110162. static MODEL_BASE_URL: string;
  110163. /**
  110164. * File name for the controller model.
  110165. */
  110166. static MODEL_FILENAME: string;
  110167. /**
  110168. * Gamepad Id prefix used to identify this controller.
  110169. */
  110170. static readonly GAMEPAD_ID_PREFIX: string;
  110171. private readonly _buttonIndexToObservableNameMap;
  110172. /**
  110173. * Creates a new GearVRController from a gamepad
  110174. * @param vrGamepad the gamepad that the controller should be created from
  110175. */
  110176. constructor(vrGamepad: any);
  110177. /**
  110178. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110179. * @param scene scene in which to add meshes
  110180. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110181. */
  110182. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110183. /**
  110184. * Called once for each button that changed state since the last frame
  110185. * @param buttonIdx Which button index changed
  110186. * @param state New state of the button
  110187. * @param changes Which properties on the state changed since last frame
  110188. */
  110189. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110190. }
  110191. }
  110192. declare module BABYLON {
  110193. /**
  110194. * Class containing static functions to help procedurally build meshes
  110195. */
  110196. export class PolyhedronBuilder {
  110197. /**
  110198. * Creates a polyhedron mesh
  110199. * * 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
  110200. * * The parameter `size` (positive float, default 1) sets the polygon size
  110201. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110202. * * 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`
  110203. * * 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
  110204. * * 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)`)
  110205. * * 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
  110206. * * 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
  110207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110210. * @param name defines the name of the mesh
  110211. * @param options defines the options used to create the mesh
  110212. * @param scene defines the hosting scene
  110213. * @returns the polyhedron mesh
  110214. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110215. */
  110216. static CreatePolyhedron(name: string, options: {
  110217. type?: number;
  110218. size?: number;
  110219. sizeX?: number;
  110220. sizeY?: number;
  110221. sizeZ?: number;
  110222. custom?: any;
  110223. faceUV?: Vector4[];
  110224. faceColors?: Color4[];
  110225. flat?: boolean;
  110226. updatable?: boolean;
  110227. sideOrientation?: number;
  110228. frontUVs?: Vector4;
  110229. backUVs?: Vector4;
  110230. }, scene?: Nullable<Scene>): Mesh;
  110231. }
  110232. }
  110233. declare module BABYLON {
  110234. /**
  110235. * Gizmo that enables scaling a mesh along 3 axis
  110236. */
  110237. export class ScaleGizmo extends Gizmo {
  110238. /**
  110239. * Internal gizmo used for interactions on the x axis
  110240. */
  110241. xGizmo: AxisScaleGizmo;
  110242. /**
  110243. * Internal gizmo used for interactions on the y axis
  110244. */
  110245. yGizmo: AxisScaleGizmo;
  110246. /**
  110247. * Internal gizmo used for interactions on the z axis
  110248. */
  110249. zGizmo: AxisScaleGizmo;
  110250. /**
  110251. * Internal gizmo used to scale all axis equally
  110252. */
  110253. uniformScaleGizmo: AxisScaleGizmo;
  110254. private _meshAttached;
  110255. private _updateGizmoRotationToMatchAttachedMesh;
  110256. private _snapDistance;
  110257. private _scaleRatio;
  110258. private _uniformScalingMesh;
  110259. private _octahedron;
  110260. /** Fires an event when any of it's sub gizmos are dragged */
  110261. onDragStartObservable: Observable<unknown>;
  110262. /** Fires an event when any of it's sub gizmos are released from dragging */
  110263. onDragEndObservable: Observable<unknown>;
  110264. attachedMesh: Nullable<AbstractMesh>;
  110265. /**
  110266. * Creates a ScaleGizmo
  110267. * @param gizmoLayer The utility layer the gizmo will be added to
  110268. */
  110269. constructor(gizmoLayer?: UtilityLayerRenderer);
  110270. updateGizmoRotationToMatchAttachedMesh: boolean;
  110271. /**
  110272. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110273. */
  110274. snapDistance: number;
  110275. /**
  110276. * Ratio for the scale of the gizmo (Default: 1)
  110277. */
  110278. scaleRatio: number;
  110279. /**
  110280. * Disposes of the gizmo
  110281. */
  110282. dispose(): void;
  110283. }
  110284. }
  110285. declare module BABYLON {
  110286. /**
  110287. * Single axis scale gizmo
  110288. */
  110289. export class AxisScaleGizmo extends Gizmo {
  110290. /**
  110291. * Drag behavior responsible for the gizmos dragging interactions
  110292. */
  110293. dragBehavior: PointerDragBehavior;
  110294. private _pointerObserver;
  110295. /**
  110296. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110297. */
  110298. snapDistance: number;
  110299. /**
  110300. * Event that fires each time the gizmo snaps to a new location.
  110301. * * snapDistance is the the change in distance
  110302. */
  110303. onSnapObservable: Observable<{
  110304. snapDistance: number;
  110305. }>;
  110306. /**
  110307. * If the scaling operation should be done on all axis (default: false)
  110308. */
  110309. uniformScaling: boolean;
  110310. private _isEnabled;
  110311. private _parent;
  110312. private _arrow;
  110313. private _coloredMaterial;
  110314. private _hoverMaterial;
  110315. /**
  110316. * Creates an AxisScaleGizmo
  110317. * @param gizmoLayer The utility layer the gizmo will be added to
  110318. * @param dragAxis The axis which the gizmo will be able to scale on
  110319. * @param color The color of the gizmo
  110320. */
  110321. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  110322. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110323. /**
  110324. * If the gizmo is enabled
  110325. */
  110326. isEnabled: boolean;
  110327. /**
  110328. * Disposes of the gizmo
  110329. */
  110330. dispose(): void;
  110331. /**
  110332. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110333. * @param mesh The mesh to replace the default mesh of the gizmo
  110334. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110335. */
  110336. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110337. }
  110338. }
  110339. declare module BABYLON {
  110340. /**
  110341. * Bounding box gizmo
  110342. */
  110343. export class BoundingBoxGizmo extends Gizmo {
  110344. private _lineBoundingBox;
  110345. private _rotateSpheresParent;
  110346. private _scaleBoxesParent;
  110347. private _boundingDimensions;
  110348. private _renderObserver;
  110349. private _pointerObserver;
  110350. private _scaleDragSpeed;
  110351. private _tmpQuaternion;
  110352. private _tmpVector;
  110353. private _tmpRotationMatrix;
  110354. /**
  110355. * 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)
  110356. */
  110357. ignoreChildren: boolean;
  110358. /**
  110359. * 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)
  110360. */
  110361. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110362. /**
  110363. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110364. */
  110365. rotationSphereSize: number;
  110366. /**
  110367. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110368. */
  110369. scaleBoxSize: number;
  110370. /**
  110371. * 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)
  110372. */
  110373. fixedDragMeshScreenSize: boolean;
  110374. /**
  110375. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110376. */
  110377. fixedDragMeshScreenSizeDistanceFactor: number;
  110378. /**
  110379. * Fired when a rotation sphere or scale box is dragged
  110380. */
  110381. onDragStartObservable: Observable<{}>;
  110382. /**
  110383. * Fired when a scale box is dragged
  110384. */
  110385. onScaleBoxDragObservable: Observable<{}>;
  110386. /**
  110387. * Fired when a scale box drag is ended
  110388. */
  110389. onScaleBoxDragEndObservable: Observable<{}>;
  110390. /**
  110391. * Fired when a rotation sphere is dragged
  110392. */
  110393. onRotationSphereDragObservable: Observable<{}>;
  110394. /**
  110395. * Fired when a rotation sphere drag is ended
  110396. */
  110397. onRotationSphereDragEndObservable: Observable<{}>;
  110398. /**
  110399. * 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)
  110400. */
  110401. scalePivot: Nullable<Vector3>;
  110402. /**
  110403. * Mesh used as a pivot to rotate the attached mesh
  110404. */
  110405. private _anchorMesh;
  110406. private _existingMeshScale;
  110407. private _dragMesh;
  110408. private pointerDragBehavior;
  110409. private coloredMaterial;
  110410. private hoverColoredMaterial;
  110411. /**
  110412. * Sets the color of the bounding box gizmo
  110413. * @param color the color to set
  110414. */
  110415. setColor(color: Color3): void;
  110416. /**
  110417. * Creates an BoundingBoxGizmo
  110418. * @param gizmoLayer The utility layer the gizmo will be added to
  110419. * @param color The color of the gizmo
  110420. */
  110421. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110422. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110423. private _selectNode;
  110424. /**
  110425. * Updates the bounding box information for the Gizmo
  110426. */
  110427. updateBoundingBox(): void;
  110428. private _updateRotationSpheres;
  110429. private _updateScaleBoxes;
  110430. /**
  110431. * Enables rotation on the specified axis and disables rotation on the others
  110432. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110433. */
  110434. setEnabledRotationAxis(axis: string): void;
  110435. /**
  110436. * Enables/disables scaling
  110437. * @param enable if scaling should be enabled
  110438. */
  110439. setEnabledScaling(enable: boolean): void;
  110440. private _updateDummy;
  110441. /**
  110442. * Enables a pointer drag behavior on the bounding box of the gizmo
  110443. */
  110444. enableDragBehavior(): void;
  110445. /**
  110446. * Disposes of the gizmo
  110447. */
  110448. dispose(): void;
  110449. /**
  110450. * 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)
  110451. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110452. * @returns the bounding box mesh with the passed in mesh as a child
  110453. */
  110454. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110455. /**
  110456. * CustomMeshes are not supported by this gizmo
  110457. * @param mesh The mesh to replace the default mesh of the gizmo
  110458. */
  110459. setCustomMesh(mesh: Mesh): void;
  110460. }
  110461. }
  110462. declare module BABYLON {
  110463. /**
  110464. * Single plane rotation gizmo
  110465. */
  110466. export class PlaneRotationGizmo extends Gizmo {
  110467. /**
  110468. * Drag behavior responsible for the gizmos dragging interactions
  110469. */
  110470. dragBehavior: PointerDragBehavior;
  110471. private _pointerObserver;
  110472. /**
  110473. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110474. */
  110475. snapDistance: number;
  110476. /**
  110477. * Event that fires each time the gizmo snaps to a new location.
  110478. * * snapDistance is the the change in distance
  110479. */
  110480. onSnapObservable: Observable<{
  110481. snapDistance: number;
  110482. }>;
  110483. private _isEnabled;
  110484. private _parent;
  110485. /**
  110486. * Creates a PlaneRotationGizmo
  110487. * @param gizmoLayer The utility layer the gizmo will be added to
  110488. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110489. * @param color The color of the gizmo
  110490. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110491. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110492. */
  110493. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110494. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110495. /**
  110496. * If the gizmo is enabled
  110497. */
  110498. isEnabled: boolean;
  110499. /**
  110500. * Disposes of the gizmo
  110501. */
  110502. dispose(): void;
  110503. }
  110504. }
  110505. declare module BABYLON {
  110506. /**
  110507. * Gizmo that enables rotating a mesh along 3 axis
  110508. */
  110509. export class RotationGizmo extends Gizmo {
  110510. /**
  110511. * Internal gizmo used for interactions on the x axis
  110512. */
  110513. xGizmo: PlaneRotationGizmo;
  110514. /**
  110515. * Internal gizmo used for interactions on the y axis
  110516. */
  110517. yGizmo: PlaneRotationGizmo;
  110518. /**
  110519. * Internal gizmo used for interactions on the z axis
  110520. */
  110521. zGizmo: PlaneRotationGizmo;
  110522. /** Fires an event when any of it's sub gizmos are dragged */
  110523. onDragStartObservable: Observable<unknown>;
  110524. /** Fires an event when any of it's sub gizmos are released from dragging */
  110525. onDragEndObservable: Observable<unknown>;
  110526. private _meshAttached;
  110527. attachedMesh: Nullable<AbstractMesh>;
  110528. /**
  110529. * Creates a RotationGizmo
  110530. * @param gizmoLayer The utility layer the gizmo will be added to
  110531. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110532. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110533. */
  110534. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110535. updateGizmoRotationToMatchAttachedMesh: boolean;
  110536. /**
  110537. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110538. */
  110539. snapDistance: number;
  110540. /**
  110541. * Ratio for the scale of the gizmo (Default: 1)
  110542. */
  110543. scaleRatio: number;
  110544. /**
  110545. * Disposes of the gizmo
  110546. */
  110547. dispose(): void;
  110548. /**
  110549. * CustomMeshes are not supported by this gizmo
  110550. * @param mesh The mesh to replace the default mesh of the gizmo
  110551. */
  110552. setCustomMesh(mesh: Mesh): void;
  110553. }
  110554. }
  110555. declare module BABYLON {
  110556. /**
  110557. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110558. */
  110559. export class GizmoManager implements IDisposable {
  110560. private scene;
  110561. /**
  110562. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110563. */
  110564. gizmos: {
  110565. positionGizmo: Nullable<PositionGizmo>;
  110566. rotationGizmo: Nullable<RotationGizmo>;
  110567. scaleGizmo: Nullable<ScaleGizmo>;
  110568. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110569. };
  110570. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110571. clearGizmoOnEmptyPointerEvent: boolean;
  110572. /** Fires an event when the manager is attached to a mesh */
  110573. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110574. private _gizmosEnabled;
  110575. private _pointerObserver;
  110576. private _attachedMesh;
  110577. private _boundingBoxColor;
  110578. private _defaultUtilityLayer;
  110579. private _defaultKeepDepthUtilityLayer;
  110580. /**
  110581. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110582. */
  110583. boundingBoxDragBehavior: SixDofDragBehavior;
  110584. /**
  110585. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110586. */
  110587. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110588. /**
  110589. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110590. */
  110591. usePointerToAttachGizmos: boolean;
  110592. /**
  110593. * Utility layer that the bounding box gizmo belongs to
  110594. */
  110595. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110596. /**
  110597. * Utility layer that all gizmos besides bounding box belong to
  110598. */
  110599. readonly utilityLayer: UtilityLayerRenderer;
  110600. /**
  110601. * Instatiates a gizmo manager
  110602. * @param scene the scene to overlay the gizmos on top of
  110603. */
  110604. constructor(scene: Scene);
  110605. /**
  110606. * Attaches a set of gizmos to the specified mesh
  110607. * @param mesh The mesh the gizmo's should be attached to
  110608. */
  110609. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110610. /**
  110611. * If the position gizmo is enabled
  110612. */
  110613. positionGizmoEnabled: boolean;
  110614. /**
  110615. * If the rotation gizmo is enabled
  110616. */
  110617. rotationGizmoEnabled: boolean;
  110618. /**
  110619. * If the scale gizmo is enabled
  110620. */
  110621. scaleGizmoEnabled: boolean;
  110622. /**
  110623. * If the boundingBox gizmo is enabled
  110624. */
  110625. boundingBoxGizmoEnabled: boolean;
  110626. /**
  110627. * Disposes of the gizmo manager
  110628. */
  110629. dispose(): void;
  110630. }
  110631. }
  110632. declare module BABYLON {
  110633. /**
  110634. * A directional light is defined by a direction (what a surprise!).
  110635. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110636. * 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.
  110637. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110638. */
  110639. export class DirectionalLight extends ShadowLight {
  110640. private _shadowFrustumSize;
  110641. /**
  110642. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110643. */
  110644. /**
  110645. * Specifies a fix frustum size for the shadow generation.
  110646. */
  110647. shadowFrustumSize: number;
  110648. private _shadowOrthoScale;
  110649. /**
  110650. * Gets the shadow projection scale against the optimal computed one.
  110651. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110652. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110653. */
  110654. /**
  110655. * Sets the shadow projection scale against the optimal computed one.
  110656. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110657. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110658. */
  110659. shadowOrthoScale: number;
  110660. /**
  110661. * Automatically compute the projection matrix to best fit (including all the casters)
  110662. * on each frame.
  110663. */
  110664. autoUpdateExtends: boolean;
  110665. private _orthoLeft;
  110666. private _orthoRight;
  110667. private _orthoTop;
  110668. private _orthoBottom;
  110669. /**
  110670. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110671. * The directional light is emitted from everywhere in the given direction.
  110672. * It can cast shadows.
  110673. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110674. * @param name The friendly name of the light
  110675. * @param direction The direction of the light
  110676. * @param scene The scene the light belongs to
  110677. */
  110678. constructor(name: string, direction: Vector3, scene: Scene);
  110679. /**
  110680. * Returns the string "DirectionalLight".
  110681. * @return The class name
  110682. */
  110683. getClassName(): string;
  110684. /**
  110685. * Returns the integer 1.
  110686. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110687. */
  110688. getTypeID(): number;
  110689. /**
  110690. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110691. * Returns the DirectionalLight Shadow projection matrix.
  110692. */
  110693. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110694. /**
  110695. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110696. * Returns the DirectionalLight Shadow projection matrix.
  110697. */
  110698. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110699. /**
  110700. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110701. * Returns the DirectionalLight Shadow projection matrix.
  110702. */
  110703. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110704. protected _buildUniformLayout(): void;
  110705. /**
  110706. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110707. * @param effect The effect to update
  110708. * @param lightIndex The index of the light in the effect to update
  110709. * @returns The directional light
  110710. */
  110711. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110712. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110713. /**
  110714. * Gets the minZ used for shadow according to both the scene and the light.
  110715. *
  110716. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110717. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110718. * @param activeCamera The camera we are returning the min for
  110719. * @returns the depth min z
  110720. */
  110721. getDepthMinZ(activeCamera: Camera): number;
  110722. /**
  110723. * Gets the maxZ used for shadow according to both the scene and the light.
  110724. *
  110725. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110726. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110727. * @param activeCamera The camera we are returning the max for
  110728. * @returns the depth max z
  110729. */
  110730. getDepthMaxZ(activeCamera: Camera): number;
  110731. /**
  110732. * Prepares the list of defines specific to the light type.
  110733. * @param defines the list of defines
  110734. * @param lightIndex defines the index of the light for the effect
  110735. */
  110736. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110737. }
  110738. }
  110739. declare module BABYLON {
  110740. /**
  110741. * Class containing static functions to help procedurally build meshes
  110742. */
  110743. export class HemisphereBuilder {
  110744. /**
  110745. * Creates a hemisphere mesh
  110746. * @param name defines the name of the mesh
  110747. * @param options defines the options used to create the mesh
  110748. * @param scene defines the hosting scene
  110749. * @returns the hemisphere mesh
  110750. */
  110751. static CreateHemisphere(name: string, options: {
  110752. segments?: number;
  110753. diameter?: number;
  110754. sideOrientation?: number;
  110755. }, scene: any): Mesh;
  110756. }
  110757. }
  110758. declare module BABYLON {
  110759. /**
  110760. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110761. * These values define a cone of light starting from the position, emitting toward the direction.
  110762. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110763. * and the exponent defines the speed of the decay of the light with distance (reach).
  110764. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110765. */
  110766. export class SpotLight extends ShadowLight {
  110767. private _angle;
  110768. private _innerAngle;
  110769. private _cosHalfAngle;
  110770. private _lightAngleScale;
  110771. private _lightAngleOffset;
  110772. /**
  110773. * Gets the cone angle of the spot light in Radians.
  110774. */
  110775. /**
  110776. * Sets the cone angle of the spot light in Radians.
  110777. */
  110778. angle: number;
  110779. /**
  110780. * Only used in gltf falloff mode, this defines the angle where
  110781. * the directional falloff will start before cutting at angle which could be seen
  110782. * as outer angle.
  110783. */
  110784. /**
  110785. * Only used in gltf falloff mode, this defines the angle where
  110786. * the directional falloff will start before cutting at angle which could be seen
  110787. * as outer angle.
  110788. */
  110789. innerAngle: number;
  110790. private _shadowAngleScale;
  110791. /**
  110792. * Allows scaling the angle of the light for shadow generation only.
  110793. */
  110794. /**
  110795. * Allows scaling the angle of the light for shadow generation only.
  110796. */
  110797. shadowAngleScale: number;
  110798. /**
  110799. * The light decay speed with the distance from the emission spot.
  110800. */
  110801. exponent: number;
  110802. private _projectionTextureMatrix;
  110803. /**
  110804. * Allows reading the projecton texture
  110805. */
  110806. readonly projectionTextureMatrix: Matrix;
  110807. protected _projectionTextureLightNear: number;
  110808. /**
  110809. * Gets the near clip of the Spotlight for texture projection.
  110810. */
  110811. /**
  110812. * Sets the near clip of the Spotlight for texture projection.
  110813. */
  110814. projectionTextureLightNear: number;
  110815. protected _projectionTextureLightFar: number;
  110816. /**
  110817. * Gets the far clip of the Spotlight for texture projection.
  110818. */
  110819. /**
  110820. * Sets the far clip of the Spotlight for texture projection.
  110821. */
  110822. projectionTextureLightFar: number;
  110823. protected _projectionTextureUpDirection: Vector3;
  110824. /**
  110825. * Gets the Up vector of the Spotlight for texture projection.
  110826. */
  110827. /**
  110828. * Sets the Up vector of the Spotlight for texture projection.
  110829. */
  110830. projectionTextureUpDirection: Vector3;
  110831. private _projectionTexture;
  110832. /**
  110833. * Gets the projection texture of the light.
  110834. */
  110835. /**
  110836. * Sets the projection texture of the light.
  110837. */
  110838. projectionTexture: Nullable<BaseTexture>;
  110839. private _projectionTextureViewLightDirty;
  110840. private _projectionTextureProjectionLightDirty;
  110841. private _projectionTextureDirty;
  110842. private _projectionTextureViewTargetVector;
  110843. private _projectionTextureViewLightMatrix;
  110844. private _projectionTextureProjectionLightMatrix;
  110845. private _projectionTextureScalingMatrix;
  110846. /**
  110847. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110848. * It can cast shadows.
  110849. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110850. * @param name The light friendly name
  110851. * @param position The position of the spot light in the scene
  110852. * @param direction The direction of the light in the scene
  110853. * @param angle The cone angle of the light in Radians
  110854. * @param exponent The light decay speed with the distance from the emission spot
  110855. * @param scene The scene the lights belongs to
  110856. */
  110857. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  110858. /**
  110859. * Returns the string "SpotLight".
  110860. * @returns the class name
  110861. */
  110862. getClassName(): string;
  110863. /**
  110864. * Returns the integer 2.
  110865. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110866. */
  110867. getTypeID(): number;
  110868. /**
  110869. * Overrides the direction setter to recompute the projection texture view light Matrix.
  110870. */
  110871. protected _setDirection(value: Vector3): void;
  110872. /**
  110873. * Overrides the position setter to recompute the projection texture view light Matrix.
  110874. */
  110875. protected _setPosition(value: Vector3): void;
  110876. /**
  110877. * 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.
  110878. * Returns the SpotLight.
  110879. */
  110880. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110881. protected _computeProjectionTextureViewLightMatrix(): void;
  110882. protected _computeProjectionTextureProjectionLightMatrix(): void;
  110883. /**
  110884. * Main function for light texture projection matrix computing.
  110885. */
  110886. protected _computeProjectionTextureMatrix(): void;
  110887. protected _buildUniformLayout(): void;
  110888. private _computeAngleValues;
  110889. /**
  110890. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  110891. * @param effect The effect to update
  110892. * @param lightIndex The index of the light in the effect to update
  110893. * @returns The spot light
  110894. */
  110895. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  110896. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  110897. /**
  110898. * Disposes the light and the associated resources.
  110899. */
  110900. dispose(): void;
  110901. /**
  110902. * Prepares the list of defines specific to the light type.
  110903. * @param defines the list of defines
  110904. * @param lightIndex defines the index of the light for the effect
  110905. */
  110906. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110907. }
  110908. }
  110909. declare module BABYLON {
  110910. /**
  110911. * Gizmo that enables viewing a light
  110912. */
  110913. export class LightGizmo extends Gizmo {
  110914. private _lightMesh;
  110915. private _material;
  110916. private cachedPosition;
  110917. private cachedForward;
  110918. /**
  110919. * Creates a LightGizmo
  110920. * @param gizmoLayer The utility layer the gizmo will be added to
  110921. */
  110922. constructor(gizmoLayer?: UtilityLayerRenderer);
  110923. private _light;
  110924. /**
  110925. * The light that the gizmo is attached to
  110926. */
  110927. light: Nullable<Light>;
  110928. /**
  110929. * Gets the material used to render the light gizmo
  110930. */
  110931. readonly material: StandardMaterial;
  110932. /**
  110933. * @hidden
  110934. * Updates the gizmo to match the attached mesh's position/rotation
  110935. */
  110936. protected _update(): void;
  110937. private static _Scale;
  110938. /**
  110939. * Creates the lines for a light mesh
  110940. */
  110941. private static _createLightLines;
  110942. /**
  110943. * Disposes of the light gizmo
  110944. */
  110945. dispose(): void;
  110946. private static _CreateHemisphericLightMesh;
  110947. private static _CreatePointLightMesh;
  110948. private static _CreateSpotLightMesh;
  110949. private static _CreateDirectionalLightMesh;
  110950. }
  110951. }
  110952. declare module BABYLON {
  110953. /** @hidden */
  110954. export var backgroundFragmentDeclaration: {
  110955. name: string;
  110956. shader: string;
  110957. };
  110958. }
  110959. declare module BABYLON {
  110960. /** @hidden */
  110961. export var backgroundUboDeclaration: {
  110962. name: string;
  110963. shader: string;
  110964. };
  110965. }
  110966. declare module BABYLON {
  110967. /** @hidden */
  110968. export var backgroundPixelShader: {
  110969. name: string;
  110970. shader: string;
  110971. };
  110972. }
  110973. declare module BABYLON {
  110974. /** @hidden */
  110975. export var backgroundVertexDeclaration: {
  110976. name: string;
  110977. shader: string;
  110978. };
  110979. }
  110980. declare module BABYLON {
  110981. /** @hidden */
  110982. export var backgroundVertexShader: {
  110983. name: string;
  110984. shader: string;
  110985. };
  110986. }
  110987. declare module BABYLON {
  110988. /**
  110989. * Background material used to create an efficient environement around your scene.
  110990. */
  110991. export class BackgroundMaterial extends PushMaterial {
  110992. /**
  110993. * Standard reflectance value at parallel view angle.
  110994. */
  110995. static StandardReflectance0: number;
  110996. /**
  110997. * Standard reflectance value at grazing angle.
  110998. */
  110999. static StandardReflectance90: number;
  111000. protected _primaryColor: Color3;
  111001. /**
  111002. * Key light Color (multiply against the environement texture)
  111003. */
  111004. primaryColor: Color3;
  111005. protected __perceptualColor: Nullable<Color3>;
  111006. /**
  111007. * Experimental Internal Use Only.
  111008. *
  111009. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  111010. * This acts as a helper to set the primary color to a more "human friendly" value.
  111011. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  111012. * output color as close as possible from the chosen value.
  111013. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  111014. * part of lighting setup.)
  111015. */
  111016. _perceptualColor: Nullable<Color3>;
  111017. protected _primaryColorShadowLevel: float;
  111018. /**
  111019. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  111020. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  111021. */
  111022. primaryColorShadowLevel: float;
  111023. protected _primaryColorHighlightLevel: float;
  111024. /**
  111025. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  111026. * The primary color is used at the level chosen to define what the white area would look.
  111027. */
  111028. primaryColorHighlightLevel: float;
  111029. protected _reflectionTexture: Nullable<BaseTexture>;
  111030. /**
  111031. * Reflection Texture used in the material.
  111032. * Should be author in a specific way for the best result (refer to the documentation).
  111033. */
  111034. reflectionTexture: Nullable<BaseTexture>;
  111035. protected _reflectionBlur: float;
  111036. /**
  111037. * Reflection Texture level of blur.
  111038. *
  111039. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  111040. * texture twice.
  111041. */
  111042. reflectionBlur: float;
  111043. protected _diffuseTexture: Nullable<BaseTexture>;
  111044. /**
  111045. * Diffuse Texture used in the material.
  111046. * Should be author in a specific way for the best result (refer to the documentation).
  111047. */
  111048. diffuseTexture: Nullable<BaseTexture>;
  111049. protected _shadowLights: Nullable<IShadowLight[]>;
  111050. /**
  111051. * Specify the list of lights casting shadow on the material.
  111052. * All scene shadow lights will be included if null.
  111053. */
  111054. shadowLights: Nullable<IShadowLight[]>;
  111055. protected _shadowLevel: float;
  111056. /**
  111057. * Helps adjusting the shadow to a softer level if required.
  111058. * 0 means black shadows and 1 means no shadows.
  111059. */
  111060. shadowLevel: float;
  111061. protected _sceneCenter: Vector3;
  111062. /**
  111063. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  111064. * It is usually zero but might be interesting to modify according to your setup.
  111065. */
  111066. sceneCenter: Vector3;
  111067. protected _opacityFresnel: boolean;
  111068. /**
  111069. * This helps specifying that the material is falling off to the sky box at grazing angle.
  111070. * This helps ensuring a nice transition when the camera goes under the ground.
  111071. */
  111072. opacityFresnel: boolean;
  111073. protected _reflectionFresnel: boolean;
  111074. /**
  111075. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  111076. * This helps adding a mirror texture on the ground.
  111077. */
  111078. reflectionFresnel: boolean;
  111079. protected _reflectionFalloffDistance: number;
  111080. /**
  111081. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  111082. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  111083. */
  111084. reflectionFalloffDistance: number;
  111085. protected _reflectionAmount: number;
  111086. /**
  111087. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  111088. */
  111089. reflectionAmount: number;
  111090. protected _reflectionReflectance0: number;
  111091. /**
  111092. * This specifies the weight of the reflection at grazing angle.
  111093. */
  111094. reflectionReflectance0: number;
  111095. protected _reflectionReflectance90: number;
  111096. /**
  111097. * This specifies the weight of the reflection at a perpendicular point of view.
  111098. */
  111099. reflectionReflectance90: number;
  111100. /**
  111101. * Sets the reflection reflectance fresnel values according to the default standard
  111102. * empirically know to work well :-)
  111103. */
  111104. reflectionStandardFresnelWeight: number;
  111105. protected _useRGBColor: boolean;
  111106. /**
  111107. * Helps to directly use the maps channels instead of their level.
  111108. */
  111109. useRGBColor: boolean;
  111110. protected _enableNoise: boolean;
  111111. /**
  111112. * This helps reducing the banding effect that could occur on the background.
  111113. */
  111114. enableNoise: boolean;
  111115. /**
  111116. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111117. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  111118. * Recommended to be keep at 1.0 except for special cases.
  111119. */
  111120. fovMultiplier: number;
  111121. private _fovMultiplier;
  111122. /**
  111123. * Enable the FOV adjustment feature controlled by fovMultiplier.
  111124. */
  111125. useEquirectangularFOV: boolean;
  111126. private _maxSimultaneousLights;
  111127. /**
  111128. * Number of Simultaneous lights allowed on the material.
  111129. */
  111130. maxSimultaneousLights: int;
  111131. /**
  111132. * Default configuration related to image processing available in the Background Material.
  111133. */
  111134. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111135. /**
  111136. * Keep track of the image processing observer to allow dispose and replace.
  111137. */
  111138. private _imageProcessingObserver;
  111139. /**
  111140. * Attaches a new image processing configuration to the PBR Material.
  111141. * @param configuration (if null the scene configuration will be use)
  111142. */
  111143. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111144. /**
  111145. * Gets the image processing configuration used either in this material.
  111146. */
  111147. /**
  111148. * Sets the Default image processing configuration used either in the this material.
  111149. *
  111150. * If sets to null, the scene one is in use.
  111151. */
  111152. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  111153. /**
  111154. * Gets wether the color curves effect is enabled.
  111155. */
  111156. /**
  111157. * Sets wether the color curves effect is enabled.
  111158. */
  111159. cameraColorCurvesEnabled: boolean;
  111160. /**
  111161. * Gets wether the color grading effect is enabled.
  111162. */
  111163. /**
  111164. * Gets wether the color grading effect is enabled.
  111165. */
  111166. cameraColorGradingEnabled: boolean;
  111167. /**
  111168. * Gets wether tonemapping is enabled or not.
  111169. */
  111170. /**
  111171. * Sets wether tonemapping is enabled or not
  111172. */
  111173. cameraToneMappingEnabled: boolean;
  111174. /**
  111175. * The camera exposure used on this material.
  111176. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111177. * This corresponds to a photographic exposure.
  111178. */
  111179. /**
  111180. * The camera exposure used on this material.
  111181. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111182. * This corresponds to a photographic exposure.
  111183. */
  111184. cameraExposure: float;
  111185. /**
  111186. * Gets The camera contrast used on this material.
  111187. */
  111188. /**
  111189. * Sets The camera contrast used on this material.
  111190. */
  111191. cameraContrast: float;
  111192. /**
  111193. * Gets the Color Grading 2D Lookup Texture.
  111194. */
  111195. /**
  111196. * Sets the Color Grading 2D Lookup Texture.
  111197. */
  111198. cameraColorGradingTexture: Nullable<BaseTexture>;
  111199. /**
  111200. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111201. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111202. * 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;
  111203. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111204. */
  111205. /**
  111206. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111207. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111208. * 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;
  111209. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111210. */
  111211. cameraColorCurves: Nullable<ColorCurves>;
  111212. /**
  111213. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  111214. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  111215. */
  111216. switchToBGR: boolean;
  111217. private _renderTargets;
  111218. private _reflectionControls;
  111219. private _white;
  111220. private _primaryShadowColor;
  111221. private _primaryHighlightColor;
  111222. /**
  111223. * Instantiates a Background Material in the given scene
  111224. * @param name The friendly name of the material
  111225. * @param scene The scene to add the material to
  111226. */
  111227. constructor(name: string, scene: Scene);
  111228. /**
  111229. * Gets a boolean indicating that current material needs to register RTT
  111230. */
  111231. readonly hasRenderTargetTextures: boolean;
  111232. /**
  111233. * The entire material has been created in order to prevent overdraw.
  111234. * @returns false
  111235. */
  111236. needAlphaTesting(): boolean;
  111237. /**
  111238. * The entire material has been created in order to prevent overdraw.
  111239. * @returns true if blending is enable
  111240. */
  111241. needAlphaBlending(): boolean;
  111242. /**
  111243. * Checks wether the material is ready to be rendered for a given mesh.
  111244. * @param mesh The mesh to render
  111245. * @param subMesh The submesh to check against
  111246. * @param useInstances Specify wether or not the material is used with instances
  111247. * @returns true if all the dependencies are ready (Textures, Effects...)
  111248. */
  111249. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111250. /**
  111251. * Compute the primary color according to the chosen perceptual color.
  111252. */
  111253. private _computePrimaryColorFromPerceptualColor;
  111254. /**
  111255. * Compute the highlights and shadow colors according to their chosen levels.
  111256. */
  111257. private _computePrimaryColors;
  111258. /**
  111259. * Build the uniform buffer used in the material.
  111260. */
  111261. buildUniformLayout(): void;
  111262. /**
  111263. * Unbind the material.
  111264. */
  111265. unbind(): void;
  111266. /**
  111267. * Bind only the world matrix to the material.
  111268. * @param world The world matrix to bind.
  111269. */
  111270. bindOnlyWorldMatrix(world: Matrix): void;
  111271. /**
  111272. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  111273. * @param world The world matrix to bind.
  111274. * @param subMesh The submesh to bind for.
  111275. */
  111276. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111277. /**
  111278. * Checks to see if a texture is used in the material.
  111279. * @param texture - Base texture to use.
  111280. * @returns - Boolean specifying if a texture is used in the material.
  111281. */
  111282. hasTexture(texture: BaseTexture): boolean;
  111283. /**
  111284. * Dispose the material.
  111285. * @param forceDisposeEffect Force disposal of the associated effect.
  111286. * @param forceDisposeTextures Force disposal of the associated textures.
  111287. */
  111288. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111289. /**
  111290. * Clones the material.
  111291. * @param name The cloned name.
  111292. * @returns The cloned material.
  111293. */
  111294. clone(name: string): BackgroundMaterial;
  111295. /**
  111296. * Serializes the current material to its JSON representation.
  111297. * @returns The JSON representation.
  111298. */
  111299. serialize(): any;
  111300. /**
  111301. * Gets the class name of the material
  111302. * @returns "BackgroundMaterial"
  111303. */
  111304. getClassName(): string;
  111305. /**
  111306. * Parse a JSON input to create back a background material.
  111307. * @param source The JSON data to parse
  111308. * @param scene The scene to create the parsed material in
  111309. * @param rootUrl The root url of the assets the material depends upon
  111310. * @returns the instantiated BackgroundMaterial.
  111311. */
  111312. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  111313. }
  111314. }
  111315. declare module BABYLON {
  111316. /**
  111317. * Represents the different options available during the creation of
  111318. * a Environment helper.
  111319. *
  111320. * This can control the default ground, skybox and image processing setup of your scene.
  111321. */
  111322. export interface IEnvironmentHelperOptions {
  111323. /**
  111324. * Specifies wether or not to create a ground.
  111325. * True by default.
  111326. */
  111327. createGround: boolean;
  111328. /**
  111329. * Specifies the ground size.
  111330. * 15 by default.
  111331. */
  111332. groundSize: number;
  111333. /**
  111334. * The texture used on the ground for the main color.
  111335. * Comes from the BabylonJS CDN by default.
  111336. *
  111337. * Remarks: Can be either a texture or a url.
  111338. */
  111339. groundTexture: string | BaseTexture;
  111340. /**
  111341. * The color mixed in the ground texture by default.
  111342. * BabylonJS clearColor by default.
  111343. */
  111344. groundColor: Color3;
  111345. /**
  111346. * Specifies the ground opacity.
  111347. * 1 by default.
  111348. */
  111349. groundOpacity: number;
  111350. /**
  111351. * Enables the ground to receive shadows.
  111352. * True by default.
  111353. */
  111354. enableGroundShadow: boolean;
  111355. /**
  111356. * Helps preventing the shadow to be fully black on the ground.
  111357. * 0.5 by default.
  111358. */
  111359. groundShadowLevel: number;
  111360. /**
  111361. * Creates a mirror texture attach to the ground.
  111362. * false by default.
  111363. */
  111364. enableGroundMirror: boolean;
  111365. /**
  111366. * Specifies the ground mirror size ratio.
  111367. * 0.3 by default as the default kernel is 64.
  111368. */
  111369. groundMirrorSizeRatio: number;
  111370. /**
  111371. * Specifies the ground mirror blur kernel size.
  111372. * 64 by default.
  111373. */
  111374. groundMirrorBlurKernel: number;
  111375. /**
  111376. * Specifies the ground mirror visibility amount.
  111377. * 1 by default
  111378. */
  111379. groundMirrorAmount: number;
  111380. /**
  111381. * Specifies the ground mirror reflectance weight.
  111382. * This uses the standard weight of the background material to setup the fresnel effect
  111383. * of the mirror.
  111384. * 1 by default.
  111385. */
  111386. groundMirrorFresnelWeight: number;
  111387. /**
  111388. * Specifies the ground mirror Falloff distance.
  111389. * This can helps reducing the size of the reflection.
  111390. * 0 by Default.
  111391. */
  111392. groundMirrorFallOffDistance: number;
  111393. /**
  111394. * Specifies the ground mirror texture type.
  111395. * Unsigned Int by Default.
  111396. */
  111397. groundMirrorTextureType: number;
  111398. /**
  111399. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111400. * the shown objects.
  111401. */
  111402. groundYBias: number;
  111403. /**
  111404. * Specifies wether or not to create a skybox.
  111405. * True by default.
  111406. */
  111407. createSkybox: boolean;
  111408. /**
  111409. * Specifies the skybox size.
  111410. * 20 by default.
  111411. */
  111412. skyboxSize: number;
  111413. /**
  111414. * The texture used on the skybox for the main color.
  111415. * Comes from the BabylonJS CDN by default.
  111416. *
  111417. * Remarks: Can be either a texture or a url.
  111418. */
  111419. skyboxTexture: string | BaseTexture;
  111420. /**
  111421. * The color mixed in the skybox texture by default.
  111422. * BabylonJS clearColor by default.
  111423. */
  111424. skyboxColor: Color3;
  111425. /**
  111426. * The background rotation around the Y axis of the scene.
  111427. * This helps aligning the key lights of your scene with the background.
  111428. * 0 by default.
  111429. */
  111430. backgroundYRotation: number;
  111431. /**
  111432. * Compute automatically the size of the elements to best fit with the scene.
  111433. */
  111434. sizeAuto: boolean;
  111435. /**
  111436. * Default position of the rootMesh if autoSize is not true.
  111437. */
  111438. rootPosition: Vector3;
  111439. /**
  111440. * Sets up the image processing in the scene.
  111441. * true by default.
  111442. */
  111443. setupImageProcessing: boolean;
  111444. /**
  111445. * The texture used as your environment texture in the scene.
  111446. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111447. *
  111448. * Remarks: Can be either a texture or a url.
  111449. */
  111450. environmentTexture: string | BaseTexture;
  111451. /**
  111452. * The value of the exposure to apply to the scene.
  111453. * 0.6 by default if setupImageProcessing is true.
  111454. */
  111455. cameraExposure: number;
  111456. /**
  111457. * The value of the contrast to apply to the scene.
  111458. * 1.6 by default if setupImageProcessing is true.
  111459. */
  111460. cameraContrast: number;
  111461. /**
  111462. * Specifies wether or not tonemapping should be enabled in the scene.
  111463. * true by default if setupImageProcessing is true.
  111464. */
  111465. toneMappingEnabled: boolean;
  111466. }
  111467. /**
  111468. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111469. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111470. * It also helps with the default setup of your imageProcessing configuration.
  111471. */
  111472. export class EnvironmentHelper {
  111473. /**
  111474. * Default ground texture URL.
  111475. */
  111476. private static _groundTextureCDNUrl;
  111477. /**
  111478. * Default skybox texture URL.
  111479. */
  111480. private static _skyboxTextureCDNUrl;
  111481. /**
  111482. * Default environment texture URL.
  111483. */
  111484. private static _environmentTextureCDNUrl;
  111485. /**
  111486. * Creates the default options for the helper.
  111487. */
  111488. private static _getDefaultOptions;
  111489. private _rootMesh;
  111490. /**
  111491. * Gets the root mesh created by the helper.
  111492. */
  111493. readonly rootMesh: Mesh;
  111494. private _skybox;
  111495. /**
  111496. * Gets the skybox created by the helper.
  111497. */
  111498. readonly skybox: Nullable<Mesh>;
  111499. private _skyboxTexture;
  111500. /**
  111501. * Gets the skybox texture created by the helper.
  111502. */
  111503. readonly skyboxTexture: Nullable<BaseTexture>;
  111504. private _skyboxMaterial;
  111505. /**
  111506. * Gets the skybox material created by the helper.
  111507. */
  111508. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111509. private _ground;
  111510. /**
  111511. * Gets the ground mesh created by the helper.
  111512. */
  111513. readonly ground: Nullable<Mesh>;
  111514. private _groundTexture;
  111515. /**
  111516. * Gets the ground texture created by the helper.
  111517. */
  111518. readonly groundTexture: Nullable<BaseTexture>;
  111519. private _groundMirror;
  111520. /**
  111521. * Gets the ground mirror created by the helper.
  111522. */
  111523. readonly groundMirror: Nullable<MirrorTexture>;
  111524. /**
  111525. * Gets the ground mirror render list to helps pushing the meshes
  111526. * you wish in the ground reflection.
  111527. */
  111528. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111529. private _groundMaterial;
  111530. /**
  111531. * Gets the ground material created by the helper.
  111532. */
  111533. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111534. /**
  111535. * Stores the creation options.
  111536. */
  111537. private readonly _scene;
  111538. private _options;
  111539. /**
  111540. * This observable will be notified with any error during the creation of the environment,
  111541. * mainly texture creation errors.
  111542. */
  111543. onErrorObservable: Observable<{
  111544. message?: string;
  111545. exception?: any;
  111546. }>;
  111547. /**
  111548. * constructor
  111549. * @param options Defines the options we want to customize the helper
  111550. * @param scene The scene to add the material to
  111551. */
  111552. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111553. /**
  111554. * Updates the background according to the new options
  111555. * @param options
  111556. */
  111557. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111558. /**
  111559. * Sets the primary color of all the available elements.
  111560. * @param color the main color to affect to the ground and the background
  111561. */
  111562. setMainColor(color: Color3): void;
  111563. /**
  111564. * Setup the image processing according to the specified options.
  111565. */
  111566. private _setupImageProcessing;
  111567. /**
  111568. * Setup the environment texture according to the specified options.
  111569. */
  111570. private _setupEnvironmentTexture;
  111571. /**
  111572. * Setup the background according to the specified options.
  111573. */
  111574. private _setupBackground;
  111575. /**
  111576. * Get the scene sizes according to the setup.
  111577. */
  111578. private _getSceneSize;
  111579. /**
  111580. * Setup the ground according to the specified options.
  111581. */
  111582. private _setupGround;
  111583. /**
  111584. * Setup the ground material according to the specified options.
  111585. */
  111586. private _setupGroundMaterial;
  111587. /**
  111588. * Setup the ground diffuse texture according to the specified options.
  111589. */
  111590. private _setupGroundDiffuseTexture;
  111591. /**
  111592. * Setup the ground mirror texture according to the specified options.
  111593. */
  111594. private _setupGroundMirrorTexture;
  111595. /**
  111596. * Setup the ground to receive the mirror texture.
  111597. */
  111598. private _setupMirrorInGroundMaterial;
  111599. /**
  111600. * Setup the skybox according to the specified options.
  111601. */
  111602. private _setupSkybox;
  111603. /**
  111604. * Setup the skybox material according to the specified options.
  111605. */
  111606. private _setupSkyboxMaterial;
  111607. /**
  111608. * Setup the skybox reflection texture according to the specified options.
  111609. */
  111610. private _setupSkyboxReflectionTexture;
  111611. private _errorHandler;
  111612. /**
  111613. * Dispose all the elements created by the Helper.
  111614. */
  111615. dispose(): void;
  111616. }
  111617. }
  111618. declare module BABYLON {
  111619. /**
  111620. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111621. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111622. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111623. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111624. */
  111625. export class PhotoDome extends TransformNode {
  111626. /**
  111627. * Define the image as a Monoscopic panoramic 360 image.
  111628. */
  111629. static readonly MODE_MONOSCOPIC: number;
  111630. /**
  111631. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111632. */
  111633. static readonly MODE_TOPBOTTOM: number;
  111634. /**
  111635. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111636. */
  111637. static readonly MODE_SIDEBYSIDE: number;
  111638. private _useDirectMapping;
  111639. /**
  111640. * The texture being displayed on the sphere
  111641. */
  111642. protected _photoTexture: Texture;
  111643. /**
  111644. * Gets or sets the texture being displayed on the sphere
  111645. */
  111646. photoTexture: Texture;
  111647. /**
  111648. * Observable raised when an error occured while loading the 360 image
  111649. */
  111650. onLoadErrorObservable: Observable<string>;
  111651. /**
  111652. * The skybox material
  111653. */
  111654. protected _material: BackgroundMaterial;
  111655. /**
  111656. * The surface used for the skybox
  111657. */
  111658. protected _mesh: Mesh;
  111659. /**
  111660. * Gets the mesh used for the skybox.
  111661. */
  111662. readonly mesh: Mesh;
  111663. /**
  111664. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111665. * Also see the options.resolution property.
  111666. */
  111667. fovMultiplier: number;
  111668. private _imageMode;
  111669. /**
  111670. * Gets or set the current video mode for the video. It can be:
  111671. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111672. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111673. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111674. */
  111675. imageMode: number;
  111676. /**
  111677. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111678. * @param name Element's name, child elements will append suffixes for their own names.
  111679. * @param urlsOfPhoto defines the url of the photo to display
  111680. * @param options defines an object containing optional or exposed sub element properties
  111681. * @param onError defines a callback called when an error occured while loading the texture
  111682. */
  111683. constructor(name: string, urlOfPhoto: string, options: {
  111684. resolution?: number;
  111685. size?: number;
  111686. useDirectMapping?: boolean;
  111687. faceForward?: boolean;
  111688. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111689. private _onBeforeCameraRenderObserver;
  111690. private _changeImageMode;
  111691. /**
  111692. * Releases resources associated with this node.
  111693. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111694. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111695. */
  111696. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111697. }
  111698. }
  111699. declare module BABYLON {
  111700. /**
  111701. * Class used to host RGBD texture specific utilities
  111702. */
  111703. export class RGBDTextureTools {
  111704. /**
  111705. * Expand the RGBD Texture from RGBD to Half Float if possible.
  111706. * @param texture the texture to expand.
  111707. */
  111708. static ExpandRGBDTexture(texture: Texture): void;
  111709. }
  111710. }
  111711. declare module BABYLON {
  111712. /**
  111713. * Class used to host texture specific utilities
  111714. */
  111715. export class BRDFTextureTools {
  111716. /**
  111717. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111718. * @param scene defines the hosting scene
  111719. * @returns the environment BRDF texture
  111720. */
  111721. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111722. private static _environmentBRDFBase64Texture;
  111723. }
  111724. }
  111725. declare module BABYLON {
  111726. /**
  111727. * @hidden
  111728. */
  111729. export interface IMaterialClearCoatDefines {
  111730. CLEARCOAT: boolean;
  111731. CLEARCOAT_DEFAULTIOR: boolean;
  111732. CLEARCOAT_TEXTURE: boolean;
  111733. CLEARCOAT_TEXTUREDIRECTUV: number;
  111734. CLEARCOAT_BUMP: boolean;
  111735. CLEARCOAT_BUMPDIRECTUV: number;
  111736. CLEARCOAT_TINT: boolean;
  111737. CLEARCOAT_TINT_TEXTURE: boolean;
  111738. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111739. /** @hidden */
  111740. _areTexturesDirty: boolean;
  111741. }
  111742. /**
  111743. * Define the code related to the clear coat parameters of the pbr material.
  111744. */
  111745. export class PBRClearCoatConfiguration {
  111746. /**
  111747. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111748. * The default fits with a polyurethane material.
  111749. */
  111750. private static readonly _DefaultIndexOfRefraction;
  111751. private _isEnabled;
  111752. /**
  111753. * Defines if the clear coat is enabled in the material.
  111754. */
  111755. isEnabled: boolean;
  111756. /**
  111757. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111758. */
  111759. intensity: number;
  111760. /**
  111761. * Defines the clear coat layer roughness.
  111762. */
  111763. roughness: number;
  111764. private _indexOfRefraction;
  111765. /**
  111766. * Defines the index of refraction of the clear coat.
  111767. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111768. * The default fits with a polyurethane material.
  111769. * Changing the default value is more performance intensive.
  111770. */
  111771. indexOfRefraction: number;
  111772. private _texture;
  111773. /**
  111774. * Stores the clear coat values in a texture.
  111775. */
  111776. texture: Nullable<BaseTexture>;
  111777. private _bumpTexture;
  111778. /**
  111779. * Define the clear coat specific bump texture.
  111780. */
  111781. bumpTexture: Nullable<BaseTexture>;
  111782. private _isTintEnabled;
  111783. /**
  111784. * Defines if the clear coat tint is enabled in the material.
  111785. */
  111786. isTintEnabled: boolean;
  111787. /**
  111788. * Defines the clear coat tint of the material.
  111789. * This is only use if tint is enabled
  111790. */
  111791. tintColor: Color3;
  111792. /**
  111793. * Defines the distance at which the tint color should be found in the
  111794. * clear coat media.
  111795. * This is only use if tint is enabled
  111796. */
  111797. tintColorAtDistance: number;
  111798. /**
  111799. * Defines the clear coat layer thickness.
  111800. * This is only use if tint is enabled
  111801. */
  111802. tintThickness: number;
  111803. private _tintTexture;
  111804. /**
  111805. * Stores the clear tint values in a texture.
  111806. * rgb is tint
  111807. * a is a thickness factor
  111808. */
  111809. tintTexture: Nullable<BaseTexture>;
  111810. /** @hidden */
  111811. private _internalMarkAllSubMeshesAsTexturesDirty;
  111812. /** @hidden */
  111813. _markAllSubMeshesAsTexturesDirty(): void;
  111814. /**
  111815. * Instantiate a new istance of clear coat configuration.
  111816. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111817. */
  111818. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111819. /**
  111820. * Gets wehter the submesh is ready to be used or not.
  111821. * @param defines the list of "defines" to update.
  111822. * @param scene defines the scene the material belongs to.
  111823. * @param engine defines the engine the material belongs to.
  111824. * @param disableBumpMap defines wether the material disables bump or not.
  111825. * @returns - boolean indicating that the submesh is ready or not.
  111826. */
  111827. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111828. /**
  111829. * Checks to see if a texture is used in the material.
  111830. * @param defines the list of "defines" to update.
  111831. * @param scene defines the scene to the material belongs to.
  111832. */
  111833. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111834. /**
  111835. * Binds the material data.
  111836. * @param uniformBuffer defines the Uniform buffer to fill in.
  111837. * @param scene defines the scene the material belongs to.
  111838. * @param engine defines the engine the material belongs to.
  111839. * @param disableBumpMap defines wether the material disables bump or not.
  111840. * @param isFrozen defines wether the material is frozen or not.
  111841. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111842. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111843. */
  111844. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111845. /**
  111846. * Checks to see if a texture is used in the material.
  111847. * @param texture - Base texture to use.
  111848. * @returns - Boolean specifying if a texture is used in the material.
  111849. */
  111850. hasTexture(texture: BaseTexture): boolean;
  111851. /**
  111852. * Returns an array of the actively used textures.
  111853. * @param activeTextures Array of BaseTextures
  111854. */
  111855. getActiveTextures(activeTextures: BaseTexture[]): void;
  111856. /**
  111857. * Returns the animatable textures.
  111858. * @param animatables Array of animatable textures.
  111859. */
  111860. getAnimatables(animatables: IAnimatable[]): void;
  111861. /**
  111862. * Disposes the resources of the material.
  111863. * @param forceDisposeTextures - Forces the disposal of all textures.
  111864. */
  111865. dispose(forceDisposeTextures?: boolean): void;
  111866. /**
  111867. * Get the current class name of the texture useful for serialization or dynamic coding.
  111868. * @returns "PBRClearCoatConfiguration"
  111869. */
  111870. getClassName(): string;
  111871. /**
  111872. * Add fallbacks to the effect fallbacks list.
  111873. * @param defines defines the Base texture to use.
  111874. * @param fallbacks defines the current fallback list.
  111875. * @param currentRank defines the current fallback rank.
  111876. * @returns the new fallback rank.
  111877. */
  111878. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111879. /**
  111880. * Add the required uniforms to the current list.
  111881. * @param uniforms defines the current uniform list.
  111882. */
  111883. static AddUniforms(uniforms: string[]): void;
  111884. /**
  111885. * Add the required samplers to the current list.
  111886. * @param samplers defines the current sampler list.
  111887. */
  111888. static AddSamplers(samplers: string[]): void;
  111889. /**
  111890. * Add the required uniforms to the current buffer.
  111891. * @param uniformBuffer defines the current uniform buffer.
  111892. */
  111893. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111894. /**
  111895. * Makes a duplicate of the current configuration into another one.
  111896. * @param clearCoatConfiguration define the config where to copy the info
  111897. */
  111898. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  111899. /**
  111900. * Serializes this clear coat configuration.
  111901. * @returns - An object with the serialized config.
  111902. */
  111903. serialize(): any;
  111904. /**
  111905. * Parses a anisotropy Configuration from a serialized object.
  111906. * @param source - Serialized object.
  111907. * @param scene Defines the scene we are parsing for
  111908. * @param rootUrl Defines the rootUrl to load from
  111909. */
  111910. parse(source: any, scene: Scene, rootUrl: string): void;
  111911. }
  111912. }
  111913. declare module BABYLON {
  111914. /**
  111915. * @hidden
  111916. */
  111917. export interface IMaterialAnisotropicDefines {
  111918. ANISOTROPIC: boolean;
  111919. ANISOTROPIC_TEXTURE: boolean;
  111920. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111921. MAINUV1: boolean;
  111922. _areTexturesDirty: boolean;
  111923. _needUVs: boolean;
  111924. }
  111925. /**
  111926. * Define the code related to the anisotropic parameters of the pbr material.
  111927. */
  111928. export class PBRAnisotropicConfiguration {
  111929. private _isEnabled;
  111930. /**
  111931. * Defines if the anisotropy is enabled in the material.
  111932. */
  111933. isEnabled: boolean;
  111934. /**
  111935. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  111936. */
  111937. intensity: number;
  111938. /**
  111939. * Defines if the effect is along the tangents, bitangents or in between.
  111940. * By default, the effect is "strectching" the highlights along the tangents.
  111941. */
  111942. direction: Vector2;
  111943. private _texture;
  111944. /**
  111945. * Stores the anisotropy values in a texture.
  111946. * rg is direction (like normal from -1 to 1)
  111947. * b is a intensity
  111948. */
  111949. texture: Nullable<BaseTexture>;
  111950. /** @hidden */
  111951. private _internalMarkAllSubMeshesAsTexturesDirty;
  111952. /** @hidden */
  111953. _markAllSubMeshesAsTexturesDirty(): void;
  111954. /**
  111955. * Instantiate a new istance of anisotropy configuration.
  111956. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111957. */
  111958. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111959. /**
  111960. * Specifies that the submesh is ready to be used.
  111961. * @param defines the list of "defines" to update.
  111962. * @param scene defines the scene the material belongs to.
  111963. * @returns - boolean indicating that the submesh is ready or not.
  111964. */
  111965. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  111966. /**
  111967. * Checks to see if a texture is used in the material.
  111968. * @param defines the list of "defines" to update.
  111969. * @param mesh the mesh we are preparing the defines for.
  111970. * @param scene defines the scene the material belongs to.
  111971. */
  111972. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  111973. /**
  111974. * Binds the material data.
  111975. * @param uniformBuffer defines the Uniform buffer to fill in.
  111976. * @param scene defines the scene the material belongs to.
  111977. * @param isFrozen defines wether the material is frozen or not.
  111978. */
  111979. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111980. /**
  111981. * Checks to see if a texture is used in the material.
  111982. * @param texture - Base texture to use.
  111983. * @returns - Boolean specifying if a texture is used in the material.
  111984. */
  111985. hasTexture(texture: BaseTexture): boolean;
  111986. /**
  111987. * Returns an array of the actively used textures.
  111988. * @param activeTextures Array of BaseTextures
  111989. */
  111990. getActiveTextures(activeTextures: BaseTexture[]): void;
  111991. /**
  111992. * Returns the animatable textures.
  111993. * @param animatables Array of animatable textures.
  111994. */
  111995. getAnimatables(animatables: IAnimatable[]): void;
  111996. /**
  111997. * Disposes the resources of the material.
  111998. * @param forceDisposeTextures - Forces the disposal of all textures.
  111999. */
  112000. dispose(forceDisposeTextures?: boolean): void;
  112001. /**
  112002. * Get the current class name of the texture useful for serialization or dynamic coding.
  112003. * @returns "PBRAnisotropicConfiguration"
  112004. */
  112005. getClassName(): string;
  112006. /**
  112007. * Add fallbacks to the effect fallbacks list.
  112008. * @param defines defines the Base texture to use.
  112009. * @param fallbacks defines the current fallback list.
  112010. * @param currentRank defines the current fallback rank.
  112011. * @returns the new fallback rank.
  112012. */
  112013. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112014. /**
  112015. * Add the required uniforms to the current list.
  112016. * @param uniforms defines the current uniform list.
  112017. */
  112018. static AddUniforms(uniforms: string[]): void;
  112019. /**
  112020. * Add the required uniforms to the current buffer.
  112021. * @param uniformBuffer defines the current uniform buffer.
  112022. */
  112023. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112024. /**
  112025. * Add the required samplers to the current list.
  112026. * @param samplers defines the current sampler list.
  112027. */
  112028. static AddSamplers(samplers: string[]): void;
  112029. /**
  112030. * Makes a duplicate of the current configuration into another one.
  112031. * @param anisotropicConfiguration define the config where to copy the info
  112032. */
  112033. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  112034. /**
  112035. * Serializes this anisotropy configuration.
  112036. * @returns - An object with the serialized config.
  112037. */
  112038. serialize(): any;
  112039. /**
  112040. * Parses a anisotropy Configuration from a serialized object.
  112041. * @param source - Serialized object.
  112042. * @param scene Defines the scene we are parsing for
  112043. * @param rootUrl Defines the rootUrl to load from
  112044. */
  112045. parse(source: any, scene: Scene, rootUrl: string): void;
  112046. }
  112047. }
  112048. declare module BABYLON {
  112049. /**
  112050. * @hidden
  112051. */
  112052. export interface IMaterialBRDFDefines {
  112053. BRDF_V_HEIGHT_CORRELATED: boolean;
  112054. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112055. SPHERICAL_HARMONICS: boolean;
  112056. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112057. /** @hidden */
  112058. _areMiscDirty: boolean;
  112059. }
  112060. /**
  112061. * Define the code related to the BRDF parameters of the pbr material.
  112062. */
  112063. export class PBRBRDFConfiguration {
  112064. /**
  112065. * Default value used for the energy conservation.
  112066. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112067. */
  112068. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  112069. /**
  112070. * Default value used for the Smith Visibility Height Correlated mode.
  112071. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112072. */
  112073. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  112074. /**
  112075. * Default value used for the IBL diffuse part.
  112076. * This can help switching back to the polynomials mode globally which is a tiny bit
  112077. * less GPU intensive at the drawback of a lower quality.
  112078. */
  112079. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  112080. /**
  112081. * Default value used for activating energy conservation for the specular workflow.
  112082. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112083. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112084. */
  112085. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  112086. private _useEnergyConservation;
  112087. /**
  112088. * Defines if the material uses energy conservation.
  112089. */
  112090. useEnergyConservation: boolean;
  112091. private _useSmithVisibilityHeightCorrelated;
  112092. /**
  112093. * LEGACY Mode set to false
  112094. * Defines if the material uses height smith correlated visibility term.
  112095. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  112096. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  112097. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  112098. * Not relying on height correlated will also disable energy conservation.
  112099. */
  112100. useSmithVisibilityHeightCorrelated: boolean;
  112101. private _useSphericalHarmonics;
  112102. /**
  112103. * LEGACY Mode set to false
  112104. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  112105. * diffuse part of the IBL.
  112106. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  112107. * to the ground truth.
  112108. */
  112109. useSphericalHarmonics: boolean;
  112110. private _useSpecularGlossinessInputEnergyConservation;
  112111. /**
  112112. * Defines if the material uses energy conservation, when the specular workflow is active.
  112113. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112114. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112115. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  112116. */
  112117. useSpecularGlossinessInputEnergyConservation: boolean;
  112118. /** @hidden */
  112119. private _internalMarkAllSubMeshesAsMiscDirty;
  112120. /** @hidden */
  112121. _markAllSubMeshesAsMiscDirty(): void;
  112122. /**
  112123. * Instantiate a new istance of clear coat configuration.
  112124. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  112125. */
  112126. constructor(markAllSubMeshesAsMiscDirty: () => void);
  112127. /**
  112128. * Checks to see if a texture is used in the material.
  112129. * @param defines the list of "defines" to update.
  112130. */
  112131. prepareDefines(defines: IMaterialBRDFDefines): void;
  112132. /**
  112133. * Get the current class name of the texture useful for serialization or dynamic coding.
  112134. * @returns "PBRClearCoatConfiguration"
  112135. */
  112136. getClassName(): string;
  112137. /**
  112138. * Makes a duplicate of the current configuration into another one.
  112139. * @param brdfConfiguration define the config where to copy the info
  112140. */
  112141. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  112142. /**
  112143. * Serializes this BRDF configuration.
  112144. * @returns - An object with the serialized config.
  112145. */
  112146. serialize(): any;
  112147. /**
  112148. * Parses a anisotropy Configuration from a serialized object.
  112149. * @param source - Serialized object.
  112150. * @param scene Defines the scene we are parsing for
  112151. * @param rootUrl Defines the rootUrl to load from
  112152. */
  112153. parse(source: any, scene: Scene, rootUrl: string): void;
  112154. }
  112155. }
  112156. declare module BABYLON {
  112157. /**
  112158. * @hidden
  112159. */
  112160. export interface IMaterialSheenDefines {
  112161. SHEEN: boolean;
  112162. SHEEN_TEXTURE: boolean;
  112163. SHEEN_TEXTUREDIRECTUV: number;
  112164. SHEEN_LINKWITHALBEDO: boolean;
  112165. /** @hidden */
  112166. _areTexturesDirty: boolean;
  112167. }
  112168. /**
  112169. * Define the code related to the Sheen parameters of the pbr material.
  112170. */
  112171. export class PBRSheenConfiguration {
  112172. private _isEnabled;
  112173. /**
  112174. * Defines if the material uses sheen.
  112175. */
  112176. isEnabled: boolean;
  112177. private _linkSheenWithAlbedo;
  112178. /**
  112179. * Defines if the sheen is linked to the sheen color.
  112180. */
  112181. linkSheenWithAlbedo: boolean;
  112182. /**
  112183. * Defines the sheen intensity.
  112184. */
  112185. intensity: number;
  112186. /**
  112187. * Defines the sheen color.
  112188. */
  112189. color: Color3;
  112190. private _texture;
  112191. /**
  112192. * Stores the sheen tint values in a texture.
  112193. * rgb is tint
  112194. * a is a intensity
  112195. */
  112196. texture: Nullable<BaseTexture>;
  112197. /** @hidden */
  112198. private _internalMarkAllSubMeshesAsTexturesDirty;
  112199. /** @hidden */
  112200. _markAllSubMeshesAsTexturesDirty(): void;
  112201. /**
  112202. * Instantiate a new istance of clear coat configuration.
  112203. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112204. */
  112205. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112206. /**
  112207. * Specifies that the submesh is ready to be used.
  112208. * @param defines the list of "defines" to update.
  112209. * @param scene defines the scene the material belongs to.
  112210. * @returns - boolean indicating that the submesh is ready or not.
  112211. */
  112212. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  112213. /**
  112214. * Checks to see if a texture is used in the material.
  112215. * @param defines the list of "defines" to update.
  112216. * @param scene defines the scene the material belongs to.
  112217. */
  112218. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  112219. /**
  112220. * Binds the material data.
  112221. * @param uniformBuffer defines the Uniform buffer to fill in.
  112222. * @param scene defines the scene the material belongs to.
  112223. * @param isFrozen defines wether the material is frozen or not.
  112224. */
  112225. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112226. /**
  112227. * Checks to see if a texture is used in the material.
  112228. * @param texture - Base texture to use.
  112229. * @returns - Boolean specifying if a texture is used in the material.
  112230. */
  112231. hasTexture(texture: BaseTexture): boolean;
  112232. /**
  112233. * Returns an array of the actively used textures.
  112234. * @param activeTextures Array of BaseTextures
  112235. */
  112236. getActiveTextures(activeTextures: BaseTexture[]): void;
  112237. /**
  112238. * Returns the animatable textures.
  112239. * @param animatables Array of animatable textures.
  112240. */
  112241. getAnimatables(animatables: IAnimatable[]): void;
  112242. /**
  112243. * Disposes the resources of the material.
  112244. * @param forceDisposeTextures - Forces the disposal of all textures.
  112245. */
  112246. dispose(forceDisposeTextures?: boolean): void;
  112247. /**
  112248. * Get the current class name of the texture useful for serialization or dynamic coding.
  112249. * @returns "PBRSheenConfiguration"
  112250. */
  112251. getClassName(): string;
  112252. /**
  112253. * Add fallbacks to the effect fallbacks list.
  112254. * @param defines defines the Base texture to use.
  112255. * @param fallbacks defines the current fallback list.
  112256. * @param currentRank defines the current fallback rank.
  112257. * @returns the new fallback rank.
  112258. */
  112259. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112260. /**
  112261. * Add the required uniforms to the current list.
  112262. * @param uniforms defines the current uniform list.
  112263. */
  112264. static AddUniforms(uniforms: string[]): void;
  112265. /**
  112266. * Add the required uniforms to the current buffer.
  112267. * @param uniformBuffer defines the current uniform buffer.
  112268. */
  112269. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112270. /**
  112271. * Add the required samplers to the current list.
  112272. * @param samplers defines the current sampler list.
  112273. */
  112274. static AddSamplers(samplers: string[]): void;
  112275. /**
  112276. * Makes a duplicate of the current configuration into another one.
  112277. * @param sheenConfiguration define the config where to copy the info
  112278. */
  112279. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  112280. /**
  112281. * Serializes this BRDF configuration.
  112282. * @returns - An object with the serialized config.
  112283. */
  112284. serialize(): any;
  112285. /**
  112286. * Parses a anisotropy Configuration from a serialized object.
  112287. * @param source - Serialized object.
  112288. * @param scene Defines the scene we are parsing for
  112289. * @param rootUrl Defines the rootUrl to load from
  112290. */
  112291. parse(source: any, scene: Scene, rootUrl: string): void;
  112292. }
  112293. }
  112294. declare module BABYLON {
  112295. /**
  112296. * @hidden
  112297. */
  112298. export interface IMaterialSubSurfaceDefines {
  112299. SUBSURFACE: boolean;
  112300. SS_REFRACTION: boolean;
  112301. SS_TRANSLUCENCY: boolean;
  112302. SS_SCATERRING: boolean;
  112303. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112304. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112305. SS_REFRACTIONMAP_3D: boolean;
  112306. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112307. SS_LODINREFRACTIONALPHA: boolean;
  112308. SS_GAMMAREFRACTION: boolean;
  112309. SS_RGBDREFRACTION: boolean;
  112310. SS_LINEARSPECULARREFRACTION: boolean;
  112311. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112312. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112313. /** @hidden */
  112314. _areTexturesDirty: boolean;
  112315. }
  112316. /**
  112317. * Define the code related to the sub surface parameters of the pbr material.
  112318. */
  112319. export class PBRSubSurfaceConfiguration {
  112320. private _isRefractionEnabled;
  112321. /**
  112322. * Defines if the refraction is enabled in the material.
  112323. */
  112324. isRefractionEnabled: boolean;
  112325. private _isTranslucencyEnabled;
  112326. /**
  112327. * Defines if the translucency is enabled in the material.
  112328. */
  112329. isTranslucencyEnabled: boolean;
  112330. private _isScatteringEnabled;
  112331. /**
  112332. * Defines the refraction intensity of the material.
  112333. * The refraction when enabled replaces the Diffuse part of the material.
  112334. * The intensity helps transitionning between diffuse and refraction.
  112335. */
  112336. refractionIntensity: number;
  112337. /**
  112338. * Defines the translucency intensity of the material.
  112339. * When translucency has been enabled, this defines how much of the "translucency"
  112340. * is addded to the diffuse part of the material.
  112341. */
  112342. translucencyIntensity: number;
  112343. /**
  112344. * Defines the scattering intensity of the material.
  112345. * When scattering has been enabled, this defines how much of the "scattered light"
  112346. * is addded to the diffuse part of the material.
  112347. */
  112348. scatteringIntensity: number;
  112349. private _thicknessTexture;
  112350. /**
  112351. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  112352. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  112353. * 0 would mean minimumThickness
  112354. * 1 would mean maximumThickness
  112355. * The other channels might be use as a mask to vary the different effects intensity.
  112356. */
  112357. thicknessTexture: Nullable<BaseTexture>;
  112358. private _refractionTexture;
  112359. /**
  112360. * Defines the texture to use for refraction.
  112361. */
  112362. refractionTexture: Nullable<BaseTexture>;
  112363. private _indexOfRefraction;
  112364. /**
  112365. * Defines the index of refraction used in the material.
  112366. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112367. */
  112368. indexOfRefraction: number;
  112369. private _invertRefractionY;
  112370. /**
  112371. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112372. */
  112373. invertRefractionY: boolean;
  112374. private _linkRefractionWithTransparency;
  112375. /**
  112376. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112377. * Materials half opaque for instance using refraction could benefit from this control.
  112378. */
  112379. linkRefractionWithTransparency: boolean;
  112380. /**
  112381. * Defines the minimum thickness stored in the thickness map.
  112382. * If no thickness map is defined, this value will be used to simulate thickness.
  112383. */
  112384. minimumThickness: number;
  112385. /**
  112386. * Defines the maximum thickness stored in the thickness map.
  112387. */
  112388. maximumThickness: number;
  112389. /**
  112390. * Defines the volume tint of the material.
  112391. * This is used for both translucency and scattering.
  112392. */
  112393. tintColor: Color3;
  112394. /**
  112395. * Defines the distance at which the tint color should be found in the media.
  112396. * This is used for refraction only.
  112397. */
  112398. tintColorAtDistance: number;
  112399. /**
  112400. * Defines how far each channel transmit through the media.
  112401. * It is defined as a color to simplify it selection.
  112402. */
  112403. diffusionDistance: Color3;
  112404. private _useMaskFromThicknessTexture;
  112405. /**
  112406. * Stores the intensity of the different subsurface effects in the thickness texture.
  112407. * * the green channel is the translucency intensity.
  112408. * * the blue channel is the scattering intensity.
  112409. * * the alpha channel is the refraction intensity.
  112410. */
  112411. useMaskFromThicknessTexture: boolean;
  112412. /** @hidden */
  112413. private _internalMarkAllSubMeshesAsTexturesDirty;
  112414. /** @hidden */
  112415. _markAllSubMeshesAsTexturesDirty(): void;
  112416. /**
  112417. * Instantiate a new istance of sub surface configuration.
  112418. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112419. */
  112420. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112421. /**
  112422. * Gets wehter the submesh is ready to be used or not.
  112423. * @param defines the list of "defines" to update.
  112424. * @param scene defines the scene the material belongs to.
  112425. * @returns - boolean indicating that the submesh is ready or not.
  112426. */
  112427. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112428. /**
  112429. * Checks to see if a texture is used in the material.
  112430. * @param defines the list of "defines" to update.
  112431. * @param scene defines the scene to the material belongs to.
  112432. */
  112433. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112434. /**
  112435. * Binds the material data.
  112436. * @param uniformBuffer defines the Uniform buffer to fill in.
  112437. * @param scene defines the scene the material belongs to.
  112438. * @param engine defines the engine the material belongs to.
  112439. * @param isFrozen defines wether the material is frozen or not.
  112440. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112441. */
  112442. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112443. /**
  112444. * Unbinds the material from the mesh.
  112445. * @param activeEffect defines the effect that should be unbound from.
  112446. * @returns true if unbound, otherwise false
  112447. */
  112448. unbind(activeEffect: Effect): boolean;
  112449. /**
  112450. * Returns the texture used for refraction or null if none is used.
  112451. * @param scene defines the scene the material belongs to.
  112452. * @returns - Refraction texture if present. If no refraction texture and refraction
  112453. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112454. */
  112455. private _getRefractionTexture;
  112456. /**
  112457. * Returns true if alpha blending should be disabled.
  112458. */
  112459. readonly disableAlphaBlending: boolean;
  112460. /**
  112461. * Fills the list of render target textures.
  112462. * @param renderTargets the list of render targets to update
  112463. */
  112464. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112465. /**
  112466. * Checks to see if a texture is used in the material.
  112467. * @param texture - Base texture to use.
  112468. * @returns - Boolean specifying if a texture is used in the material.
  112469. */
  112470. hasTexture(texture: BaseTexture): boolean;
  112471. /**
  112472. * Gets a boolean indicating that current material needs to register RTT
  112473. * @returns true if this uses a render target otherwise false.
  112474. */
  112475. hasRenderTargetTextures(): boolean;
  112476. /**
  112477. * Returns an array of the actively used textures.
  112478. * @param activeTextures Array of BaseTextures
  112479. */
  112480. getActiveTextures(activeTextures: BaseTexture[]): void;
  112481. /**
  112482. * Returns the animatable textures.
  112483. * @param animatables Array of animatable textures.
  112484. */
  112485. getAnimatables(animatables: IAnimatable[]): void;
  112486. /**
  112487. * Disposes the resources of the material.
  112488. * @param forceDisposeTextures - Forces the disposal of all textures.
  112489. */
  112490. dispose(forceDisposeTextures?: boolean): void;
  112491. /**
  112492. * Get the current class name of the texture useful for serialization or dynamic coding.
  112493. * @returns "PBRSubSurfaceConfiguration"
  112494. */
  112495. getClassName(): string;
  112496. /**
  112497. * Add fallbacks to the effect fallbacks list.
  112498. * @param defines defines the Base texture to use.
  112499. * @param fallbacks defines the current fallback list.
  112500. * @param currentRank defines the current fallback rank.
  112501. * @returns the new fallback rank.
  112502. */
  112503. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112504. /**
  112505. * Add the required uniforms to the current list.
  112506. * @param uniforms defines the current uniform list.
  112507. */
  112508. static AddUniforms(uniforms: string[]): void;
  112509. /**
  112510. * Add the required samplers to the current list.
  112511. * @param samplers defines the current sampler list.
  112512. */
  112513. static AddSamplers(samplers: string[]): void;
  112514. /**
  112515. * Add the required uniforms to the current buffer.
  112516. * @param uniformBuffer defines the current uniform buffer.
  112517. */
  112518. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112519. /**
  112520. * Makes a duplicate of the current configuration into another one.
  112521. * @param configuration define the config where to copy the info
  112522. */
  112523. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112524. /**
  112525. * Serializes this Sub Surface configuration.
  112526. * @returns - An object with the serialized config.
  112527. */
  112528. serialize(): any;
  112529. /**
  112530. * Parses a anisotropy Configuration from a serialized object.
  112531. * @param source - Serialized object.
  112532. * @param scene Defines the scene we are parsing for
  112533. * @param rootUrl Defines the rootUrl to load from
  112534. */
  112535. parse(source: any, scene: Scene, rootUrl: string): void;
  112536. }
  112537. }
  112538. declare module BABYLON {
  112539. /** @hidden */
  112540. export var pbrFragmentDeclaration: {
  112541. name: string;
  112542. shader: string;
  112543. };
  112544. }
  112545. declare module BABYLON {
  112546. /** @hidden */
  112547. export var pbrUboDeclaration: {
  112548. name: string;
  112549. shader: string;
  112550. };
  112551. }
  112552. declare module BABYLON {
  112553. /** @hidden */
  112554. export var pbrFragmentExtraDeclaration: {
  112555. name: string;
  112556. shader: string;
  112557. };
  112558. }
  112559. declare module BABYLON {
  112560. /** @hidden */
  112561. export var pbrFragmentSamplersDeclaration: {
  112562. name: string;
  112563. shader: string;
  112564. };
  112565. }
  112566. declare module BABYLON {
  112567. /** @hidden */
  112568. export var pbrHelperFunctions: {
  112569. name: string;
  112570. shader: string;
  112571. };
  112572. }
  112573. declare module BABYLON {
  112574. /** @hidden */
  112575. export var harmonicsFunctions: {
  112576. name: string;
  112577. shader: string;
  112578. };
  112579. }
  112580. declare module BABYLON {
  112581. /** @hidden */
  112582. export var pbrDirectLightingSetupFunctions: {
  112583. name: string;
  112584. shader: string;
  112585. };
  112586. }
  112587. declare module BABYLON {
  112588. /** @hidden */
  112589. export var pbrDirectLightingFalloffFunctions: {
  112590. name: string;
  112591. shader: string;
  112592. };
  112593. }
  112594. declare module BABYLON {
  112595. /** @hidden */
  112596. export var pbrBRDFFunctions: {
  112597. name: string;
  112598. shader: string;
  112599. };
  112600. }
  112601. declare module BABYLON {
  112602. /** @hidden */
  112603. export var pbrDirectLightingFunctions: {
  112604. name: string;
  112605. shader: string;
  112606. };
  112607. }
  112608. declare module BABYLON {
  112609. /** @hidden */
  112610. export var pbrIBLFunctions: {
  112611. name: string;
  112612. shader: string;
  112613. };
  112614. }
  112615. declare module BABYLON {
  112616. /** @hidden */
  112617. export var pbrDebug: {
  112618. name: string;
  112619. shader: string;
  112620. };
  112621. }
  112622. declare module BABYLON {
  112623. /** @hidden */
  112624. export var pbrPixelShader: {
  112625. name: string;
  112626. shader: string;
  112627. };
  112628. }
  112629. declare module BABYLON {
  112630. /** @hidden */
  112631. export var pbrVertexDeclaration: {
  112632. name: string;
  112633. shader: string;
  112634. };
  112635. }
  112636. declare module BABYLON {
  112637. /** @hidden */
  112638. export var pbrVertexShader: {
  112639. name: string;
  112640. shader: string;
  112641. };
  112642. }
  112643. declare module BABYLON {
  112644. /**
  112645. * Manages the defines for the PBR Material.
  112646. * @hidden
  112647. */
  112648. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112649. PBR: boolean;
  112650. MAINUV1: boolean;
  112651. MAINUV2: boolean;
  112652. UV1: boolean;
  112653. UV2: boolean;
  112654. ALBEDO: boolean;
  112655. ALBEDODIRECTUV: number;
  112656. VERTEXCOLOR: boolean;
  112657. AMBIENT: boolean;
  112658. AMBIENTDIRECTUV: number;
  112659. AMBIENTINGRAYSCALE: boolean;
  112660. OPACITY: boolean;
  112661. VERTEXALPHA: boolean;
  112662. OPACITYDIRECTUV: number;
  112663. OPACITYRGB: boolean;
  112664. ALPHATEST: boolean;
  112665. DEPTHPREPASS: boolean;
  112666. ALPHABLEND: boolean;
  112667. ALPHAFROMALBEDO: boolean;
  112668. ALPHATESTVALUE: string;
  112669. SPECULAROVERALPHA: boolean;
  112670. RADIANCEOVERALPHA: boolean;
  112671. ALPHAFRESNEL: boolean;
  112672. LINEARALPHAFRESNEL: boolean;
  112673. PREMULTIPLYALPHA: boolean;
  112674. EMISSIVE: boolean;
  112675. EMISSIVEDIRECTUV: number;
  112676. REFLECTIVITY: boolean;
  112677. REFLECTIVITYDIRECTUV: number;
  112678. SPECULARTERM: boolean;
  112679. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112680. MICROSURFACEAUTOMATIC: boolean;
  112681. LODBASEDMICROSFURACE: boolean;
  112682. MICROSURFACEMAP: boolean;
  112683. MICROSURFACEMAPDIRECTUV: number;
  112684. METALLICWORKFLOW: boolean;
  112685. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112686. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112687. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112688. AOSTOREINMETALMAPRED: boolean;
  112689. ENVIRONMENTBRDF: boolean;
  112690. ENVIRONMENTBRDF_RGBD: boolean;
  112691. NORMAL: boolean;
  112692. TANGENT: boolean;
  112693. BUMP: boolean;
  112694. BUMPDIRECTUV: number;
  112695. OBJECTSPACE_NORMALMAP: boolean;
  112696. PARALLAX: boolean;
  112697. PARALLAXOCCLUSION: boolean;
  112698. NORMALXYSCALE: boolean;
  112699. LIGHTMAP: boolean;
  112700. LIGHTMAPDIRECTUV: number;
  112701. USELIGHTMAPASSHADOWMAP: boolean;
  112702. GAMMALIGHTMAP: boolean;
  112703. RGBDLIGHTMAP: boolean;
  112704. REFLECTION: boolean;
  112705. REFLECTIONMAP_3D: boolean;
  112706. REFLECTIONMAP_SPHERICAL: boolean;
  112707. REFLECTIONMAP_PLANAR: boolean;
  112708. REFLECTIONMAP_CUBIC: boolean;
  112709. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112710. REFLECTIONMAP_PROJECTION: boolean;
  112711. REFLECTIONMAP_SKYBOX: boolean;
  112712. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112713. REFLECTIONMAP_EXPLICIT: boolean;
  112714. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112715. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112716. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112717. INVERTCUBICMAP: boolean;
  112718. USESPHERICALFROMREFLECTIONMAP: boolean;
  112719. USEIRRADIANCEMAP: boolean;
  112720. SPHERICAL_HARMONICS: boolean;
  112721. USESPHERICALINVERTEX: boolean;
  112722. REFLECTIONMAP_OPPOSITEZ: boolean;
  112723. LODINREFLECTIONALPHA: boolean;
  112724. GAMMAREFLECTION: boolean;
  112725. RGBDREFLECTION: boolean;
  112726. LINEARSPECULARREFLECTION: boolean;
  112727. RADIANCEOCCLUSION: boolean;
  112728. HORIZONOCCLUSION: boolean;
  112729. INSTANCES: boolean;
  112730. NUM_BONE_INFLUENCERS: number;
  112731. BonesPerMesh: number;
  112732. BONETEXTURE: boolean;
  112733. NONUNIFORMSCALING: boolean;
  112734. MORPHTARGETS: boolean;
  112735. MORPHTARGETS_NORMAL: boolean;
  112736. MORPHTARGETS_TANGENT: boolean;
  112737. MORPHTARGETS_UV: boolean;
  112738. NUM_MORPH_INFLUENCERS: number;
  112739. IMAGEPROCESSING: boolean;
  112740. VIGNETTE: boolean;
  112741. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112742. VIGNETTEBLENDMODEOPAQUE: boolean;
  112743. TONEMAPPING: boolean;
  112744. TONEMAPPING_ACES: boolean;
  112745. CONTRAST: boolean;
  112746. COLORCURVES: boolean;
  112747. COLORGRADING: boolean;
  112748. COLORGRADING3D: boolean;
  112749. SAMPLER3DGREENDEPTH: boolean;
  112750. SAMPLER3DBGRMAP: boolean;
  112751. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112752. EXPOSURE: boolean;
  112753. MULTIVIEW: boolean;
  112754. USEPHYSICALLIGHTFALLOFF: boolean;
  112755. USEGLTFLIGHTFALLOFF: boolean;
  112756. TWOSIDEDLIGHTING: boolean;
  112757. SHADOWFLOAT: boolean;
  112758. CLIPPLANE: boolean;
  112759. CLIPPLANE2: boolean;
  112760. CLIPPLANE3: boolean;
  112761. CLIPPLANE4: boolean;
  112762. POINTSIZE: boolean;
  112763. FOG: boolean;
  112764. LOGARITHMICDEPTH: boolean;
  112765. FORCENORMALFORWARD: boolean;
  112766. SPECULARAA: boolean;
  112767. CLEARCOAT: boolean;
  112768. CLEARCOAT_DEFAULTIOR: boolean;
  112769. CLEARCOAT_TEXTURE: boolean;
  112770. CLEARCOAT_TEXTUREDIRECTUV: number;
  112771. CLEARCOAT_BUMP: boolean;
  112772. CLEARCOAT_BUMPDIRECTUV: number;
  112773. CLEARCOAT_TINT: boolean;
  112774. CLEARCOAT_TINT_TEXTURE: boolean;
  112775. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112776. ANISOTROPIC: boolean;
  112777. ANISOTROPIC_TEXTURE: boolean;
  112778. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112779. BRDF_V_HEIGHT_CORRELATED: boolean;
  112780. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112781. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112782. SHEEN: boolean;
  112783. SHEEN_TEXTURE: boolean;
  112784. SHEEN_TEXTUREDIRECTUV: number;
  112785. SHEEN_LINKWITHALBEDO: boolean;
  112786. SUBSURFACE: boolean;
  112787. SS_REFRACTION: boolean;
  112788. SS_TRANSLUCENCY: boolean;
  112789. SS_SCATERRING: boolean;
  112790. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112791. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112792. SS_REFRACTIONMAP_3D: boolean;
  112793. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112794. SS_LODINREFRACTIONALPHA: boolean;
  112795. SS_GAMMAREFRACTION: boolean;
  112796. SS_RGBDREFRACTION: boolean;
  112797. SS_LINEARSPECULARREFRACTION: boolean;
  112798. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112799. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112800. UNLIT: boolean;
  112801. DEBUGMODE: number;
  112802. /**
  112803. * Initializes the PBR Material defines.
  112804. */
  112805. constructor();
  112806. /**
  112807. * Resets the PBR Material defines.
  112808. */
  112809. reset(): void;
  112810. }
  112811. /**
  112812. * The Physically based material base class of BJS.
  112813. *
  112814. * This offers the main features of a standard PBR material.
  112815. * For more information, please refer to the documentation :
  112816. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112817. */
  112818. export abstract class PBRBaseMaterial extends PushMaterial {
  112819. /**
  112820. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112821. */
  112822. static readonly PBRMATERIAL_OPAQUE: number;
  112823. /**
  112824. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112825. */
  112826. static readonly PBRMATERIAL_ALPHATEST: number;
  112827. /**
  112828. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112829. */
  112830. static readonly PBRMATERIAL_ALPHABLEND: number;
  112831. /**
  112832. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112833. * They are also discarded below the alpha cutoff threshold to improve performances.
  112834. */
  112835. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112836. /**
  112837. * Defines the default value of how much AO map is occluding the analytical lights
  112838. * (point spot...).
  112839. */
  112840. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112841. /**
  112842. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112843. */
  112844. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112845. /**
  112846. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112847. * to enhance interoperability with other engines.
  112848. */
  112849. static readonly LIGHTFALLOFF_GLTF: number;
  112850. /**
  112851. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  112852. * to enhance interoperability with other materials.
  112853. */
  112854. static readonly LIGHTFALLOFF_STANDARD: number;
  112855. /**
  112856. * Intensity of the direct lights e.g. the four lights available in your scene.
  112857. * This impacts both the direct diffuse and specular highlights.
  112858. */
  112859. protected _directIntensity: number;
  112860. /**
  112861. * Intensity of the emissive part of the material.
  112862. * This helps controlling the emissive effect without modifying the emissive color.
  112863. */
  112864. protected _emissiveIntensity: number;
  112865. /**
  112866. * Intensity of the environment e.g. how much the environment will light the object
  112867. * either through harmonics for rough material or through the refelction for shiny ones.
  112868. */
  112869. protected _environmentIntensity: number;
  112870. /**
  112871. * This is a special control allowing the reduction of the specular highlights coming from the
  112872. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112873. */
  112874. protected _specularIntensity: number;
  112875. /**
  112876. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  112877. */
  112878. private _lightingInfos;
  112879. /**
  112880. * Debug Control allowing disabling the bump map on this material.
  112881. */
  112882. protected _disableBumpMap: boolean;
  112883. /**
  112884. * AKA Diffuse Texture in standard nomenclature.
  112885. */
  112886. protected _albedoTexture: Nullable<BaseTexture>;
  112887. /**
  112888. * AKA Occlusion Texture in other nomenclature.
  112889. */
  112890. protected _ambientTexture: Nullable<BaseTexture>;
  112891. /**
  112892. * AKA Occlusion Texture Intensity in other nomenclature.
  112893. */
  112894. protected _ambientTextureStrength: number;
  112895. /**
  112896. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112897. * 1 means it completely occludes it
  112898. * 0 mean it has no impact
  112899. */
  112900. protected _ambientTextureImpactOnAnalyticalLights: number;
  112901. /**
  112902. * Stores the alpha values in a texture.
  112903. */
  112904. protected _opacityTexture: Nullable<BaseTexture>;
  112905. /**
  112906. * Stores the reflection values in a texture.
  112907. */
  112908. protected _reflectionTexture: Nullable<BaseTexture>;
  112909. /**
  112910. * Stores the emissive values in a texture.
  112911. */
  112912. protected _emissiveTexture: Nullable<BaseTexture>;
  112913. /**
  112914. * AKA Specular texture in other nomenclature.
  112915. */
  112916. protected _reflectivityTexture: Nullable<BaseTexture>;
  112917. /**
  112918. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112919. */
  112920. protected _metallicTexture: Nullable<BaseTexture>;
  112921. /**
  112922. * Specifies the metallic scalar of the metallic/roughness workflow.
  112923. * Can also be used to scale the metalness values of the metallic texture.
  112924. */
  112925. protected _metallic: Nullable<number>;
  112926. /**
  112927. * Specifies the roughness scalar of the metallic/roughness workflow.
  112928. * Can also be used to scale the roughness values of the metallic texture.
  112929. */
  112930. protected _roughness: Nullable<number>;
  112931. /**
  112932. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112933. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112934. */
  112935. protected _microSurfaceTexture: Nullable<BaseTexture>;
  112936. /**
  112937. * Stores surface normal data used to displace a mesh in a texture.
  112938. */
  112939. protected _bumpTexture: Nullable<BaseTexture>;
  112940. /**
  112941. * Stores the pre-calculated light information of a mesh in a texture.
  112942. */
  112943. protected _lightmapTexture: Nullable<BaseTexture>;
  112944. /**
  112945. * The color of a material in ambient lighting.
  112946. */
  112947. protected _ambientColor: Color3;
  112948. /**
  112949. * AKA Diffuse Color in other nomenclature.
  112950. */
  112951. protected _albedoColor: Color3;
  112952. /**
  112953. * AKA Specular Color in other nomenclature.
  112954. */
  112955. protected _reflectivityColor: Color3;
  112956. /**
  112957. * The color applied when light is reflected from a material.
  112958. */
  112959. protected _reflectionColor: Color3;
  112960. /**
  112961. * The color applied when light is emitted from a material.
  112962. */
  112963. protected _emissiveColor: Color3;
  112964. /**
  112965. * AKA Glossiness in other nomenclature.
  112966. */
  112967. protected _microSurface: number;
  112968. /**
  112969. * Specifies that the material will use the light map as a show map.
  112970. */
  112971. protected _useLightmapAsShadowmap: boolean;
  112972. /**
  112973. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112974. * makes the reflect vector face the model (under horizon).
  112975. */
  112976. protected _useHorizonOcclusion: boolean;
  112977. /**
  112978. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112979. * too much the area relying on ambient texture to define their ambient occlusion.
  112980. */
  112981. protected _useRadianceOcclusion: boolean;
  112982. /**
  112983. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112984. */
  112985. protected _useAlphaFromAlbedoTexture: boolean;
  112986. /**
  112987. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  112988. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  112989. */
  112990. protected _useSpecularOverAlpha: boolean;
  112991. /**
  112992. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  112993. */
  112994. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  112995. /**
  112996. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  112997. */
  112998. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  112999. /**
  113000. * Specifies if the metallic texture contains the roughness information in its green channel.
  113001. */
  113002. protected _useRoughnessFromMetallicTextureGreen: boolean;
  113003. /**
  113004. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113005. */
  113006. protected _useMetallnessFromMetallicTextureBlue: boolean;
  113007. /**
  113008. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113009. */
  113010. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  113011. /**
  113012. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113013. */
  113014. protected _useAmbientInGrayScale: boolean;
  113015. /**
  113016. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113017. * The material will try to infer what glossiness each pixel should be.
  113018. */
  113019. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  113020. /**
  113021. * Defines the falloff type used in this material.
  113022. * It by default is Physical.
  113023. */
  113024. protected _lightFalloff: number;
  113025. /**
  113026. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113027. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113028. */
  113029. protected _useRadianceOverAlpha: boolean;
  113030. /**
  113031. * Allows using an object space normal map (instead of tangent space).
  113032. */
  113033. protected _useObjectSpaceNormalMap: boolean;
  113034. /**
  113035. * Allows using the bump map in parallax mode.
  113036. */
  113037. protected _useParallax: boolean;
  113038. /**
  113039. * Allows using the bump map in parallax occlusion mode.
  113040. */
  113041. protected _useParallaxOcclusion: boolean;
  113042. /**
  113043. * Controls the scale bias of the parallax mode.
  113044. */
  113045. protected _parallaxScaleBias: number;
  113046. /**
  113047. * If sets to true, disables all the lights affecting the material.
  113048. */
  113049. protected _disableLighting: boolean;
  113050. /**
  113051. * Number of Simultaneous lights allowed on the material.
  113052. */
  113053. protected _maxSimultaneousLights: number;
  113054. /**
  113055. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113056. */
  113057. protected _invertNormalMapX: boolean;
  113058. /**
  113059. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113060. */
  113061. protected _invertNormalMapY: boolean;
  113062. /**
  113063. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113064. */
  113065. protected _twoSidedLighting: boolean;
  113066. /**
  113067. * Defines the alpha limits in alpha test mode.
  113068. */
  113069. protected _alphaCutOff: number;
  113070. /**
  113071. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113072. */
  113073. protected _forceAlphaTest: boolean;
  113074. /**
  113075. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113076. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113077. */
  113078. protected _useAlphaFresnel: boolean;
  113079. /**
  113080. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113081. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113082. */
  113083. protected _useLinearAlphaFresnel: boolean;
  113084. /**
  113085. * The transparency mode of the material.
  113086. */
  113087. protected _transparencyMode: Nullable<number>;
  113088. /**
  113089. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  113090. * from cos thetav and roughness:
  113091. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  113092. */
  113093. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  113094. /**
  113095. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113096. */
  113097. protected _forceIrradianceInFragment: boolean;
  113098. /**
  113099. * Force normal to face away from face.
  113100. */
  113101. protected _forceNormalForward: boolean;
  113102. /**
  113103. * Enables specular anti aliasing in the PBR shader.
  113104. * It will both interacts on the Geometry for analytical and IBL lighting.
  113105. * It also prefilter the roughness map based on the bump values.
  113106. */
  113107. protected _enableSpecularAntiAliasing: boolean;
  113108. /**
  113109. * Default configuration related to image processing available in the PBR Material.
  113110. */
  113111. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113112. /**
  113113. * Keep track of the image processing observer to allow dispose and replace.
  113114. */
  113115. private _imageProcessingObserver;
  113116. /**
  113117. * Attaches a new image processing configuration to the PBR Material.
  113118. * @param configuration
  113119. */
  113120. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113121. /**
  113122. * Stores the available render targets.
  113123. */
  113124. private _renderTargets;
  113125. /**
  113126. * Sets the global ambient color for the material used in lighting calculations.
  113127. */
  113128. private _globalAmbientColor;
  113129. /**
  113130. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  113131. */
  113132. private _useLogarithmicDepth;
  113133. /**
  113134. * If set to true, no lighting calculations will be applied.
  113135. */
  113136. private _unlit;
  113137. private _debugMode;
  113138. /**
  113139. * @hidden
  113140. * This is reserved for the inspector.
  113141. * Defines the material debug mode.
  113142. * It helps seeing only some components of the material while troubleshooting.
  113143. */
  113144. debugMode: number;
  113145. /**
  113146. * @hidden
  113147. * This is reserved for the inspector.
  113148. * Specify from where on screen the debug mode should start.
  113149. * The value goes from -1 (full screen) to 1 (not visible)
  113150. * It helps with side by side comparison against the final render
  113151. * This defaults to -1
  113152. */
  113153. private debugLimit;
  113154. /**
  113155. * @hidden
  113156. * This is reserved for the inspector.
  113157. * As the default viewing range might not be enough (if the ambient is really small for instance)
  113158. * You can use the factor to better multiply the final value.
  113159. */
  113160. private debugFactor;
  113161. /**
  113162. * Defines the clear coat layer parameters for the material.
  113163. */
  113164. readonly clearCoat: PBRClearCoatConfiguration;
  113165. /**
  113166. * Defines the anisotropic parameters for the material.
  113167. */
  113168. readonly anisotropy: PBRAnisotropicConfiguration;
  113169. /**
  113170. * Defines the BRDF parameters for the material.
  113171. */
  113172. readonly brdf: PBRBRDFConfiguration;
  113173. /**
  113174. * Defines the Sheen parameters for the material.
  113175. */
  113176. readonly sheen: PBRSheenConfiguration;
  113177. /**
  113178. * Defines the SubSurface parameters for the material.
  113179. */
  113180. readonly subSurface: PBRSubSurfaceConfiguration;
  113181. /**
  113182. * Custom callback helping to override the default shader used in the material.
  113183. */
  113184. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  113185. protected _rebuildInParallel: boolean;
  113186. /**
  113187. * Instantiates a new PBRMaterial instance.
  113188. *
  113189. * @param name The material name
  113190. * @param scene The scene the material will be use in.
  113191. */
  113192. constructor(name: string, scene: Scene);
  113193. /**
  113194. * Gets a boolean indicating that current material needs to register RTT
  113195. */
  113196. readonly hasRenderTargetTextures: boolean;
  113197. /**
  113198. * Gets the name of the material class.
  113199. */
  113200. getClassName(): string;
  113201. /**
  113202. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113203. */
  113204. /**
  113205. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113206. */
  113207. useLogarithmicDepth: boolean;
  113208. /**
  113209. * Gets the current transparency mode.
  113210. */
  113211. /**
  113212. * Sets the transparency mode of the material.
  113213. *
  113214. * | Value | Type | Description |
  113215. * | ----- | ----------------------------------- | ----------- |
  113216. * | 0 | OPAQUE | |
  113217. * | 1 | ALPHATEST | |
  113218. * | 2 | ALPHABLEND | |
  113219. * | 3 | ALPHATESTANDBLEND | |
  113220. *
  113221. */
  113222. transparencyMode: Nullable<number>;
  113223. /**
  113224. * Returns true if alpha blending should be disabled.
  113225. */
  113226. private readonly _disableAlphaBlending;
  113227. /**
  113228. * Specifies whether or not this material should be rendered in alpha blend mode.
  113229. */
  113230. needAlphaBlending(): boolean;
  113231. /**
  113232. * Specifies if the mesh will require alpha blending.
  113233. * @param mesh - BJS mesh.
  113234. */
  113235. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  113236. /**
  113237. * Specifies whether or not this material should be rendered in alpha test mode.
  113238. */
  113239. needAlphaTesting(): boolean;
  113240. /**
  113241. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  113242. */
  113243. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  113244. /**
  113245. * Gets the texture used for the alpha test.
  113246. */
  113247. getAlphaTestTexture(): Nullable<BaseTexture>;
  113248. /**
  113249. * Specifies that the submesh is ready to be used.
  113250. * @param mesh - BJS mesh.
  113251. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  113252. * @param useInstances - Specifies that instances should be used.
  113253. * @returns - boolean indicating that the submesh is ready or not.
  113254. */
  113255. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113256. /**
  113257. * Specifies if the material uses metallic roughness workflow.
  113258. * @returns boolean specifiying if the material uses metallic roughness workflow.
  113259. */
  113260. isMetallicWorkflow(): boolean;
  113261. private _prepareEffect;
  113262. private _prepareDefines;
  113263. /**
  113264. * Force shader compilation
  113265. */
  113266. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  113267. clipPlane: boolean;
  113268. }>): void;
  113269. /**
  113270. * Initializes the uniform buffer layout for the shader.
  113271. */
  113272. buildUniformLayout(): void;
  113273. /**
  113274. * Unbinds the material from the mesh
  113275. */
  113276. unbind(): void;
  113277. /**
  113278. * Binds the submesh data.
  113279. * @param world - The world matrix.
  113280. * @param mesh - The BJS mesh.
  113281. * @param subMesh - A submesh of the BJS mesh.
  113282. */
  113283. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113284. /**
  113285. * Returns the animatable textures.
  113286. * @returns - Array of animatable textures.
  113287. */
  113288. getAnimatables(): IAnimatable[];
  113289. /**
  113290. * Returns the texture used for reflections.
  113291. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  113292. */
  113293. private _getReflectionTexture;
  113294. /**
  113295. * Returns an array of the actively used textures.
  113296. * @returns - Array of BaseTextures
  113297. */
  113298. getActiveTextures(): BaseTexture[];
  113299. /**
  113300. * Checks to see if a texture is used in the material.
  113301. * @param texture - Base texture to use.
  113302. * @returns - Boolean specifying if a texture is used in the material.
  113303. */
  113304. hasTexture(texture: BaseTexture): boolean;
  113305. /**
  113306. * Disposes the resources of the material.
  113307. * @param forceDisposeEffect - Forces the disposal of effects.
  113308. * @param forceDisposeTextures - Forces the disposal of all textures.
  113309. */
  113310. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113311. }
  113312. }
  113313. declare module BABYLON {
  113314. /**
  113315. * The Physically based material of BJS.
  113316. *
  113317. * This offers the main features of a standard PBR material.
  113318. * For more information, please refer to the documentation :
  113319. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113320. */
  113321. export class PBRMaterial extends PBRBaseMaterial {
  113322. /**
  113323. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113324. */
  113325. static readonly PBRMATERIAL_OPAQUE: number;
  113326. /**
  113327. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113328. */
  113329. static readonly PBRMATERIAL_ALPHATEST: number;
  113330. /**
  113331. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113332. */
  113333. static readonly PBRMATERIAL_ALPHABLEND: number;
  113334. /**
  113335. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113336. * They are also discarded below the alpha cutoff threshold to improve performances.
  113337. */
  113338. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113339. /**
  113340. * Defines the default value of how much AO map is occluding the analytical lights
  113341. * (point spot...).
  113342. */
  113343. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113344. /**
  113345. * Intensity of the direct lights e.g. the four lights available in your scene.
  113346. * This impacts both the direct diffuse and specular highlights.
  113347. */
  113348. directIntensity: number;
  113349. /**
  113350. * Intensity of the emissive part of the material.
  113351. * This helps controlling the emissive effect without modifying the emissive color.
  113352. */
  113353. emissiveIntensity: number;
  113354. /**
  113355. * Intensity of the environment e.g. how much the environment will light the object
  113356. * either through harmonics for rough material or through the refelction for shiny ones.
  113357. */
  113358. environmentIntensity: number;
  113359. /**
  113360. * This is a special control allowing the reduction of the specular highlights coming from the
  113361. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113362. */
  113363. specularIntensity: number;
  113364. /**
  113365. * Debug Control allowing disabling the bump map on this material.
  113366. */
  113367. disableBumpMap: boolean;
  113368. /**
  113369. * AKA Diffuse Texture in standard nomenclature.
  113370. */
  113371. albedoTexture: BaseTexture;
  113372. /**
  113373. * AKA Occlusion Texture in other nomenclature.
  113374. */
  113375. ambientTexture: BaseTexture;
  113376. /**
  113377. * AKA Occlusion Texture Intensity in other nomenclature.
  113378. */
  113379. ambientTextureStrength: number;
  113380. /**
  113381. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113382. * 1 means it completely occludes it
  113383. * 0 mean it has no impact
  113384. */
  113385. ambientTextureImpactOnAnalyticalLights: number;
  113386. /**
  113387. * Stores the alpha values in a texture.
  113388. */
  113389. opacityTexture: BaseTexture;
  113390. /**
  113391. * Stores the reflection values in a texture.
  113392. */
  113393. reflectionTexture: Nullable<BaseTexture>;
  113394. /**
  113395. * Stores the emissive values in a texture.
  113396. */
  113397. emissiveTexture: BaseTexture;
  113398. /**
  113399. * AKA Specular texture in other nomenclature.
  113400. */
  113401. reflectivityTexture: BaseTexture;
  113402. /**
  113403. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113404. */
  113405. metallicTexture: BaseTexture;
  113406. /**
  113407. * Specifies the metallic scalar of the metallic/roughness workflow.
  113408. * Can also be used to scale the metalness values of the metallic texture.
  113409. */
  113410. metallic: Nullable<number>;
  113411. /**
  113412. * Specifies the roughness scalar of the metallic/roughness workflow.
  113413. * Can also be used to scale the roughness values of the metallic texture.
  113414. */
  113415. roughness: Nullable<number>;
  113416. /**
  113417. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113418. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113419. */
  113420. microSurfaceTexture: BaseTexture;
  113421. /**
  113422. * Stores surface normal data used to displace a mesh in a texture.
  113423. */
  113424. bumpTexture: BaseTexture;
  113425. /**
  113426. * Stores the pre-calculated light information of a mesh in a texture.
  113427. */
  113428. lightmapTexture: BaseTexture;
  113429. /**
  113430. * Stores the refracted light information in a texture.
  113431. */
  113432. refractionTexture: Nullable<BaseTexture>;
  113433. /**
  113434. * The color of a material in ambient lighting.
  113435. */
  113436. ambientColor: Color3;
  113437. /**
  113438. * AKA Diffuse Color in other nomenclature.
  113439. */
  113440. albedoColor: Color3;
  113441. /**
  113442. * AKA Specular Color in other nomenclature.
  113443. */
  113444. reflectivityColor: Color3;
  113445. /**
  113446. * The color reflected from the material.
  113447. */
  113448. reflectionColor: Color3;
  113449. /**
  113450. * The color emitted from the material.
  113451. */
  113452. emissiveColor: Color3;
  113453. /**
  113454. * AKA Glossiness in other nomenclature.
  113455. */
  113456. microSurface: number;
  113457. /**
  113458. * source material index of refraction (IOR)' / 'destination material IOR.
  113459. */
  113460. indexOfRefraction: number;
  113461. /**
  113462. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113463. */
  113464. invertRefractionY: boolean;
  113465. /**
  113466. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113467. * Materials half opaque for instance using refraction could benefit from this control.
  113468. */
  113469. linkRefractionWithTransparency: boolean;
  113470. /**
  113471. * If true, the light map contains occlusion information instead of lighting info.
  113472. */
  113473. useLightmapAsShadowmap: boolean;
  113474. /**
  113475. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113476. */
  113477. useAlphaFromAlbedoTexture: boolean;
  113478. /**
  113479. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113480. */
  113481. forceAlphaTest: boolean;
  113482. /**
  113483. * Defines the alpha limits in alpha test mode.
  113484. */
  113485. alphaCutOff: number;
  113486. /**
  113487. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113488. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113489. */
  113490. useSpecularOverAlpha: boolean;
  113491. /**
  113492. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113493. */
  113494. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113495. /**
  113496. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113497. */
  113498. useRoughnessFromMetallicTextureAlpha: boolean;
  113499. /**
  113500. * Specifies if the metallic texture contains the roughness information in its green channel.
  113501. */
  113502. useRoughnessFromMetallicTextureGreen: boolean;
  113503. /**
  113504. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113505. */
  113506. useMetallnessFromMetallicTextureBlue: boolean;
  113507. /**
  113508. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113509. */
  113510. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113511. /**
  113512. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113513. */
  113514. useAmbientInGrayScale: boolean;
  113515. /**
  113516. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113517. * The material will try to infer what glossiness each pixel should be.
  113518. */
  113519. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113520. /**
  113521. * BJS is using an harcoded light falloff based on a manually sets up range.
  113522. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113523. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113524. */
  113525. /**
  113526. * BJS is using an harcoded light falloff based on a manually sets up range.
  113527. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113528. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113529. */
  113530. usePhysicalLightFalloff: boolean;
  113531. /**
  113532. * In order to support the falloff compatibility with gltf, a special mode has been added
  113533. * to reproduce the gltf light falloff.
  113534. */
  113535. /**
  113536. * In order to support the falloff compatibility with gltf, a special mode has been added
  113537. * to reproduce the gltf light falloff.
  113538. */
  113539. useGLTFLightFalloff: boolean;
  113540. /**
  113541. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113542. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113543. */
  113544. useRadianceOverAlpha: boolean;
  113545. /**
  113546. * Allows using an object space normal map (instead of tangent space).
  113547. */
  113548. useObjectSpaceNormalMap: boolean;
  113549. /**
  113550. * Allows using the bump map in parallax mode.
  113551. */
  113552. useParallax: boolean;
  113553. /**
  113554. * Allows using the bump map in parallax occlusion mode.
  113555. */
  113556. useParallaxOcclusion: boolean;
  113557. /**
  113558. * Controls the scale bias of the parallax mode.
  113559. */
  113560. parallaxScaleBias: number;
  113561. /**
  113562. * If sets to true, disables all the lights affecting the material.
  113563. */
  113564. disableLighting: boolean;
  113565. /**
  113566. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113567. */
  113568. forceIrradianceInFragment: boolean;
  113569. /**
  113570. * Number of Simultaneous lights allowed on the material.
  113571. */
  113572. maxSimultaneousLights: number;
  113573. /**
  113574. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113575. */
  113576. invertNormalMapX: boolean;
  113577. /**
  113578. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113579. */
  113580. invertNormalMapY: boolean;
  113581. /**
  113582. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113583. */
  113584. twoSidedLighting: boolean;
  113585. /**
  113586. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113587. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113588. */
  113589. useAlphaFresnel: boolean;
  113590. /**
  113591. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113592. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113593. */
  113594. useLinearAlphaFresnel: boolean;
  113595. /**
  113596. * Let user defines the brdf lookup texture used for IBL.
  113597. * A default 8bit version is embedded but you could point at :
  113598. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113599. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113600. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113601. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113602. */
  113603. environmentBRDFTexture: Nullable<BaseTexture>;
  113604. /**
  113605. * Force normal to face away from face.
  113606. */
  113607. forceNormalForward: boolean;
  113608. /**
  113609. * Enables specular anti aliasing in the PBR shader.
  113610. * It will both interacts on the Geometry for analytical and IBL lighting.
  113611. * It also prefilter the roughness map based on the bump values.
  113612. */
  113613. enableSpecularAntiAliasing: boolean;
  113614. /**
  113615. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113616. * makes the reflect vector face the model (under horizon).
  113617. */
  113618. useHorizonOcclusion: boolean;
  113619. /**
  113620. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113621. * too much the area relying on ambient texture to define their ambient occlusion.
  113622. */
  113623. useRadianceOcclusion: boolean;
  113624. /**
  113625. * If set to true, no lighting calculations will be applied.
  113626. */
  113627. unlit: boolean;
  113628. /**
  113629. * Gets the image processing configuration used either in this material.
  113630. */
  113631. /**
  113632. * Sets the Default image processing configuration used either in the this material.
  113633. *
  113634. * If sets to null, the scene one is in use.
  113635. */
  113636. imageProcessingConfiguration: ImageProcessingConfiguration;
  113637. /**
  113638. * Gets wether the color curves effect is enabled.
  113639. */
  113640. /**
  113641. * Sets wether the color curves effect is enabled.
  113642. */
  113643. cameraColorCurvesEnabled: boolean;
  113644. /**
  113645. * Gets wether the color grading effect is enabled.
  113646. */
  113647. /**
  113648. * Gets wether the color grading effect is enabled.
  113649. */
  113650. cameraColorGradingEnabled: boolean;
  113651. /**
  113652. * Gets wether tonemapping is enabled or not.
  113653. */
  113654. /**
  113655. * Sets wether tonemapping is enabled or not
  113656. */
  113657. cameraToneMappingEnabled: boolean;
  113658. /**
  113659. * The camera exposure used on this material.
  113660. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113661. * This corresponds to a photographic exposure.
  113662. */
  113663. /**
  113664. * The camera exposure used on this material.
  113665. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113666. * This corresponds to a photographic exposure.
  113667. */
  113668. cameraExposure: number;
  113669. /**
  113670. * Gets The camera contrast used on this material.
  113671. */
  113672. /**
  113673. * Sets The camera contrast used on this material.
  113674. */
  113675. cameraContrast: number;
  113676. /**
  113677. * Gets the Color Grading 2D Lookup Texture.
  113678. */
  113679. /**
  113680. * Sets the Color Grading 2D Lookup Texture.
  113681. */
  113682. cameraColorGradingTexture: Nullable<BaseTexture>;
  113683. /**
  113684. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113685. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113686. * 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;
  113687. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113688. */
  113689. /**
  113690. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113691. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113692. * 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;
  113693. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113694. */
  113695. cameraColorCurves: Nullable<ColorCurves>;
  113696. /**
  113697. * Instantiates a new PBRMaterial instance.
  113698. *
  113699. * @param name The material name
  113700. * @param scene The scene the material will be use in.
  113701. */
  113702. constructor(name: string, scene: Scene);
  113703. /**
  113704. * Returns the name of this material class.
  113705. */
  113706. getClassName(): string;
  113707. /**
  113708. * Makes a duplicate of the current material.
  113709. * @param name - name to use for the new material.
  113710. */
  113711. clone(name: string): PBRMaterial;
  113712. /**
  113713. * Serializes this PBR Material.
  113714. * @returns - An object with the serialized material.
  113715. */
  113716. serialize(): any;
  113717. /**
  113718. * Parses a PBR Material from a serialized object.
  113719. * @param source - Serialized object.
  113720. * @param scene - BJS scene instance.
  113721. * @param rootUrl - url for the scene object
  113722. * @returns - PBRMaterial
  113723. */
  113724. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113725. }
  113726. }
  113727. declare module BABYLON {
  113728. /**
  113729. * Direct draw surface info
  113730. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113731. */
  113732. export interface DDSInfo {
  113733. /**
  113734. * Width of the texture
  113735. */
  113736. width: number;
  113737. /**
  113738. * Width of the texture
  113739. */
  113740. height: number;
  113741. /**
  113742. * Number of Mipmaps for the texture
  113743. * @see https://en.wikipedia.org/wiki/Mipmap
  113744. */
  113745. mipmapCount: number;
  113746. /**
  113747. * If the textures format is a known fourCC format
  113748. * @see https://www.fourcc.org/
  113749. */
  113750. isFourCC: boolean;
  113751. /**
  113752. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113753. */
  113754. isRGB: boolean;
  113755. /**
  113756. * If the texture is a lumincance format
  113757. */
  113758. isLuminance: boolean;
  113759. /**
  113760. * If this is a cube texture
  113761. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113762. */
  113763. isCube: boolean;
  113764. /**
  113765. * If the texture is a compressed format eg. FOURCC_DXT1
  113766. */
  113767. isCompressed: boolean;
  113768. /**
  113769. * The dxgiFormat of the texture
  113770. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113771. */
  113772. dxgiFormat: number;
  113773. /**
  113774. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113775. */
  113776. textureType: number;
  113777. /**
  113778. * Sphericle polynomial created for the dds texture
  113779. */
  113780. sphericalPolynomial?: SphericalPolynomial;
  113781. }
  113782. /**
  113783. * Class used to provide DDS decompression tools
  113784. */
  113785. export class DDSTools {
  113786. /**
  113787. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113788. */
  113789. static StoreLODInAlphaChannel: boolean;
  113790. /**
  113791. * Gets DDS information from an array buffer
  113792. * @param arrayBuffer defines the array buffer to read data from
  113793. * @returns the DDS information
  113794. */
  113795. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113796. private static _FloatView;
  113797. private static _Int32View;
  113798. private static _ToHalfFloat;
  113799. private static _FromHalfFloat;
  113800. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113801. private static _GetHalfFloatRGBAArrayBuffer;
  113802. private static _GetFloatRGBAArrayBuffer;
  113803. private static _GetFloatAsUIntRGBAArrayBuffer;
  113804. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113805. private static _GetRGBAArrayBuffer;
  113806. private static _ExtractLongWordOrder;
  113807. private static _GetRGBArrayBuffer;
  113808. private static _GetLuminanceArrayBuffer;
  113809. /**
  113810. * Uploads DDS Levels to a Babylon Texture
  113811. * @hidden
  113812. */
  113813. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113814. }
  113815. interface Engine {
  113816. /**
  113817. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113818. * @param rootUrl defines the url where the file to load is located
  113819. * @param scene defines the current scene
  113820. * @param lodScale defines scale to apply to the mip map selection
  113821. * @param lodOffset defines offset to apply to the mip map selection
  113822. * @param onLoad defines an optional callback raised when the texture is loaded
  113823. * @param onError defines an optional callback raised if there is an issue to load the texture
  113824. * @param format defines the format of the data
  113825. * @param forcedExtension defines the extension to use to pick the right loader
  113826. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113827. * @returns the cube texture as an InternalTexture
  113828. */
  113829. 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;
  113830. }
  113831. }
  113832. declare module BABYLON {
  113833. /**
  113834. * Implementation of the DDS Texture Loader.
  113835. * @hidden
  113836. */
  113837. export class _DDSTextureLoader implements IInternalTextureLoader {
  113838. /**
  113839. * Defines wether the loader supports cascade loading the different faces.
  113840. */
  113841. readonly supportCascades: boolean;
  113842. /**
  113843. * This returns if the loader support the current file information.
  113844. * @param extension defines the file extension of the file being loaded
  113845. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113846. * @param fallback defines the fallback internal texture if any
  113847. * @param isBase64 defines whether the texture is encoded as a base64
  113848. * @param isBuffer defines whether the texture data are stored as a buffer
  113849. * @returns true if the loader can load the specified file
  113850. */
  113851. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113852. /**
  113853. * Transform the url before loading if required.
  113854. * @param rootUrl the url of the texture
  113855. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113856. * @returns the transformed texture
  113857. */
  113858. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113859. /**
  113860. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113861. * @param rootUrl the url of the texture
  113862. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113863. * @returns the fallback texture
  113864. */
  113865. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113866. /**
  113867. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113868. * @param data contains the texture data
  113869. * @param texture defines the BabylonJS internal texture
  113870. * @param createPolynomials will be true if polynomials have been requested
  113871. * @param onLoad defines the callback to trigger once the texture is ready
  113872. * @param onError defines the callback to trigger in case of error
  113873. */
  113874. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113875. /**
  113876. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113877. * @param data contains the texture data
  113878. * @param texture defines the BabylonJS internal texture
  113879. * @param callback defines the method to call once ready to upload
  113880. */
  113881. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113882. }
  113883. }
  113884. declare module BABYLON {
  113885. /**
  113886. * Implementation of the ENV Texture Loader.
  113887. * @hidden
  113888. */
  113889. export class _ENVTextureLoader implements IInternalTextureLoader {
  113890. /**
  113891. * Defines wether the loader supports cascade loading the different faces.
  113892. */
  113893. readonly supportCascades: boolean;
  113894. /**
  113895. * This returns if the loader support the current file information.
  113896. * @param extension defines the file extension of the file being loaded
  113897. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113898. * @param fallback defines the fallback internal texture if any
  113899. * @param isBase64 defines whether the texture is encoded as a base64
  113900. * @param isBuffer defines whether the texture data are stored as a buffer
  113901. * @returns true if the loader can load the specified file
  113902. */
  113903. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113904. /**
  113905. * Transform the url before loading if required.
  113906. * @param rootUrl the url of the texture
  113907. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113908. * @returns the transformed texture
  113909. */
  113910. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113911. /**
  113912. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113913. * @param rootUrl the url of the texture
  113914. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113915. * @returns the fallback texture
  113916. */
  113917. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113918. /**
  113919. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113920. * @param data contains the texture data
  113921. * @param texture defines the BabylonJS internal texture
  113922. * @param createPolynomials will be true if polynomials have been requested
  113923. * @param onLoad defines the callback to trigger once the texture is ready
  113924. * @param onError defines the callback to trigger in case of error
  113925. */
  113926. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113927. /**
  113928. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113929. * @param data contains the texture data
  113930. * @param texture defines the BabylonJS internal texture
  113931. * @param callback defines the method to call once ready to upload
  113932. */
  113933. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113934. }
  113935. }
  113936. declare module BABYLON {
  113937. /**
  113938. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  113939. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  113940. */
  113941. export class KhronosTextureContainer {
  113942. /** contents of the KTX container file */
  113943. arrayBuffer: any;
  113944. private static HEADER_LEN;
  113945. private static COMPRESSED_2D;
  113946. private static COMPRESSED_3D;
  113947. private static TEX_2D;
  113948. private static TEX_3D;
  113949. /**
  113950. * Gets the openGL type
  113951. */
  113952. glType: number;
  113953. /**
  113954. * Gets the openGL type size
  113955. */
  113956. glTypeSize: number;
  113957. /**
  113958. * Gets the openGL format
  113959. */
  113960. glFormat: number;
  113961. /**
  113962. * Gets the openGL internal format
  113963. */
  113964. glInternalFormat: number;
  113965. /**
  113966. * Gets the base internal format
  113967. */
  113968. glBaseInternalFormat: number;
  113969. /**
  113970. * Gets image width in pixel
  113971. */
  113972. pixelWidth: number;
  113973. /**
  113974. * Gets image height in pixel
  113975. */
  113976. pixelHeight: number;
  113977. /**
  113978. * Gets image depth in pixels
  113979. */
  113980. pixelDepth: number;
  113981. /**
  113982. * Gets the number of array elements
  113983. */
  113984. numberOfArrayElements: number;
  113985. /**
  113986. * Gets the number of faces
  113987. */
  113988. numberOfFaces: number;
  113989. /**
  113990. * Gets the number of mipmap levels
  113991. */
  113992. numberOfMipmapLevels: number;
  113993. /**
  113994. * Gets the bytes of key value data
  113995. */
  113996. bytesOfKeyValueData: number;
  113997. /**
  113998. * Gets the load type
  113999. */
  114000. loadType: number;
  114001. /**
  114002. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  114003. */
  114004. isInvalid: boolean;
  114005. /**
  114006. * Creates a new KhronosTextureContainer
  114007. * @param arrayBuffer contents of the KTX container file
  114008. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  114009. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  114010. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  114011. */
  114012. constructor(
  114013. /** contents of the KTX container file */
  114014. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  114015. /**
  114016. * Uploads KTX content to a Babylon Texture.
  114017. * It is assumed that the texture has already been created & is currently bound
  114018. * @hidden
  114019. */
  114020. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  114021. private _upload2DCompressedLevels;
  114022. }
  114023. }
  114024. declare module BABYLON {
  114025. /**
  114026. * Implementation of the KTX Texture Loader.
  114027. * @hidden
  114028. */
  114029. export class _KTXTextureLoader implements IInternalTextureLoader {
  114030. /**
  114031. * Defines wether the loader supports cascade loading the different faces.
  114032. */
  114033. readonly supportCascades: boolean;
  114034. /**
  114035. * This returns if the loader support the current file information.
  114036. * @param extension defines the file extension of the file being loaded
  114037. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114038. * @param fallback defines the fallback internal texture if any
  114039. * @param isBase64 defines whether the texture is encoded as a base64
  114040. * @param isBuffer defines whether the texture data are stored as a buffer
  114041. * @returns true if the loader can load the specified file
  114042. */
  114043. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114044. /**
  114045. * Transform the url before loading if required.
  114046. * @param rootUrl the url of the texture
  114047. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114048. * @returns the transformed texture
  114049. */
  114050. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114051. /**
  114052. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114053. * @param rootUrl the url of the texture
  114054. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114055. * @returns the fallback texture
  114056. */
  114057. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114058. /**
  114059. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114060. * @param data contains the texture data
  114061. * @param texture defines the BabylonJS internal texture
  114062. * @param createPolynomials will be true if polynomials have been requested
  114063. * @param onLoad defines the callback to trigger once the texture is ready
  114064. * @param onError defines the callback to trigger in case of error
  114065. */
  114066. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114067. /**
  114068. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114069. * @param data contains the texture data
  114070. * @param texture defines the BabylonJS internal texture
  114071. * @param callback defines the method to call once ready to upload
  114072. */
  114073. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  114074. }
  114075. }
  114076. declare module BABYLON {
  114077. /**
  114078. * Options for the default xr helper
  114079. */
  114080. export class WebXRDefaultExperienceOptions {
  114081. /**
  114082. * Floor meshes that should be used for teleporting
  114083. */
  114084. floorMeshes: Array<AbstractMesh>;
  114085. }
  114086. /**
  114087. * Default experience which provides a similar setup to the previous webVRExperience
  114088. */
  114089. export class WebXRDefaultExperience {
  114090. /**
  114091. * Base experience
  114092. */
  114093. baseExperience: WebXRExperienceHelper;
  114094. /**
  114095. * Input experience extension
  114096. */
  114097. input: WebXRInput;
  114098. /**
  114099. * Loads the controller models
  114100. */
  114101. controllerModelLoader: WebXRControllerModelLoader;
  114102. /**
  114103. * Enables laser pointer and selection
  114104. */
  114105. pointerSelection: WebXRControllerPointerSelection;
  114106. /**
  114107. * Enables teleportation
  114108. */
  114109. teleportation: WebXRControllerTeleportation;
  114110. /**
  114111. * Enables ui for enetering/exiting xr
  114112. */
  114113. enterExitUI: WebXREnterExitUI;
  114114. /**
  114115. * Default output canvas xr should render to
  114116. */
  114117. outputCanvas: WebXRManagedOutputCanvas;
  114118. /**
  114119. * Creates the default xr experience
  114120. * @param scene scene
  114121. * @param options options for basic configuration
  114122. * @returns resulting WebXRDefaultExperience
  114123. */
  114124. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114125. private constructor();
  114126. /**
  114127. * DIsposes of the experience helper
  114128. */
  114129. dispose(): void;
  114130. }
  114131. }
  114132. declare module BABYLON {
  114133. /** @hidden */
  114134. export var _forceSceneHelpersToBundle: boolean;
  114135. interface Scene {
  114136. /**
  114137. * Creates a default light for the scene.
  114138. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  114139. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  114140. */
  114141. createDefaultLight(replace?: boolean): void;
  114142. /**
  114143. * Creates a default camera for the scene.
  114144. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  114145. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114146. * @param replace has default false, when true replaces the active camera in the scene
  114147. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  114148. */
  114149. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114150. /**
  114151. * Creates a default camera and a default light.
  114152. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  114153. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114154. * @param replace has the default false, when true replaces the active camera/light in the scene
  114155. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  114156. */
  114157. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114158. /**
  114159. * Creates a new sky box
  114160. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  114161. * @param environmentTexture defines the texture to use as environment texture
  114162. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  114163. * @param scale defines the overall scale of the skybox
  114164. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  114165. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  114166. * @returns a new mesh holding the sky box
  114167. */
  114168. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  114169. /**
  114170. * Creates a new environment
  114171. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  114172. * @param options defines the options you can use to configure the environment
  114173. * @returns the new EnvironmentHelper
  114174. */
  114175. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  114176. /**
  114177. * Creates a new VREXperienceHelper
  114178. * @see http://doc.babylonjs.com/how_to/webvr_helper
  114179. * @param webVROptions defines the options used to create the new VREXperienceHelper
  114180. * @returns a new VREXperienceHelper
  114181. */
  114182. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  114183. /**
  114184. * Creates a new WebXRDefaultExperience
  114185. * @see http://doc.babylonjs.com/how_to/webxr
  114186. * @param options experience options
  114187. * @returns a promise for a new WebXRDefaultExperience
  114188. */
  114189. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114190. }
  114191. }
  114192. declare module BABYLON {
  114193. /**
  114194. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  114195. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  114196. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  114197. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114198. */
  114199. export class VideoDome extends TransformNode {
  114200. /**
  114201. * Define the video source as a Monoscopic panoramic 360 video.
  114202. */
  114203. static readonly MODE_MONOSCOPIC: number;
  114204. /**
  114205. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114206. */
  114207. static readonly MODE_TOPBOTTOM: number;
  114208. /**
  114209. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114210. */
  114211. static readonly MODE_SIDEBYSIDE: number;
  114212. private _halfDome;
  114213. private _useDirectMapping;
  114214. /**
  114215. * The video texture being displayed on the sphere
  114216. */
  114217. protected _videoTexture: VideoTexture;
  114218. /**
  114219. * Gets the video texture being displayed on the sphere
  114220. */
  114221. readonly videoTexture: VideoTexture;
  114222. /**
  114223. * The skybox material
  114224. */
  114225. protected _material: BackgroundMaterial;
  114226. /**
  114227. * The surface used for the skybox
  114228. */
  114229. protected _mesh: Mesh;
  114230. /**
  114231. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  114232. */
  114233. private _halfDomeMask;
  114234. /**
  114235. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114236. * Also see the options.resolution property.
  114237. */
  114238. fovMultiplier: number;
  114239. private _videoMode;
  114240. /**
  114241. * Gets or set the current video mode for the video. It can be:
  114242. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  114243. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114244. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114245. */
  114246. videoMode: number;
  114247. /**
  114248. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  114249. *
  114250. */
  114251. /**
  114252. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  114253. */
  114254. halfDome: boolean;
  114255. /**
  114256. * Oberserver used in Stereoscopic VR Mode.
  114257. */
  114258. private _onBeforeCameraRenderObserver;
  114259. /**
  114260. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  114261. * @param name Element's name, child elements will append suffixes for their own names.
  114262. * @param urlsOrVideo defines the url(s) or the video element to use
  114263. * @param options An object containing optional or exposed sub element properties
  114264. */
  114265. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  114266. resolution?: number;
  114267. clickToPlay?: boolean;
  114268. autoPlay?: boolean;
  114269. loop?: boolean;
  114270. size?: number;
  114271. poster?: string;
  114272. faceForward?: boolean;
  114273. useDirectMapping?: boolean;
  114274. halfDomeMode?: boolean;
  114275. }, scene: Scene);
  114276. private _changeVideoMode;
  114277. /**
  114278. * Releases resources associated with this node.
  114279. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114280. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114281. */
  114282. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114283. }
  114284. }
  114285. declare module BABYLON {
  114286. /**
  114287. * This class can be used to get instrumentation data from a Babylon engine
  114288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114289. */
  114290. export class EngineInstrumentation implements IDisposable {
  114291. /**
  114292. * Define the instrumented engine.
  114293. */
  114294. engine: Engine;
  114295. private _captureGPUFrameTime;
  114296. private _gpuFrameTimeToken;
  114297. private _gpuFrameTime;
  114298. private _captureShaderCompilationTime;
  114299. private _shaderCompilationTime;
  114300. private _onBeginFrameObserver;
  114301. private _onEndFrameObserver;
  114302. private _onBeforeShaderCompilationObserver;
  114303. private _onAfterShaderCompilationObserver;
  114304. /**
  114305. * Gets the perf counter used for GPU frame time
  114306. */
  114307. readonly gpuFrameTimeCounter: PerfCounter;
  114308. /**
  114309. * Gets the GPU frame time capture status
  114310. */
  114311. /**
  114312. * Enable or disable the GPU frame time capture
  114313. */
  114314. captureGPUFrameTime: boolean;
  114315. /**
  114316. * Gets the perf counter used for shader compilation time
  114317. */
  114318. readonly shaderCompilationTimeCounter: PerfCounter;
  114319. /**
  114320. * Gets the shader compilation time capture status
  114321. */
  114322. /**
  114323. * Enable or disable the shader compilation time capture
  114324. */
  114325. captureShaderCompilationTime: boolean;
  114326. /**
  114327. * Instantiates a new engine instrumentation.
  114328. * This class can be used to get instrumentation data from a Babylon engine
  114329. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114330. * @param engine Defines the engine to instrument
  114331. */
  114332. constructor(
  114333. /**
  114334. * Define the instrumented engine.
  114335. */
  114336. engine: Engine);
  114337. /**
  114338. * Dispose and release associated resources.
  114339. */
  114340. dispose(): void;
  114341. }
  114342. }
  114343. declare module BABYLON {
  114344. /**
  114345. * This class can be used to get instrumentation data from a Babylon engine
  114346. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114347. */
  114348. export class SceneInstrumentation implements IDisposable {
  114349. /**
  114350. * Defines the scene to instrument
  114351. */
  114352. scene: Scene;
  114353. private _captureActiveMeshesEvaluationTime;
  114354. private _activeMeshesEvaluationTime;
  114355. private _captureRenderTargetsRenderTime;
  114356. private _renderTargetsRenderTime;
  114357. private _captureFrameTime;
  114358. private _frameTime;
  114359. private _captureRenderTime;
  114360. private _renderTime;
  114361. private _captureInterFrameTime;
  114362. private _interFrameTime;
  114363. private _captureParticlesRenderTime;
  114364. private _particlesRenderTime;
  114365. private _captureSpritesRenderTime;
  114366. private _spritesRenderTime;
  114367. private _capturePhysicsTime;
  114368. private _physicsTime;
  114369. private _captureAnimationsTime;
  114370. private _animationsTime;
  114371. private _captureCameraRenderTime;
  114372. private _cameraRenderTime;
  114373. private _onBeforeActiveMeshesEvaluationObserver;
  114374. private _onAfterActiveMeshesEvaluationObserver;
  114375. private _onBeforeRenderTargetsRenderObserver;
  114376. private _onAfterRenderTargetsRenderObserver;
  114377. private _onAfterRenderObserver;
  114378. private _onBeforeDrawPhaseObserver;
  114379. private _onAfterDrawPhaseObserver;
  114380. private _onBeforeAnimationsObserver;
  114381. private _onBeforeParticlesRenderingObserver;
  114382. private _onAfterParticlesRenderingObserver;
  114383. private _onBeforeSpritesRenderingObserver;
  114384. private _onAfterSpritesRenderingObserver;
  114385. private _onBeforePhysicsObserver;
  114386. private _onAfterPhysicsObserver;
  114387. private _onAfterAnimationsObserver;
  114388. private _onBeforeCameraRenderObserver;
  114389. private _onAfterCameraRenderObserver;
  114390. /**
  114391. * Gets the perf counter used for active meshes evaluation time
  114392. */
  114393. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114394. /**
  114395. * Gets the active meshes evaluation time capture status
  114396. */
  114397. /**
  114398. * Enable or disable the active meshes evaluation time capture
  114399. */
  114400. captureActiveMeshesEvaluationTime: boolean;
  114401. /**
  114402. * Gets the perf counter used for render targets render time
  114403. */
  114404. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114405. /**
  114406. * Gets the render targets render time capture status
  114407. */
  114408. /**
  114409. * Enable or disable the render targets render time capture
  114410. */
  114411. captureRenderTargetsRenderTime: boolean;
  114412. /**
  114413. * Gets the perf counter used for particles render time
  114414. */
  114415. readonly particlesRenderTimeCounter: PerfCounter;
  114416. /**
  114417. * Gets the particles render time capture status
  114418. */
  114419. /**
  114420. * Enable or disable the particles render time capture
  114421. */
  114422. captureParticlesRenderTime: boolean;
  114423. /**
  114424. * Gets the perf counter used for sprites render time
  114425. */
  114426. readonly spritesRenderTimeCounter: PerfCounter;
  114427. /**
  114428. * Gets the sprites render time capture status
  114429. */
  114430. /**
  114431. * Enable or disable the sprites render time capture
  114432. */
  114433. captureSpritesRenderTime: boolean;
  114434. /**
  114435. * Gets the perf counter used for physics time
  114436. */
  114437. readonly physicsTimeCounter: PerfCounter;
  114438. /**
  114439. * Gets the physics time capture status
  114440. */
  114441. /**
  114442. * Enable or disable the physics time capture
  114443. */
  114444. capturePhysicsTime: boolean;
  114445. /**
  114446. * Gets the perf counter used for animations time
  114447. */
  114448. readonly animationsTimeCounter: PerfCounter;
  114449. /**
  114450. * Gets the animations time capture status
  114451. */
  114452. /**
  114453. * Enable or disable the animations time capture
  114454. */
  114455. captureAnimationsTime: boolean;
  114456. /**
  114457. * Gets the perf counter used for frame time capture
  114458. */
  114459. readonly frameTimeCounter: PerfCounter;
  114460. /**
  114461. * Gets the frame time capture status
  114462. */
  114463. /**
  114464. * Enable or disable the frame time capture
  114465. */
  114466. captureFrameTime: boolean;
  114467. /**
  114468. * Gets the perf counter used for inter-frames time capture
  114469. */
  114470. readonly interFrameTimeCounter: PerfCounter;
  114471. /**
  114472. * Gets the inter-frames time capture status
  114473. */
  114474. /**
  114475. * Enable or disable the inter-frames time capture
  114476. */
  114477. captureInterFrameTime: boolean;
  114478. /**
  114479. * Gets the perf counter used for render time capture
  114480. */
  114481. readonly renderTimeCounter: PerfCounter;
  114482. /**
  114483. * Gets the render time capture status
  114484. */
  114485. /**
  114486. * Enable or disable the render time capture
  114487. */
  114488. captureRenderTime: boolean;
  114489. /**
  114490. * Gets the perf counter used for camera render time capture
  114491. */
  114492. readonly cameraRenderTimeCounter: PerfCounter;
  114493. /**
  114494. * Gets the camera render time capture status
  114495. */
  114496. /**
  114497. * Enable or disable the camera render time capture
  114498. */
  114499. captureCameraRenderTime: boolean;
  114500. /**
  114501. * Gets the perf counter used for draw calls
  114502. */
  114503. readonly drawCallsCounter: PerfCounter;
  114504. /**
  114505. * Instantiates a new scene instrumentation.
  114506. * This class can be used to get instrumentation data from a Babylon engine
  114507. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114508. * @param scene Defines the scene to instrument
  114509. */
  114510. constructor(
  114511. /**
  114512. * Defines the scene to instrument
  114513. */
  114514. scene: Scene);
  114515. /**
  114516. * Dispose and release associated resources.
  114517. */
  114518. dispose(): void;
  114519. }
  114520. }
  114521. declare module BABYLON {
  114522. /** @hidden */
  114523. export var glowMapGenerationPixelShader: {
  114524. name: string;
  114525. shader: string;
  114526. };
  114527. }
  114528. declare module BABYLON {
  114529. /** @hidden */
  114530. export var glowMapGenerationVertexShader: {
  114531. name: string;
  114532. shader: string;
  114533. };
  114534. }
  114535. declare module BABYLON {
  114536. /**
  114537. * Effect layer options. This helps customizing the behaviour
  114538. * of the effect layer.
  114539. */
  114540. export interface IEffectLayerOptions {
  114541. /**
  114542. * Multiplication factor apply to the canvas size to compute the render target size
  114543. * used to generated the objects (the smaller the faster).
  114544. */
  114545. mainTextureRatio: number;
  114546. /**
  114547. * Enforces a fixed size texture to ensure effect stability across devices.
  114548. */
  114549. mainTextureFixedSize?: number;
  114550. /**
  114551. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114552. */
  114553. alphaBlendingMode: number;
  114554. /**
  114555. * The camera attached to the layer.
  114556. */
  114557. camera: Nullable<Camera>;
  114558. /**
  114559. * The rendering group to draw the layer in.
  114560. */
  114561. renderingGroupId: number;
  114562. }
  114563. /**
  114564. * The effect layer Helps adding post process effect blended with the main pass.
  114565. *
  114566. * This can be for instance use to generate glow or higlight effects on the scene.
  114567. *
  114568. * The effect layer class can not be used directly and is intented to inherited from to be
  114569. * customized per effects.
  114570. */
  114571. export abstract class EffectLayer {
  114572. private _vertexBuffers;
  114573. private _indexBuffer;
  114574. private _cachedDefines;
  114575. private _effectLayerMapGenerationEffect;
  114576. private _effectLayerOptions;
  114577. private _mergeEffect;
  114578. protected _scene: Scene;
  114579. protected _engine: Engine;
  114580. protected _maxSize: number;
  114581. protected _mainTextureDesiredSize: ISize;
  114582. protected _mainTexture: RenderTargetTexture;
  114583. protected _shouldRender: boolean;
  114584. protected _postProcesses: PostProcess[];
  114585. protected _textures: BaseTexture[];
  114586. protected _emissiveTextureAndColor: {
  114587. texture: Nullable<BaseTexture>;
  114588. color: Color4;
  114589. };
  114590. /**
  114591. * The name of the layer
  114592. */
  114593. name: string;
  114594. /**
  114595. * The clear color of the texture used to generate the glow map.
  114596. */
  114597. neutralColor: Color4;
  114598. /**
  114599. * Specifies wether the highlight layer is enabled or not.
  114600. */
  114601. isEnabled: boolean;
  114602. /**
  114603. * Gets the camera attached to the layer.
  114604. */
  114605. readonly camera: Nullable<Camera>;
  114606. /**
  114607. * Gets the rendering group id the layer should render in.
  114608. */
  114609. renderingGroupId: number;
  114610. /**
  114611. * An event triggered when the effect layer has been disposed.
  114612. */
  114613. onDisposeObservable: Observable<EffectLayer>;
  114614. /**
  114615. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114616. */
  114617. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114618. /**
  114619. * An event triggered when the generated texture is being merged in the scene.
  114620. */
  114621. onBeforeComposeObservable: Observable<EffectLayer>;
  114622. /**
  114623. * An event triggered when the generated texture has been merged in the scene.
  114624. */
  114625. onAfterComposeObservable: Observable<EffectLayer>;
  114626. /**
  114627. * An event triggered when the efffect layer changes its size.
  114628. */
  114629. onSizeChangedObservable: Observable<EffectLayer>;
  114630. /** @hidden */
  114631. static _SceneComponentInitialization: (scene: Scene) => void;
  114632. /**
  114633. * Instantiates a new effect Layer and references it in the scene.
  114634. * @param name The name of the layer
  114635. * @param scene The scene to use the layer in
  114636. */
  114637. constructor(
  114638. /** The Friendly of the effect in the scene */
  114639. name: string, scene: Scene);
  114640. /**
  114641. * Get the effect name of the layer.
  114642. * @return The effect name
  114643. */
  114644. abstract getEffectName(): string;
  114645. /**
  114646. * Checks for the readiness of the element composing the layer.
  114647. * @param subMesh the mesh to check for
  114648. * @param useInstances specify wether or not to use instances to render the mesh
  114649. * @return true if ready otherwise, false
  114650. */
  114651. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114652. /**
  114653. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114654. * @returns true if the effect requires stencil during the main canvas render pass.
  114655. */
  114656. abstract needStencil(): boolean;
  114657. /**
  114658. * Create the merge effect. This is the shader use to blit the information back
  114659. * to the main canvas at the end of the scene rendering.
  114660. * @returns The effect containing the shader used to merge the effect on the main canvas
  114661. */
  114662. protected abstract _createMergeEffect(): Effect;
  114663. /**
  114664. * Creates the render target textures and post processes used in the effect layer.
  114665. */
  114666. protected abstract _createTextureAndPostProcesses(): void;
  114667. /**
  114668. * Implementation specific of rendering the generating effect on the main canvas.
  114669. * @param effect The effect used to render through
  114670. */
  114671. protected abstract _internalRender(effect: Effect): void;
  114672. /**
  114673. * Sets the required values for both the emissive texture and and the main color.
  114674. */
  114675. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114676. /**
  114677. * Free any resources and references associated to a mesh.
  114678. * Internal use
  114679. * @param mesh The mesh to free.
  114680. */
  114681. abstract _disposeMesh(mesh: Mesh): void;
  114682. /**
  114683. * Serializes this layer (Glow or Highlight for example)
  114684. * @returns a serialized layer object
  114685. */
  114686. abstract serialize?(): any;
  114687. /**
  114688. * Initializes the effect layer with the required options.
  114689. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114690. */
  114691. protected _init(options: Partial<IEffectLayerOptions>): void;
  114692. /**
  114693. * Generates the index buffer of the full screen quad blending to the main canvas.
  114694. */
  114695. private _generateIndexBuffer;
  114696. /**
  114697. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114698. */
  114699. private _generateVertexBuffer;
  114700. /**
  114701. * Sets the main texture desired size which is the closest power of two
  114702. * of the engine canvas size.
  114703. */
  114704. private _setMainTextureSize;
  114705. /**
  114706. * Creates the main texture for the effect layer.
  114707. */
  114708. protected _createMainTexture(): void;
  114709. /**
  114710. * Adds specific effects defines.
  114711. * @param defines The defines to add specifics to.
  114712. */
  114713. protected _addCustomEffectDefines(defines: string[]): void;
  114714. /**
  114715. * Checks for the readiness of the element composing the layer.
  114716. * @param subMesh the mesh to check for
  114717. * @param useInstances specify wether or not to use instances to render the mesh
  114718. * @param emissiveTexture the associated emissive texture used to generate the glow
  114719. * @return true if ready otherwise, false
  114720. */
  114721. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114722. /**
  114723. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114724. */
  114725. render(): void;
  114726. /**
  114727. * Determine if a given mesh will be used in the current effect.
  114728. * @param mesh mesh to test
  114729. * @returns true if the mesh will be used
  114730. */
  114731. hasMesh(mesh: AbstractMesh): boolean;
  114732. /**
  114733. * Returns true if the layer contains information to display, otherwise false.
  114734. * @returns true if the glow layer should be rendered
  114735. */
  114736. shouldRender(): boolean;
  114737. /**
  114738. * Returns true if the mesh should render, otherwise false.
  114739. * @param mesh The mesh to render
  114740. * @returns true if it should render otherwise false
  114741. */
  114742. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114743. /**
  114744. * Returns true if the mesh can be rendered, otherwise false.
  114745. * @param mesh The mesh to render
  114746. * @param material The material used on the mesh
  114747. * @returns true if it can be rendered otherwise false
  114748. */
  114749. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114750. /**
  114751. * Returns true if the mesh should render, otherwise false.
  114752. * @param mesh The mesh to render
  114753. * @returns true if it should render otherwise false
  114754. */
  114755. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114756. /**
  114757. * Renders the submesh passed in parameter to the generation map.
  114758. */
  114759. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114760. /**
  114761. * Rebuild the required buffers.
  114762. * @hidden Internal use only.
  114763. */
  114764. _rebuild(): void;
  114765. /**
  114766. * Dispose only the render target textures and post process.
  114767. */
  114768. private _disposeTextureAndPostProcesses;
  114769. /**
  114770. * Dispose the highlight layer and free resources.
  114771. */
  114772. dispose(): void;
  114773. /**
  114774. * Gets the class name of the effect layer
  114775. * @returns the string with the class name of the effect layer
  114776. */
  114777. getClassName(): string;
  114778. /**
  114779. * Creates an effect layer from parsed effect layer data
  114780. * @param parsedEffectLayer defines effect layer data
  114781. * @param scene defines the current scene
  114782. * @param rootUrl defines the root URL containing the effect layer information
  114783. * @returns a parsed effect Layer
  114784. */
  114785. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114786. }
  114787. }
  114788. declare module BABYLON {
  114789. interface AbstractScene {
  114790. /**
  114791. * The list of effect layers (highlights/glow) added to the scene
  114792. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114793. * @see http://doc.babylonjs.com/how_to/glow_layer
  114794. */
  114795. effectLayers: Array<EffectLayer>;
  114796. /**
  114797. * Removes the given effect layer from this scene.
  114798. * @param toRemove defines the effect layer to remove
  114799. * @returns the index of the removed effect layer
  114800. */
  114801. removeEffectLayer(toRemove: EffectLayer): number;
  114802. /**
  114803. * Adds the given effect layer to this scene
  114804. * @param newEffectLayer defines the effect layer to add
  114805. */
  114806. addEffectLayer(newEffectLayer: EffectLayer): void;
  114807. }
  114808. /**
  114809. * Defines the layer scene component responsible to manage any effect layers
  114810. * in a given scene.
  114811. */
  114812. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114813. /**
  114814. * The component name helpfull to identify the component in the list of scene components.
  114815. */
  114816. readonly name: string;
  114817. /**
  114818. * The scene the component belongs to.
  114819. */
  114820. scene: Scene;
  114821. private _engine;
  114822. private _renderEffects;
  114823. private _needStencil;
  114824. private _previousStencilState;
  114825. /**
  114826. * Creates a new instance of the component for the given scene
  114827. * @param scene Defines the scene to register the component in
  114828. */
  114829. constructor(scene: Scene);
  114830. /**
  114831. * Registers the component in a given scene
  114832. */
  114833. register(): void;
  114834. /**
  114835. * Rebuilds the elements related to this component in case of
  114836. * context lost for instance.
  114837. */
  114838. rebuild(): void;
  114839. /**
  114840. * Serializes the component data to the specified json object
  114841. * @param serializationObject The object to serialize to
  114842. */
  114843. serialize(serializationObject: any): void;
  114844. /**
  114845. * Adds all the elements from the container to the scene
  114846. * @param container the container holding the elements
  114847. */
  114848. addFromContainer(container: AbstractScene): void;
  114849. /**
  114850. * Removes all the elements in the container from the scene
  114851. * @param container contains the elements to remove
  114852. * @param dispose if the removed element should be disposed (default: false)
  114853. */
  114854. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114855. /**
  114856. * Disposes the component and the associated ressources.
  114857. */
  114858. dispose(): void;
  114859. private _isReadyForMesh;
  114860. private _renderMainTexture;
  114861. private _setStencil;
  114862. private _setStencilBack;
  114863. private _draw;
  114864. private _drawCamera;
  114865. private _drawRenderingGroup;
  114866. }
  114867. }
  114868. declare module BABYLON {
  114869. /** @hidden */
  114870. export var glowMapMergePixelShader: {
  114871. name: string;
  114872. shader: string;
  114873. };
  114874. }
  114875. declare module BABYLON {
  114876. /** @hidden */
  114877. export var glowMapMergeVertexShader: {
  114878. name: string;
  114879. shader: string;
  114880. };
  114881. }
  114882. declare module BABYLON {
  114883. interface AbstractScene {
  114884. /**
  114885. * Return a the first highlight layer of the scene with a given name.
  114886. * @param name The name of the highlight layer to look for.
  114887. * @return The highlight layer if found otherwise null.
  114888. */
  114889. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  114890. }
  114891. /**
  114892. * Glow layer options. This helps customizing the behaviour
  114893. * of the glow layer.
  114894. */
  114895. export interface IGlowLayerOptions {
  114896. /**
  114897. * Multiplication factor apply to the canvas size to compute the render target size
  114898. * used to generated the glowing objects (the smaller the faster).
  114899. */
  114900. mainTextureRatio: number;
  114901. /**
  114902. * Enforces a fixed size texture to ensure resize independant blur.
  114903. */
  114904. mainTextureFixedSize?: number;
  114905. /**
  114906. * How big is the kernel of the blur texture.
  114907. */
  114908. blurKernelSize: number;
  114909. /**
  114910. * The camera attached to the layer.
  114911. */
  114912. camera: Nullable<Camera>;
  114913. /**
  114914. * Enable MSAA by chosing the number of samples.
  114915. */
  114916. mainTextureSamples?: number;
  114917. /**
  114918. * The rendering group to draw the layer in.
  114919. */
  114920. renderingGroupId: number;
  114921. }
  114922. /**
  114923. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  114924. *
  114925. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114926. * glowy meshes to your scene.
  114927. *
  114928. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  114929. */
  114930. export class GlowLayer extends EffectLayer {
  114931. /**
  114932. * Effect Name of the layer.
  114933. */
  114934. static readonly EffectName: string;
  114935. /**
  114936. * The default blur kernel size used for the glow.
  114937. */
  114938. static DefaultBlurKernelSize: number;
  114939. /**
  114940. * The default texture size ratio used for the glow.
  114941. */
  114942. static DefaultTextureRatio: number;
  114943. /**
  114944. * Sets the kernel size of the blur.
  114945. */
  114946. /**
  114947. * Gets the kernel size of the blur.
  114948. */
  114949. blurKernelSize: number;
  114950. /**
  114951. * Sets the glow intensity.
  114952. */
  114953. /**
  114954. * Gets the glow intensity.
  114955. */
  114956. intensity: number;
  114957. private _options;
  114958. private _intensity;
  114959. private _horizontalBlurPostprocess1;
  114960. private _verticalBlurPostprocess1;
  114961. private _horizontalBlurPostprocess2;
  114962. private _verticalBlurPostprocess2;
  114963. private _blurTexture1;
  114964. private _blurTexture2;
  114965. private _postProcesses1;
  114966. private _postProcesses2;
  114967. private _includedOnlyMeshes;
  114968. private _excludedMeshes;
  114969. /**
  114970. * Callback used to let the user override the color selection on a per mesh basis
  114971. */
  114972. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  114973. /**
  114974. * Callback used to let the user override the texture selection on a per mesh basis
  114975. */
  114976. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  114977. /**
  114978. * Instantiates a new glow Layer and references it to the scene.
  114979. * @param name The name of the layer
  114980. * @param scene The scene to use the layer in
  114981. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  114982. */
  114983. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  114984. /**
  114985. * Get the effect name of the layer.
  114986. * @return The effect name
  114987. */
  114988. getEffectName(): string;
  114989. /**
  114990. * Create the merge effect. This is the shader use to blit the information back
  114991. * to the main canvas at the end of the scene rendering.
  114992. */
  114993. protected _createMergeEffect(): Effect;
  114994. /**
  114995. * Creates the render target textures and post processes used in the glow layer.
  114996. */
  114997. protected _createTextureAndPostProcesses(): void;
  114998. /**
  114999. * Checks for the readiness of the element composing the layer.
  115000. * @param subMesh the mesh to check for
  115001. * @param useInstances specify wether or not to use instances to render the mesh
  115002. * @param emissiveTexture the associated emissive texture used to generate the glow
  115003. * @return true if ready otherwise, false
  115004. */
  115005. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115006. /**
  115007. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115008. */
  115009. needStencil(): boolean;
  115010. /**
  115011. * Returns true if the mesh can be rendered, otherwise false.
  115012. * @param mesh The mesh to render
  115013. * @param material The material used on the mesh
  115014. * @returns true if it can be rendered otherwise false
  115015. */
  115016. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115017. /**
  115018. * Implementation specific of rendering the generating effect on the main canvas.
  115019. * @param effect The effect used to render through
  115020. */
  115021. protected _internalRender(effect: Effect): void;
  115022. /**
  115023. * Sets the required values for both the emissive texture and and the main color.
  115024. */
  115025. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115026. /**
  115027. * Returns true if the mesh should render, otherwise false.
  115028. * @param mesh The mesh to render
  115029. * @returns true if it should render otherwise false
  115030. */
  115031. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115032. /**
  115033. * Adds specific effects defines.
  115034. * @param defines The defines to add specifics to.
  115035. */
  115036. protected _addCustomEffectDefines(defines: string[]): void;
  115037. /**
  115038. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  115039. * @param mesh The mesh to exclude from the glow layer
  115040. */
  115041. addExcludedMesh(mesh: Mesh): void;
  115042. /**
  115043. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  115044. * @param mesh The mesh to remove
  115045. */
  115046. removeExcludedMesh(mesh: Mesh): void;
  115047. /**
  115048. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  115049. * @param mesh The mesh to include in the glow layer
  115050. */
  115051. addIncludedOnlyMesh(mesh: Mesh): void;
  115052. /**
  115053. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  115054. * @param mesh The mesh to remove
  115055. */
  115056. removeIncludedOnlyMesh(mesh: Mesh): void;
  115057. /**
  115058. * Determine if a given mesh will be used in the glow layer
  115059. * @param mesh The mesh to test
  115060. * @returns true if the mesh will be highlighted by the current glow layer
  115061. */
  115062. hasMesh(mesh: AbstractMesh): boolean;
  115063. /**
  115064. * Free any resources and references associated to a mesh.
  115065. * Internal use
  115066. * @param mesh The mesh to free.
  115067. * @hidden
  115068. */
  115069. _disposeMesh(mesh: Mesh): void;
  115070. /**
  115071. * Gets the class name of the effect layer
  115072. * @returns the string with the class name of the effect layer
  115073. */
  115074. getClassName(): string;
  115075. /**
  115076. * Serializes this glow layer
  115077. * @returns a serialized glow layer object
  115078. */
  115079. serialize(): any;
  115080. /**
  115081. * Creates a Glow Layer from parsed glow layer data
  115082. * @param parsedGlowLayer defines glow layer data
  115083. * @param scene defines the current scene
  115084. * @param rootUrl defines the root URL containing the glow layer information
  115085. * @returns a parsed Glow Layer
  115086. */
  115087. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  115088. }
  115089. }
  115090. declare module BABYLON {
  115091. /** @hidden */
  115092. export var glowBlurPostProcessPixelShader: {
  115093. name: string;
  115094. shader: string;
  115095. };
  115096. }
  115097. declare module BABYLON {
  115098. interface AbstractScene {
  115099. /**
  115100. * Return a the first highlight layer of the scene with a given name.
  115101. * @param name The name of the highlight layer to look for.
  115102. * @return The highlight layer if found otherwise null.
  115103. */
  115104. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  115105. }
  115106. /**
  115107. * Highlight layer options. This helps customizing the behaviour
  115108. * of the highlight layer.
  115109. */
  115110. export interface IHighlightLayerOptions {
  115111. /**
  115112. * Multiplication factor apply to the canvas size to compute the render target size
  115113. * used to generated the glowing objects (the smaller the faster).
  115114. */
  115115. mainTextureRatio: number;
  115116. /**
  115117. * Enforces a fixed size texture to ensure resize independant blur.
  115118. */
  115119. mainTextureFixedSize?: number;
  115120. /**
  115121. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  115122. * of the picture to blur (the smaller the faster).
  115123. */
  115124. blurTextureSizeRatio: number;
  115125. /**
  115126. * How big in texel of the blur texture is the vertical blur.
  115127. */
  115128. blurVerticalSize: number;
  115129. /**
  115130. * How big in texel of the blur texture is the horizontal blur.
  115131. */
  115132. blurHorizontalSize: number;
  115133. /**
  115134. * Alpha blending mode used to apply the blur. Default is combine.
  115135. */
  115136. alphaBlendingMode: number;
  115137. /**
  115138. * The camera attached to the layer.
  115139. */
  115140. camera: Nullable<Camera>;
  115141. /**
  115142. * Should we display highlight as a solid stroke?
  115143. */
  115144. isStroke?: boolean;
  115145. /**
  115146. * The rendering group to draw the layer in.
  115147. */
  115148. renderingGroupId: number;
  115149. }
  115150. /**
  115151. * The highlight layer Helps adding a glow effect around a mesh.
  115152. *
  115153. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115154. * glowy meshes to your scene.
  115155. *
  115156. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  115157. */
  115158. export class HighlightLayer extends EffectLayer {
  115159. name: string;
  115160. /**
  115161. * Effect Name of the highlight layer.
  115162. */
  115163. static readonly EffectName: string;
  115164. /**
  115165. * The neutral color used during the preparation of the glow effect.
  115166. * This is black by default as the blend operation is a blend operation.
  115167. */
  115168. static NeutralColor: Color4;
  115169. /**
  115170. * Stencil value used for glowing meshes.
  115171. */
  115172. static GlowingMeshStencilReference: number;
  115173. /**
  115174. * Stencil value used for the other meshes in the scene.
  115175. */
  115176. static NormalMeshStencilReference: number;
  115177. /**
  115178. * Specifies whether or not the inner glow is ACTIVE in the layer.
  115179. */
  115180. innerGlow: boolean;
  115181. /**
  115182. * Specifies whether or not the outer glow is ACTIVE in the layer.
  115183. */
  115184. outerGlow: boolean;
  115185. /**
  115186. * Specifies the horizontal size of the blur.
  115187. */
  115188. /**
  115189. * Gets the horizontal size of the blur.
  115190. */
  115191. blurHorizontalSize: number;
  115192. /**
  115193. * Specifies the vertical size of the blur.
  115194. */
  115195. /**
  115196. * Gets the vertical size of the blur.
  115197. */
  115198. blurVerticalSize: number;
  115199. /**
  115200. * An event triggered when the highlight layer is being blurred.
  115201. */
  115202. onBeforeBlurObservable: Observable<HighlightLayer>;
  115203. /**
  115204. * An event triggered when the highlight layer has been blurred.
  115205. */
  115206. onAfterBlurObservable: Observable<HighlightLayer>;
  115207. private _instanceGlowingMeshStencilReference;
  115208. private _options;
  115209. private _downSamplePostprocess;
  115210. private _horizontalBlurPostprocess;
  115211. private _verticalBlurPostprocess;
  115212. private _blurTexture;
  115213. private _meshes;
  115214. private _excludedMeshes;
  115215. /**
  115216. * Instantiates a new highlight Layer and references it to the scene..
  115217. * @param name The name of the layer
  115218. * @param scene The scene to use the layer in
  115219. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  115220. */
  115221. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  115222. /**
  115223. * Get the effect name of the layer.
  115224. * @return The effect name
  115225. */
  115226. getEffectName(): string;
  115227. /**
  115228. * Create the merge effect. This is the shader use to blit the information back
  115229. * to the main canvas at the end of the scene rendering.
  115230. */
  115231. protected _createMergeEffect(): Effect;
  115232. /**
  115233. * Creates the render target textures and post processes used in the highlight layer.
  115234. */
  115235. protected _createTextureAndPostProcesses(): void;
  115236. /**
  115237. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115238. */
  115239. needStencil(): boolean;
  115240. /**
  115241. * Checks for the readiness of the element composing the layer.
  115242. * @param subMesh the mesh to check for
  115243. * @param useInstances specify wether or not to use instances to render the mesh
  115244. * @param emissiveTexture the associated emissive texture used to generate the glow
  115245. * @return true if ready otherwise, false
  115246. */
  115247. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115248. /**
  115249. * Implementation specific of rendering the generating effect on the main canvas.
  115250. * @param effect The effect used to render through
  115251. */
  115252. protected _internalRender(effect: Effect): void;
  115253. /**
  115254. * Returns true if the layer contains information to display, otherwise false.
  115255. */
  115256. shouldRender(): boolean;
  115257. /**
  115258. * Returns true if the mesh should render, otherwise false.
  115259. * @param mesh The mesh to render
  115260. * @returns true if it should render otherwise false
  115261. */
  115262. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115263. /**
  115264. * Sets the required values for both the emissive texture and and the main color.
  115265. */
  115266. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115267. /**
  115268. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  115269. * @param mesh The mesh to exclude from the highlight layer
  115270. */
  115271. addExcludedMesh(mesh: Mesh): void;
  115272. /**
  115273. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  115274. * @param mesh The mesh to highlight
  115275. */
  115276. removeExcludedMesh(mesh: Mesh): void;
  115277. /**
  115278. * Determine if a given mesh will be highlighted by the current HighlightLayer
  115279. * @param mesh mesh to test
  115280. * @returns true if the mesh will be highlighted by the current HighlightLayer
  115281. */
  115282. hasMesh(mesh: AbstractMesh): boolean;
  115283. /**
  115284. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  115285. * @param mesh The mesh to highlight
  115286. * @param color The color of the highlight
  115287. * @param glowEmissiveOnly Extract the glow from the emissive texture
  115288. */
  115289. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  115290. /**
  115291. * Remove a mesh from the highlight layer in order to make it stop glowing.
  115292. * @param mesh The mesh to highlight
  115293. */
  115294. removeMesh(mesh: Mesh): void;
  115295. /**
  115296. * Force the stencil to the normal expected value for none glowing parts
  115297. */
  115298. private _defaultStencilReference;
  115299. /**
  115300. * Free any resources and references associated to a mesh.
  115301. * Internal use
  115302. * @param mesh The mesh to free.
  115303. * @hidden
  115304. */
  115305. _disposeMesh(mesh: Mesh): void;
  115306. /**
  115307. * Dispose the highlight layer and free resources.
  115308. */
  115309. dispose(): void;
  115310. /**
  115311. * Gets the class name of the effect layer
  115312. * @returns the string with the class name of the effect layer
  115313. */
  115314. getClassName(): string;
  115315. /**
  115316. * Serializes this Highlight layer
  115317. * @returns a serialized Highlight layer object
  115318. */
  115319. serialize(): any;
  115320. /**
  115321. * Creates a Highlight layer from parsed Highlight layer data
  115322. * @param parsedHightlightLayer defines the Highlight layer data
  115323. * @param scene defines the current scene
  115324. * @param rootUrl defines the root URL containing the Highlight layer information
  115325. * @returns a parsed Highlight layer
  115326. */
  115327. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  115328. }
  115329. }
  115330. declare module BABYLON {
  115331. interface AbstractScene {
  115332. /**
  115333. * The list of layers (background and foreground) of the scene
  115334. */
  115335. layers: Array<Layer>;
  115336. }
  115337. /**
  115338. * Defines the layer scene component responsible to manage any layers
  115339. * in a given scene.
  115340. */
  115341. export class LayerSceneComponent implements ISceneComponent {
  115342. /**
  115343. * The component name helpfull to identify the component in the list of scene components.
  115344. */
  115345. readonly name: string;
  115346. /**
  115347. * The scene the component belongs to.
  115348. */
  115349. scene: Scene;
  115350. private _engine;
  115351. /**
  115352. * Creates a new instance of the component for the given scene
  115353. * @param scene Defines the scene to register the component in
  115354. */
  115355. constructor(scene: Scene);
  115356. /**
  115357. * Registers the component in a given scene
  115358. */
  115359. register(): void;
  115360. /**
  115361. * Rebuilds the elements related to this component in case of
  115362. * context lost for instance.
  115363. */
  115364. rebuild(): void;
  115365. /**
  115366. * Disposes the component and the associated ressources.
  115367. */
  115368. dispose(): void;
  115369. private _draw;
  115370. private _drawCameraPredicate;
  115371. private _drawCameraBackground;
  115372. private _drawCameraForeground;
  115373. private _drawRenderTargetPredicate;
  115374. private _drawRenderTargetBackground;
  115375. private _drawRenderTargetForeground;
  115376. /**
  115377. * Adds all the elements from the container to the scene
  115378. * @param container the container holding the elements
  115379. */
  115380. addFromContainer(container: AbstractScene): void;
  115381. /**
  115382. * Removes all the elements in the container from the scene
  115383. * @param container contains the elements to remove
  115384. * @param dispose if the removed element should be disposed (default: false)
  115385. */
  115386. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115387. }
  115388. }
  115389. declare module BABYLON {
  115390. /** @hidden */
  115391. export var layerPixelShader: {
  115392. name: string;
  115393. shader: string;
  115394. };
  115395. }
  115396. declare module BABYLON {
  115397. /** @hidden */
  115398. export var layerVertexShader: {
  115399. name: string;
  115400. shader: string;
  115401. };
  115402. }
  115403. declare module BABYLON {
  115404. /**
  115405. * This represents a full screen 2d layer.
  115406. * This can be useful to display a picture in the background of your scene for instance.
  115407. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115408. */
  115409. export class Layer {
  115410. /**
  115411. * Define the name of the layer.
  115412. */
  115413. name: string;
  115414. /**
  115415. * Define the texture the layer should display.
  115416. */
  115417. texture: Nullable<Texture>;
  115418. /**
  115419. * Is the layer in background or foreground.
  115420. */
  115421. isBackground: boolean;
  115422. /**
  115423. * Define the color of the layer (instead of texture).
  115424. */
  115425. color: Color4;
  115426. /**
  115427. * Define the scale of the layer in order to zoom in out of the texture.
  115428. */
  115429. scale: Vector2;
  115430. /**
  115431. * Define an offset for the layer in order to shift the texture.
  115432. */
  115433. offset: Vector2;
  115434. /**
  115435. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115436. */
  115437. alphaBlendingMode: number;
  115438. /**
  115439. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115440. * Alpha test will not mix with the background color in case of transparency.
  115441. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115442. */
  115443. alphaTest: boolean;
  115444. /**
  115445. * Define a mask to restrict the layer to only some of the scene cameras.
  115446. */
  115447. layerMask: number;
  115448. /**
  115449. * Define the list of render target the layer is visible into.
  115450. */
  115451. renderTargetTextures: RenderTargetTexture[];
  115452. /**
  115453. * Define if the layer is only used in renderTarget or if it also
  115454. * renders in the main frame buffer of the canvas.
  115455. */
  115456. renderOnlyInRenderTargetTextures: boolean;
  115457. private _scene;
  115458. private _vertexBuffers;
  115459. private _indexBuffer;
  115460. private _effect;
  115461. private _alphaTestEffect;
  115462. /**
  115463. * An event triggered when the layer is disposed.
  115464. */
  115465. onDisposeObservable: Observable<Layer>;
  115466. private _onDisposeObserver;
  115467. /**
  115468. * Back compatibility with callback before the onDisposeObservable existed.
  115469. * The set callback will be triggered when the layer has been disposed.
  115470. */
  115471. onDispose: () => void;
  115472. /**
  115473. * An event triggered before rendering the scene
  115474. */
  115475. onBeforeRenderObservable: Observable<Layer>;
  115476. private _onBeforeRenderObserver;
  115477. /**
  115478. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115479. * The set callback will be triggered just before rendering the layer.
  115480. */
  115481. onBeforeRender: () => void;
  115482. /**
  115483. * An event triggered after rendering the scene
  115484. */
  115485. onAfterRenderObservable: Observable<Layer>;
  115486. private _onAfterRenderObserver;
  115487. /**
  115488. * Back compatibility with callback before the onAfterRenderObservable existed.
  115489. * The set callback will be triggered just after rendering the layer.
  115490. */
  115491. onAfterRender: () => void;
  115492. /**
  115493. * Instantiates a new layer.
  115494. * This represents a full screen 2d layer.
  115495. * This can be useful to display a picture in the background of your scene for instance.
  115496. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115497. * @param name Define the name of the layer in the scene
  115498. * @param imgUrl Define the url of the texture to display in the layer
  115499. * @param scene Define the scene the layer belongs to
  115500. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115501. * @param color Defines a color for the layer
  115502. */
  115503. constructor(
  115504. /**
  115505. * Define the name of the layer.
  115506. */
  115507. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115508. private _createIndexBuffer;
  115509. /** @hidden */
  115510. _rebuild(): void;
  115511. /**
  115512. * Renders the layer in the scene.
  115513. */
  115514. render(): void;
  115515. /**
  115516. * Disposes and releases the associated ressources.
  115517. */
  115518. dispose(): void;
  115519. }
  115520. }
  115521. declare module BABYLON {
  115522. /** @hidden */
  115523. export var lensFlarePixelShader: {
  115524. name: string;
  115525. shader: string;
  115526. };
  115527. }
  115528. declare module BABYLON {
  115529. /** @hidden */
  115530. export var lensFlareVertexShader: {
  115531. name: string;
  115532. shader: string;
  115533. };
  115534. }
  115535. declare module BABYLON {
  115536. /**
  115537. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115538. * It is usually composed of several `lensFlare`.
  115539. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115540. */
  115541. export class LensFlareSystem {
  115542. /**
  115543. * Define the name of the lens flare system
  115544. */
  115545. name: string;
  115546. /**
  115547. * List of lens flares used in this system.
  115548. */
  115549. lensFlares: LensFlare[];
  115550. /**
  115551. * Define a limit from the border the lens flare can be visible.
  115552. */
  115553. borderLimit: number;
  115554. /**
  115555. * Define a viewport border we do not want to see the lens flare in.
  115556. */
  115557. viewportBorder: number;
  115558. /**
  115559. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115560. */
  115561. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115562. /**
  115563. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115564. */
  115565. layerMask: number;
  115566. /**
  115567. * Define the id of the lens flare system in the scene.
  115568. * (equal to name by default)
  115569. */
  115570. id: string;
  115571. private _scene;
  115572. private _emitter;
  115573. private _vertexBuffers;
  115574. private _indexBuffer;
  115575. private _effect;
  115576. private _positionX;
  115577. private _positionY;
  115578. private _isEnabled;
  115579. /** @hidden */
  115580. static _SceneComponentInitialization: (scene: Scene) => void;
  115581. /**
  115582. * Instantiates a lens flare system.
  115583. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115584. * It is usually composed of several `lensFlare`.
  115585. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115586. * @param name Define the name of the lens flare system in the scene
  115587. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115588. * @param scene Define the scene the lens flare system belongs to
  115589. */
  115590. constructor(
  115591. /**
  115592. * Define the name of the lens flare system
  115593. */
  115594. name: string, emitter: any, scene: Scene);
  115595. /**
  115596. * Define if the lens flare system is enabled.
  115597. */
  115598. isEnabled: boolean;
  115599. /**
  115600. * Get the scene the effects belongs to.
  115601. * @returns the scene holding the lens flare system
  115602. */
  115603. getScene(): Scene;
  115604. /**
  115605. * Get the emitter of the lens flare system.
  115606. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115607. * @returns the emitter of the lens flare system
  115608. */
  115609. getEmitter(): any;
  115610. /**
  115611. * Set the emitter of the lens flare system.
  115612. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115613. * @param newEmitter Define the new emitter of the system
  115614. */
  115615. setEmitter(newEmitter: any): void;
  115616. /**
  115617. * Get the lens flare system emitter position.
  115618. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115619. * @returns the position
  115620. */
  115621. getEmitterPosition(): Vector3;
  115622. /**
  115623. * @hidden
  115624. */
  115625. computeEffectivePosition(globalViewport: Viewport): boolean;
  115626. /** @hidden */
  115627. _isVisible(): boolean;
  115628. /**
  115629. * @hidden
  115630. */
  115631. render(): boolean;
  115632. /**
  115633. * Dispose and release the lens flare with its associated resources.
  115634. */
  115635. dispose(): void;
  115636. /**
  115637. * Parse a lens flare system from a JSON repressentation
  115638. * @param parsedLensFlareSystem Define the JSON to parse
  115639. * @param scene Define the scene the parsed system should be instantiated in
  115640. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115641. * @returns the parsed system
  115642. */
  115643. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115644. /**
  115645. * Serialize the current Lens Flare System into a JSON representation.
  115646. * @returns the serialized JSON
  115647. */
  115648. serialize(): any;
  115649. }
  115650. }
  115651. declare module BABYLON {
  115652. /**
  115653. * This represents one of the lens effect in a `lensFlareSystem`.
  115654. * It controls one of the indiviual texture used in the effect.
  115655. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115656. */
  115657. export class LensFlare {
  115658. /**
  115659. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115660. */
  115661. size: number;
  115662. /**
  115663. * 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.
  115664. */
  115665. position: number;
  115666. /**
  115667. * Define the lens color.
  115668. */
  115669. color: Color3;
  115670. /**
  115671. * Define the lens texture.
  115672. */
  115673. texture: Nullable<Texture>;
  115674. /**
  115675. * Define the alpha mode to render this particular lens.
  115676. */
  115677. alphaMode: number;
  115678. private _system;
  115679. /**
  115680. * Creates a new Lens Flare.
  115681. * This represents one of the lens effect in a `lensFlareSystem`.
  115682. * It controls one of the indiviual texture used in the effect.
  115683. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115684. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  115685. * @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.
  115686. * @param color Define the lens color
  115687. * @param imgUrl Define the lens texture url
  115688. * @param system Define the `lensFlareSystem` this flare is part of
  115689. * @returns The newly created Lens Flare
  115690. */
  115691. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115692. /**
  115693. * Instantiates a new Lens Flare.
  115694. * This represents one of the lens effect in a `lensFlareSystem`.
  115695. * It controls one of the indiviual texture used in the effect.
  115696. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115697. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115698. * @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.
  115699. * @param color Define the lens color
  115700. * @param imgUrl Define the lens texture url
  115701. * @param system Define the `lensFlareSystem` this flare is part of
  115702. */
  115703. constructor(
  115704. /**
  115705. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115706. */
  115707. size: number,
  115708. /**
  115709. * 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.
  115710. */
  115711. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115712. /**
  115713. * Dispose and release the lens flare with its associated resources.
  115714. */
  115715. dispose(): void;
  115716. }
  115717. }
  115718. declare module BABYLON {
  115719. interface AbstractScene {
  115720. /**
  115721. * The list of lens flare system added to the scene
  115722. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115723. */
  115724. lensFlareSystems: Array<LensFlareSystem>;
  115725. /**
  115726. * Removes the given lens flare system from this scene.
  115727. * @param toRemove The lens flare system to remove
  115728. * @returns The index of the removed lens flare system
  115729. */
  115730. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115731. /**
  115732. * Adds the given lens flare system to this scene
  115733. * @param newLensFlareSystem The lens flare system to add
  115734. */
  115735. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115736. /**
  115737. * Gets a lens flare system using its name
  115738. * @param name defines the name to look for
  115739. * @returns the lens flare system or null if not found
  115740. */
  115741. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115742. /**
  115743. * Gets a lens flare system using its id
  115744. * @param id defines the id to look for
  115745. * @returns the lens flare system or null if not found
  115746. */
  115747. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115748. }
  115749. /**
  115750. * Defines the lens flare scene component responsible to manage any lens flares
  115751. * in a given scene.
  115752. */
  115753. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115754. /**
  115755. * The component name helpfull to identify the component in the list of scene components.
  115756. */
  115757. readonly name: string;
  115758. /**
  115759. * The scene the component belongs to.
  115760. */
  115761. scene: Scene;
  115762. /**
  115763. * Creates a new instance of the component for the given scene
  115764. * @param scene Defines the scene to register the component in
  115765. */
  115766. constructor(scene: Scene);
  115767. /**
  115768. * Registers the component in a given scene
  115769. */
  115770. register(): void;
  115771. /**
  115772. * Rebuilds the elements related to this component in case of
  115773. * context lost for instance.
  115774. */
  115775. rebuild(): void;
  115776. /**
  115777. * Adds all the elements from the container to the scene
  115778. * @param container the container holding the elements
  115779. */
  115780. addFromContainer(container: AbstractScene): void;
  115781. /**
  115782. * Removes all the elements in the container from the scene
  115783. * @param container contains the elements to remove
  115784. * @param dispose if the removed element should be disposed (default: false)
  115785. */
  115786. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115787. /**
  115788. * Serializes the component data to the specified json object
  115789. * @param serializationObject The object to serialize to
  115790. */
  115791. serialize(serializationObject: any): void;
  115792. /**
  115793. * Disposes the component and the associated ressources.
  115794. */
  115795. dispose(): void;
  115796. private _draw;
  115797. }
  115798. }
  115799. declare module BABYLON {
  115800. /**
  115801. * Defines the shadow generator component responsible to manage any shadow generators
  115802. * in a given scene.
  115803. */
  115804. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115805. /**
  115806. * The component name helpfull to identify the component in the list of scene components.
  115807. */
  115808. readonly name: string;
  115809. /**
  115810. * The scene the component belongs to.
  115811. */
  115812. scene: Scene;
  115813. /**
  115814. * Creates a new instance of the component for the given scene
  115815. * @param scene Defines the scene to register the component in
  115816. */
  115817. constructor(scene: Scene);
  115818. /**
  115819. * Registers the component in a given scene
  115820. */
  115821. register(): void;
  115822. /**
  115823. * Rebuilds the elements related to this component in case of
  115824. * context lost for instance.
  115825. */
  115826. rebuild(): void;
  115827. /**
  115828. * Serializes the component data to the specified json object
  115829. * @param serializationObject The object to serialize to
  115830. */
  115831. serialize(serializationObject: any): void;
  115832. /**
  115833. * Adds all the elements from the container to the scene
  115834. * @param container the container holding the elements
  115835. */
  115836. addFromContainer(container: AbstractScene): void;
  115837. /**
  115838. * Removes all the elements in the container from the scene
  115839. * @param container contains the elements to remove
  115840. * @param dispose if the removed element should be disposed (default: false)
  115841. */
  115842. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115843. /**
  115844. * Rebuilds the elements related to this component in case of
  115845. * context lost for instance.
  115846. */
  115847. dispose(): void;
  115848. private _gatherRenderTargets;
  115849. }
  115850. }
  115851. declare module BABYLON {
  115852. /**
  115853. * A point light is a light defined by an unique point in world space.
  115854. * The light is emitted in every direction from this point.
  115855. * A good example of a point light is a standard light bulb.
  115856. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115857. */
  115858. export class PointLight extends ShadowLight {
  115859. private _shadowAngle;
  115860. /**
  115861. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115862. * This specifies what angle the shadow will use to be created.
  115863. *
  115864. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115865. */
  115866. /**
  115867. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115868. * This specifies what angle the shadow will use to be created.
  115869. *
  115870. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115871. */
  115872. shadowAngle: number;
  115873. /**
  115874. * Gets the direction if it has been set.
  115875. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115876. */
  115877. /**
  115878. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115879. */
  115880. direction: Vector3;
  115881. /**
  115882. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  115883. * A PointLight emits the light in every direction.
  115884. * It can cast shadows.
  115885. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  115886. * ```javascript
  115887. * var pointLight = new PointLight("pl", camera.position, scene);
  115888. * ```
  115889. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115890. * @param name The light friendly name
  115891. * @param position The position of the point light in the scene
  115892. * @param scene The scene the lights belongs to
  115893. */
  115894. constructor(name: string, position: Vector3, scene: Scene);
  115895. /**
  115896. * Returns the string "PointLight"
  115897. * @returns the class name
  115898. */
  115899. getClassName(): string;
  115900. /**
  115901. * Returns the integer 0.
  115902. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115903. */
  115904. getTypeID(): number;
  115905. /**
  115906. * Specifies wether or not the shadowmap should be a cube texture.
  115907. * @returns true if the shadowmap needs to be a cube texture.
  115908. */
  115909. needCube(): boolean;
  115910. /**
  115911. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  115912. * @param faceIndex The index of the face we are computed the direction to generate shadow
  115913. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  115914. */
  115915. getShadowDirection(faceIndex?: number): Vector3;
  115916. /**
  115917. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  115918. * - fov = PI / 2
  115919. * - aspect ratio : 1.0
  115920. * - z-near and far equal to the active camera minZ and maxZ.
  115921. * Returns the PointLight.
  115922. */
  115923. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115924. protected _buildUniformLayout(): void;
  115925. /**
  115926. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  115927. * @param effect The effect to update
  115928. * @param lightIndex The index of the light in the effect to update
  115929. * @returns The point light
  115930. */
  115931. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  115932. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115933. /**
  115934. * Prepares the list of defines specific to the light type.
  115935. * @param defines the list of defines
  115936. * @param lightIndex defines the index of the light for the effect
  115937. */
  115938. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115939. }
  115940. }
  115941. declare module BABYLON {
  115942. /**
  115943. * Header information of HDR texture files.
  115944. */
  115945. export interface HDRInfo {
  115946. /**
  115947. * The height of the texture in pixels.
  115948. */
  115949. height: number;
  115950. /**
  115951. * The width of the texture in pixels.
  115952. */
  115953. width: number;
  115954. /**
  115955. * The index of the beginning of the data in the binary file.
  115956. */
  115957. dataPosition: number;
  115958. }
  115959. /**
  115960. * This groups tools to convert HDR texture to native colors array.
  115961. */
  115962. export class HDRTools {
  115963. private static Ldexp;
  115964. private static Rgbe2float;
  115965. private static readStringLine;
  115966. /**
  115967. * Reads header information from an RGBE texture stored in a native array.
  115968. * More information on this format are available here:
  115969. * https://en.wikipedia.org/wiki/RGBE_image_format
  115970. *
  115971. * @param uint8array The binary file stored in native array.
  115972. * @return The header information.
  115973. */
  115974. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  115975. /**
  115976. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  115977. * This RGBE texture needs to store the information as a panorama.
  115978. *
  115979. * More information on this format are available here:
  115980. * https://en.wikipedia.org/wiki/RGBE_image_format
  115981. *
  115982. * @param buffer The binary file stored in an array buffer.
  115983. * @param size The expected size of the extracted cubemap.
  115984. * @return The Cube Map information.
  115985. */
  115986. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  115987. /**
  115988. * Returns the pixels data extracted from an RGBE texture.
  115989. * This pixels will be stored left to right up to down in the R G B order in one array.
  115990. *
  115991. * More information on this format are available here:
  115992. * https://en.wikipedia.org/wiki/RGBE_image_format
  115993. *
  115994. * @param uint8array The binary file stored in an array buffer.
  115995. * @param hdrInfo The header information of the file.
  115996. * @return The pixels data in RGB right to left up to down order.
  115997. */
  115998. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  115999. private static RGBE_ReadPixels_RLE;
  116000. }
  116001. }
  116002. declare module BABYLON {
  116003. /**
  116004. * This represents a texture coming from an HDR input.
  116005. *
  116006. * The only supported format is currently panorama picture stored in RGBE format.
  116007. * Example of such files can be found on HDRLib: http://hdrlib.com/
  116008. */
  116009. export class HDRCubeTexture extends BaseTexture {
  116010. private static _facesMapping;
  116011. private _generateHarmonics;
  116012. private _noMipmap;
  116013. private _textureMatrix;
  116014. private _size;
  116015. private _onLoad;
  116016. private _onError;
  116017. /**
  116018. * The texture URL.
  116019. */
  116020. url: string;
  116021. /**
  116022. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  116023. */
  116024. coordinatesMode: number;
  116025. protected _isBlocking: boolean;
  116026. /**
  116027. * Sets wether or not the texture is blocking during loading.
  116028. */
  116029. /**
  116030. * Gets wether or not the texture is blocking during loading.
  116031. */
  116032. isBlocking: boolean;
  116033. protected _rotationY: number;
  116034. /**
  116035. * Sets texture matrix rotation angle around Y axis in radians.
  116036. */
  116037. /**
  116038. * Gets texture matrix rotation angle around Y axis radians.
  116039. */
  116040. rotationY: number;
  116041. /**
  116042. * Gets or sets the center of the bounding box associated with the cube texture
  116043. * It must define where the camera used to render the texture was set
  116044. */
  116045. boundingBoxPosition: Vector3;
  116046. private _boundingBoxSize;
  116047. /**
  116048. * Gets or sets the size of the bounding box associated with the cube texture
  116049. * When defined, the cubemap will switch to local mode
  116050. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  116051. * @example https://www.babylonjs-playground.com/#RNASML
  116052. */
  116053. boundingBoxSize: Vector3;
  116054. /**
  116055. * Instantiates an HDRTexture from the following parameters.
  116056. *
  116057. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  116058. * @param scene The scene the texture will be used in
  116059. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116060. * @param noMipmap Forces to not generate the mipmap if true
  116061. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  116062. * @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)
  116063. * @param reserved Reserved flag for internal use.
  116064. */
  116065. 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>);
  116066. /**
  116067. * Get the current class name of the texture useful for serialization or dynamic coding.
  116068. * @returns "HDRCubeTexture"
  116069. */
  116070. getClassName(): string;
  116071. /**
  116072. * Occurs when the file is raw .hdr file.
  116073. */
  116074. private loadTexture;
  116075. clone(): HDRCubeTexture;
  116076. delayLoad(): void;
  116077. /**
  116078. * Get the texture reflection matrix used to rotate/transform the reflection.
  116079. * @returns the reflection matrix
  116080. */
  116081. getReflectionTextureMatrix(): Matrix;
  116082. /**
  116083. * Set the texture reflection matrix used to rotate/transform the reflection.
  116084. * @param value Define the reflection matrix to set
  116085. */
  116086. setReflectionTextureMatrix(value: Matrix): void;
  116087. /**
  116088. * Parses a JSON representation of an HDR Texture in order to create the texture
  116089. * @param parsedTexture Define the JSON representation
  116090. * @param scene Define the scene the texture should be created in
  116091. * @param rootUrl Define the root url in case we need to load relative dependencies
  116092. * @returns the newly created texture after parsing
  116093. */
  116094. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  116095. serialize(): any;
  116096. }
  116097. }
  116098. declare module BABYLON {
  116099. /**
  116100. * Class used to control physics engine
  116101. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116102. */
  116103. export class PhysicsEngine implements IPhysicsEngine {
  116104. private _physicsPlugin;
  116105. /**
  116106. * Global value used to control the smallest number supported by the simulation
  116107. */
  116108. static Epsilon: number;
  116109. private _impostors;
  116110. private _joints;
  116111. /**
  116112. * Gets the gravity vector used by the simulation
  116113. */
  116114. gravity: Vector3;
  116115. /**
  116116. * Factory used to create the default physics plugin.
  116117. * @returns The default physics plugin
  116118. */
  116119. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  116120. /**
  116121. * Creates a new Physics Engine
  116122. * @param gravity defines the gravity vector used by the simulation
  116123. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116124. */
  116125. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  116126. /**
  116127. * Sets the gravity vector used by the simulation
  116128. * @param gravity defines the gravity vector to use
  116129. */
  116130. setGravity(gravity: Vector3): void;
  116131. /**
  116132. * Set the time step of the physics engine.
  116133. * Default is 1/60.
  116134. * To slow it down, enter 1/600 for example.
  116135. * To speed it up, 1/30
  116136. * @param newTimeStep defines the new timestep to apply to this world.
  116137. */
  116138. setTimeStep(newTimeStep?: number): void;
  116139. /**
  116140. * Get the time step of the physics engine.
  116141. * @returns the current time step
  116142. */
  116143. getTimeStep(): number;
  116144. /**
  116145. * Release all resources
  116146. */
  116147. dispose(): void;
  116148. /**
  116149. * Gets the name of the current physics plugin
  116150. * @returns the name of the plugin
  116151. */
  116152. getPhysicsPluginName(): string;
  116153. /**
  116154. * Adding a new impostor for the impostor tracking.
  116155. * This will be done by the impostor itself.
  116156. * @param impostor the impostor to add
  116157. */
  116158. addImpostor(impostor: PhysicsImpostor): void;
  116159. /**
  116160. * Remove an impostor from the engine.
  116161. * This impostor and its mesh will not longer be updated by the physics engine.
  116162. * @param impostor the impostor to remove
  116163. */
  116164. removeImpostor(impostor: PhysicsImpostor): void;
  116165. /**
  116166. * Add a joint to the physics engine
  116167. * @param mainImpostor defines the main impostor to which the joint is added.
  116168. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116169. * @param joint defines the joint that will connect both impostors.
  116170. */
  116171. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116172. /**
  116173. * Removes a joint from the simulation
  116174. * @param mainImpostor defines the impostor used with the joint
  116175. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116176. * @param joint defines the joint to remove
  116177. */
  116178. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116179. /**
  116180. * Called by the scene. No need to call it.
  116181. * @param delta defines the timespam between frames
  116182. */
  116183. _step(delta: number): void;
  116184. /**
  116185. * Gets the current plugin used to run the simulation
  116186. * @returns current plugin
  116187. */
  116188. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116189. /**
  116190. * Gets the list of physic impostors
  116191. * @returns an array of PhysicsImpostor
  116192. */
  116193. getImpostors(): Array<PhysicsImpostor>;
  116194. /**
  116195. * Gets the impostor for a physics enabled object
  116196. * @param object defines the object impersonated by the impostor
  116197. * @returns the PhysicsImpostor or null if not found
  116198. */
  116199. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116200. /**
  116201. * Gets the impostor for a physics body object
  116202. * @param body defines physics body used by the impostor
  116203. * @returns the PhysicsImpostor or null if not found
  116204. */
  116205. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116206. /**
  116207. * Does a raycast in the physics world
  116208. * @param from when should the ray start?
  116209. * @param to when should the ray end?
  116210. * @returns PhysicsRaycastResult
  116211. */
  116212. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116213. }
  116214. }
  116215. declare module BABYLON {
  116216. /** @hidden */
  116217. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  116218. private _useDeltaForWorldStep;
  116219. world: any;
  116220. name: string;
  116221. private _physicsMaterials;
  116222. private _fixedTimeStep;
  116223. private _cannonRaycastResult;
  116224. private _raycastResult;
  116225. private _physicsBodysToRemoveAfterStep;
  116226. BJSCANNON: any;
  116227. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  116228. setGravity(gravity: Vector3): void;
  116229. setTimeStep(timeStep: number): void;
  116230. getTimeStep(): number;
  116231. executeStep(delta: number): void;
  116232. private _removeMarkedPhysicsBodiesFromWorld;
  116233. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116234. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116235. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116236. private _processChildMeshes;
  116237. removePhysicsBody(impostor: PhysicsImpostor): void;
  116238. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116239. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116240. private _addMaterial;
  116241. private _checkWithEpsilon;
  116242. private _createShape;
  116243. private _createHeightmap;
  116244. private _minus90X;
  116245. private _plus90X;
  116246. private _tmpPosition;
  116247. private _tmpDeltaPosition;
  116248. private _tmpUnityRotation;
  116249. private _updatePhysicsBodyTransformation;
  116250. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116251. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116252. isSupported(): boolean;
  116253. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116254. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116255. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116256. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116257. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116258. getBodyMass(impostor: PhysicsImpostor): number;
  116259. getBodyFriction(impostor: PhysicsImpostor): number;
  116260. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116261. getBodyRestitution(impostor: PhysicsImpostor): number;
  116262. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116263. sleepBody(impostor: PhysicsImpostor): void;
  116264. wakeUpBody(impostor: PhysicsImpostor): void;
  116265. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  116266. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116267. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116268. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116269. getRadius(impostor: PhysicsImpostor): number;
  116270. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116271. dispose(): void;
  116272. private _extendNamespace;
  116273. /**
  116274. * Does a raycast in the physics world
  116275. * @param from when should the ray start?
  116276. * @param to when should the ray end?
  116277. * @returns PhysicsRaycastResult
  116278. */
  116279. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116280. }
  116281. }
  116282. declare module BABYLON {
  116283. /** @hidden */
  116284. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  116285. world: any;
  116286. name: string;
  116287. BJSOIMO: any;
  116288. private _raycastResult;
  116289. constructor(iterations?: number, oimoInjection?: any);
  116290. setGravity(gravity: Vector3): void;
  116291. setTimeStep(timeStep: number): void;
  116292. getTimeStep(): number;
  116293. private _tmpImpostorsArray;
  116294. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116295. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116296. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116297. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116298. private _tmpPositionVector;
  116299. removePhysicsBody(impostor: PhysicsImpostor): void;
  116300. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116301. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116302. isSupported(): boolean;
  116303. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116304. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116305. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116306. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116307. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116308. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116309. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116310. getBodyMass(impostor: PhysicsImpostor): number;
  116311. getBodyFriction(impostor: PhysicsImpostor): number;
  116312. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116313. getBodyRestitution(impostor: PhysicsImpostor): number;
  116314. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116315. sleepBody(impostor: PhysicsImpostor): void;
  116316. wakeUpBody(impostor: PhysicsImpostor): void;
  116317. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116318. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  116319. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116320. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116321. getRadius(impostor: PhysicsImpostor): number;
  116322. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116323. dispose(): void;
  116324. /**
  116325. * Does a raycast in the physics world
  116326. * @param from when should the ray start?
  116327. * @param to when should the ray end?
  116328. * @returns PhysicsRaycastResult
  116329. */
  116330. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116331. }
  116332. }
  116333. declare module BABYLON {
  116334. /**
  116335. * Class containing static functions to help procedurally build meshes
  116336. */
  116337. export class RibbonBuilder {
  116338. /**
  116339. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116340. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116341. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116342. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116343. * * 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
  116344. * * 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
  116345. * * 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
  116346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116348. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116349. * * 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
  116350. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116351. * * 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
  116352. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116354. * @param name defines the name of the mesh
  116355. * @param options defines the options used to create the mesh
  116356. * @param scene defines the hosting scene
  116357. * @returns the ribbon mesh
  116358. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116359. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116360. */
  116361. static CreateRibbon(name: string, options: {
  116362. pathArray: Vector3[][];
  116363. closeArray?: boolean;
  116364. closePath?: boolean;
  116365. offset?: number;
  116366. updatable?: boolean;
  116367. sideOrientation?: number;
  116368. frontUVs?: Vector4;
  116369. backUVs?: Vector4;
  116370. instance?: Mesh;
  116371. invertUV?: boolean;
  116372. uvs?: Vector2[];
  116373. colors?: Color4[];
  116374. }, scene?: Nullable<Scene>): Mesh;
  116375. }
  116376. }
  116377. declare module BABYLON {
  116378. /**
  116379. * Class containing static functions to help procedurally build meshes
  116380. */
  116381. export class ShapeBuilder {
  116382. /**
  116383. * 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.
  116384. * * 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.
  116385. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116386. * * 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.
  116387. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116388. * * 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
  116389. * * 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
  116390. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116395. * @param name defines the name of the mesh
  116396. * @param options defines the options used to create the mesh
  116397. * @param scene defines the hosting scene
  116398. * @returns the extruded shape mesh
  116399. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116401. */
  116402. static ExtrudeShape(name: string, options: {
  116403. shape: Vector3[];
  116404. path: Vector3[];
  116405. scale?: number;
  116406. rotation?: number;
  116407. cap?: number;
  116408. updatable?: boolean;
  116409. sideOrientation?: number;
  116410. frontUVs?: Vector4;
  116411. backUVs?: Vector4;
  116412. instance?: Mesh;
  116413. invertUV?: boolean;
  116414. }, scene?: Nullable<Scene>): Mesh;
  116415. /**
  116416. * Creates an custom extruded shape mesh.
  116417. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116418. * * 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.
  116419. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116420. * * 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
  116421. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116422. * * 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
  116423. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116424. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116425. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116426. * * 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
  116427. * * 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
  116428. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116431. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116433. * @param name defines the name of the mesh
  116434. * @param options defines the options used to create the mesh
  116435. * @param scene defines the hosting scene
  116436. * @returns the custom extruded shape mesh
  116437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116438. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116440. */
  116441. static ExtrudeShapeCustom(name: string, options: {
  116442. shape: Vector3[];
  116443. path: Vector3[];
  116444. scaleFunction?: any;
  116445. rotationFunction?: any;
  116446. ribbonCloseArray?: boolean;
  116447. ribbonClosePath?: boolean;
  116448. cap?: number;
  116449. updatable?: boolean;
  116450. sideOrientation?: number;
  116451. frontUVs?: Vector4;
  116452. backUVs?: Vector4;
  116453. instance?: Mesh;
  116454. invertUV?: boolean;
  116455. }, scene?: Nullable<Scene>): Mesh;
  116456. private static _ExtrudeShapeGeneric;
  116457. }
  116458. }
  116459. declare module BABYLON {
  116460. /**
  116461. * AmmoJS Physics plugin
  116462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116463. * @see https://github.com/kripken/ammo.js/
  116464. */
  116465. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116466. private _useDeltaForWorldStep;
  116467. /**
  116468. * Reference to the Ammo library
  116469. */
  116470. bjsAMMO: any;
  116471. /**
  116472. * Created ammoJS world which physics bodies are added to
  116473. */
  116474. world: any;
  116475. /**
  116476. * Name of the plugin
  116477. */
  116478. name: string;
  116479. private _timeStep;
  116480. private _fixedTimeStep;
  116481. private _maxSteps;
  116482. private _tmpQuaternion;
  116483. private _tmpAmmoTransform;
  116484. private _tmpAmmoQuaternion;
  116485. private _tmpAmmoConcreteContactResultCallback;
  116486. private _collisionConfiguration;
  116487. private _dispatcher;
  116488. private _overlappingPairCache;
  116489. private _solver;
  116490. private _softBodySolver;
  116491. private _tmpAmmoVectorA;
  116492. private _tmpAmmoVectorB;
  116493. private _tmpAmmoVectorC;
  116494. private _tmpAmmoVectorD;
  116495. private _tmpContactCallbackResult;
  116496. private _tmpAmmoVectorRCA;
  116497. private _tmpAmmoVectorRCB;
  116498. private _raycastResult;
  116499. private static readonly DISABLE_COLLISION_FLAG;
  116500. private static readonly KINEMATIC_FLAG;
  116501. private static readonly DISABLE_DEACTIVATION_FLAG;
  116502. /**
  116503. * Initializes the ammoJS plugin
  116504. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116505. * @param ammoInjection can be used to inject your own ammo reference
  116506. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116507. */
  116508. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116509. /**
  116510. * Sets the gravity of the physics world (m/(s^2))
  116511. * @param gravity Gravity to set
  116512. */
  116513. setGravity(gravity: Vector3): void;
  116514. /**
  116515. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116516. * @param timeStep timestep to use in seconds
  116517. */
  116518. setTimeStep(timeStep: number): void;
  116519. /**
  116520. * 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)
  116521. * @param fixedTimeStep fixedTimeStep to use in seconds
  116522. */
  116523. setFixedTimeStep(fixedTimeStep: number): void;
  116524. /**
  116525. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116526. * @param maxSteps the maximum number of steps by the physics engine per frame
  116527. */
  116528. setMaxSteps(maxSteps: number): void;
  116529. /**
  116530. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116531. * @returns the current timestep in seconds
  116532. */
  116533. getTimeStep(): number;
  116534. private _isImpostorInContact;
  116535. private _isImpostorPairInContact;
  116536. private _stepSimulation;
  116537. /**
  116538. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116539. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116540. * After the step the babylon meshes are set to the position of the physics imposters
  116541. * @param delta amount of time to step forward
  116542. * @param impostors array of imposters to update before/after the step
  116543. */
  116544. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116545. /**
  116546. * Update babylon mesh to match physics world object
  116547. * @param impostor imposter to match
  116548. */
  116549. private _afterSoftStep;
  116550. /**
  116551. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116552. * @param impostor imposter to match
  116553. */
  116554. private _ropeStep;
  116555. /**
  116556. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116557. * @param impostor imposter to match
  116558. */
  116559. private _softbodyOrClothStep;
  116560. private _tmpVector;
  116561. private _tmpMatrix;
  116562. /**
  116563. * Applies an impulse on the imposter
  116564. * @param impostor imposter to apply impulse to
  116565. * @param force amount of force to be applied to the imposter
  116566. * @param contactPoint the location to apply the impulse on the imposter
  116567. */
  116568. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116569. /**
  116570. * Applies a force on the imposter
  116571. * @param impostor imposter to apply force
  116572. * @param force amount of force to be applied to the imposter
  116573. * @param contactPoint the location to apply the force on the imposter
  116574. */
  116575. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116576. /**
  116577. * Creates a physics body using the plugin
  116578. * @param impostor the imposter to create the physics body on
  116579. */
  116580. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116581. /**
  116582. * Removes the physics body from the imposter and disposes of the body's memory
  116583. * @param impostor imposter to remove the physics body from
  116584. */
  116585. removePhysicsBody(impostor: PhysicsImpostor): void;
  116586. /**
  116587. * Generates a joint
  116588. * @param impostorJoint the imposter joint to create the joint with
  116589. */
  116590. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116591. /**
  116592. * Removes a joint
  116593. * @param impostorJoint the imposter joint to remove the joint from
  116594. */
  116595. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116596. private _addMeshVerts;
  116597. /**
  116598. * Initialise the soft body vertices to match its object's (mesh) vertices
  116599. * Softbody vertices (nodes) are in world space and to match this
  116600. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116601. * @param impostor to create the softbody for
  116602. */
  116603. private _softVertexData;
  116604. /**
  116605. * Create an impostor's soft body
  116606. * @param impostor to create the softbody for
  116607. */
  116608. private _createSoftbody;
  116609. /**
  116610. * Create cloth for an impostor
  116611. * @param impostor to create the softbody for
  116612. */
  116613. private _createCloth;
  116614. /**
  116615. * Create rope for an impostor
  116616. * @param impostor to create the softbody for
  116617. */
  116618. private _createRope;
  116619. private _addHullVerts;
  116620. private _createShape;
  116621. /**
  116622. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116623. * @param impostor imposter containing the physics body and babylon object
  116624. */
  116625. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116626. /**
  116627. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116628. * @param impostor imposter containing the physics body and babylon object
  116629. * @param newPosition new position
  116630. * @param newRotation new rotation
  116631. */
  116632. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116633. /**
  116634. * If this plugin is supported
  116635. * @returns true if its supported
  116636. */
  116637. isSupported(): boolean;
  116638. /**
  116639. * Sets the linear velocity of the physics body
  116640. * @param impostor imposter to set the velocity on
  116641. * @param velocity velocity to set
  116642. */
  116643. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116644. /**
  116645. * Sets the angular velocity of the physics body
  116646. * @param impostor imposter to set the velocity on
  116647. * @param velocity velocity to set
  116648. */
  116649. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116650. /**
  116651. * gets the linear velocity
  116652. * @param impostor imposter to get linear velocity from
  116653. * @returns linear velocity
  116654. */
  116655. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116656. /**
  116657. * gets the angular velocity
  116658. * @param impostor imposter to get angular velocity from
  116659. * @returns angular velocity
  116660. */
  116661. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116662. /**
  116663. * Sets the mass of physics body
  116664. * @param impostor imposter to set the mass on
  116665. * @param mass mass to set
  116666. */
  116667. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116668. /**
  116669. * Gets the mass of the physics body
  116670. * @param impostor imposter to get the mass from
  116671. * @returns mass
  116672. */
  116673. getBodyMass(impostor: PhysicsImpostor): number;
  116674. /**
  116675. * Gets friction of the impostor
  116676. * @param impostor impostor to get friction from
  116677. * @returns friction value
  116678. */
  116679. getBodyFriction(impostor: PhysicsImpostor): number;
  116680. /**
  116681. * Sets friction of the impostor
  116682. * @param impostor impostor to set friction on
  116683. * @param friction friction value
  116684. */
  116685. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116686. /**
  116687. * Gets restitution of the impostor
  116688. * @param impostor impostor to get restitution from
  116689. * @returns restitution value
  116690. */
  116691. getBodyRestitution(impostor: PhysicsImpostor): number;
  116692. /**
  116693. * Sets resitution of the impostor
  116694. * @param impostor impostor to set resitution on
  116695. * @param restitution resitution value
  116696. */
  116697. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116698. /**
  116699. * Gets pressure inside the impostor
  116700. * @param impostor impostor to get pressure from
  116701. * @returns pressure value
  116702. */
  116703. getBodyPressure(impostor: PhysicsImpostor): number;
  116704. /**
  116705. * Sets pressure inside a soft body impostor
  116706. * Cloth and rope must remain 0 pressure
  116707. * @param impostor impostor to set pressure on
  116708. * @param pressure pressure value
  116709. */
  116710. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116711. /**
  116712. * Gets stiffness of the impostor
  116713. * @param impostor impostor to get stiffness from
  116714. * @returns pressure value
  116715. */
  116716. getBodyStiffness(impostor: PhysicsImpostor): number;
  116717. /**
  116718. * Sets stiffness of the impostor
  116719. * @param impostor impostor to set stiffness on
  116720. * @param stiffness stiffness value from 0 to 1
  116721. */
  116722. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116723. /**
  116724. * Gets velocityIterations of the impostor
  116725. * @param impostor impostor to get velocity iterations from
  116726. * @returns velocityIterations value
  116727. */
  116728. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116729. /**
  116730. * Sets velocityIterations of the impostor
  116731. * @param impostor impostor to set velocity iterations on
  116732. * @param velocityIterations velocityIterations value
  116733. */
  116734. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116735. /**
  116736. * Gets positionIterations of the impostor
  116737. * @param impostor impostor to get position iterations from
  116738. * @returns positionIterations value
  116739. */
  116740. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116741. /**
  116742. * Sets positionIterations of the impostor
  116743. * @param impostor impostor to set position on
  116744. * @param positionIterations positionIterations value
  116745. */
  116746. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116747. /**
  116748. * Append an anchor to a cloth object
  116749. * @param impostor is the cloth impostor to add anchor to
  116750. * @param otherImpostor is the rigid impostor to anchor to
  116751. * @param width ratio across width from 0 to 1
  116752. * @param height ratio up height from 0 to 1
  116753. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116754. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116755. */
  116756. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116757. /**
  116758. * Append an hook to a rope object
  116759. * @param impostor is the rope impostor to add hook to
  116760. * @param otherImpostor is the rigid impostor to hook to
  116761. * @param length ratio along the rope from 0 to 1
  116762. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116763. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116764. */
  116765. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116766. /**
  116767. * Sleeps the physics body and stops it from being active
  116768. * @param impostor impostor to sleep
  116769. */
  116770. sleepBody(impostor: PhysicsImpostor): void;
  116771. /**
  116772. * Activates the physics body
  116773. * @param impostor impostor to activate
  116774. */
  116775. wakeUpBody(impostor: PhysicsImpostor): void;
  116776. /**
  116777. * Updates the distance parameters of the joint
  116778. * @param joint joint to update
  116779. * @param maxDistance maximum distance of the joint
  116780. * @param minDistance minimum distance of the joint
  116781. */
  116782. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116783. /**
  116784. * Sets a motor on the joint
  116785. * @param joint joint to set motor on
  116786. * @param speed speed of the motor
  116787. * @param maxForce maximum force of the motor
  116788. * @param motorIndex index of the motor
  116789. */
  116790. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116791. /**
  116792. * Sets the motors limit
  116793. * @param joint joint to set limit on
  116794. * @param upperLimit upper limit
  116795. * @param lowerLimit lower limit
  116796. */
  116797. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116798. /**
  116799. * Syncs the position and rotation of a mesh with the impostor
  116800. * @param mesh mesh to sync
  116801. * @param impostor impostor to update the mesh with
  116802. */
  116803. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116804. /**
  116805. * Gets the radius of the impostor
  116806. * @param impostor impostor to get radius from
  116807. * @returns the radius
  116808. */
  116809. getRadius(impostor: PhysicsImpostor): number;
  116810. /**
  116811. * Gets the box size of the impostor
  116812. * @param impostor impostor to get box size from
  116813. * @param result the resulting box size
  116814. */
  116815. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116816. /**
  116817. * Disposes of the impostor
  116818. */
  116819. dispose(): void;
  116820. /**
  116821. * Does a raycast in the physics world
  116822. * @param from when should the ray start?
  116823. * @param to when should the ray end?
  116824. * @returns PhysicsRaycastResult
  116825. */
  116826. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116827. }
  116828. }
  116829. declare module BABYLON {
  116830. interface AbstractScene {
  116831. /**
  116832. * The list of reflection probes added to the scene
  116833. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116834. */
  116835. reflectionProbes: Array<ReflectionProbe>;
  116836. /**
  116837. * Removes the given reflection probe from this scene.
  116838. * @param toRemove The reflection probe to remove
  116839. * @returns The index of the removed reflection probe
  116840. */
  116841. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116842. /**
  116843. * Adds the given reflection probe to this scene.
  116844. * @param newReflectionProbe The reflection probe to add
  116845. */
  116846. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116847. }
  116848. /**
  116849. * Class used to generate realtime reflection / refraction cube textures
  116850. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116851. */
  116852. export class ReflectionProbe {
  116853. /** defines the name of the probe */
  116854. name: string;
  116855. private _scene;
  116856. private _renderTargetTexture;
  116857. private _projectionMatrix;
  116858. private _viewMatrix;
  116859. private _target;
  116860. private _add;
  116861. private _attachedMesh;
  116862. private _invertYAxis;
  116863. /** Gets or sets probe position (center of the cube map) */
  116864. position: Vector3;
  116865. /**
  116866. * Creates a new reflection probe
  116867. * @param name defines the name of the probe
  116868. * @param size defines the texture resolution (for each face)
  116869. * @param scene defines the hosting scene
  116870. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  116871. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  116872. */
  116873. constructor(
  116874. /** defines the name of the probe */
  116875. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  116876. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  116877. samples: number;
  116878. /** Gets or sets the refresh rate to use (on every frame by default) */
  116879. refreshRate: number;
  116880. /**
  116881. * Gets the hosting scene
  116882. * @returns a Scene
  116883. */
  116884. getScene(): Scene;
  116885. /** Gets the internal CubeTexture used to render to */
  116886. readonly cubeTexture: RenderTargetTexture;
  116887. /** Gets the list of meshes to render */
  116888. readonly renderList: Nullable<AbstractMesh[]>;
  116889. /**
  116890. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  116891. * @param mesh defines the mesh to attach to
  116892. */
  116893. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  116894. /**
  116895. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  116896. * @param renderingGroupId The rendering group id corresponding to its index
  116897. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  116898. */
  116899. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  116900. /**
  116901. * Clean all associated resources
  116902. */
  116903. dispose(): void;
  116904. /**
  116905. * Converts the reflection probe information to a readable string for debug purpose.
  116906. * @param fullDetails Supports for multiple levels of logging within scene loading
  116907. * @returns the human readable reflection probe info
  116908. */
  116909. toString(fullDetails?: boolean): string;
  116910. /**
  116911. * Get the class name of the relfection probe.
  116912. * @returns "ReflectionProbe"
  116913. */
  116914. getClassName(): string;
  116915. /**
  116916. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  116917. * @returns The JSON representation of the texture
  116918. */
  116919. serialize(): any;
  116920. /**
  116921. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  116922. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  116923. * @param scene Define the scene the parsed reflection probe should be instantiated in
  116924. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  116925. * @returns The parsed reflection probe if successful
  116926. */
  116927. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  116928. }
  116929. }
  116930. declare module BABYLON {
  116931. /** @hidden */
  116932. export var _BabylonLoaderRegistered: boolean;
  116933. }
  116934. declare module BABYLON {
  116935. /**
  116936. * The Physically based simple base material of BJS.
  116937. *
  116938. * This enables better naming and convention enforcements on top of the pbrMaterial.
  116939. * It is used as the base class for both the specGloss and metalRough conventions.
  116940. */
  116941. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  116942. /**
  116943. * Number of Simultaneous lights allowed on the material.
  116944. */
  116945. maxSimultaneousLights: number;
  116946. /**
  116947. * If sets to true, disables all the lights affecting the material.
  116948. */
  116949. disableLighting: boolean;
  116950. /**
  116951. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  116952. */
  116953. environmentTexture: BaseTexture;
  116954. /**
  116955. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116956. */
  116957. invertNormalMapX: boolean;
  116958. /**
  116959. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116960. */
  116961. invertNormalMapY: boolean;
  116962. /**
  116963. * Normal map used in the model.
  116964. */
  116965. normalTexture: BaseTexture;
  116966. /**
  116967. * Emissivie color used to self-illuminate the model.
  116968. */
  116969. emissiveColor: Color3;
  116970. /**
  116971. * Emissivie texture used to self-illuminate the model.
  116972. */
  116973. emissiveTexture: BaseTexture;
  116974. /**
  116975. * Occlusion Channel Strenght.
  116976. */
  116977. occlusionStrength: number;
  116978. /**
  116979. * Occlusion Texture of the material (adding extra occlusion effects).
  116980. */
  116981. occlusionTexture: BaseTexture;
  116982. /**
  116983. * Defines the alpha limits in alpha test mode.
  116984. */
  116985. alphaCutOff: number;
  116986. /**
  116987. * Gets the current double sided mode.
  116988. */
  116989. /**
  116990. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116991. */
  116992. doubleSided: boolean;
  116993. /**
  116994. * Stores the pre-calculated light information of a mesh in a texture.
  116995. */
  116996. lightmapTexture: BaseTexture;
  116997. /**
  116998. * If true, the light map contains occlusion information instead of lighting info.
  116999. */
  117000. useLightmapAsShadowmap: boolean;
  117001. /**
  117002. * Instantiates a new PBRMaterial instance.
  117003. *
  117004. * @param name The material name
  117005. * @param scene The scene the material will be use in.
  117006. */
  117007. constructor(name: string, scene: Scene);
  117008. getClassName(): string;
  117009. }
  117010. }
  117011. declare module BABYLON {
  117012. /**
  117013. * The PBR material of BJS following the metal roughness convention.
  117014. *
  117015. * This fits to the PBR convention in the GLTF definition:
  117016. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  117017. */
  117018. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  117019. /**
  117020. * The base color has two different interpretations depending on the value of metalness.
  117021. * When the material is a metal, the base color is the specific measured reflectance value
  117022. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  117023. * of the material.
  117024. */
  117025. baseColor: Color3;
  117026. /**
  117027. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  117028. * well as opacity information in the alpha channel.
  117029. */
  117030. baseTexture: BaseTexture;
  117031. /**
  117032. * Specifies the metallic scalar value of the material.
  117033. * Can also be used to scale the metalness values of the metallic texture.
  117034. */
  117035. metallic: number;
  117036. /**
  117037. * Specifies the roughness scalar value of the material.
  117038. * Can also be used to scale the roughness values of the metallic texture.
  117039. */
  117040. roughness: number;
  117041. /**
  117042. * Texture containing both the metallic value in the B channel and the
  117043. * roughness value in the G channel to keep better precision.
  117044. */
  117045. metallicRoughnessTexture: BaseTexture;
  117046. /**
  117047. * Instantiates a new PBRMetalRoughnessMaterial instance.
  117048. *
  117049. * @param name The material name
  117050. * @param scene The scene the material will be use in.
  117051. */
  117052. constructor(name: string, scene: Scene);
  117053. /**
  117054. * Return the currrent class name of the material.
  117055. */
  117056. getClassName(): string;
  117057. /**
  117058. * Makes a duplicate of the current material.
  117059. * @param name - name to use for the new material.
  117060. */
  117061. clone(name: string): PBRMetallicRoughnessMaterial;
  117062. /**
  117063. * Serialize the material to a parsable JSON object.
  117064. */
  117065. serialize(): any;
  117066. /**
  117067. * Parses a JSON object correponding to the serialize function.
  117068. */
  117069. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  117070. }
  117071. }
  117072. declare module BABYLON {
  117073. /**
  117074. * The PBR material of BJS following the specular glossiness convention.
  117075. *
  117076. * This fits to the PBR convention in the GLTF definition:
  117077. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  117078. */
  117079. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  117080. /**
  117081. * Specifies the diffuse color of the material.
  117082. */
  117083. diffuseColor: Color3;
  117084. /**
  117085. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  117086. * channel.
  117087. */
  117088. diffuseTexture: BaseTexture;
  117089. /**
  117090. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  117091. */
  117092. specularColor: Color3;
  117093. /**
  117094. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  117095. */
  117096. glossiness: number;
  117097. /**
  117098. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  117099. */
  117100. specularGlossinessTexture: BaseTexture;
  117101. /**
  117102. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  117103. *
  117104. * @param name The material name
  117105. * @param scene The scene the material will be use in.
  117106. */
  117107. constructor(name: string, scene: Scene);
  117108. /**
  117109. * Return the currrent class name of the material.
  117110. */
  117111. getClassName(): string;
  117112. /**
  117113. * Makes a duplicate of the current material.
  117114. * @param name - name to use for the new material.
  117115. */
  117116. clone(name: string): PBRSpecularGlossinessMaterial;
  117117. /**
  117118. * Serialize the material to a parsable JSON object.
  117119. */
  117120. serialize(): any;
  117121. /**
  117122. * Parses a JSON object correponding to the serialize function.
  117123. */
  117124. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  117125. }
  117126. }
  117127. declare module BABYLON {
  117128. /**
  117129. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  117130. * It can help converting any input color in a desired output one. This can then be used to create effects
  117131. * from sepia, black and white to sixties or futuristic rendering...
  117132. *
  117133. * The only supported format is currently 3dl.
  117134. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  117135. */
  117136. export class ColorGradingTexture extends BaseTexture {
  117137. /**
  117138. * The current texture matrix. (will always be identity in color grading texture)
  117139. */
  117140. private _textureMatrix;
  117141. /**
  117142. * The texture URL.
  117143. */
  117144. url: string;
  117145. /**
  117146. * Empty line regex stored for GC.
  117147. */
  117148. private static _noneEmptyLineRegex;
  117149. private _engine;
  117150. /**
  117151. * Instantiates a ColorGradingTexture from the following parameters.
  117152. *
  117153. * @param url The location of the color gradind data (currently only supporting 3dl)
  117154. * @param scene The scene the texture will be used in
  117155. */
  117156. constructor(url: string, scene: Scene);
  117157. /**
  117158. * Returns the texture matrix used in most of the material.
  117159. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  117160. */
  117161. getTextureMatrix(): Matrix;
  117162. /**
  117163. * Occurs when the file being loaded is a .3dl LUT file.
  117164. */
  117165. private load3dlTexture;
  117166. /**
  117167. * Starts the loading process of the texture.
  117168. */
  117169. private loadTexture;
  117170. /**
  117171. * Clones the color gradind texture.
  117172. */
  117173. clone(): ColorGradingTexture;
  117174. /**
  117175. * Called during delayed load for textures.
  117176. */
  117177. delayLoad(): void;
  117178. /**
  117179. * Parses a color grading texture serialized by Babylon.
  117180. * @param parsedTexture The texture information being parsedTexture
  117181. * @param scene The scene to load the texture in
  117182. * @param rootUrl The root url of the data assets to load
  117183. * @return A color gradind texture
  117184. */
  117185. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  117186. /**
  117187. * Serializes the LUT texture to json format.
  117188. */
  117189. serialize(): any;
  117190. }
  117191. }
  117192. declare module BABYLON {
  117193. /**
  117194. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  117195. */
  117196. export class EquiRectangularCubeTexture extends BaseTexture {
  117197. /** The six faces of the cube. */
  117198. private static _FacesMapping;
  117199. private _noMipmap;
  117200. private _onLoad;
  117201. private _onError;
  117202. /** The size of the cubemap. */
  117203. private _size;
  117204. /** The buffer of the image. */
  117205. private _buffer;
  117206. /** The width of the input image. */
  117207. private _width;
  117208. /** The height of the input image. */
  117209. private _height;
  117210. /** The URL to the image. */
  117211. url: string;
  117212. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  117213. coordinatesMode: number;
  117214. /**
  117215. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  117216. * @param url The location of the image
  117217. * @param scene The scene the texture will be used in
  117218. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117219. * @param noMipmap Forces to not generate the mipmap if true
  117220. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  117221. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  117222. * @param onLoad — defines a callback called when texture is loaded
  117223. * @param onError — defines a callback called if there is an error
  117224. */
  117225. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  117226. /**
  117227. * Load the image data, by putting the image on a canvas and extracting its buffer.
  117228. */
  117229. private loadImage;
  117230. /**
  117231. * Convert the image buffer into a cubemap and create a CubeTexture.
  117232. */
  117233. private loadTexture;
  117234. /**
  117235. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  117236. * @param buffer The ArrayBuffer that should be converted.
  117237. * @returns The buffer as Float32Array.
  117238. */
  117239. private getFloat32ArrayFromArrayBuffer;
  117240. /**
  117241. * Get the current class name of the texture useful for serialization or dynamic coding.
  117242. * @returns "EquiRectangularCubeTexture"
  117243. */
  117244. getClassName(): string;
  117245. /**
  117246. * Create a clone of the current EquiRectangularCubeTexture and return it.
  117247. * @returns A clone of the current EquiRectangularCubeTexture.
  117248. */
  117249. clone(): EquiRectangularCubeTexture;
  117250. }
  117251. }
  117252. declare module BABYLON {
  117253. /**
  117254. * Based on jsTGALoader - Javascript loader for TGA file
  117255. * By Vincent Thibault
  117256. * @see http://blog.robrowser.com/javascript-tga-loader.html
  117257. */
  117258. export class TGATools {
  117259. private static _TYPE_INDEXED;
  117260. private static _TYPE_RGB;
  117261. private static _TYPE_GREY;
  117262. private static _TYPE_RLE_INDEXED;
  117263. private static _TYPE_RLE_RGB;
  117264. private static _TYPE_RLE_GREY;
  117265. private static _ORIGIN_MASK;
  117266. private static _ORIGIN_SHIFT;
  117267. private static _ORIGIN_BL;
  117268. private static _ORIGIN_BR;
  117269. private static _ORIGIN_UL;
  117270. private static _ORIGIN_UR;
  117271. /**
  117272. * Gets the header of a TGA file
  117273. * @param data defines the TGA data
  117274. * @returns the header
  117275. */
  117276. static GetTGAHeader(data: Uint8Array): any;
  117277. /**
  117278. * Uploads TGA content to a Babylon Texture
  117279. * @hidden
  117280. */
  117281. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  117282. /** @hidden */
  117283. 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;
  117284. /** @hidden */
  117285. 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;
  117286. /** @hidden */
  117287. 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;
  117288. /** @hidden */
  117289. 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;
  117290. /** @hidden */
  117291. 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;
  117292. /** @hidden */
  117293. 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;
  117294. }
  117295. }
  117296. declare module BABYLON {
  117297. /**
  117298. * Implementation of the TGA Texture Loader.
  117299. * @hidden
  117300. */
  117301. export class _TGATextureLoader implements IInternalTextureLoader {
  117302. /**
  117303. * Defines wether the loader supports cascade loading the different faces.
  117304. */
  117305. readonly supportCascades: boolean;
  117306. /**
  117307. * This returns if the loader support the current file information.
  117308. * @param extension defines the file extension of the file being loaded
  117309. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117310. * @param fallback defines the fallback internal texture if any
  117311. * @param isBase64 defines whether the texture is encoded as a base64
  117312. * @param isBuffer defines whether the texture data are stored as a buffer
  117313. * @returns true if the loader can load the specified file
  117314. */
  117315. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117316. /**
  117317. * Transform the url before loading if required.
  117318. * @param rootUrl the url of the texture
  117319. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117320. * @returns the transformed texture
  117321. */
  117322. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117323. /**
  117324. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117325. * @param rootUrl the url of the texture
  117326. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117327. * @returns the fallback texture
  117328. */
  117329. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117330. /**
  117331. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117332. * @param data contains the texture data
  117333. * @param texture defines the BabylonJS internal texture
  117334. * @param createPolynomials will be true if polynomials have been requested
  117335. * @param onLoad defines the callback to trigger once the texture is ready
  117336. * @param onError defines the callback to trigger in case of error
  117337. */
  117338. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117339. /**
  117340. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117341. * @param data contains the texture data
  117342. * @param texture defines the BabylonJS internal texture
  117343. * @param callback defines the method to call once ready to upload
  117344. */
  117345. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117346. }
  117347. }
  117348. declare module BABYLON {
  117349. /**
  117350. * Info about the .basis files
  117351. */
  117352. class BasisFileInfo {
  117353. /**
  117354. * If the file has alpha
  117355. */
  117356. hasAlpha: boolean;
  117357. /**
  117358. * Info about each image of the basis file
  117359. */
  117360. images: Array<{
  117361. levels: Array<{
  117362. width: number;
  117363. height: number;
  117364. transcodedPixels: ArrayBufferView;
  117365. }>;
  117366. }>;
  117367. }
  117368. /**
  117369. * Result of transcoding a basis file
  117370. */
  117371. class TranscodeResult {
  117372. /**
  117373. * Info about the .basis file
  117374. */
  117375. fileInfo: BasisFileInfo;
  117376. /**
  117377. * Format to use when loading the file
  117378. */
  117379. format: number;
  117380. }
  117381. /**
  117382. * Configuration options for the Basis transcoder
  117383. */
  117384. export class BasisTranscodeConfiguration {
  117385. /**
  117386. * Supported compression formats used to determine the supported output format of the transcoder
  117387. */
  117388. supportedCompressionFormats?: {
  117389. /**
  117390. * etc1 compression format
  117391. */
  117392. etc1?: boolean;
  117393. /**
  117394. * s3tc compression format
  117395. */
  117396. s3tc?: boolean;
  117397. /**
  117398. * pvrtc compression format
  117399. */
  117400. pvrtc?: boolean;
  117401. /**
  117402. * etc2 compression format
  117403. */
  117404. etc2?: boolean;
  117405. };
  117406. /**
  117407. * If mipmap levels should be loaded for transcoded images (Default: true)
  117408. */
  117409. loadMipmapLevels?: boolean;
  117410. /**
  117411. * Index of a single image to load (Default: all images)
  117412. */
  117413. loadSingleImage?: number;
  117414. }
  117415. /**
  117416. * Used to load .Basis files
  117417. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117418. */
  117419. export class BasisTools {
  117420. private static _IgnoreSupportedFormats;
  117421. /**
  117422. * URL to use when loading the basis transcoder
  117423. */
  117424. static JSModuleURL: string;
  117425. /**
  117426. * URL to use when loading the wasm module for the transcoder
  117427. */
  117428. static WasmModuleURL: string;
  117429. /**
  117430. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117431. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117432. * @returns internal format corresponding to the Basis format
  117433. */
  117434. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117435. private static _WorkerPromise;
  117436. private static _Worker;
  117437. private static _actionId;
  117438. private static _CreateWorkerAsync;
  117439. /**
  117440. * Transcodes a loaded image file to compressed pixel data
  117441. * @param imageData image data to transcode
  117442. * @param config configuration options for the transcoding
  117443. * @returns a promise resulting in the transcoded image
  117444. */
  117445. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117446. /**
  117447. * Loads a texture from the transcode result
  117448. * @param texture texture load to
  117449. * @param transcodeResult the result of transcoding the basis file to load from
  117450. */
  117451. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117452. }
  117453. }
  117454. declare module BABYLON {
  117455. /**
  117456. * Loader for .basis file format
  117457. */
  117458. export class _BasisTextureLoader implements IInternalTextureLoader {
  117459. /**
  117460. * Defines whether the loader supports cascade loading the different faces.
  117461. */
  117462. readonly supportCascades: boolean;
  117463. /**
  117464. * This returns if the loader support the current file information.
  117465. * @param extension defines the file extension of the file being loaded
  117466. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117467. * @param fallback defines the fallback internal texture if any
  117468. * @param isBase64 defines whether the texture is encoded as a base64
  117469. * @param isBuffer defines whether the texture data are stored as a buffer
  117470. * @returns true if the loader can load the specified file
  117471. */
  117472. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117473. /**
  117474. * Transform the url before loading if required.
  117475. * @param rootUrl the url of the texture
  117476. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117477. * @returns the transformed texture
  117478. */
  117479. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117480. /**
  117481. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117482. * @param rootUrl the url of the texture
  117483. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117484. * @returns the fallback texture
  117485. */
  117486. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117487. /**
  117488. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117489. * @param data contains the texture data
  117490. * @param texture defines the BabylonJS internal texture
  117491. * @param createPolynomials will be true if polynomials have been requested
  117492. * @param onLoad defines the callback to trigger once the texture is ready
  117493. * @param onError defines the callback to trigger in case of error
  117494. */
  117495. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117496. /**
  117497. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117498. * @param data contains the texture data
  117499. * @param texture defines the BabylonJS internal texture
  117500. * @param callback defines the method to call once ready to upload
  117501. */
  117502. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117503. }
  117504. }
  117505. declare module BABYLON {
  117506. /**
  117507. * 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.
  117508. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117509. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117510. */
  117511. export class CustomProceduralTexture extends ProceduralTexture {
  117512. private _animate;
  117513. private _time;
  117514. private _config;
  117515. private _texturePath;
  117516. /**
  117517. * Instantiates a new Custom Procedural Texture.
  117518. * 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.
  117519. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117520. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117521. * @param name Define the name of the texture
  117522. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117523. * @param size Define the size of the texture to create
  117524. * @param scene Define the scene the texture belongs to
  117525. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117526. * @param generateMipMaps Define if the texture should creates mip maps or not
  117527. */
  117528. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117529. private _loadJson;
  117530. /**
  117531. * Is the texture ready to be used ? (rendered at least once)
  117532. * @returns true if ready, otherwise, false.
  117533. */
  117534. isReady(): boolean;
  117535. /**
  117536. * Render the texture to its associated render target.
  117537. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117538. */
  117539. render(useCameraPostProcess?: boolean): void;
  117540. /**
  117541. * Update the list of dependant textures samplers in the shader.
  117542. */
  117543. updateTextures(): void;
  117544. /**
  117545. * Update the uniform values of the procedural texture in the shader.
  117546. */
  117547. updateShaderUniforms(): void;
  117548. /**
  117549. * Define if the texture animates or not.
  117550. */
  117551. animate: boolean;
  117552. }
  117553. }
  117554. declare module BABYLON {
  117555. /** @hidden */
  117556. export var noisePixelShader: {
  117557. name: string;
  117558. shader: string;
  117559. };
  117560. }
  117561. declare module BABYLON {
  117562. /**
  117563. * Class used to generate noise procedural textures
  117564. */
  117565. export class NoiseProceduralTexture extends ProceduralTexture {
  117566. private _time;
  117567. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117568. brightness: number;
  117569. /** Defines the number of octaves to process */
  117570. octaves: number;
  117571. /** Defines the level of persistence (0.8 by default) */
  117572. persistence: number;
  117573. /** Gets or sets animation speed factor (default is 1) */
  117574. animationSpeedFactor: number;
  117575. /**
  117576. * Creates a new NoiseProceduralTexture
  117577. * @param name defines the name fo the texture
  117578. * @param size defines the size of the texture (default is 256)
  117579. * @param scene defines the hosting scene
  117580. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117581. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117582. */
  117583. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117584. private _updateShaderUniforms;
  117585. protected _getDefines(): string;
  117586. /** Generate the current state of the procedural texture */
  117587. render(useCameraPostProcess?: boolean): void;
  117588. /**
  117589. * Serializes this noise procedural texture
  117590. * @returns a serialized noise procedural texture object
  117591. */
  117592. serialize(): any;
  117593. /**
  117594. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117595. * @param parsedTexture defines parsed texture data
  117596. * @param scene defines the current scene
  117597. * @param rootUrl defines the root URL containing noise procedural texture information
  117598. * @returns a parsed NoiseProceduralTexture
  117599. */
  117600. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117601. }
  117602. }
  117603. declare module BABYLON {
  117604. /**
  117605. * Raw cube texture where the raw buffers are passed in
  117606. */
  117607. export class RawCubeTexture extends CubeTexture {
  117608. /**
  117609. * Creates a cube texture where the raw buffers are passed in.
  117610. * @param scene defines the scene the texture is attached to
  117611. * @param data defines the array of data to use to create each face
  117612. * @param size defines the size of the textures
  117613. * @param format defines the format of the data
  117614. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117615. * @param generateMipMaps defines if the engine should generate the mip levels
  117616. * @param invertY defines if data must be stored with Y axis inverted
  117617. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117618. * @param compression defines the compression used (null by default)
  117619. */
  117620. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117621. /**
  117622. * Updates the raw cube texture.
  117623. * @param data defines the data to store
  117624. * @param format defines the data format
  117625. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117626. * @param invertY defines if data must be stored with Y axis inverted
  117627. * @param compression defines the compression used (null by default)
  117628. * @param level defines which level of the texture to update
  117629. */
  117630. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117631. /**
  117632. * Updates a raw cube texture with RGBD encoded data.
  117633. * @param data defines the array of data [mipmap][face] to use to create each face
  117634. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117635. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117636. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117637. * @returns a promsie that resolves when the operation is complete
  117638. */
  117639. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117640. /**
  117641. * Clones the raw cube texture.
  117642. * @return a new cube texture
  117643. */
  117644. clone(): CubeTexture;
  117645. /** @hidden */
  117646. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117647. }
  117648. }
  117649. declare module BABYLON {
  117650. /**
  117651. * Class used to store 3D textures containing user data
  117652. */
  117653. export class RawTexture3D extends Texture {
  117654. /** Gets or sets the texture format to use */
  117655. format: number;
  117656. private _engine;
  117657. /**
  117658. * Create a new RawTexture3D
  117659. * @param data defines the data of the texture
  117660. * @param width defines the width of the texture
  117661. * @param height defines the height of the texture
  117662. * @param depth defines the depth of the texture
  117663. * @param format defines the texture format to use
  117664. * @param scene defines the hosting scene
  117665. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117666. * @param invertY defines if texture must be stored with Y axis inverted
  117667. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117668. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117669. */
  117670. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117671. /** Gets or sets the texture format to use */
  117672. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117673. /**
  117674. * Update the texture with new data
  117675. * @param data defines the data to store in the texture
  117676. */
  117677. update(data: ArrayBufferView): void;
  117678. }
  117679. }
  117680. declare module BABYLON {
  117681. /**
  117682. * Creates a refraction texture used by refraction channel of the standard material.
  117683. * It is like a mirror but to see through a material.
  117684. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117685. */
  117686. export class RefractionTexture extends RenderTargetTexture {
  117687. /**
  117688. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117689. * 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.
  117690. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117691. */
  117692. refractionPlane: Plane;
  117693. /**
  117694. * Define how deep under the surface we should see.
  117695. */
  117696. depth: number;
  117697. /**
  117698. * Creates a refraction texture used by refraction channel of the standard material.
  117699. * It is like a mirror but to see through a material.
  117700. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117701. * @param name Define the texture name
  117702. * @param size Define the size of the underlying texture
  117703. * @param scene Define the scene the refraction belongs to
  117704. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117705. */
  117706. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117707. /**
  117708. * Clone the refraction texture.
  117709. * @returns the cloned texture
  117710. */
  117711. clone(): RefractionTexture;
  117712. /**
  117713. * Serialize the texture to a JSON representation you could use in Parse later on
  117714. * @returns the serialized JSON representation
  117715. */
  117716. serialize(): any;
  117717. }
  117718. }
  117719. declare module BABYLON {
  117720. /**
  117721. * Defines the options related to the creation of an HtmlElementTexture
  117722. */
  117723. export interface IHtmlElementTextureOptions {
  117724. /**
  117725. * Defines wether mip maps should be created or not.
  117726. */
  117727. generateMipMaps?: boolean;
  117728. /**
  117729. * Defines the sampling mode of the texture.
  117730. */
  117731. samplingMode?: number;
  117732. /**
  117733. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117734. */
  117735. engine: Nullable<Engine>;
  117736. /**
  117737. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117738. */
  117739. scene: Nullable<Scene>;
  117740. }
  117741. /**
  117742. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117743. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117744. * is automatically managed.
  117745. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117746. * in your application.
  117747. *
  117748. * As the update is not automatic, you need to call them manually.
  117749. */
  117750. export class HtmlElementTexture extends BaseTexture {
  117751. /**
  117752. * The texture URL.
  117753. */
  117754. element: HTMLVideoElement | HTMLCanvasElement;
  117755. private static readonly DefaultOptions;
  117756. private _textureMatrix;
  117757. private _engine;
  117758. private _isVideo;
  117759. private _generateMipMaps;
  117760. private _samplingMode;
  117761. /**
  117762. * Instantiates a HtmlElementTexture from the following parameters.
  117763. *
  117764. * @param name Defines the name of the texture
  117765. * @param element Defines the video or canvas the texture is filled with
  117766. * @param options Defines the other none mandatory texture creation options
  117767. */
  117768. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117769. private _createInternalTexture;
  117770. /**
  117771. * Returns the texture matrix used in most of the material.
  117772. */
  117773. getTextureMatrix(): Matrix;
  117774. /**
  117775. * Updates the content of the texture.
  117776. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117777. */
  117778. update(invertY?: Nullable<boolean>): void;
  117779. }
  117780. }
  117781. declare module BABYLON {
  117782. /**
  117783. * Enum used to define the target of a block
  117784. */
  117785. export enum NodeMaterialBlockTargets {
  117786. /** Vertex shader */
  117787. Vertex = 1,
  117788. /** Fragment shader */
  117789. Fragment = 2,
  117790. /** Neutral */
  117791. Neutral = 4,
  117792. /** Vertex and Fragment */
  117793. VertexAndFragment = 3
  117794. }
  117795. }
  117796. declare module BABYLON {
  117797. /**
  117798. * Defines the kind of connection point for node based material
  117799. */
  117800. export enum NodeMaterialBlockConnectionPointTypes {
  117801. /** Float */
  117802. Float = 1,
  117803. /** Int */
  117804. Int = 2,
  117805. /** Vector2 */
  117806. Vector2 = 4,
  117807. /** Vector3 */
  117808. Vector3 = 8,
  117809. /** Vector4 */
  117810. Vector4 = 16,
  117811. /** Color3 */
  117812. Color3 = 32,
  117813. /** Color4 */
  117814. Color4 = 64,
  117815. /** Matrix */
  117816. Matrix = 128,
  117817. /** Detect type based on connection */
  117818. AutoDetect = 1024,
  117819. /** Output type that will be defined by input type */
  117820. BasedOnInput = 2048
  117821. }
  117822. }
  117823. declare module BABYLON {
  117824. /**
  117825. * Root class for all node material optimizers
  117826. */
  117827. export class NodeMaterialOptimizer {
  117828. /**
  117829. * Function used to optimize a NodeMaterial graph
  117830. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  117831. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  117832. */
  117833. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  117834. }
  117835. }
  117836. declare module BABYLON {
  117837. /**
  117838. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  117839. */
  117840. export class TransformBlock extends NodeMaterialBlock {
  117841. /**
  117842. * Defines the value to use to complement W value to transform it to a Vector4
  117843. */
  117844. complementW: number;
  117845. /**
  117846. * Defines the value to use to complement z value to transform it to a Vector4
  117847. */
  117848. complementZ: number;
  117849. /**
  117850. * Creates a new TransformBlock
  117851. * @param name defines the block name
  117852. */
  117853. constructor(name: string);
  117854. /**
  117855. * Gets the current class name
  117856. * @returns the class name
  117857. */
  117858. getClassName(): string;
  117859. /**
  117860. * Gets the vector input
  117861. */
  117862. readonly vector: NodeMaterialConnectionPoint;
  117863. /**
  117864. * Gets the output component
  117865. */
  117866. readonly output: NodeMaterialConnectionPoint;
  117867. /**
  117868. * Gets the matrix transform input
  117869. */
  117870. readonly transform: NodeMaterialConnectionPoint;
  117871. protected _buildBlock(state: NodeMaterialBuildState): this;
  117872. serialize(): any;
  117873. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117874. protected _dumpPropertiesCode(): string;
  117875. }
  117876. }
  117877. declare module BABYLON {
  117878. /**
  117879. * Block used to output the vertex position
  117880. */
  117881. export class VertexOutputBlock extends NodeMaterialBlock {
  117882. /**
  117883. * Creates a new VertexOutputBlock
  117884. * @param name defines the block name
  117885. */
  117886. constructor(name: string);
  117887. /**
  117888. * Gets the current class name
  117889. * @returns the class name
  117890. */
  117891. getClassName(): string;
  117892. /**
  117893. * Gets the vector input component
  117894. */
  117895. readonly vector: NodeMaterialConnectionPoint;
  117896. protected _buildBlock(state: NodeMaterialBuildState): this;
  117897. }
  117898. }
  117899. declare module BABYLON {
  117900. /**
  117901. * Block used to output the final color
  117902. */
  117903. export class FragmentOutputBlock extends NodeMaterialBlock {
  117904. /**
  117905. * Create a new FragmentOutputBlock
  117906. * @param name defines the block name
  117907. */
  117908. constructor(name: string);
  117909. /**
  117910. * Gets the current class name
  117911. * @returns the class name
  117912. */
  117913. getClassName(): string;
  117914. /**
  117915. * Gets the rgba input component
  117916. */
  117917. readonly rgba: NodeMaterialConnectionPoint;
  117918. /**
  117919. * Gets the rgb input component
  117920. */
  117921. readonly rgb: NodeMaterialConnectionPoint;
  117922. /**
  117923. * Gets the a input component
  117924. */
  117925. readonly a: NodeMaterialConnectionPoint;
  117926. protected _buildBlock(state: NodeMaterialBuildState): this;
  117927. }
  117928. }
  117929. declare module BABYLON {
  117930. /**
  117931. * Enum used to define system values e.g. values automatically provided by the system
  117932. */
  117933. export enum NodeMaterialSystemValues {
  117934. /** World */
  117935. World = 1,
  117936. /** View */
  117937. View = 2,
  117938. /** Projection */
  117939. Projection = 3,
  117940. /** ViewProjection */
  117941. ViewProjection = 4,
  117942. /** WorldView */
  117943. WorldView = 5,
  117944. /** WorldViewProjection */
  117945. WorldViewProjection = 6,
  117946. /** CameraPosition */
  117947. CameraPosition = 7,
  117948. /** Fog Color */
  117949. FogColor = 8
  117950. }
  117951. }
  117952. declare module BABYLON {
  117953. /**
  117954. * Block used to read a reflection texture from a sampler
  117955. */
  117956. export class ReflectionTextureBlock extends NodeMaterialBlock {
  117957. private _define3DName;
  117958. private _defineCubicName;
  117959. private _defineExplicitName;
  117960. private _defineProjectionName;
  117961. private _defineLocalCubicName;
  117962. private _defineSphericalName;
  117963. private _definePlanarName;
  117964. private _defineEquirectangularName;
  117965. private _defineMirroredEquirectangularFixedName;
  117966. private _defineEquirectangularFixedName;
  117967. private _defineSkyboxName;
  117968. private _cubeSamplerName;
  117969. private _2DSamplerName;
  117970. private _positionUVWName;
  117971. private _directionWName;
  117972. private _reflectionCoordsName;
  117973. private _reflection2DCoordsName;
  117974. private _reflectionColorName;
  117975. private _reflectionMatrixName;
  117976. /**
  117977. * Gets or sets the texture associated with the node
  117978. */
  117979. texture: Nullable<BaseTexture>;
  117980. /**
  117981. * Create a new TextureBlock
  117982. * @param name defines the block name
  117983. */
  117984. constructor(name: string);
  117985. /**
  117986. * Gets the current class name
  117987. * @returns the class name
  117988. */
  117989. getClassName(): string;
  117990. /**
  117991. * Gets the world position input component
  117992. */
  117993. readonly position: NodeMaterialConnectionPoint;
  117994. /**
  117995. * Gets the world position input component
  117996. */
  117997. readonly worldPosition: NodeMaterialConnectionPoint;
  117998. /**
  117999. * Gets the world normal input component
  118000. */
  118001. readonly worldNormal: NodeMaterialConnectionPoint;
  118002. /**
  118003. * Gets the world input component
  118004. */
  118005. readonly world: NodeMaterialConnectionPoint;
  118006. /**
  118007. * Gets the camera (or eye) position component
  118008. */
  118009. readonly cameraPosition: NodeMaterialConnectionPoint;
  118010. /**
  118011. * Gets the view input component
  118012. */
  118013. readonly view: NodeMaterialConnectionPoint;
  118014. /**
  118015. * Gets the rgb output component
  118016. */
  118017. readonly rgb: NodeMaterialConnectionPoint;
  118018. /**
  118019. * Gets the r output component
  118020. */
  118021. readonly r: NodeMaterialConnectionPoint;
  118022. /**
  118023. * Gets the g output component
  118024. */
  118025. readonly g: NodeMaterialConnectionPoint;
  118026. /**
  118027. * Gets the b output component
  118028. */
  118029. readonly b: NodeMaterialConnectionPoint;
  118030. autoConfigure(material: NodeMaterial): void;
  118031. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118032. isReady(): boolean;
  118033. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118034. private _injectVertexCode;
  118035. private _writeOutput;
  118036. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118037. serialize(): any;
  118038. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118039. }
  118040. }
  118041. declare module BABYLON {
  118042. /**
  118043. * Interface used to configure the node material editor
  118044. */
  118045. export interface INodeMaterialEditorOptions {
  118046. /** Define the URl to load node editor script */
  118047. editorURL?: string;
  118048. }
  118049. /** @hidden */
  118050. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  118051. /** BONES */
  118052. NUM_BONE_INFLUENCERS: number;
  118053. BonesPerMesh: number;
  118054. BONETEXTURE: boolean;
  118055. /** MORPH TARGETS */
  118056. MORPHTARGETS: boolean;
  118057. MORPHTARGETS_NORMAL: boolean;
  118058. MORPHTARGETS_TANGENT: boolean;
  118059. MORPHTARGETS_UV: boolean;
  118060. NUM_MORPH_INFLUENCERS: number;
  118061. /** IMAGE PROCESSING */
  118062. IMAGEPROCESSING: boolean;
  118063. VIGNETTE: boolean;
  118064. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118065. VIGNETTEBLENDMODEOPAQUE: boolean;
  118066. TONEMAPPING: boolean;
  118067. TONEMAPPING_ACES: boolean;
  118068. CONTRAST: boolean;
  118069. EXPOSURE: boolean;
  118070. COLORCURVES: boolean;
  118071. COLORGRADING: boolean;
  118072. COLORGRADING3D: boolean;
  118073. SAMPLER3DGREENDEPTH: boolean;
  118074. SAMPLER3DBGRMAP: boolean;
  118075. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118076. /** MISC. */
  118077. BUMPDIRECTUV: number;
  118078. constructor();
  118079. setValue(name: string, value: boolean): void;
  118080. }
  118081. /**
  118082. * Class used to configure NodeMaterial
  118083. */
  118084. export interface INodeMaterialOptions {
  118085. /**
  118086. * Defines if blocks should emit comments
  118087. */
  118088. emitComments: boolean;
  118089. }
  118090. /**
  118091. * Class used to create a node based material built by assembling shader blocks
  118092. */
  118093. export class NodeMaterial extends PushMaterial {
  118094. private static _BuildIdGenerator;
  118095. private _options;
  118096. private _vertexCompilationState;
  118097. private _fragmentCompilationState;
  118098. private _sharedData;
  118099. private _buildId;
  118100. private _buildWasSuccessful;
  118101. private _cachedWorldViewMatrix;
  118102. private _cachedWorldViewProjectionMatrix;
  118103. private _optimizers;
  118104. private _animationFrame;
  118105. /** Define the URl to load node editor script */
  118106. static EditorURL: string;
  118107. private BJSNODEMATERIALEDITOR;
  118108. /** Get the inspector from bundle or global */
  118109. private _getGlobalNodeMaterialEditor;
  118110. /**
  118111. * 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)
  118112. */
  118113. ignoreAlpha: boolean;
  118114. /**
  118115. * Defines the maximum number of lights that can be used in the material
  118116. */
  118117. maxSimultaneousLights: number;
  118118. /**
  118119. * Observable raised when the material is built
  118120. */
  118121. onBuildObservable: Observable<NodeMaterial>;
  118122. /**
  118123. * Gets or sets the root nodes of the material vertex shader
  118124. */
  118125. _vertexOutputNodes: NodeMaterialBlock[];
  118126. /**
  118127. * Gets or sets the root nodes of the material fragment (pixel) shader
  118128. */
  118129. _fragmentOutputNodes: NodeMaterialBlock[];
  118130. /** Gets or sets options to control the node material overall behavior */
  118131. options: INodeMaterialOptions;
  118132. /**
  118133. * Default configuration related to image processing available in the standard Material.
  118134. */
  118135. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118136. /**
  118137. * Gets the image processing configuration used either in this material.
  118138. */
  118139. /**
  118140. * Sets the Default image processing configuration used either in the this material.
  118141. *
  118142. * If sets to null, the scene one is in use.
  118143. */
  118144. imageProcessingConfiguration: ImageProcessingConfiguration;
  118145. /**
  118146. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  118147. */
  118148. attachedBlocks: NodeMaterialBlock[];
  118149. /**
  118150. * Create a new node based material
  118151. * @param name defines the material name
  118152. * @param scene defines the hosting scene
  118153. * @param options defines creation option
  118154. */
  118155. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  118156. /**
  118157. * Gets the current class name of the material e.g. "NodeMaterial"
  118158. * @returns the class name
  118159. */
  118160. getClassName(): string;
  118161. /**
  118162. * Keep track of the image processing observer to allow dispose and replace.
  118163. */
  118164. private _imageProcessingObserver;
  118165. /**
  118166. * Attaches a new image processing configuration to the Standard Material.
  118167. * @param configuration
  118168. */
  118169. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118170. /**
  118171. * Get a block by its name
  118172. * @param name defines the name of the block to retrieve
  118173. * @returns the required block or null if not found
  118174. */
  118175. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  118176. /**
  118177. * Get a block by its name
  118178. * @param predicate defines the predicate used to find the good candidate
  118179. * @returns the required block or null if not found
  118180. */
  118181. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  118182. /**
  118183. * Get an input block by its name
  118184. * @param predicate defines the predicate used to find the good candidate
  118185. * @returns the required input block or null if not found
  118186. */
  118187. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  118188. /**
  118189. * Gets the list of input blocks attached to this material
  118190. * @returns an array of InputBlocks
  118191. */
  118192. getInputBlocks(): InputBlock[];
  118193. /**
  118194. * Adds a new optimizer to the list of optimizers
  118195. * @param optimizer defines the optimizers to add
  118196. * @returns the current material
  118197. */
  118198. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118199. /**
  118200. * Remove an optimizer from the list of optimizers
  118201. * @param optimizer defines the optimizers to remove
  118202. * @returns the current material
  118203. */
  118204. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118205. /**
  118206. * Add a new block to the list of output nodes
  118207. * @param node defines the node to add
  118208. * @returns the current material
  118209. */
  118210. addOutputNode(node: NodeMaterialBlock): this;
  118211. /**
  118212. * Remove a block from the list of root nodes
  118213. * @param node defines the node to remove
  118214. * @returns the current material
  118215. */
  118216. removeOutputNode(node: NodeMaterialBlock): this;
  118217. private _addVertexOutputNode;
  118218. private _removeVertexOutputNode;
  118219. private _addFragmentOutputNode;
  118220. private _removeFragmentOutputNode;
  118221. /**
  118222. * Specifies if the material will require alpha blending
  118223. * @returns a boolean specifying if alpha blending is needed
  118224. */
  118225. needAlphaBlending(): boolean;
  118226. /**
  118227. * Specifies if this material should be rendered in alpha test mode
  118228. * @returns a boolean specifying if an alpha test is needed.
  118229. */
  118230. needAlphaTesting(): boolean;
  118231. private _initializeBlock;
  118232. private _resetDualBlocks;
  118233. /**
  118234. * Build the material and generates the inner effect
  118235. * @param verbose defines if the build should log activity
  118236. */
  118237. build(verbose?: boolean): void;
  118238. /**
  118239. * Runs an otpimization phase to try to improve the shader code
  118240. */
  118241. optimize(): void;
  118242. private _prepareDefinesForAttributes;
  118243. /**
  118244. * Get if the submesh is ready to be used and all its information available.
  118245. * Child classes can use it to update shaders
  118246. * @param mesh defines the mesh to check
  118247. * @param subMesh defines which submesh to check
  118248. * @param useInstances specifies that instances should be used
  118249. * @returns a boolean indicating that the submesh is ready or not
  118250. */
  118251. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118252. /**
  118253. * Get a string representing the shaders built by the current node graph
  118254. */
  118255. readonly compiledShaders: string;
  118256. /**
  118257. * Binds the world matrix to the material
  118258. * @param world defines the world transformation matrix
  118259. */
  118260. bindOnlyWorldMatrix(world: Matrix): void;
  118261. /**
  118262. * Binds the submesh to this material by preparing the effect and shader to draw
  118263. * @param world defines the world transformation matrix
  118264. * @param mesh defines the mesh containing the submesh
  118265. * @param subMesh defines the submesh to bind the material to
  118266. */
  118267. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118268. /**
  118269. * Gets the active textures from the material
  118270. * @returns an array of textures
  118271. */
  118272. getActiveTextures(): BaseTexture[];
  118273. /**
  118274. * Gets the list of texture blocks
  118275. * @returns an array of texture blocks
  118276. */
  118277. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  118278. /**
  118279. * Specifies if the material uses a texture
  118280. * @param texture defines the texture to check against the material
  118281. * @returns a boolean specifying if the material uses the texture
  118282. */
  118283. hasTexture(texture: BaseTexture): boolean;
  118284. /**
  118285. * Disposes the material
  118286. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  118287. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  118288. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  118289. */
  118290. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  118291. /** Creates the node editor window. */
  118292. private _createNodeEditor;
  118293. /**
  118294. * Launch the node material editor
  118295. * @param config Define the configuration of the editor
  118296. * @return a promise fulfilled when the node editor is visible
  118297. */
  118298. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  118299. /**
  118300. * Clear the current material
  118301. */
  118302. clear(): void;
  118303. /**
  118304. * Clear the current material and set it to a default state
  118305. */
  118306. setToDefault(): void;
  118307. /**
  118308. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  118309. * @param url defines the url to load from
  118310. * @returns a promise that will fullfil when the material is fully loaded
  118311. */
  118312. loadAsync(url: string): Promise<unknown>;
  118313. private _gatherBlocks;
  118314. /**
  118315. * Generate a string containing the code declaration required to create an equivalent of this material
  118316. * @returns a string
  118317. */
  118318. generateCode(): string;
  118319. /**
  118320. * Serializes this material in a JSON representation
  118321. * @returns the serialized material object
  118322. */
  118323. serialize(): any;
  118324. private _restoreConnections;
  118325. /**
  118326. * Clear the current graph and load a new one from a serialization object
  118327. * @param source defines the JSON representation of the material
  118328. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118329. */
  118330. loadFromSerialization(source: any, rootUrl?: string): void;
  118331. /**
  118332. * Creates a node material from parsed material data
  118333. * @param source defines the JSON representation of the material
  118334. * @param scene defines the hosting scene
  118335. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118336. * @returns a new node material
  118337. */
  118338. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  118339. /**
  118340. * Creates a new node material set to default basic configuration
  118341. * @param name defines the name of the material
  118342. * @param scene defines the hosting scene
  118343. * @returns a new NodeMaterial
  118344. */
  118345. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  118346. }
  118347. }
  118348. declare module BABYLON {
  118349. /**
  118350. * Block used to read a texture from a sampler
  118351. */
  118352. export class TextureBlock extends NodeMaterialBlock {
  118353. private _defineName;
  118354. private _samplerName;
  118355. private _transformedUVName;
  118356. private _textureTransformName;
  118357. private _textureInfoName;
  118358. private _mainUVName;
  118359. private _mainUVDefineName;
  118360. /**
  118361. * Gets or sets the texture associated with the node
  118362. */
  118363. texture: Nullable<Texture>;
  118364. /**
  118365. * Create a new TextureBlock
  118366. * @param name defines the block name
  118367. */
  118368. constructor(name: string);
  118369. /**
  118370. * Gets the current class name
  118371. * @returns the class name
  118372. */
  118373. getClassName(): string;
  118374. /**
  118375. * Gets the uv input component
  118376. */
  118377. readonly uv: NodeMaterialConnectionPoint;
  118378. /**
  118379. * Gets the rgba output component
  118380. */
  118381. readonly rgba: NodeMaterialConnectionPoint;
  118382. /**
  118383. * Gets the rgb output component
  118384. */
  118385. readonly rgb: NodeMaterialConnectionPoint;
  118386. /**
  118387. * Gets the r output component
  118388. */
  118389. readonly r: NodeMaterialConnectionPoint;
  118390. /**
  118391. * Gets the g output component
  118392. */
  118393. readonly g: NodeMaterialConnectionPoint;
  118394. /**
  118395. * Gets the b output component
  118396. */
  118397. readonly b: NodeMaterialConnectionPoint;
  118398. /**
  118399. * Gets the a output component
  118400. */
  118401. readonly a: NodeMaterialConnectionPoint;
  118402. readonly target: NodeMaterialBlockTargets;
  118403. autoConfigure(material: NodeMaterial): void;
  118404. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118405. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118406. isReady(): boolean;
  118407. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118408. private readonly _isMixed;
  118409. private _injectVertexCode;
  118410. private _writeOutput;
  118411. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118412. protected _dumpPropertiesCode(): string;
  118413. serialize(): any;
  118414. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118415. }
  118416. }
  118417. declare module BABYLON {
  118418. /**
  118419. * Class used to store shared data between 2 NodeMaterialBuildState
  118420. */
  118421. export class NodeMaterialBuildStateSharedData {
  118422. /**
  118423. * Gets the list of emitted varyings
  118424. */
  118425. temps: string[];
  118426. /**
  118427. * Gets the list of emitted varyings
  118428. */
  118429. varyings: string[];
  118430. /**
  118431. * Gets the varying declaration string
  118432. */
  118433. varyingDeclaration: string;
  118434. /**
  118435. * Input blocks
  118436. */
  118437. inputBlocks: InputBlock[];
  118438. /**
  118439. * Input blocks
  118440. */
  118441. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118442. /**
  118443. * Bindable blocks (Blocks that need to set data to the effect)
  118444. */
  118445. bindableBlocks: NodeMaterialBlock[];
  118446. /**
  118447. * List of blocks that can provide a compilation fallback
  118448. */
  118449. blocksWithFallbacks: NodeMaterialBlock[];
  118450. /**
  118451. * List of blocks that can provide a define update
  118452. */
  118453. blocksWithDefines: NodeMaterialBlock[];
  118454. /**
  118455. * List of blocks that can provide a repeatable content
  118456. */
  118457. repeatableContentBlocks: NodeMaterialBlock[];
  118458. /**
  118459. * List of blocks that can provide a dynamic list of uniforms
  118460. */
  118461. dynamicUniformBlocks: NodeMaterialBlock[];
  118462. /**
  118463. * List of blocks that can block the isReady function for the material
  118464. */
  118465. blockingBlocks: NodeMaterialBlock[];
  118466. /**
  118467. * Gets the list of animated inputs
  118468. */
  118469. animatedInputs: InputBlock[];
  118470. /**
  118471. * Build Id used to avoid multiple recompilations
  118472. */
  118473. buildId: number;
  118474. /** List of emitted variables */
  118475. variableNames: {
  118476. [key: string]: number;
  118477. };
  118478. /** List of emitted defines */
  118479. defineNames: {
  118480. [key: string]: number;
  118481. };
  118482. /** Should emit comments? */
  118483. emitComments: boolean;
  118484. /** Emit build activity */
  118485. verbose: boolean;
  118486. /** Gets or sets the hosting scene */
  118487. scene: Scene;
  118488. /**
  118489. * Gets the compilation hints emitted at compilation time
  118490. */
  118491. hints: {
  118492. needWorldViewMatrix: boolean;
  118493. needWorldViewProjectionMatrix: boolean;
  118494. needAlphaBlending: boolean;
  118495. needAlphaTesting: boolean;
  118496. };
  118497. /**
  118498. * List of compilation checks
  118499. */
  118500. checks: {
  118501. emitVertex: boolean;
  118502. emitFragment: boolean;
  118503. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118504. };
  118505. /** Creates a new shared data */
  118506. constructor();
  118507. /**
  118508. * Emits console errors and exceptions if there is a failing check
  118509. */
  118510. emitErrors(): void;
  118511. }
  118512. }
  118513. declare module BABYLON {
  118514. /**
  118515. * Class used to store node based material build state
  118516. */
  118517. export class NodeMaterialBuildState {
  118518. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118519. supportUniformBuffers: boolean;
  118520. /**
  118521. * Gets the list of emitted attributes
  118522. */
  118523. attributes: string[];
  118524. /**
  118525. * Gets the list of emitted uniforms
  118526. */
  118527. uniforms: string[];
  118528. /**
  118529. * Gets the list of emitted uniform buffers
  118530. */
  118531. uniformBuffers: string[];
  118532. /**
  118533. * Gets the list of emitted samplers
  118534. */
  118535. samplers: string[];
  118536. /**
  118537. * Gets the list of emitted functions
  118538. */
  118539. functions: {
  118540. [key: string]: string;
  118541. };
  118542. /**
  118543. * Gets the list of emitted extensions
  118544. */
  118545. extensions: {
  118546. [key: string]: string;
  118547. };
  118548. /**
  118549. * Gets the target of the compilation state
  118550. */
  118551. target: NodeMaterialBlockTargets;
  118552. /**
  118553. * Gets the list of emitted counters
  118554. */
  118555. counters: {
  118556. [key: string]: number;
  118557. };
  118558. /**
  118559. * Shared data between multiple NodeMaterialBuildState instances
  118560. */
  118561. sharedData: NodeMaterialBuildStateSharedData;
  118562. /** @hidden */
  118563. _vertexState: NodeMaterialBuildState;
  118564. /** @hidden */
  118565. _attributeDeclaration: string;
  118566. /** @hidden */
  118567. _uniformDeclaration: string;
  118568. /** @hidden */
  118569. _samplerDeclaration: string;
  118570. /** @hidden */
  118571. _varyingTransfer: string;
  118572. private _repeatableContentAnchorIndex;
  118573. /** @hidden */
  118574. _builtCompilationString: string;
  118575. /**
  118576. * Gets the emitted compilation strings
  118577. */
  118578. compilationString: string;
  118579. /**
  118580. * Finalize the compilation strings
  118581. * @param state defines the current compilation state
  118582. */
  118583. finalize(state: NodeMaterialBuildState): void;
  118584. /** @hidden */
  118585. readonly _repeatableContentAnchor: string;
  118586. /** @hidden */
  118587. _getFreeVariableName(prefix: string): string;
  118588. /** @hidden */
  118589. _getFreeDefineName(prefix: string): string;
  118590. /** @hidden */
  118591. _excludeVariableName(name: string): void;
  118592. /** @hidden */
  118593. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118594. /** @hidden */
  118595. _emitExtension(name: string, extension: string): void;
  118596. /** @hidden */
  118597. _emitFunction(name: string, code: string, comments: string): void;
  118598. /** @hidden */
  118599. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118600. replaceStrings?: {
  118601. search: RegExp;
  118602. replace: string;
  118603. }[];
  118604. repeatKey?: string;
  118605. }): string;
  118606. /** @hidden */
  118607. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118608. repeatKey?: string;
  118609. removeAttributes?: boolean;
  118610. removeUniforms?: boolean;
  118611. removeVaryings?: boolean;
  118612. removeIfDef?: boolean;
  118613. replaceStrings?: {
  118614. search: RegExp;
  118615. replace: string;
  118616. }[];
  118617. }, storeKey?: string): void;
  118618. /** @hidden */
  118619. _registerTempVariable(name: string): boolean;
  118620. /** @hidden */
  118621. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118622. /** @hidden */
  118623. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118624. }
  118625. }
  118626. declare module BABYLON {
  118627. /**
  118628. * Defines a block that can be used inside a node based material
  118629. */
  118630. export class NodeMaterialBlock {
  118631. private _buildId;
  118632. private _buildTarget;
  118633. private _target;
  118634. private _isFinalMerger;
  118635. private _isInput;
  118636. /** @hidden */
  118637. _codeVariableName: string;
  118638. /** @hidden */
  118639. _inputs: NodeMaterialConnectionPoint[];
  118640. /** @hidden */
  118641. _outputs: NodeMaterialConnectionPoint[];
  118642. /** @hidden */
  118643. _preparationId: number;
  118644. /**
  118645. * Gets or sets the name of the block
  118646. */
  118647. name: string;
  118648. /**
  118649. * Gets or sets the unique id of the node
  118650. */
  118651. uniqueId: number;
  118652. /**
  118653. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118654. */
  118655. readonly isFinalMerger: boolean;
  118656. /**
  118657. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118658. */
  118659. readonly isInput: boolean;
  118660. /**
  118661. * Gets or sets the build Id
  118662. */
  118663. buildId: number;
  118664. /**
  118665. * Gets or sets the target of the block
  118666. */
  118667. target: NodeMaterialBlockTargets;
  118668. /**
  118669. * Gets the list of input points
  118670. */
  118671. readonly inputs: NodeMaterialConnectionPoint[];
  118672. /** Gets the list of output points */
  118673. readonly outputs: NodeMaterialConnectionPoint[];
  118674. /**
  118675. * Find an input by its name
  118676. * @param name defines the name of the input to look for
  118677. * @returns the input or null if not found
  118678. */
  118679. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118680. /**
  118681. * Find an output by its name
  118682. * @param name defines the name of the outputto look for
  118683. * @returns the output or null if not found
  118684. */
  118685. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118686. /**
  118687. * Creates a new NodeMaterialBlock
  118688. * @param name defines the block name
  118689. * @param target defines the target of that block (Vertex by default)
  118690. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118691. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118692. */
  118693. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118694. /**
  118695. * Initialize the block and prepare the context for build
  118696. * @param state defines the state that will be used for the build
  118697. */
  118698. initialize(state: NodeMaterialBuildState): void;
  118699. /**
  118700. * Bind data to effect. Will only be called for blocks with isBindable === true
  118701. * @param effect defines the effect to bind data to
  118702. * @param nodeMaterial defines the hosting NodeMaterial
  118703. * @param mesh defines the mesh that will be rendered
  118704. */
  118705. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118706. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118707. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118708. protected _writeFloat(value: number): string;
  118709. /**
  118710. * Gets the current class name e.g. "NodeMaterialBlock"
  118711. * @returns the class name
  118712. */
  118713. getClassName(): string;
  118714. /**
  118715. * Register a new input. Must be called inside a block constructor
  118716. * @param name defines the connection point name
  118717. * @param type defines the connection point type
  118718. * @param isOptional defines a boolean indicating that this input can be omitted
  118719. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118720. * @returns the current block
  118721. */
  118722. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118723. /**
  118724. * Register a new output. Must be called inside a block constructor
  118725. * @param name defines the connection point name
  118726. * @param type defines the connection point type
  118727. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118728. * @returns the current block
  118729. */
  118730. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118731. /**
  118732. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118733. * @param forOutput defines an optional connection point to check compatibility with
  118734. * @returns the first available input or null
  118735. */
  118736. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118737. /**
  118738. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118739. * @param forBlock defines an optional block to check compatibility with
  118740. * @returns the first available input or null
  118741. */
  118742. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118743. /**
  118744. * Gets the sibling of the given output
  118745. * @param current defines the current output
  118746. * @returns the next output in the list or null
  118747. */
  118748. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118749. /**
  118750. * Connect current block with another block
  118751. * @param other defines the block to connect with
  118752. * @param options define the various options to help pick the right connections
  118753. * @returns the current block
  118754. */
  118755. connectTo(other: NodeMaterialBlock, options?: {
  118756. input?: string;
  118757. output?: string;
  118758. outputSwizzle?: string;
  118759. }): this | undefined;
  118760. protected _buildBlock(state: NodeMaterialBuildState): void;
  118761. /**
  118762. * Add uniforms, samplers and uniform buffers at compilation time
  118763. * @param state defines the state to update
  118764. * @param nodeMaterial defines the node material requesting the update
  118765. * @param defines defines the material defines to update
  118766. */
  118767. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118768. /**
  118769. * Add potential fallbacks if shader compilation fails
  118770. * @param mesh defines the mesh to be rendered
  118771. * @param fallbacks defines the current prioritized list of fallbacks
  118772. */
  118773. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118774. /**
  118775. * Initialize defines for shader compilation
  118776. * @param mesh defines the mesh to be rendered
  118777. * @param nodeMaterial defines the node material requesting the update
  118778. * @param defines defines the material defines to update
  118779. * @param useInstances specifies that instances should be used
  118780. */
  118781. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118782. /**
  118783. * Update defines for shader compilation
  118784. * @param mesh defines the mesh to be rendered
  118785. * @param nodeMaterial defines the node material requesting the update
  118786. * @param defines defines the material defines to update
  118787. * @param useInstances specifies that instances should be used
  118788. */
  118789. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118790. /**
  118791. * Lets the block try to connect some inputs automatically
  118792. * @param material defines the hosting NodeMaterial
  118793. */
  118794. autoConfigure(material: NodeMaterial): void;
  118795. /**
  118796. * Function called when a block is declared as repeatable content generator
  118797. * @param vertexShaderState defines the current compilation state for the vertex shader
  118798. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118799. * @param mesh defines the mesh to be rendered
  118800. * @param defines defines the material defines to update
  118801. */
  118802. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118803. /**
  118804. * Checks if the block is ready
  118805. * @param mesh defines the mesh to be rendered
  118806. * @param nodeMaterial defines the node material requesting the update
  118807. * @param defines defines the material defines to update
  118808. * @param useInstances specifies that instances should be used
  118809. * @returns true if the block is ready
  118810. */
  118811. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118812. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118813. private _processBuild;
  118814. /**
  118815. * Compile the current node and generate the shader code
  118816. * @param state defines the current compilation state (uniforms, samplers, current string)
  118817. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118818. * @returns true if already built
  118819. */
  118820. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118821. protected _inputRename(name: string): string;
  118822. protected _outputRename(name: string): string;
  118823. protected _dumpPropertiesCode(): string;
  118824. /** @hidden */
  118825. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118826. /**
  118827. * Clone the current block to a new identical block
  118828. * @param scene defines the hosting scene
  118829. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118830. * @returns a copy of the current block
  118831. */
  118832. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  118833. /**
  118834. * Serializes this block in a JSON representation
  118835. * @returns the serialized block object
  118836. */
  118837. serialize(): any;
  118838. /** @hidden */
  118839. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118840. }
  118841. }
  118842. declare module BABYLON {
  118843. /**
  118844. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  118845. */
  118846. export enum NodeMaterialBlockConnectionPointMode {
  118847. /** Value is an uniform */
  118848. Uniform = 0,
  118849. /** Value is a mesh attribute */
  118850. Attribute = 1,
  118851. /** Value is a varying between vertex and fragment shaders */
  118852. Varying = 2,
  118853. /** Mode is undefined */
  118854. Undefined = 3
  118855. }
  118856. }
  118857. declare module BABYLON {
  118858. /**
  118859. * Enum defining the type of animations supported by InputBlock
  118860. */
  118861. export enum AnimatedInputBlockTypes {
  118862. /** No animation */
  118863. None = 0,
  118864. /** Time based animation. Will only work for floats */
  118865. Time = 1
  118866. }
  118867. }
  118868. declare module BABYLON {
  118869. /**
  118870. * Block used to expose an input value
  118871. */
  118872. export class InputBlock extends NodeMaterialBlock {
  118873. private _mode;
  118874. private _associatedVariableName;
  118875. private _storedValue;
  118876. private _valueCallback;
  118877. private _type;
  118878. private _animationType;
  118879. /** Gets or set a value used to limit the range of float values */
  118880. min: number;
  118881. /** Gets or set a value used to limit the range of float values */
  118882. max: number;
  118883. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  118884. matrixMode: number;
  118885. /** @hidden */
  118886. _systemValue: Nullable<NodeMaterialSystemValues>;
  118887. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  118888. visibleInInspector: boolean;
  118889. /**
  118890. * Gets or sets the connection point type (default is float)
  118891. */
  118892. readonly type: NodeMaterialBlockConnectionPointTypes;
  118893. /**
  118894. * Creates a new InputBlock
  118895. * @param name defines the block name
  118896. * @param target defines the target of that block (Vertex by default)
  118897. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  118898. */
  118899. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  118900. /**
  118901. * Gets the output component
  118902. */
  118903. readonly output: NodeMaterialConnectionPoint;
  118904. /**
  118905. * Set the source of this connection point to a vertex attribute
  118906. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  118907. * @returns the current connection point
  118908. */
  118909. setAsAttribute(attributeName?: string): InputBlock;
  118910. /**
  118911. * Set the source of this connection point to a system value
  118912. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  118913. * @returns the current connection point
  118914. */
  118915. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  118916. /**
  118917. * Gets or sets the value of that point.
  118918. * Please note that this value will be ignored if valueCallback is defined
  118919. */
  118920. value: any;
  118921. /**
  118922. * Gets or sets a callback used to get the value of that point.
  118923. * Please note that setting this value will force the connection point to ignore the value property
  118924. */
  118925. valueCallback: () => any;
  118926. /**
  118927. * Gets or sets the associated variable name in the shader
  118928. */
  118929. associatedVariableName: string;
  118930. /** Gets or sets the type of animation applied to the input */
  118931. animationType: AnimatedInputBlockTypes;
  118932. /**
  118933. * Gets a boolean indicating that this connection point not defined yet
  118934. */
  118935. readonly isUndefined: boolean;
  118936. /**
  118937. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  118938. * In this case the connection point name must be the name of the uniform to use.
  118939. * Can only be set on inputs
  118940. */
  118941. isUniform: boolean;
  118942. /**
  118943. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  118944. * In this case the connection point name must be the name of the attribute to use
  118945. * Can only be set on inputs
  118946. */
  118947. isAttribute: boolean;
  118948. /**
  118949. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  118950. * Can only be set on exit points
  118951. */
  118952. isVarying: boolean;
  118953. /**
  118954. * Gets a boolean indicating that the current connection point is a system value
  118955. */
  118956. readonly isSystemValue: boolean;
  118957. /**
  118958. * Gets or sets the current well known value or null if not defined as a system value
  118959. */
  118960. systemValue: Nullable<NodeMaterialSystemValues>;
  118961. /**
  118962. * Gets the current class name
  118963. * @returns the class name
  118964. */
  118965. getClassName(): string;
  118966. /**
  118967. * Animate the input if animationType !== None
  118968. * @param scene defines the rendering scene
  118969. */
  118970. animate(scene: Scene): void;
  118971. private _emitDefine;
  118972. initialize(state: NodeMaterialBuildState): void;
  118973. /**
  118974. * Set the input block to its default value (based on its type)
  118975. */
  118976. setDefaultValue(): void;
  118977. protected _dumpPropertiesCode(): string;
  118978. private _emit;
  118979. /** @hidden */
  118980. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  118981. /** @hidden */
  118982. _transmit(effect: Effect, scene: Scene): void;
  118983. protected _buildBlock(state: NodeMaterialBuildState): void;
  118984. serialize(): any;
  118985. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118986. }
  118987. }
  118988. declare module BABYLON {
  118989. /**
  118990. * Defines a connection point for a block
  118991. */
  118992. export class NodeMaterialConnectionPoint {
  118993. /** @hidden */
  118994. _ownerBlock: NodeMaterialBlock;
  118995. /** @hidden */
  118996. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  118997. private _endpoints;
  118998. private _associatedVariableName;
  118999. /** @hidden */
  119000. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119001. /** @hidden */
  119002. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119003. private _type;
  119004. /** @hidden */
  119005. _enforceAssociatedVariableName: boolean;
  119006. /**
  119007. * Gets or sets the additional types supported byt this connection point
  119008. */
  119009. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119010. /**
  119011. * Gets or sets the associated variable name in the shader
  119012. */
  119013. associatedVariableName: string;
  119014. /**
  119015. * Gets or sets the connection point type (default is float)
  119016. */
  119017. type: NodeMaterialBlockConnectionPointTypes;
  119018. /**
  119019. * Gets or sets the connection point name
  119020. */
  119021. name: string;
  119022. /**
  119023. * Gets or sets a boolean indicating that this connection point can be omitted
  119024. */
  119025. isOptional: boolean;
  119026. /**
  119027. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  119028. */
  119029. define: string;
  119030. /** Gets or sets the target of that connection point */
  119031. target: NodeMaterialBlockTargets;
  119032. /**
  119033. * Gets a boolean indicating that the current point is connected
  119034. */
  119035. readonly isConnected: boolean;
  119036. /**
  119037. * Gets a boolean indicating that the current point is connected to an input block
  119038. */
  119039. readonly isConnectedToInputBlock: boolean;
  119040. /**
  119041. * Gets a the connected input block (if any)
  119042. */
  119043. readonly connectInputBlock: Nullable<InputBlock>;
  119044. /** Get the other side of the connection (if any) */
  119045. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119046. /** Get the block that owns this connection point */
  119047. readonly ownerBlock: NodeMaterialBlock;
  119048. /** Get the block connected on the other side of this connection (if any) */
  119049. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  119050. /** Get the block connected on the endpoints of this connection (if any) */
  119051. readonly connectedBlocks: Array<NodeMaterialBlock>;
  119052. /** Gets the list of connected endpoints */
  119053. readonly endpoints: NodeMaterialConnectionPoint[];
  119054. /** Gets a boolean indicating if that output point is connected to at least one input */
  119055. readonly hasEndpoints: boolean;
  119056. /**
  119057. * Creates a new connection point
  119058. * @param name defines the connection point name
  119059. * @param ownerBlock defines the block hosting this connection point
  119060. */
  119061. constructor(name: string, ownerBlock: NodeMaterialBlock);
  119062. /**
  119063. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  119064. * @returns the class name
  119065. */
  119066. getClassName(): string;
  119067. /**
  119068. * Gets an boolean indicating if the current point can be connected to another point
  119069. * @param connectionPoint defines the other connection point
  119070. * @returns true if the connection is possible
  119071. */
  119072. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  119073. /**
  119074. * Connect this point to another connection point
  119075. * @param connectionPoint defines the other connection point
  119076. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  119077. * @returns the current connection point
  119078. */
  119079. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  119080. /**
  119081. * Disconnect this point from one of his endpoint
  119082. * @param endpoint defines the other connection point
  119083. * @returns the current connection point
  119084. */
  119085. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  119086. /**
  119087. * Serializes this point in a JSON representation
  119088. * @returns the serialized point object
  119089. */
  119090. serialize(): any;
  119091. }
  119092. }
  119093. declare module BABYLON {
  119094. /**
  119095. * Block used to add support for vertex skinning (bones)
  119096. */
  119097. export class BonesBlock extends NodeMaterialBlock {
  119098. /**
  119099. * Creates a new BonesBlock
  119100. * @param name defines the block name
  119101. */
  119102. constructor(name: string);
  119103. /**
  119104. * Initialize the block and prepare the context for build
  119105. * @param state defines the state that will be used for the build
  119106. */
  119107. initialize(state: NodeMaterialBuildState): void;
  119108. /**
  119109. * Gets the current class name
  119110. * @returns the class name
  119111. */
  119112. getClassName(): string;
  119113. /**
  119114. * Gets the matrix indices input component
  119115. */
  119116. readonly matricesIndices: NodeMaterialConnectionPoint;
  119117. /**
  119118. * Gets the matrix weights input component
  119119. */
  119120. readonly matricesWeights: NodeMaterialConnectionPoint;
  119121. /**
  119122. * Gets the extra matrix indices input component
  119123. */
  119124. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  119125. /**
  119126. * Gets the extra matrix weights input component
  119127. */
  119128. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  119129. /**
  119130. * Gets the world input component
  119131. */
  119132. readonly world: NodeMaterialConnectionPoint;
  119133. /**
  119134. * Gets the output component
  119135. */
  119136. readonly output: NodeMaterialConnectionPoint;
  119137. autoConfigure(material: NodeMaterial): void;
  119138. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119139. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119140. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119141. protected _buildBlock(state: NodeMaterialBuildState): this;
  119142. }
  119143. }
  119144. declare module BABYLON {
  119145. /**
  119146. * Block used to add support for instances
  119147. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  119148. */
  119149. export class InstancesBlock extends NodeMaterialBlock {
  119150. /**
  119151. * Creates a new InstancesBlock
  119152. * @param name defines the block name
  119153. */
  119154. constructor(name: string);
  119155. /**
  119156. * Gets the current class name
  119157. * @returns the class name
  119158. */
  119159. getClassName(): string;
  119160. /**
  119161. * Gets the first world row input component
  119162. */
  119163. readonly world0: NodeMaterialConnectionPoint;
  119164. /**
  119165. * Gets the second world row input component
  119166. */
  119167. readonly world1: NodeMaterialConnectionPoint;
  119168. /**
  119169. * Gets the third world row input component
  119170. */
  119171. readonly world2: NodeMaterialConnectionPoint;
  119172. /**
  119173. * Gets the forth world row input component
  119174. */
  119175. readonly world3: NodeMaterialConnectionPoint;
  119176. /**
  119177. * Gets the world input component
  119178. */
  119179. readonly world: NodeMaterialConnectionPoint;
  119180. /**
  119181. * Gets the output component
  119182. */
  119183. readonly output: NodeMaterialConnectionPoint;
  119184. autoConfigure(material: NodeMaterial): void;
  119185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119186. protected _buildBlock(state: NodeMaterialBuildState): this;
  119187. }
  119188. }
  119189. declare module BABYLON {
  119190. /**
  119191. * Block used to add morph targets support to vertex shader
  119192. */
  119193. export class MorphTargetsBlock extends NodeMaterialBlock {
  119194. private _repeatableContentAnchor;
  119195. private _repeatebleContentGenerated;
  119196. /**
  119197. * Create a new MorphTargetsBlock
  119198. * @param name defines the block name
  119199. */
  119200. constructor(name: string);
  119201. /**
  119202. * Gets the current class name
  119203. * @returns the class name
  119204. */
  119205. getClassName(): string;
  119206. /**
  119207. * Gets the position input component
  119208. */
  119209. readonly position: NodeMaterialConnectionPoint;
  119210. /**
  119211. * Gets the normal input component
  119212. */
  119213. readonly normal: NodeMaterialConnectionPoint;
  119214. /**
  119215. * Gets the tangent input component
  119216. */
  119217. readonly tangent: NodeMaterialConnectionPoint;
  119218. /**
  119219. * Gets the tangent input component
  119220. */
  119221. readonly uv: NodeMaterialConnectionPoint;
  119222. /**
  119223. * Gets the position output component
  119224. */
  119225. readonly positionOutput: NodeMaterialConnectionPoint;
  119226. /**
  119227. * Gets the normal output component
  119228. */
  119229. readonly normalOutput: NodeMaterialConnectionPoint;
  119230. /**
  119231. * Gets the tangent output component
  119232. */
  119233. readonly tangentOutput: NodeMaterialConnectionPoint;
  119234. /**
  119235. * Gets the tangent output component
  119236. */
  119237. readonly uvOutput: NodeMaterialConnectionPoint;
  119238. initialize(state: NodeMaterialBuildState): void;
  119239. autoConfigure(material: NodeMaterial): void;
  119240. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119241. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119242. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119243. protected _buildBlock(state: NodeMaterialBuildState): this;
  119244. }
  119245. }
  119246. declare module BABYLON {
  119247. /**
  119248. * Block used to get data information from a light
  119249. */
  119250. export class LightInformationBlock extends NodeMaterialBlock {
  119251. private _lightDataUniformName;
  119252. private _lightColorUniformName;
  119253. /**
  119254. * Gets or sets the light associated with this block
  119255. */
  119256. light: Nullable<Light>;
  119257. /**
  119258. * Creates a new LightInformationBlock
  119259. * @param name defines the block name
  119260. */
  119261. constructor(name: string);
  119262. /**
  119263. * Gets the current class name
  119264. * @returns the class name
  119265. */
  119266. getClassName(): string;
  119267. /**
  119268. * Gets the world position input component
  119269. */
  119270. readonly worldPosition: NodeMaterialConnectionPoint;
  119271. /**
  119272. * Gets the direction output component
  119273. */
  119274. readonly direction: NodeMaterialConnectionPoint;
  119275. /**
  119276. * Gets the direction output component
  119277. */
  119278. readonly color: NodeMaterialConnectionPoint;
  119279. /**
  119280. * Gets the direction output component
  119281. */
  119282. readonly intensity: NodeMaterialConnectionPoint;
  119283. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119284. protected _buildBlock(state: NodeMaterialBuildState): this;
  119285. serialize(): any;
  119286. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119287. }
  119288. }
  119289. declare module BABYLON {
  119290. /**
  119291. * Block used to add an alpha test in the fragment shader
  119292. */
  119293. export class AlphaTestBlock extends NodeMaterialBlock {
  119294. /**
  119295. * Gets or sets the alpha value where alpha testing happens
  119296. */
  119297. alphaCutOff: number;
  119298. /**
  119299. * Create a new AlphaTestBlock
  119300. * @param name defines the block name
  119301. */
  119302. constructor(name: string);
  119303. /**
  119304. * Gets the current class name
  119305. * @returns the class name
  119306. */
  119307. getClassName(): string;
  119308. /**
  119309. * Gets the color input component
  119310. */
  119311. readonly color: NodeMaterialConnectionPoint;
  119312. /**
  119313. * Gets the alpha input component
  119314. */
  119315. readonly alpha: NodeMaterialConnectionPoint;
  119316. protected _buildBlock(state: NodeMaterialBuildState): this;
  119317. protected _dumpPropertiesCode(): string;
  119318. serialize(): any;
  119319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119320. }
  119321. }
  119322. declare module BABYLON {
  119323. /**
  119324. * Block used to add image processing support to fragment shader
  119325. */
  119326. export class ImageProcessingBlock extends NodeMaterialBlock {
  119327. /**
  119328. * Create a new ImageProcessingBlock
  119329. * @param name defines the block name
  119330. */
  119331. constructor(name: string);
  119332. /**
  119333. * Gets the current class name
  119334. * @returns the class name
  119335. */
  119336. getClassName(): string;
  119337. /**
  119338. * Gets the color input component
  119339. */
  119340. readonly color: NodeMaterialConnectionPoint;
  119341. /**
  119342. * Gets the output component
  119343. */
  119344. readonly output: NodeMaterialConnectionPoint;
  119345. /**
  119346. * Initialize the block and prepare the context for build
  119347. * @param state defines the state that will be used for the build
  119348. */
  119349. initialize(state: NodeMaterialBuildState): void;
  119350. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  119351. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119352. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119353. protected _buildBlock(state: NodeMaterialBuildState): this;
  119354. }
  119355. }
  119356. declare module BABYLON {
  119357. /**
  119358. * Block used to pertub normals based on a normal map
  119359. */
  119360. export class PerturbNormalBlock extends NodeMaterialBlock {
  119361. private _tangentSpaceParameterName;
  119362. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  119363. invertX: boolean;
  119364. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  119365. invertY: boolean;
  119366. /**
  119367. * Create a new PerturbNormalBlock
  119368. * @param name defines the block name
  119369. */
  119370. constructor(name: string);
  119371. /**
  119372. * Gets the current class name
  119373. * @returns the class name
  119374. */
  119375. getClassName(): string;
  119376. /**
  119377. * Gets the world position input component
  119378. */
  119379. readonly worldPosition: NodeMaterialConnectionPoint;
  119380. /**
  119381. * Gets the world normal input component
  119382. */
  119383. readonly worldNormal: NodeMaterialConnectionPoint;
  119384. /**
  119385. * Gets the uv input component
  119386. */
  119387. readonly uv: NodeMaterialConnectionPoint;
  119388. /**
  119389. * Gets the normal map color input component
  119390. */
  119391. readonly normalMapColor: NodeMaterialConnectionPoint;
  119392. /**
  119393. * Gets the strength input component
  119394. */
  119395. readonly strength: NodeMaterialConnectionPoint;
  119396. /**
  119397. * Gets the output component
  119398. */
  119399. readonly output: NodeMaterialConnectionPoint;
  119400. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119401. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119402. autoConfigure(material: NodeMaterial): void;
  119403. protected _buildBlock(state: NodeMaterialBuildState): this;
  119404. protected _dumpPropertiesCode(): string;
  119405. serialize(): any;
  119406. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119407. }
  119408. }
  119409. declare module BABYLON {
  119410. /**
  119411. * Block used to add support for scene fog
  119412. */
  119413. export class FogBlock extends NodeMaterialBlock {
  119414. private _fogDistanceName;
  119415. private _fogParameters;
  119416. /**
  119417. * Create a new FogBlock
  119418. * @param name defines the block name
  119419. */
  119420. constructor(name: string);
  119421. /**
  119422. * Gets the current class name
  119423. * @returns the class name
  119424. */
  119425. getClassName(): string;
  119426. /**
  119427. * Gets the world position input component
  119428. */
  119429. readonly worldPosition: NodeMaterialConnectionPoint;
  119430. /**
  119431. * Gets the view input component
  119432. */
  119433. readonly view: NodeMaterialConnectionPoint;
  119434. /**
  119435. * Gets the color input component
  119436. */
  119437. readonly input: NodeMaterialConnectionPoint;
  119438. /**
  119439. * Gets the fog color input component
  119440. */
  119441. readonly fogColor: NodeMaterialConnectionPoint;
  119442. /**
  119443. * Gets the output component
  119444. */
  119445. readonly output: NodeMaterialConnectionPoint;
  119446. autoConfigure(material: NodeMaterial): void;
  119447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119448. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119449. protected _buildBlock(state: NodeMaterialBuildState): this;
  119450. }
  119451. }
  119452. declare module BABYLON {
  119453. /**
  119454. * Block used to add light in the fragment shader
  119455. */
  119456. export class LightBlock extends NodeMaterialBlock {
  119457. private _lightId;
  119458. /**
  119459. * Gets or sets the light associated with this block
  119460. */
  119461. light: Nullable<Light>;
  119462. /**
  119463. * Create a new LightBlock
  119464. * @param name defines the block name
  119465. */
  119466. constructor(name: string);
  119467. /**
  119468. * Gets the current class name
  119469. * @returns the class name
  119470. */
  119471. getClassName(): string;
  119472. /**
  119473. * Gets the world position input component
  119474. */
  119475. readonly worldPosition: NodeMaterialConnectionPoint;
  119476. /**
  119477. * Gets the world normal input component
  119478. */
  119479. readonly worldNormal: NodeMaterialConnectionPoint;
  119480. /**
  119481. * Gets the camera (or eye) position component
  119482. */
  119483. readonly cameraPosition: NodeMaterialConnectionPoint;
  119484. /**
  119485. * Gets the diffuse output component
  119486. */
  119487. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119488. /**
  119489. * Gets the specular output component
  119490. */
  119491. readonly specularOutput: NodeMaterialConnectionPoint;
  119492. autoConfigure(material: NodeMaterial): void;
  119493. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119494. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119495. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119496. private _injectVertexCode;
  119497. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119498. serialize(): any;
  119499. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119500. }
  119501. }
  119502. declare module BABYLON {
  119503. /**
  119504. * Block used to multiply 2 values
  119505. */
  119506. export class MultiplyBlock extends NodeMaterialBlock {
  119507. /**
  119508. * Creates a new MultiplyBlock
  119509. * @param name defines the block name
  119510. */
  119511. constructor(name: string);
  119512. /**
  119513. * Gets the current class name
  119514. * @returns the class name
  119515. */
  119516. getClassName(): string;
  119517. /**
  119518. * Gets the left operand input component
  119519. */
  119520. readonly left: NodeMaterialConnectionPoint;
  119521. /**
  119522. * Gets the right operand input component
  119523. */
  119524. readonly right: NodeMaterialConnectionPoint;
  119525. /**
  119526. * Gets the output component
  119527. */
  119528. readonly output: NodeMaterialConnectionPoint;
  119529. protected _buildBlock(state: NodeMaterialBuildState): this;
  119530. }
  119531. }
  119532. declare module BABYLON {
  119533. /**
  119534. * Block used to add 2 vectors
  119535. */
  119536. export class AddBlock extends NodeMaterialBlock {
  119537. /**
  119538. * Creates a new AddBlock
  119539. * @param name defines the block name
  119540. */
  119541. constructor(name: string);
  119542. /**
  119543. * Gets the current class name
  119544. * @returns the class name
  119545. */
  119546. getClassName(): string;
  119547. /**
  119548. * Gets the left operand input component
  119549. */
  119550. readonly left: NodeMaterialConnectionPoint;
  119551. /**
  119552. * Gets the right operand input component
  119553. */
  119554. readonly right: NodeMaterialConnectionPoint;
  119555. /**
  119556. * Gets the output component
  119557. */
  119558. readonly output: NodeMaterialConnectionPoint;
  119559. protected _buildBlock(state: NodeMaterialBuildState): this;
  119560. }
  119561. }
  119562. declare module BABYLON {
  119563. /**
  119564. * Block used to scale a vector by a float
  119565. */
  119566. export class ScaleBlock extends NodeMaterialBlock {
  119567. /**
  119568. * Creates a new ScaleBlock
  119569. * @param name defines the block name
  119570. */
  119571. constructor(name: string);
  119572. /**
  119573. * Gets the current class name
  119574. * @returns the class name
  119575. */
  119576. getClassName(): string;
  119577. /**
  119578. * Gets the input component
  119579. */
  119580. readonly input: NodeMaterialConnectionPoint;
  119581. /**
  119582. * Gets the factor input component
  119583. */
  119584. readonly factor: NodeMaterialConnectionPoint;
  119585. /**
  119586. * Gets the output component
  119587. */
  119588. readonly output: NodeMaterialConnectionPoint;
  119589. protected _buildBlock(state: NodeMaterialBuildState): this;
  119590. }
  119591. }
  119592. declare module BABYLON {
  119593. /**
  119594. * Block used to clamp a float
  119595. */
  119596. export class ClampBlock extends NodeMaterialBlock {
  119597. /** Gets or sets the minimum range */
  119598. minimum: number;
  119599. /** Gets or sets the maximum range */
  119600. maximum: number;
  119601. /**
  119602. * Creates a new ClampBlock
  119603. * @param name defines the block name
  119604. */
  119605. constructor(name: string);
  119606. /**
  119607. * Gets the current class name
  119608. * @returns the class name
  119609. */
  119610. getClassName(): string;
  119611. /**
  119612. * Gets the value input component
  119613. */
  119614. readonly value: NodeMaterialConnectionPoint;
  119615. /**
  119616. * Gets the output component
  119617. */
  119618. readonly output: NodeMaterialConnectionPoint;
  119619. protected _buildBlock(state: NodeMaterialBuildState): this;
  119620. protected _dumpPropertiesCode(): string;
  119621. serialize(): any;
  119622. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119623. }
  119624. }
  119625. declare module BABYLON {
  119626. /**
  119627. * Block used to apply a cross product between 2 vectors
  119628. */
  119629. export class CrossBlock extends NodeMaterialBlock {
  119630. /**
  119631. * Creates a new CrossBlock
  119632. * @param name defines the block name
  119633. */
  119634. constructor(name: string);
  119635. /**
  119636. * Gets the current class name
  119637. * @returns the class name
  119638. */
  119639. getClassName(): string;
  119640. /**
  119641. * Gets the left operand input component
  119642. */
  119643. readonly left: NodeMaterialConnectionPoint;
  119644. /**
  119645. * Gets the right operand input component
  119646. */
  119647. readonly right: NodeMaterialConnectionPoint;
  119648. /**
  119649. * Gets the output component
  119650. */
  119651. readonly output: NodeMaterialConnectionPoint;
  119652. protected _buildBlock(state: NodeMaterialBuildState): this;
  119653. }
  119654. }
  119655. declare module BABYLON {
  119656. /**
  119657. * Block used to apply a dot product between 2 vectors
  119658. */
  119659. export class DotBlock extends NodeMaterialBlock {
  119660. /**
  119661. * Creates a new DotBlock
  119662. * @param name defines the block name
  119663. */
  119664. constructor(name: string);
  119665. /**
  119666. * Gets the current class name
  119667. * @returns the class name
  119668. */
  119669. getClassName(): string;
  119670. /**
  119671. * Gets the left operand input component
  119672. */
  119673. readonly left: NodeMaterialConnectionPoint;
  119674. /**
  119675. * Gets the right operand input component
  119676. */
  119677. readonly right: NodeMaterialConnectionPoint;
  119678. /**
  119679. * Gets the output component
  119680. */
  119681. readonly output: NodeMaterialConnectionPoint;
  119682. protected _buildBlock(state: NodeMaterialBuildState): this;
  119683. }
  119684. }
  119685. declare module BABYLON {
  119686. /**
  119687. * Block used to remap a float from a range to a new one
  119688. */
  119689. export class RemapBlock extends NodeMaterialBlock {
  119690. /**
  119691. * Gets or sets the source range
  119692. */
  119693. sourceRange: Vector2;
  119694. /**
  119695. * Gets or sets the target range
  119696. */
  119697. targetRange: Vector2;
  119698. /**
  119699. * Creates a new RemapBlock
  119700. * @param name defines the block name
  119701. */
  119702. constructor(name: string);
  119703. /**
  119704. * Gets the current class name
  119705. * @returns the class name
  119706. */
  119707. getClassName(): string;
  119708. /**
  119709. * Gets the input component
  119710. */
  119711. readonly input: NodeMaterialConnectionPoint;
  119712. /**
  119713. * Gets the source min input component
  119714. */
  119715. readonly sourceMin: NodeMaterialConnectionPoint;
  119716. /**
  119717. * Gets the source max input component
  119718. */
  119719. readonly sourceMax: NodeMaterialConnectionPoint;
  119720. /**
  119721. * Gets the target min input component
  119722. */
  119723. readonly targetMin: NodeMaterialConnectionPoint;
  119724. /**
  119725. * Gets the target max input component
  119726. */
  119727. readonly targetMax: NodeMaterialConnectionPoint;
  119728. /**
  119729. * Gets the output component
  119730. */
  119731. readonly output: NodeMaterialConnectionPoint;
  119732. protected _buildBlock(state: NodeMaterialBuildState): this;
  119733. protected _dumpPropertiesCode(): string;
  119734. serialize(): any;
  119735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119736. }
  119737. }
  119738. declare module BABYLON {
  119739. /**
  119740. * Block used to normalize a vector
  119741. */
  119742. export class NormalizeBlock extends NodeMaterialBlock {
  119743. /**
  119744. * Creates a new NormalizeBlock
  119745. * @param name defines the block name
  119746. */
  119747. constructor(name: string);
  119748. /**
  119749. * Gets the current class name
  119750. * @returns the class name
  119751. */
  119752. getClassName(): string;
  119753. /**
  119754. * Gets the input component
  119755. */
  119756. readonly input: NodeMaterialConnectionPoint;
  119757. /**
  119758. * Gets the output component
  119759. */
  119760. readonly output: NodeMaterialConnectionPoint;
  119761. protected _buildBlock(state: NodeMaterialBuildState): this;
  119762. }
  119763. }
  119764. declare module BABYLON {
  119765. /**
  119766. * Operations supported by the Trigonometry block
  119767. */
  119768. export enum TrigonometryBlockOperations {
  119769. /** Cos */
  119770. Cos = 0,
  119771. /** Sin */
  119772. Sin = 1,
  119773. /** Abs */
  119774. Abs = 2,
  119775. /** Exp */
  119776. Exp = 3,
  119777. /** Exp2 */
  119778. Exp2 = 4,
  119779. /** Round */
  119780. Round = 5,
  119781. /** Floor */
  119782. Floor = 6,
  119783. /** Ceiling */
  119784. Ceiling = 7,
  119785. /** Square root */
  119786. Sqrt = 8
  119787. }
  119788. /**
  119789. * Block used to apply trigonometry operation to floats
  119790. */
  119791. export class TrigonometryBlock extends NodeMaterialBlock {
  119792. /**
  119793. * Gets or sets the operation applied by the block
  119794. */
  119795. operation: TrigonometryBlockOperations;
  119796. /**
  119797. * Creates a new TrigonometryBlock
  119798. * @param name defines the block name
  119799. */
  119800. constructor(name: string);
  119801. /**
  119802. * Gets the current class name
  119803. * @returns the class name
  119804. */
  119805. getClassName(): string;
  119806. /**
  119807. * Gets the input component
  119808. */
  119809. readonly input: NodeMaterialConnectionPoint;
  119810. /**
  119811. * Gets the output component
  119812. */
  119813. readonly output: NodeMaterialConnectionPoint;
  119814. protected _buildBlock(state: NodeMaterialBuildState): this;
  119815. serialize(): any;
  119816. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119817. }
  119818. }
  119819. declare module BABYLON {
  119820. /**
  119821. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119822. */
  119823. export class ColorMergerBlock extends NodeMaterialBlock {
  119824. /**
  119825. * Create a new ColorMergerBlock
  119826. * @param name defines the block name
  119827. */
  119828. constructor(name: string);
  119829. /**
  119830. * Gets the current class name
  119831. * @returns the class name
  119832. */
  119833. getClassName(): string;
  119834. /**
  119835. * Gets the r component (input)
  119836. */
  119837. readonly r: NodeMaterialConnectionPoint;
  119838. /**
  119839. * Gets the g component (input)
  119840. */
  119841. readonly g: NodeMaterialConnectionPoint;
  119842. /**
  119843. * Gets the b component (input)
  119844. */
  119845. readonly b: NodeMaterialConnectionPoint;
  119846. /**
  119847. * Gets the a component (input)
  119848. */
  119849. readonly a: NodeMaterialConnectionPoint;
  119850. /**
  119851. * Gets the rgba component (output)
  119852. */
  119853. readonly rgba: NodeMaterialConnectionPoint;
  119854. /**
  119855. * Gets the rgb component (output)
  119856. */
  119857. readonly rgb: NodeMaterialConnectionPoint;
  119858. protected _buildBlock(state: NodeMaterialBuildState): this;
  119859. }
  119860. }
  119861. declare module BABYLON {
  119862. /**
  119863. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  119864. */
  119865. export class VectorMergerBlock extends NodeMaterialBlock {
  119866. /**
  119867. * Create a new VectorMergerBlock
  119868. * @param name defines the block name
  119869. */
  119870. constructor(name: string);
  119871. /**
  119872. * Gets the current class name
  119873. * @returns the class name
  119874. */
  119875. getClassName(): string;
  119876. /**
  119877. * Gets the x component (input)
  119878. */
  119879. readonly x: NodeMaterialConnectionPoint;
  119880. /**
  119881. * Gets the y component (input)
  119882. */
  119883. readonly y: NodeMaterialConnectionPoint;
  119884. /**
  119885. * Gets the z component (input)
  119886. */
  119887. readonly z: NodeMaterialConnectionPoint;
  119888. /**
  119889. * Gets the w component (input)
  119890. */
  119891. readonly w: NodeMaterialConnectionPoint;
  119892. /**
  119893. * Gets the xyzw component (output)
  119894. */
  119895. readonly xyzw: NodeMaterialConnectionPoint;
  119896. /**
  119897. * Gets the xyz component (output)
  119898. */
  119899. readonly xyz: NodeMaterialConnectionPoint;
  119900. /**
  119901. * Gets the xy component (output)
  119902. */
  119903. readonly xy: NodeMaterialConnectionPoint;
  119904. protected _buildBlock(state: NodeMaterialBuildState): this;
  119905. }
  119906. }
  119907. declare module BABYLON {
  119908. /**
  119909. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  119910. */
  119911. export class ColorSplitterBlock extends NodeMaterialBlock {
  119912. /**
  119913. * Create a new ColorSplitterBlock
  119914. * @param name defines the block name
  119915. */
  119916. constructor(name: string);
  119917. /**
  119918. * Gets the current class name
  119919. * @returns the class name
  119920. */
  119921. getClassName(): string;
  119922. /**
  119923. * Gets the rgba component (input)
  119924. */
  119925. readonly rgba: NodeMaterialConnectionPoint;
  119926. /**
  119927. * Gets the rgb component (input)
  119928. */
  119929. readonly rgbIn: NodeMaterialConnectionPoint;
  119930. /**
  119931. * Gets the rgb component (output)
  119932. */
  119933. readonly rgbOut: NodeMaterialConnectionPoint;
  119934. /**
  119935. * Gets the r component (output)
  119936. */
  119937. readonly r: NodeMaterialConnectionPoint;
  119938. /**
  119939. * Gets the g component (output)
  119940. */
  119941. readonly g: NodeMaterialConnectionPoint;
  119942. /**
  119943. * Gets the b component (output)
  119944. */
  119945. readonly b: NodeMaterialConnectionPoint;
  119946. /**
  119947. * Gets the a component (output)
  119948. */
  119949. readonly a: NodeMaterialConnectionPoint;
  119950. protected _inputRename(name: string): string;
  119951. protected _outputRename(name: string): string;
  119952. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119953. }
  119954. }
  119955. declare module BABYLON {
  119956. /**
  119957. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  119958. */
  119959. export class VectorSplitterBlock extends NodeMaterialBlock {
  119960. /**
  119961. * Create a new VectorSplitterBlock
  119962. * @param name defines the block name
  119963. */
  119964. constructor(name: string);
  119965. /**
  119966. * Gets the current class name
  119967. * @returns the class name
  119968. */
  119969. getClassName(): string;
  119970. /**
  119971. * Gets the xyzw component (input)
  119972. */
  119973. readonly xyzw: NodeMaterialConnectionPoint;
  119974. /**
  119975. * Gets the xyz component (input)
  119976. */
  119977. readonly xyzIn: NodeMaterialConnectionPoint;
  119978. /**
  119979. * Gets the xy component (input)
  119980. */
  119981. readonly xyIn: NodeMaterialConnectionPoint;
  119982. /**
  119983. * Gets the xyz component (output)
  119984. */
  119985. readonly xyzOut: NodeMaterialConnectionPoint;
  119986. /**
  119987. * Gets the xy component (output)
  119988. */
  119989. readonly xyOut: NodeMaterialConnectionPoint;
  119990. /**
  119991. * Gets the x component (output)
  119992. */
  119993. readonly x: NodeMaterialConnectionPoint;
  119994. /**
  119995. * Gets the y component (output)
  119996. */
  119997. readonly y: NodeMaterialConnectionPoint;
  119998. /**
  119999. * Gets the z component (output)
  120000. */
  120001. readonly z: NodeMaterialConnectionPoint;
  120002. /**
  120003. * Gets the w component (output)
  120004. */
  120005. readonly w: NodeMaterialConnectionPoint;
  120006. protected _inputRename(name: string): string;
  120007. protected _outputRename(name: string): string;
  120008. protected _buildBlock(state: NodeMaterialBuildState): this;
  120009. }
  120010. }
  120011. declare module BABYLON {
  120012. /**
  120013. * Block used to lerp 2 values
  120014. */
  120015. export class LerpBlock extends NodeMaterialBlock {
  120016. /**
  120017. * Creates a new LerpBlock
  120018. * @param name defines the block name
  120019. */
  120020. constructor(name: string);
  120021. /**
  120022. * Gets the current class name
  120023. * @returns the class name
  120024. */
  120025. getClassName(): string;
  120026. /**
  120027. * Gets the left operand input component
  120028. */
  120029. readonly left: NodeMaterialConnectionPoint;
  120030. /**
  120031. * Gets the right operand input component
  120032. */
  120033. readonly right: NodeMaterialConnectionPoint;
  120034. /**
  120035. * Gets the gradient operand input component
  120036. */
  120037. readonly gradient: NodeMaterialConnectionPoint;
  120038. /**
  120039. * Gets the output component
  120040. */
  120041. readonly output: NodeMaterialConnectionPoint;
  120042. protected _buildBlock(state: NodeMaterialBuildState): this;
  120043. }
  120044. }
  120045. declare module BABYLON {
  120046. /**
  120047. * Block used to divide 2 vectors
  120048. */
  120049. export class DivideBlock extends NodeMaterialBlock {
  120050. /**
  120051. * Creates a new DivideBlock
  120052. * @param name defines the block name
  120053. */
  120054. constructor(name: string);
  120055. /**
  120056. * Gets the current class name
  120057. * @returns the class name
  120058. */
  120059. getClassName(): string;
  120060. /**
  120061. * Gets the left operand input component
  120062. */
  120063. readonly left: NodeMaterialConnectionPoint;
  120064. /**
  120065. * Gets the right operand input component
  120066. */
  120067. readonly right: NodeMaterialConnectionPoint;
  120068. /**
  120069. * Gets the output component
  120070. */
  120071. readonly output: NodeMaterialConnectionPoint;
  120072. protected _buildBlock(state: NodeMaterialBuildState): this;
  120073. }
  120074. }
  120075. declare module BABYLON {
  120076. /**
  120077. * Block used to subtract 2 vectors
  120078. */
  120079. export class SubtractBlock extends NodeMaterialBlock {
  120080. /**
  120081. * Creates a new SubtractBlock
  120082. * @param name defines the block name
  120083. */
  120084. constructor(name: string);
  120085. /**
  120086. * Gets the current class name
  120087. * @returns the class name
  120088. */
  120089. getClassName(): string;
  120090. /**
  120091. * Gets the left operand input component
  120092. */
  120093. readonly left: NodeMaterialConnectionPoint;
  120094. /**
  120095. * Gets the right operand input component
  120096. */
  120097. readonly right: NodeMaterialConnectionPoint;
  120098. /**
  120099. * Gets the output component
  120100. */
  120101. readonly output: NodeMaterialConnectionPoint;
  120102. protected _buildBlock(state: NodeMaterialBuildState): this;
  120103. }
  120104. }
  120105. declare module BABYLON {
  120106. /**
  120107. * Block used to step a value
  120108. */
  120109. export class StepBlock extends NodeMaterialBlock {
  120110. /**
  120111. * Creates a new AddBlock
  120112. * @param name defines the block name
  120113. */
  120114. constructor(name: string);
  120115. /**
  120116. * Gets the current class name
  120117. * @returns the class name
  120118. */
  120119. getClassName(): string;
  120120. /**
  120121. * Gets the value operand input component
  120122. */
  120123. readonly value: NodeMaterialConnectionPoint;
  120124. /**
  120125. * Gets the edge operand input component
  120126. */
  120127. readonly edge: NodeMaterialConnectionPoint;
  120128. /**
  120129. * Gets the output component
  120130. */
  120131. readonly output: NodeMaterialConnectionPoint;
  120132. protected _buildBlock(state: NodeMaterialBuildState): this;
  120133. }
  120134. }
  120135. declare module BABYLON {
  120136. /**
  120137. * Block used to get the opposite (1 - x) of a value
  120138. */
  120139. export class OneMinusBlock extends NodeMaterialBlock {
  120140. /**
  120141. * Creates a new OneMinusBlock
  120142. * @param name defines the block name
  120143. */
  120144. constructor(name: string);
  120145. /**
  120146. * Gets the current class name
  120147. * @returns the class name
  120148. */
  120149. getClassName(): string;
  120150. /**
  120151. * Gets the input component
  120152. */
  120153. readonly input: NodeMaterialConnectionPoint;
  120154. /**
  120155. * Gets the output component
  120156. */
  120157. readonly output: NodeMaterialConnectionPoint;
  120158. protected _buildBlock(state: NodeMaterialBuildState): this;
  120159. }
  120160. }
  120161. declare module BABYLON {
  120162. /**
  120163. * Block used to get the view direction
  120164. */
  120165. export class ViewDirectionBlock extends NodeMaterialBlock {
  120166. /**
  120167. * Creates a new ViewDirectionBlock
  120168. * @param name defines the block name
  120169. */
  120170. constructor(name: string);
  120171. /**
  120172. * Gets the current class name
  120173. * @returns the class name
  120174. */
  120175. getClassName(): string;
  120176. /**
  120177. * Gets the world position component
  120178. */
  120179. readonly worldPosition: NodeMaterialConnectionPoint;
  120180. /**
  120181. * Gets the camera position component
  120182. */
  120183. readonly cameraPosition: NodeMaterialConnectionPoint;
  120184. /**
  120185. * Gets the output component
  120186. */
  120187. readonly output: NodeMaterialConnectionPoint;
  120188. autoConfigure(material: NodeMaterial): void;
  120189. protected _buildBlock(state: NodeMaterialBuildState): this;
  120190. }
  120191. }
  120192. declare module BABYLON {
  120193. /**
  120194. * Block used to compute fresnel value
  120195. */
  120196. export class FresnelBlock extends NodeMaterialBlock {
  120197. /**
  120198. * Create a new FresnelBlock
  120199. * @param name defines the block name
  120200. */
  120201. constructor(name: string);
  120202. /**
  120203. * Gets the current class name
  120204. * @returns the class name
  120205. */
  120206. getClassName(): string;
  120207. /**
  120208. * Gets the world normal input component
  120209. */
  120210. readonly worldNormal: NodeMaterialConnectionPoint;
  120211. /**
  120212. * Gets the view direction input component
  120213. */
  120214. readonly viewDirection: NodeMaterialConnectionPoint;
  120215. /**
  120216. * Gets the bias input component
  120217. */
  120218. readonly bias: NodeMaterialConnectionPoint;
  120219. /**
  120220. * Gets the camera (or eye) position component
  120221. */
  120222. readonly power: NodeMaterialConnectionPoint;
  120223. /**
  120224. * Gets the fresnel output component
  120225. */
  120226. readonly fresnel: NodeMaterialConnectionPoint;
  120227. autoConfigure(material: NodeMaterial): void;
  120228. protected _buildBlock(state: NodeMaterialBuildState): this;
  120229. }
  120230. }
  120231. declare module BABYLON {
  120232. /**
  120233. * Block used to get the max of 2 values
  120234. */
  120235. export class MaxBlock extends NodeMaterialBlock {
  120236. /**
  120237. * Creates a new MaxBlock
  120238. * @param name defines the block name
  120239. */
  120240. constructor(name: string);
  120241. /**
  120242. * Gets the current class name
  120243. * @returns the class name
  120244. */
  120245. getClassName(): string;
  120246. /**
  120247. * Gets the left operand input component
  120248. */
  120249. readonly left: NodeMaterialConnectionPoint;
  120250. /**
  120251. * Gets the right operand input component
  120252. */
  120253. readonly right: NodeMaterialConnectionPoint;
  120254. /**
  120255. * Gets the output component
  120256. */
  120257. readonly output: NodeMaterialConnectionPoint;
  120258. protected _buildBlock(state: NodeMaterialBuildState): this;
  120259. }
  120260. }
  120261. declare module BABYLON {
  120262. /**
  120263. * Block used to get the min of 2 values
  120264. */
  120265. export class MinBlock extends NodeMaterialBlock {
  120266. /**
  120267. * Creates a new MinBlock
  120268. * @param name defines the block name
  120269. */
  120270. constructor(name: string);
  120271. /**
  120272. * Gets the current class name
  120273. * @returns the class name
  120274. */
  120275. getClassName(): string;
  120276. /**
  120277. * Gets the left operand input component
  120278. */
  120279. readonly left: NodeMaterialConnectionPoint;
  120280. /**
  120281. * Gets the right operand input component
  120282. */
  120283. readonly right: NodeMaterialConnectionPoint;
  120284. /**
  120285. * Gets the output component
  120286. */
  120287. readonly output: NodeMaterialConnectionPoint;
  120288. protected _buildBlock(state: NodeMaterialBuildState): this;
  120289. }
  120290. }
  120291. declare module BABYLON {
  120292. /**
  120293. * Block used to get the distance between 2 values
  120294. */
  120295. export class DistanceBlock extends NodeMaterialBlock {
  120296. /**
  120297. * Creates a new DistanceBlock
  120298. * @param name defines the block name
  120299. */
  120300. constructor(name: string);
  120301. /**
  120302. * Gets the current class name
  120303. * @returns the class name
  120304. */
  120305. getClassName(): string;
  120306. /**
  120307. * Gets the left operand input component
  120308. */
  120309. readonly left: NodeMaterialConnectionPoint;
  120310. /**
  120311. * Gets the right operand input component
  120312. */
  120313. readonly right: NodeMaterialConnectionPoint;
  120314. /**
  120315. * Gets the output component
  120316. */
  120317. readonly output: NodeMaterialConnectionPoint;
  120318. protected _buildBlock(state: NodeMaterialBuildState): this;
  120319. }
  120320. }
  120321. declare module BABYLON {
  120322. /**
  120323. * Block used to get the length of a vector
  120324. */
  120325. export class LengthBlock extends NodeMaterialBlock {
  120326. /**
  120327. * Creates a new LengthBlock
  120328. * @param name defines the block name
  120329. */
  120330. constructor(name: string);
  120331. /**
  120332. * Gets the current class name
  120333. * @returns the class name
  120334. */
  120335. getClassName(): string;
  120336. /**
  120337. * Gets the value input component
  120338. */
  120339. readonly value: NodeMaterialConnectionPoint;
  120340. /**
  120341. * Gets the output component
  120342. */
  120343. readonly output: NodeMaterialConnectionPoint;
  120344. protected _buildBlock(state: NodeMaterialBuildState): this;
  120345. }
  120346. }
  120347. declare module BABYLON {
  120348. /**
  120349. * Block used to get negative version of a value (i.e. x * -1)
  120350. */
  120351. export class NegateBlock extends NodeMaterialBlock {
  120352. /**
  120353. * Creates a new NegateBlock
  120354. * @param name defines the block name
  120355. */
  120356. constructor(name: string);
  120357. /**
  120358. * Gets the current class name
  120359. * @returns the class name
  120360. */
  120361. getClassName(): string;
  120362. /**
  120363. * Gets the value input component
  120364. */
  120365. readonly value: NodeMaterialConnectionPoint;
  120366. /**
  120367. * Gets the output component
  120368. */
  120369. readonly output: NodeMaterialConnectionPoint;
  120370. protected _buildBlock(state: NodeMaterialBuildState): this;
  120371. }
  120372. }
  120373. declare module BABYLON {
  120374. /**
  120375. * Block used to get the value of the first parameter raised to the power of the second
  120376. */
  120377. export class PowBlock extends NodeMaterialBlock {
  120378. /**
  120379. * Creates a new PowBlock
  120380. * @param name defines the block name
  120381. */
  120382. constructor(name: string);
  120383. /**
  120384. * Gets the current class name
  120385. * @returns the class name
  120386. */
  120387. getClassName(): string;
  120388. /**
  120389. * Gets the value operand input component
  120390. */
  120391. readonly value: NodeMaterialConnectionPoint;
  120392. /**
  120393. * Gets the power operand input component
  120394. */
  120395. readonly power: NodeMaterialConnectionPoint;
  120396. /**
  120397. * Gets the output component
  120398. */
  120399. readonly output: NodeMaterialConnectionPoint;
  120400. protected _buildBlock(state: NodeMaterialBuildState): this;
  120401. }
  120402. }
  120403. declare module BABYLON {
  120404. /**
  120405. * Effect Render Options
  120406. */
  120407. export interface IEffectRendererOptions {
  120408. /**
  120409. * Defines the vertices positions.
  120410. */
  120411. positions?: number[];
  120412. /**
  120413. * Defines the indices.
  120414. */
  120415. indices?: number[];
  120416. }
  120417. /**
  120418. * Helper class to render one or more effects
  120419. */
  120420. export class EffectRenderer {
  120421. private engine;
  120422. private static _DefaultOptions;
  120423. private _vertexBuffers;
  120424. private _indexBuffer;
  120425. private _ringBufferIndex;
  120426. private _ringScreenBuffer;
  120427. private _fullscreenViewport;
  120428. private _getNextFrameBuffer;
  120429. /**
  120430. * Creates an effect renderer
  120431. * @param engine the engine to use for rendering
  120432. * @param options defines the options of the effect renderer
  120433. */
  120434. constructor(engine: Engine, options?: IEffectRendererOptions);
  120435. /**
  120436. * Sets the current viewport in normalized coordinates 0-1
  120437. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  120438. */
  120439. setViewport(viewport?: Viewport): void;
  120440. /**
  120441. * Binds the embedded attributes buffer to the effect.
  120442. * @param effect Defines the effect to bind the attributes for
  120443. */
  120444. bindBuffers(effect: Effect): void;
  120445. /**
  120446. * Sets the current effect wrapper to use during draw.
  120447. * The effect needs to be ready before calling this api.
  120448. * This also sets the default full screen position attribute.
  120449. * @param effectWrapper Defines the effect to draw with
  120450. */
  120451. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  120452. /**
  120453. * Draws a full screen quad.
  120454. */
  120455. draw(): void;
  120456. /**
  120457. * renders one or more effects to a specified texture
  120458. * @param effectWrappers list of effects to renderer
  120459. * @param outputTexture texture to draw to, if null it will render to the screen
  120460. */
  120461. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  120462. /**
  120463. * Disposes of the effect renderer
  120464. */
  120465. dispose(): void;
  120466. }
  120467. /**
  120468. * Options to create an EffectWrapper
  120469. */
  120470. interface EffectWrapperCreationOptions {
  120471. /**
  120472. * Engine to use to create the effect
  120473. */
  120474. engine: Engine;
  120475. /**
  120476. * Fragment shader for the effect
  120477. */
  120478. fragmentShader: string;
  120479. /**
  120480. * Vertex shader for the effect
  120481. */
  120482. vertexShader?: string;
  120483. /**
  120484. * Attributes to use in the shader
  120485. */
  120486. attributeNames?: Array<string>;
  120487. /**
  120488. * Uniforms to use in the shader
  120489. */
  120490. uniformNames?: Array<string>;
  120491. /**
  120492. * Texture sampler names to use in the shader
  120493. */
  120494. samplerNames?: Array<string>;
  120495. /**
  120496. * The friendly name of the effect displayed in Spector.
  120497. */
  120498. name?: string;
  120499. }
  120500. /**
  120501. * Wraps an effect to be used for rendering
  120502. */
  120503. export class EffectWrapper {
  120504. /**
  120505. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  120506. */
  120507. onApplyObservable: Observable<{}>;
  120508. /**
  120509. * The underlying effect
  120510. */
  120511. effect: Effect;
  120512. /**
  120513. * Creates an effect to be renderer
  120514. * @param creationOptions options to create the effect
  120515. */
  120516. constructor(creationOptions: EffectWrapperCreationOptions);
  120517. /**
  120518. * Disposes of the effect wrapper
  120519. */
  120520. dispose(): void;
  120521. }
  120522. }
  120523. declare module BABYLON {
  120524. /**
  120525. * Helper class to push actions to a pool of workers.
  120526. */
  120527. export class WorkerPool implements IDisposable {
  120528. private _workerInfos;
  120529. private _pendingActions;
  120530. /**
  120531. * Constructor
  120532. * @param workers Array of workers to use for actions
  120533. */
  120534. constructor(workers: Array<Worker>);
  120535. /**
  120536. * Terminates all workers and clears any pending actions.
  120537. */
  120538. dispose(): void;
  120539. /**
  120540. * Pushes an action to the worker pool. If all the workers are active, the action will be
  120541. * pended until a worker has completed its action.
  120542. * @param action The action to perform. Call onComplete when the action is complete.
  120543. */
  120544. push(action: (worker: Worker, onComplete: () => void) => void): void;
  120545. private _execute;
  120546. }
  120547. }
  120548. declare module BABYLON {
  120549. /**
  120550. * Configuration for Draco compression
  120551. */
  120552. export interface IDracoCompressionConfiguration {
  120553. /**
  120554. * Configuration for the decoder.
  120555. */
  120556. decoder: {
  120557. /**
  120558. * The url to the WebAssembly module.
  120559. */
  120560. wasmUrl?: string;
  120561. /**
  120562. * The url to the WebAssembly binary.
  120563. */
  120564. wasmBinaryUrl?: string;
  120565. /**
  120566. * The url to the fallback JavaScript module.
  120567. */
  120568. fallbackUrl?: string;
  120569. };
  120570. }
  120571. /**
  120572. * Draco compression (https://google.github.io/draco/)
  120573. *
  120574. * This class wraps the Draco module.
  120575. *
  120576. * **Encoder**
  120577. *
  120578. * The encoder is not currently implemented.
  120579. *
  120580. * **Decoder**
  120581. *
  120582. * 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.
  120583. *
  120584. * To update the configuration, use the following code:
  120585. * ```javascript
  120586. * DracoCompression.Configuration = {
  120587. * decoder: {
  120588. * wasmUrl: "<url to the WebAssembly library>",
  120589. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120590. * fallbackUrl: "<url to the fallback JavaScript library>",
  120591. * }
  120592. * };
  120593. * ```
  120594. *
  120595. * 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.
  120596. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120597. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120598. *
  120599. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120600. * ```javascript
  120601. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120602. * ```
  120603. *
  120604. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120605. */
  120606. export class DracoCompression implements IDisposable {
  120607. private _workerPoolPromise?;
  120608. private _decoderModulePromise?;
  120609. /**
  120610. * The configuration. Defaults to the following urls:
  120611. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120612. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120613. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120614. */
  120615. static Configuration: IDracoCompressionConfiguration;
  120616. /**
  120617. * Returns true if the decoder configuration is available.
  120618. */
  120619. static readonly DecoderAvailable: boolean;
  120620. /**
  120621. * Default number of workers to create when creating the draco compression object.
  120622. */
  120623. static DefaultNumWorkers: number;
  120624. private static GetDefaultNumWorkers;
  120625. private static _Default;
  120626. /**
  120627. * Default instance for the draco compression object.
  120628. */
  120629. static readonly Default: DracoCompression;
  120630. /**
  120631. * Constructor
  120632. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120633. */
  120634. constructor(numWorkers?: number);
  120635. /**
  120636. * Stop all async operations and release resources.
  120637. */
  120638. dispose(): void;
  120639. /**
  120640. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120641. * @returns a promise that resolves when ready
  120642. */
  120643. whenReadyAsync(): Promise<void>;
  120644. /**
  120645. * Decode Draco compressed mesh data to vertex data.
  120646. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120647. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120648. * @returns A promise that resolves with the decoded vertex data
  120649. */
  120650. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120651. [kind: string]: number;
  120652. }): Promise<VertexData>;
  120653. }
  120654. }
  120655. declare module BABYLON {
  120656. /**
  120657. * Class for building Constructive Solid Geometry
  120658. */
  120659. export class CSG {
  120660. private polygons;
  120661. /**
  120662. * The world matrix
  120663. */
  120664. matrix: Matrix;
  120665. /**
  120666. * Stores the position
  120667. */
  120668. position: Vector3;
  120669. /**
  120670. * Stores the rotation
  120671. */
  120672. rotation: Vector3;
  120673. /**
  120674. * Stores the rotation quaternion
  120675. */
  120676. rotationQuaternion: Nullable<Quaternion>;
  120677. /**
  120678. * Stores the scaling vector
  120679. */
  120680. scaling: Vector3;
  120681. /**
  120682. * Convert the Mesh to CSG
  120683. * @param mesh The Mesh to convert to CSG
  120684. * @returns A new CSG from the Mesh
  120685. */
  120686. static FromMesh(mesh: Mesh): CSG;
  120687. /**
  120688. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120689. * @param polygons Polygons used to construct a CSG solid
  120690. */
  120691. private static FromPolygons;
  120692. /**
  120693. * Clones, or makes a deep copy, of the CSG
  120694. * @returns A new CSG
  120695. */
  120696. clone(): CSG;
  120697. /**
  120698. * Unions this CSG with another CSG
  120699. * @param csg The CSG to union against this CSG
  120700. * @returns The unioned CSG
  120701. */
  120702. union(csg: CSG): CSG;
  120703. /**
  120704. * Unions this CSG with another CSG in place
  120705. * @param csg The CSG to union against this CSG
  120706. */
  120707. unionInPlace(csg: CSG): void;
  120708. /**
  120709. * Subtracts this CSG with another CSG
  120710. * @param csg The CSG to subtract against this CSG
  120711. * @returns A new CSG
  120712. */
  120713. subtract(csg: CSG): CSG;
  120714. /**
  120715. * Subtracts this CSG with another CSG in place
  120716. * @param csg The CSG to subtact against this CSG
  120717. */
  120718. subtractInPlace(csg: CSG): void;
  120719. /**
  120720. * Intersect this CSG with another CSG
  120721. * @param csg The CSG to intersect against this CSG
  120722. * @returns A new CSG
  120723. */
  120724. intersect(csg: CSG): CSG;
  120725. /**
  120726. * Intersects this CSG with another CSG in place
  120727. * @param csg The CSG to intersect against this CSG
  120728. */
  120729. intersectInPlace(csg: CSG): void;
  120730. /**
  120731. * Return a new CSG solid with solid and empty space switched. This solid is
  120732. * not modified.
  120733. * @returns A new CSG solid with solid and empty space switched
  120734. */
  120735. inverse(): CSG;
  120736. /**
  120737. * Inverses the CSG in place
  120738. */
  120739. inverseInPlace(): void;
  120740. /**
  120741. * This is used to keep meshes transformations so they can be restored
  120742. * when we build back a Babylon Mesh
  120743. * NB : All CSG operations are performed in world coordinates
  120744. * @param csg The CSG to copy the transform attributes from
  120745. * @returns This CSG
  120746. */
  120747. copyTransformAttributes(csg: CSG): CSG;
  120748. /**
  120749. * Build Raw mesh from CSG
  120750. * Coordinates here are in world space
  120751. * @param name The name of the mesh geometry
  120752. * @param scene The Scene
  120753. * @param keepSubMeshes Specifies if the submeshes should be kept
  120754. * @returns A new Mesh
  120755. */
  120756. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120757. /**
  120758. * Build Mesh from CSG taking material and transforms into account
  120759. * @param name The name of the Mesh
  120760. * @param material The material of the Mesh
  120761. * @param scene The Scene
  120762. * @param keepSubMeshes Specifies if submeshes should be kept
  120763. * @returns The new Mesh
  120764. */
  120765. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120766. }
  120767. }
  120768. declare module BABYLON {
  120769. /**
  120770. * Class used to create a trail following a mesh
  120771. */
  120772. export class TrailMesh extends Mesh {
  120773. private _generator;
  120774. private _autoStart;
  120775. private _running;
  120776. private _diameter;
  120777. private _length;
  120778. private _sectionPolygonPointsCount;
  120779. private _sectionVectors;
  120780. private _sectionNormalVectors;
  120781. private _beforeRenderObserver;
  120782. /**
  120783. * @constructor
  120784. * @param name The value used by scene.getMeshByName() to do a lookup.
  120785. * @param generator The mesh to generate a trail.
  120786. * @param scene The scene to add this mesh to.
  120787. * @param diameter Diameter of trailing mesh. Default is 1.
  120788. * @param length Length of trailing mesh. Default is 60.
  120789. * @param autoStart Automatically start trailing mesh. Default true.
  120790. */
  120791. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120792. /**
  120793. * "TrailMesh"
  120794. * @returns "TrailMesh"
  120795. */
  120796. getClassName(): string;
  120797. private _createMesh;
  120798. /**
  120799. * Start trailing mesh.
  120800. */
  120801. start(): void;
  120802. /**
  120803. * Stop trailing mesh.
  120804. */
  120805. stop(): void;
  120806. /**
  120807. * Update trailing mesh geometry.
  120808. */
  120809. update(): void;
  120810. /**
  120811. * Returns a new TrailMesh object.
  120812. * @param name is a string, the name given to the new mesh
  120813. * @param newGenerator use new generator object for cloned trail mesh
  120814. * @returns a new mesh
  120815. */
  120816. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  120817. /**
  120818. * Serializes this trail mesh
  120819. * @param serializationObject object to write serialization to
  120820. */
  120821. serialize(serializationObject: any): void;
  120822. /**
  120823. * Parses a serialized trail mesh
  120824. * @param parsedMesh the serialized mesh
  120825. * @param scene the scene to create the trail mesh in
  120826. * @returns the created trail mesh
  120827. */
  120828. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  120829. }
  120830. }
  120831. declare module BABYLON {
  120832. /**
  120833. * Class containing static functions to help procedurally build meshes
  120834. */
  120835. export class TiledBoxBuilder {
  120836. /**
  120837. * Creates a box mesh
  120838. * 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)
  120839. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120843. * @param name defines the name of the mesh
  120844. * @param options defines the options used to create the mesh
  120845. * @param scene defines the hosting scene
  120846. * @returns the box mesh
  120847. */
  120848. static CreateTiledBox(name: string, options: {
  120849. pattern?: number;
  120850. width?: number;
  120851. height?: number;
  120852. depth?: number;
  120853. tileSize?: number;
  120854. tileWidth?: number;
  120855. tileHeight?: number;
  120856. alignHorizontal?: number;
  120857. alignVertical?: number;
  120858. faceUV?: Vector4[];
  120859. faceColors?: Color4[];
  120860. sideOrientation?: number;
  120861. updatable?: boolean;
  120862. }, scene?: Nullable<Scene>): Mesh;
  120863. }
  120864. }
  120865. declare module BABYLON {
  120866. /**
  120867. * Class containing static functions to help procedurally build meshes
  120868. */
  120869. export class TorusKnotBuilder {
  120870. /**
  120871. * Creates a torus knot mesh
  120872. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120873. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120874. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120875. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120877. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120879. * @param name defines the name of the mesh
  120880. * @param options defines the options used to create the mesh
  120881. * @param scene defines the hosting scene
  120882. * @returns the torus knot mesh
  120883. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120884. */
  120885. static CreateTorusKnot(name: string, options: {
  120886. radius?: number;
  120887. tube?: number;
  120888. radialSegments?: number;
  120889. tubularSegments?: number;
  120890. p?: number;
  120891. q?: number;
  120892. updatable?: boolean;
  120893. sideOrientation?: number;
  120894. frontUVs?: Vector4;
  120895. backUVs?: Vector4;
  120896. }, scene: any): Mesh;
  120897. }
  120898. }
  120899. declare module BABYLON {
  120900. /**
  120901. * Polygon
  120902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  120903. */
  120904. export class Polygon {
  120905. /**
  120906. * Creates a rectangle
  120907. * @param xmin bottom X coord
  120908. * @param ymin bottom Y coord
  120909. * @param xmax top X coord
  120910. * @param ymax top Y coord
  120911. * @returns points that make the resulting rectation
  120912. */
  120913. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  120914. /**
  120915. * Creates a circle
  120916. * @param radius radius of circle
  120917. * @param cx scale in x
  120918. * @param cy scale in y
  120919. * @param numberOfSides number of sides that make up the circle
  120920. * @returns points that make the resulting circle
  120921. */
  120922. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  120923. /**
  120924. * Creates a polygon from input string
  120925. * @param input Input polygon data
  120926. * @returns the parsed points
  120927. */
  120928. static Parse(input: string): Vector2[];
  120929. /**
  120930. * Starts building a polygon from x and y coordinates
  120931. * @param x x coordinate
  120932. * @param y y coordinate
  120933. * @returns the started path2
  120934. */
  120935. static StartingAt(x: number, y: number): Path2;
  120936. }
  120937. /**
  120938. * Builds a polygon
  120939. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  120940. */
  120941. export class PolygonMeshBuilder {
  120942. private _points;
  120943. private _outlinepoints;
  120944. private _holes;
  120945. private _name;
  120946. private _scene;
  120947. private _epoints;
  120948. private _eholes;
  120949. private _addToepoint;
  120950. /**
  120951. * Babylon reference to the earcut plugin.
  120952. */
  120953. bjsEarcut: any;
  120954. /**
  120955. * Creates a PolygonMeshBuilder
  120956. * @param name name of the builder
  120957. * @param contours Path of the polygon
  120958. * @param scene scene to add to when creating the mesh
  120959. * @param earcutInjection can be used to inject your own earcut reference
  120960. */
  120961. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  120962. /**
  120963. * Adds a whole within the polygon
  120964. * @param hole Array of points defining the hole
  120965. * @returns this
  120966. */
  120967. addHole(hole: Vector2[]): PolygonMeshBuilder;
  120968. /**
  120969. * Creates the polygon
  120970. * @param updatable If the mesh should be updatable
  120971. * @param depth The depth of the mesh created
  120972. * @returns the created mesh
  120973. */
  120974. build(updatable?: boolean, depth?: number): Mesh;
  120975. /**
  120976. * Creates the polygon
  120977. * @param depth The depth of the mesh created
  120978. * @returns the created VertexData
  120979. */
  120980. buildVertexData(depth?: number): VertexData;
  120981. /**
  120982. * Adds a side to the polygon
  120983. * @param positions points that make the polygon
  120984. * @param normals normals of the polygon
  120985. * @param uvs uvs of the polygon
  120986. * @param indices indices of the polygon
  120987. * @param bounds bounds of the polygon
  120988. * @param points points of the polygon
  120989. * @param depth depth of the polygon
  120990. * @param flip flip of the polygon
  120991. */
  120992. private addSide;
  120993. }
  120994. }
  120995. declare module BABYLON {
  120996. /**
  120997. * Class containing static functions to help procedurally build meshes
  120998. */
  120999. export class PolygonBuilder {
  121000. /**
  121001. * Creates a polygon mesh
  121002. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121003. * * 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
  121004. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121007. * * Remember you can only change the shape positions, not their number when updating a polygon
  121008. * @param name defines the name of the mesh
  121009. * @param options defines the options used to create the mesh
  121010. * @param scene defines the hosting scene
  121011. * @param earcutInjection can be used to inject your own earcut reference
  121012. * @returns the polygon mesh
  121013. */
  121014. static CreatePolygon(name: string, options: {
  121015. shape: Vector3[];
  121016. holes?: Vector3[][];
  121017. depth?: number;
  121018. faceUV?: Vector4[];
  121019. faceColors?: Color4[];
  121020. updatable?: boolean;
  121021. sideOrientation?: number;
  121022. frontUVs?: Vector4;
  121023. backUVs?: Vector4;
  121024. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121025. /**
  121026. * Creates an extruded polygon mesh, with depth in the Y direction.
  121027. * * 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)
  121028. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121029. * @param name defines the name of the mesh
  121030. * @param options defines the options used to create the mesh
  121031. * @param scene defines the hosting scene
  121032. * @param earcutInjection can be used to inject your own earcut reference
  121033. * @returns the polygon mesh
  121034. */
  121035. static ExtrudePolygon(name: string, options: {
  121036. shape: Vector3[];
  121037. holes?: Vector3[][];
  121038. depth?: number;
  121039. faceUV?: Vector4[];
  121040. faceColors?: Color4[];
  121041. updatable?: boolean;
  121042. sideOrientation?: number;
  121043. frontUVs?: Vector4;
  121044. backUVs?: Vector4;
  121045. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121046. }
  121047. }
  121048. declare module BABYLON {
  121049. /**
  121050. * Class containing static functions to help procedurally build meshes
  121051. */
  121052. export class LatheBuilder {
  121053. /**
  121054. * Creates lathe mesh.
  121055. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121056. * * 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
  121057. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121058. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121059. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121060. * * 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
  121061. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121062. * * 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
  121063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121065. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121067. * @param name defines the name of the mesh
  121068. * @param options defines the options used to create the mesh
  121069. * @param scene defines the hosting scene
  121070. * @returns the lathe mesh
  121071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121072. */
  121073. static CreateLathe(name: string, options: {
  121074. shape: Vector3[];
  121075. radius?: number;
  121076. tessellation?: number;
  121077. clip?: number;
  121078. arc?: number;
  121079. closed?: boolean;
  121080. updatable?: boolean;
  121081. sideOrientation?: number;
  121082. frontUVs?: Vector4;
  121083. backUVs?: Vector4;
  121084. cap?: number;
  121085. invertUV?: boolean;
  121086. }, scene?: Nullable<Scene>): Mesh;
  121087. }
  121088. }
  121089. declare module BABYLON {
  121090. /**
  121091. * Class containing static functions to help procedurally build meshes
  121092. */
  121093. export class TiledPlaneBuilder {
  121094. /**
  121095. * Creates a tiled plane mesh
  121096. * * The parameter `pattern` will, depending on value, do nothing or
  121097. * * * flip (reflect about central vertical) alternate tiles across and up
  121098. * * * flip every tile on alternate rows
  121099. * * * rotate (180 degs) alternate tiles across and up
  121100. * * * rotate every tile on alternate rows
  121101. * * * flip and rotate alternate tiles across and up
  121102. * * * flip and rotate every tile on alternate rows
  121103. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  121104. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  121105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121106. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121107. * * 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)
  121108. * * 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)
  121109. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121110. * @param name defines the name of the mesh
  121111. * @param options defines the options used to create the mesh
  121112. * @param scene defines the hosting scene
  121113. * @returns the box mesh
  121114. */
  121115. static CreateTiledPlane(name: string, options: {
  121116. pattern?: number;
  121117. tileSize?: number;
  121118. tileWidth?: number;
  121119. tileHeight?: number;
  121120. size?: number;
  121121. width?: number;
  121122. height?: number;
  121123. alignHorizontal?: number;
  121124. alignVertical?: number;
  121125. sideOrientation?: number;
  121126. frontUVs?: Vector4;
  121127. backUVs?: Vector4;
  121128. updatable?: boolean;
  121129. }, scene?: Nullable<Scene>): Mesh;
  121130. }
  121131. }
  121132. declare module BABYLON {
  121133. /**
  121134. * Class containing static functions to help procedurally build meshes
  121135. */
  121136. export class TubeBuilder {
  121137. /**
  121138. * Creates a tube mesh.
  121139. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121140. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121141. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121142. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121143. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121144. * * 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)
  121145. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121146. * * 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
  121147. * * 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
  121148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121152. * @param name defines the name of the mesh
  121153. * @param options defines the options used to create the mesh
  121154. * @param scene defines the hosting scene
  121155. * @returns the tube mesh
  121156. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121157. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121158. */
  121159. static CreateTube(name: string, options: {
  121160. path: Vector3[];
  121161. radius?: number;
  121162. tessellation?: number;
  121163. radiusFunction?: {
  121164. (i: number, distance: number): number;
  121165. };
  121166. cap?: number;
  121167. arc?: number;
  121168. updatable?: boolean;
  121169. sideOrientation?: number;
  121170. frontUVs?: Vector4;
  121171. backUVs?: Vector4;
  121172. instance?: Mesh;
  121173. invertUV?: boolean;
  121174. }, scene?: Nullable<Scene>): Mesh;
  121175. }
  121176. }
  121177. declare module BABYLON {
  121178. /**
  121179. * Class containing static functions to help procedurally build meshes
  121180. */
  121181. export class IcoSphereBuilder {
  121182. /**
  121183. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121184. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121185. * * 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`)
  121186. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121187. * * 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
  121188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121191. * @param name defines the name of the mesh
  121192. * @param options defines the options used to create the mesh
  121193. * @param scene defines the hosting scene
  121194. * @returns the icosahedron mesh
  121195. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121196. */
  121197. static CreateIcoSphere(name: string, options: {
  121198. radius?: number;
  121199. radiusX?: number;
  121200. radiusY?: number;
  121201. radiusZ?: number;
  121202. flat?: boolean;
  121203. subdivisions?: number;
  121204. sideOrientation?: number;
  121205. frontUVs?: Vector4;
  121206. backUVs?: Vector4;
  121207. updatable?: boolean;
  121208. }, scene?: Nullable<Scene>): Mesh;
  121209. }
  121210. }
  121211. declare module BABYLON {
  121212. /**
  121213. * Class containing static functions to help procedurally build meshes
  121214. */
  121215. export class DecalBuilder {
  121216. /**
  121217. * Creates a decal mesh.
  121218. * 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
  121219. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121220. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121221. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121222. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121223. * @param name defines the name of the mesh
  121224. * @param sourceMesh defines the mesh where the decal must be applied
  121225. * @param options defines the options used to create the mesh
  121226. * @param scene defines the hosting scene
  121227. * @returns the decal mesh
  121228. * @see https://doc.babylonjs.com/how_to/decals
  121229. */
  121230. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121231. position?: Vector3;
  121232. normal?: Vector3;
  121233. size?: Vector3;
  121234. angle?: number;
  121235. }): Mesh;
  121236. }
  121237. }
  121238. declare module BABYLON {
  121239. /**
  121240. * Class containing static functions to help procedurally build meshes
  121241. */
  121242. export class MeshBuilder {
  121243. /**
  121244. * Creates a box mesh
  121245. * * The parameter `size` sets the size (float) of each box side (default 1)
  121246. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  121247. * * 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)
  121248. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121252. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121253. * @param name defines the name of the mesh
  121254. * @param options defines the options used to create the mesh
  121255. * @param scene defines the hosting scene
  121256. * @returns the box mesh
  121257. */
  121258. static CreateBox(name: string, options: {
  121259. size?: number;
  121260. width?: number;
  121261. height?: number;
  121262. depth?: number;
  121263. faceUV?: Vector4[];
  121264. faceColors?: Color4[];
  121265. sideOrientation?: number;
  121266. frontUVs?: Vector4;
  121267. backUVs?: Vector4;
  121268. updatable?: boolean;
  121269. }, scene?: Nullable<Scene>): Mesh;
  121270. /**
  121271. * Creates a tiled box mesh
  121272. * * faceTiles sets the pattern, tile size and number of tiles for a face
  121273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121274. * @param name defines the name of the mesh
  121275. * @param options defines the options used to create the mesh
  121276. * @param scene defines the hosting scene
  121277. * @returns the tiled box mesh
  121278. */
  121279. static CreateTiledBox(name: string, options: {
  121280. pattern?: number;
  121281. size?: number;
  121282. width?: number;
  121283. height?: number;
  121284. depth: number;
  121285. tileSize?: number;
  121286. tileWidth?: number;
  121287. tileHeight?: number;
  121288. faceUV?: Vector4[];
  121289. faceColors?: Color4[];
  121290. alignHorizontal?: number;
  121291. alignVertical?: number;
  121292. sideOrientation?: number;
  121293. updatable?: boolean;
  121294. }, scene?: Nullable<Scene>): Mesh;
  121295. /**
  121296. * Creates a sphere mesh
  121297. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  121298. * * 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`)
  121299. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  121300. * * 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
  121301. * * 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)
  121302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121305. * @param name defines the name of the mesh
  121306. * @param options defines the options used to create the mesh
  121307. * @param scene defines the hosting scene
  121308. * @returns the sphere mesh
  121309. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  121310. */
  121311. static CreateSphere(name: string, options: {
  121312. segments?: number;
  121313. diameter?: number;
  121314. diameterX?: number;
  121315. diameterY?: number;
  121316. diameterZ?: number;
  121317. arc?: number;
  121318. slice?: number;
  121319. sideOrientation?: number;
  121320. frontUVs?: Vector4;
  121321. backUVs?: Vector4;
  121322. updatable?: boolean;
  121323. }, scene?: Nullable<Scene>): Mesh;
  121324. /**
  121325. * Creates a plane polygonal mesh. By default, this is a disc
  121326. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  121327. * * 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
  121328. * * 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
  121329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121332. * @param name defines the name of the mesh
  121333. * @param options defines the options used to create the mesh
  121334. * @param scene defines the hosting scene
  121335. * @returns the plane polygonal mesh
  121336. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  121337. */
  121338. static CreateDisc(name: string, options: {
  121339. radius?: number;
  121340. tessellation?: number;
  121341. arc?: number;
  121342. updatable?: boolean;
  121343. sideOrientation?: number;
  121344. frontUVs?: Vector4;
  121345. backUVs?: Vector4;
  121346. }, scene?: Nullable<Scene>): Mesh;
  121347. /**
  121348. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121349. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121350. * * 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`)
  121351. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121352. * * 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
  121353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121356. * @param name defines the name of the mesh
  121357. * @param options defines the options used to create the mesh
  121358. * @param scene defines the hosting scene
  121359. * @returns the icosahedron mesh
  121360. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121361. */
  121362. static CreateIcoSphere(name: string, options: {
  121363. radius?: number;
  121364. radiusX?: number;
  121365. radiusY?: number;
  121366. radiusZ?: number;
  121367. flat?: boolean;
  121368. subdivisions?: number;
  121369. sideOrientation?: number;
  121370. frontUVs?: Vector4;
  121371. backUVs?: Vector4;
  121372. updatable?: boolean;
  121373. }, scene?: Nullable<Scene>): Mesh;
  121374. /**
  121375. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121376. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121377. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121378. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121379. * * 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
  121380. * * 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
  121381. * * 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
  121382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121384. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121385. * * 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
  121386. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121387. * * 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
  121388. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121390. * @param name defines the name of the mesh
  121391. * @param options defines the options used to create the mesh
  121392. * @param scene defines the hosting scene
  121393. * @returns the ribbon mesh
  121394. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121395. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121396. */
  121397. static CreateRibbon(name: string, options: {
  121398. pathArray: Vector3[][];
  121399. closeArray?: boolean;
  121400. closePath?: boolean;
  121401. offset?: number;
  121402. updatable?: boolean;
  121403. sideOrientation?: number;
  121404. frontUVs?: Vector4;
  121405. backUVs?: Vector4;
  121406. instance?: Mesh;
  121407. invertUV?: boolean;
  121408. uvs?: Vector2[];
  121409. colors?: Color4[];
  121410. }, scene?: Nullable<Scene>): Mesh;
  121411. /**
  121412. * Creates a cylinder or a cone mesh
  121413. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  121414. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  121415. * * 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.
  121416. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  121417. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  121418. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  121419. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  121420. * * 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).
  121421. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  121422. * * 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).
  121423. * * 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
  121424. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  121425. * * 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
  121426. * * 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.
  121427. * * If `enclose` is false, a ring surface is one element.
  121428. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  121429. * * 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
  121430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121433. * @param name defines the name of the mesh
  121434. * @param options defines the options used to create the mesh
  121435. * @param scene defines the hosting scene
  121436. * @returns the cylinder mesh
  121437. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  121438. */
  121439. static CreateCylinder(name: string, options: {
  121440. height?: number;
  121441. diameterTop?: number;
  121442. diameterBottom?: number;
  121443. diameter?: number;
  121444. tessellation?: number;
  121445. subdivisions?: number;
  121446. arc?: number;
  121447. faceColors?: Color4[];
  121448. faceUV?: Vector4[];
  121449. updatable?: boolean;
  121450. hasRings?: boolean;
  121451. enclose?: boolean;
  121452. cap?: number;
  121453. sideOrientation?: number;
  121454. frontUVs?: Vector4;
  121455. backUVs?: Vector4;
  121456. }, scene?: Nullable<Scene>): Mesh;
  121457. /**
  121458. * Creates a torus mesh
  121459. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  121460. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  121461. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  121462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121465. * @param name defines the name of the mesh
  121466. * @param options defines the options used to create the mesh
  121467. * @param scene defines the hosting scene
  121468. * @returns the torus mesh
  121469. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  121470. */
  121471. static CreateTorus(name: string, options: {
  121472. diameter?: number;
  121473. thickness?: number;
  121474. tessellation?: number;
  121475. updatable?: boolean;
  121476. sideOrientation?: number;
  121477. frontUVs?: Vector4;
  121478. backUVs?: Vector4;
  121479. }, scene?: Nullable<Scene>): Mesh;
  121480. /**
  121481. * Creates a torus knot mesh
  121482. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121483. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121484. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121485. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121489. * @param name defines the name of the mesh
  121490. * @param options defines the options used to create the mesh
  121491. * @param scene defines the hosting scene
  121492. * @returns the torus knot mesh
  121493. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121494. */
  121495. static CreateTorusKnot(name: string, options: {
  121496. radius?: number;
  121497. tube?: number;
  121498. radialSegments?: number;
  121499. tubularSegments?: number;
  121500. p?: number;
  121501. q?: number;
  121502. updatable?: boolean;
  121503. sideOrientation?: number;
  121504. frontUVs?: Vector4;
  121505. backUVs?: Vector4;
  121506. }, scene?: Nullable<Scene>): Mesh;
  121507. /**
  121508. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121509. * * 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
  121510. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121511. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121512. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121513. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121514. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121515. * * 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
  121516. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121519. * @param name defines the name of the new line system
  121520. * @param options defines the options used to create the line system
  121521. * @param scene defines the hosting scene
  121522. * @returns a new line system mesh
  121523. */
  121524. static CreateLineSystem(name: string, options: {
  121525. lines: Vector3[][];
  121526. updatable?: boolean;
  121527. instance?: Nullable<LinesMesh>;
  121528. colors?: Nullable<Color4[][]>;
  121529. useVertexAlpha?: boolean;
  121530. }, scene: Nullable<Scene>): LinesMesh;
  121531. /**
  121532. * Creates a line mesh
  121533. * 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
  121534. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121535. * * The parameter `points` is an array successive Vector3
  121536. * * 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
  121537. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121538. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121539. * * When updating an instance, remember that only point positions can change, not the number of points
  121540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121542. * @param name defines the name of the new line system
  121543. * @param options defines the options used to create the line system
  121544. * @param scene defines the hosting scene
  121545. * @returns a new line mesh
  121546. */
  121547. static CreateLines(name: string, options: {
  121548. points: Vector3[];
  121549. updatable?: boolean;
  121550. instance?: Nullable<LinesMesh>;
  121551. colors?: Color4[];
  121552. useVertexAlpha?: boolean;
  121553. }, scene?: Nullable<Scene>): LinesMesh;
  121554. /**
  121555. * Creates a dashed line mesh
  121556. * * 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
  121557. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121558. * * The parameter `points` is an array successive Vector3
  121559. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121560. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121561. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121562. * * 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
  121563. * * When updating an instance, remember that only point positions can change, not the number of points
  121564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121565. * @param name defines the name of the mesh
  121566. * @param options defines the options used to create the mesh
  121567. * @param scene defines the hosting scene
  121568. * @returns the dashed line mesh
  121569. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121570. */
  121571. static CreateDashedLines(name: string, options: {
  121572. points: Vector3[];
  121573. dashSize?: number;
  121574. gapSize?: number;
  121575. dashNb?: number;
  121576. updatable?: boolean;
  121577. instance?: LinesMesh;
  121578. }, scene?: Nullable<Scene>): LinesMesh;
  121579. /**
  121580. * 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.
  121581. * * 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.
  121582. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121583. * * 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.
  121584. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121585. * * 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
  121586. * * 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
  121587. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121590. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121592. * @param name defines the name of the mesh
  121593. * @param options defines the options used to create the mesh
  121594. * @param scene defines the hosting scene
  121595. * @returns the extruded shape mesh
  121596. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121598. */
  121599. static ExtrudeShape(name: string, options: {
  121600. shape: Vector3[];
  121601. path: Vector3[];
  121602. scale?: number;
  121603. rotation?: number;
  121604. cap?: number;
  121605. updatable?: boolean;
  121606. sideOrientation?: number;
  121607. frontUVs?: Vector4;
  121608. backUVs?: Vector4;
  121609. instance?: Mesh;
  121610. invertUV?: boolean;
  121611. }, scene?: Nullable<Scene>): Mesh;
  121612. /**
  121613. * Creates an custom extruded shape mesh.
  121614. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121615. * * 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.
  121616. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121617. * * 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
  121618. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121619. * * 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
  121620. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121621. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121622. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121623. * * 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
  121624. * * 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
  121625. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121628. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121630. * @param name defines the name of the mesh
  121631. * @param options defines the options used to create the mesh
  121632. * @param scene defines the hosting scene
  121633. * @returns the custom extruded shape mesh
  121634. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121635. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121637. */
  121638. static ExtrudeShapeCustom(name: string, options: {
  121639. shape: Vector3[];
  121640. path: Vector3[];
  121641. scaleFunction?: any;
  121642. rotationFunction?: any;
  121643. ribbonCloseArray?: boolean;
  121644. ribbonClosePath?: boolean;
  121645. cap?: number;
  121646. updatable?: boolean;
  121647. sideOrientation?: number;
  121648. frontUVs?: Vector4;
  121649. backUVs?: Vector4;
  121650. instance?: Mesh;
  121651. invertUV?: boolean;
  121652. }, scene?: Nullable<Scene>): Mesh;
  121653. /**
  121654. * Creates lathe mesh.
  121655. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121656. * * 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
  121657. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121658. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121659. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121660. * * 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
  121661. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121662. * * 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
  121663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121665. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121667. * @param name defines the name of the mesh
  121668. * @param options defines the options used to create the mesh
  121669. * @param scene defines the hosting scene
  121670. * @returns the lathe mesh
  121671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121672. */
  121673. static CreateLathe(name: string, options: {
  121674. shape: Vector3[];
  121675. radius?: number;
  121676. tessellation?: number;
  121677. clip?: number;
  121678. arc?: number;
  121679. closed?: boolean;
  121680. updatable?: boolean;
  121681. sideOrientation?: number;
  121682. frontUVs?: Vector4;
  121683. backUVs?: Vector4;
  121684. cap?: number;
  121685. invertUV?: boolean;
  121686. }, scene?: Nullable<Scene>): Mesh;
  121687. /**
  121688. * Creates a tiled plane mesh
  121689. * * You can set a limited pattern arrangement with the tiles
  121690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121693. * @param name defines the name of the mesh
  121694. * @param options defines the options used to create the mesh
  121695. * @param scene defines the hosting scene
  121696. * @returns the plane mesh
  121697. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121698. */
  121699. static CreateTiledPlane(name: string, options: {
  121700. pattern?: number;
  121701. tileSize?: number;
  121702. tileWidth?: number;
  121703. tileHeight?: number;
  121704. size?: number;
  121705. width?: number;
  121706. height?: number;
  121707. alignHorizontal?: number;
  121708. alignVertical?: number;
  121709. sideOrientation?: number;
  121710. frontUVs?: Vector4;
  121711. backUVs?: Vector4;
  121712. updatable?: boolean;
  121713. }, scene?: Nullable<Scene>): Mesh;
  121714. /**
  121715. * Creates a plane mesh
  121716. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121717. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121718. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121722. * @param name defines the name of the mesh
  121723. * @param options defines the options used to create the mesh
  121724. * @param scene defines the hosting scene
  121725. * @returns the plane mesh
  121726. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121727. */
  121728. static CreatePlane(name: string, options: {
  121729. size?: number;
  121730. width?: number;
  121731. height?: number;
  121732. sideOrientation?: number;
  121733. frontUVs?: Vector4;
  121734. backUVs?: Vector4;
  121735. updatable?: boolean;
  121736. sourcePlane?: Plane;
  121737. }, scene?: Nullable<Scene>): Mesh;
  121738. /**
  121739. * Creates a ground mesh
  121740. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121741. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  121742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121743. * @param name defines the name of the mesh
  121744. * @param options defines the options used to create the mesh
  121745. * @param scene defines the hosting scene
  121746. * @returns the ground mesh
  121747. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121748. */
  121749. static CreateGround(name: string, options: {
  121750. width?: number;
  121751. height?: number;
  121752. subdivisions?: number;
  121753. subdivisionsX?: number;
  121754. subdivisionsY?: number;
  121755. updatable?: boolean;
  121756. }, scene?: Nullable<Scene>): Mesh;
  121757. /**
  121758. * Creates a tiled ground mesh
  121759. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121760. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121761. * * 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
  121762. * * 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
  121763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121764. * @param name defines the name of the mesh
  121765. * @param options defines the options used to create the mesh
  121766. * @param scene defines the hosting scene
  121767. * @returns the tiled ground mesh
  121768. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121769. */
  121770. static CreateTiledGround(name: string, options: {
  121771. xmin: number;
  121772. zmin: number;
  121773. xmax: number;
  121774. zmax: number;
  121775. subdivisions?: {
  121776. w: number;
  121777. h: number;
  121778. };
  121779. precision?: {
  121780. w: number;
  121781. h: number;
  121782. };
  121783. updatable?: boolean;
  121784. }, scene?: Nullable<Scene>): Mesh;
  121785. /**
  121786. * Creates a ground mesh from a height map
  121787. * * The parameter `url` sets the URL of the height map image resource.
  121788. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121789. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121790. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121791. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121792. * * 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.
  121793. * * 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).
  121794. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121796. * @param name defines the name of the mesh
  121797. * @param url defines the url to the height map
  121798. * @param options defines the options used to create the mesh
  121799. * @param scene defines the hosting scene
  121800. * @returns the ground mesh
  121801. * @see https://doc.babylonjs.com/babylon101/height_map
  121802. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121803. */
  121804. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121805. width?: number;
  121806. height?: number;
  121807. subdivisions?: number;
  121808. minHeight?: number;
  121809. maxHeight?: number;
  121810. colorFilter?: Color3;
  121811. alphaFilter?: number;
  121812. updatable?: boolean;
  121813. onReady?: (mesh: GroundMesh) => void;
  121814. }, scene?: Nullable<Scene>): GroundMesh;
  121815. /**
  121816. * Creates a polygon mesh
  121817. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121818. * * 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
  121819. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121822. * * Remember you can only change the shape positions, not their number when updating a polygon
  121823. * @param name defines the name of the mesh
  121824. * @param options defines the options used to create the mesh
  121825. * @param scene defines the hosting scene
  121826. * @param earcutInjection can be used to inject your own earcut reference
  121827. * @returns the polygon mesh
  121828. */
  121829. static CreatePolygon(name: string, options: {
  121830. shape: Vector3[];
  121831. holes?: Vector3[][];
  121832. depth?: number;
  121833. faceUV?: Vector4[];
  121834. faceColors?: Color4[];
  121835. updatable?: boolean;
  121836. sideOrientation?: number;
  121837. frontUVs?: Vector4;
  121838. backUVs?: Vector4;
  121839. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121840. /**
  121841. * Creates an extruded polygon mesh, with depth in the Y direction.
  121842. * * 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)
  121843. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121844. * @param name defines the name of the mesh
  121845. * @param options defines the options used to create the mesh
  121846. * @param scene defines the hosting scene
  121847. * @param earcutInjection can be used to inject your own earcut reference
  121848. * @returns the polygon mesh
  121849. */
  121850. static ExtrudePolygon(name: string, options: {
  121851. shape: Vector3[];
  121852. holes?: Vector3[][];
  121853. depth?: number;
  121854. faceUV?: Vector4[];
  121855. faceColors?: Color4[];
  121856. updatable?: boolean;
  121857. sideOrientation?: number;
  121858. frontUVs?: Vector4;
  121859. backUVs?: Vector4;
  121860. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121861. /**
  121862. * Creates a tube mesh.
  121863. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121864. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121865. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121866. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121867. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121868. * * 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)
  121869. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121870. * * 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
  121871. * * 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
  121872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121874. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121876. * @param name defines the name of the mesh
  121877. * @param options defines the options used to create the mesh
  121878. * @param scene defines the hosting scene
  121879. * @returns the tube mesh
  121880. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121881. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121882. */
  121883. static CreateTube(name: string, options: {
  121884. path: Vector3[];
  121885. radius?: number;
  121886. tessellation?: number;
  121887. radiusFunction?: {
  121888. (i: number, distance: number): number;
  121889. };
  121890. cap?: number;
  121891. arc?: number;
  121892. updatable?: boolean;
  121893. sideOrientation?: number;
  121894. frontUVs?: Vector4;
  121895. backUVs?: Vector4;
  121896. instance?: Mesh;
  121897. invertUV?: boolean;
  121898. }, scene?: Nullable<Scene>): Mesh;
  121899. /**
  121900. * Creates a polyhedron mesh
  121901. * * 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
  121902. * * The parameter `size` (positive float, default 1) sets the polygon size
  121903. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121904. * * 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`
  121905. * * 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
  121906. * * 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)`)
  121907. * * 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
  121908. * * 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
  121909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121912. * @param name defines the name of the mesh
  121913. * @param options defines the options used to create the mesh
  121914. * @param scene defines the hosting scene
  121915. * @returns the polyhedron mesh
  121916. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121917. */
  121918. static CreatePolyhedron(name: string, options: {
  121919. type?: number;
  121920. size?: number;
  121921. sizeX?: number;
  121922. sizeY?: number;
  121923. sizeZ?: number;
  121924. custom?: any;
  121925. faceUV?: Vector4[];
  121926. faceColors?: Color4[];
  121927. flat?: boolean;
  121928. updatable?: boolean;
  121929. sideOrientation?: number;
  121930. frontUVs?: Vector4;
  121931. backUVs?: Vector4;
  121932. }, scene?: Nullable<Scene>): Mesh;
  121933. /**
  121934. * Creates a decal mesh.
  121935. * 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
  121936. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121937. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121938. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121939. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121940. * @param name defines the name of the mesh
  121941. * @param sourceMesh defines the mesh where the decal must be applied
  121942. * @param options defines the options used to create the mesh
  121943. * @param scene defines the hosting scene
  121944. * @returns the decal mesh
  121945. * @see https://doc.babylonjs.com/how_to/decals
  121946. */
  121947. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121948. position?: Vector3;
  121949. normal?: Vector3;
  121950. size?: Vector3;
  121951. angle?: number;
  121952. }): Mesh;
  121953. }
  121954. }
  121955. declare module BABYLON {
  121956. /**
  121957. * A simplifier interface for future simplification implementations
  121958. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121959. */
  121960. export interface ISimplifier {
  121961. /**
  121962. * Simplification of a given mesh according to the given settings.
  121963. * Since this requires computation, it is assumed that the function runs async.
  121964. * @param settings The settings of the simplification, including quality and distance
  121965. * @param successCallback A callback that will be called after the mesh was simplified.
  121966. * @param errorCallback in case of an error, this callback will be called. optional.
  121967. */
  121968. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  121969. }
  121970. /**
  121971. * Expected simplification settings.
  121972. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  121973. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121974. */
  121975. export interface ISimplificationSettings {
  121976. /**
  121977. * Gets or sets the expected quality
  121978. */
  121979. quality: number;
  121980. /**
  121981. * Gets or sets the distance when this optimized version should be used
  121982. */
  121983. distance: number;
  121984. /**
  121985. * Gets an already optimized mesh
  121986. */
  121987. optimizeMesh?: boolean;
  121988. }
  121989. /**
  121990. * Class used to specify simplification options
  121991. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121992. */
  121993. export class SimplificationSettings implements ISimplificationSettings {
  121994. /** expected quality */
  121995. quality: number;
  121996. /** distance when this optimized version should be used */
  121997. distance: number;
  121998. /** already optimized mesh */
  121999. optimizeMesh?: boolean | undefined;
  122000. /**
  122001. * Creates a SimplificationSettings
  122002. * @param quality expected quality
  122003. * @param distance distance when this optimized version should be used
  122004. * @param optimizeMesh already optimized mesh
  122005. */
  122006. constructor(
  122007. /** expected quality */
  122008. quality: number,
  122009. /** distance when this optimized version should be used */
  122010. distance: number,
  122011. /** already optimized mesh */
  122012. optimizeMesh?: boolean | undefined);
  122013. }
  122014. /**
  122015. * Interface used to define a simplification task
  122016. */
  122017. export interface ISimplificationTask {
  122018. /**
  122019. * Array of settings
  122020. */
  122021. settings: Array<ISimplificationSettings>;
  122022. /**
  122023. * Simplification type
  122024. */
  122025. simplificationType: SimplificationType;
  122026. /**
  122027. * Mesh to simplify
  122028. */
  122029. mesh: Mesh;
  122030. /**
  122031. * Callback called on success
  122032. */
  122033. successCallback?: () => void;
  122034. /**
  122035. * Defines if parallel processing can be used
  122036. */
  122037. parallelProcessing: boolean;
  122038. }
  122039. /**
  122040. * Queue used to order the simplification tasks
  122041. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122042. */
  122043. export class SimplificationQueue {
  122044. private _simplificationArray;
  122045. /**
  122046. * Gets a boolean indicating that the process is still running
  122047. */
  122048. running: boolean;
  122049. /**
  122050. * Creates a new queue
  122051. */
  122052. constructor();
  122053. /**
  122054. * Adds a new simplification task
  122055. * @param task defines a task to add
  122056. */
  122057. addTask(task: ISimplificationTask): void;
  122058. /**
  122059. * Execute next task
  122060. */
  122061. executeNext(): void;
  122062. /**
  122063. * Execute a simplification task
  122064. * @param task defines the task to run
  122065. */
  122066. runSimplification(task: ISimplificationTask): void;
  122067. private getSimplifier;
  122068. }
  122069. /**
  122070. * The implemented types of simplification
  122071. * At the moment only Quadratic Error Decimation is implemented
  122072. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122073. */
  122074. export enum SimplificationType {
  122075. /** Quadratic error decimation */
  122076. QUADRATIC = 0
  122077. }
  122078. }
  122079. declare module BABYLON {
  122080. interface Scene {
  122081. /** @hidden (Backing field) */
  122082. _simplificationQueue: SimplificationQueue;
  122083. /**
  122084. * Gets or sets the simplification queue attached to the scene
  122085. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122086. */
  122087. simplificationQueue: SimplificationQueue;
  122088. }
  122089. interface Mesh {
  122090. /**
  122091. * Simplify the mesh according to the given array of settings.
  122092. * Function will return immediately and will simplify async
  122093. * @param settings a collection of simplification settings
  122094. * @param parallelProcessing should all levels calculate parallel or one after the other
  122095. * @param simplificationType the type of simplification to run
  122096. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  122097. * @returns the current mesh
  122098. */
  122099. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  122100. }
  122101. /**
  122102. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  122103. * created in a scene
  122104. */
  122105. export class SimplicationQueueSceneComponent implements ISceneComponent {
  122106. /**
  122107. * The component name helpfull to identify the component in the list of scene components.
  122108. */
  122109. readonly name: string;
  122110. /**
  122111. * The scene the component belongs to.
  122112. */
  122113. scene: Scene;
  122114. /**
  122115. * Creates a new instance of the component for the given scene
  122116. * @param scene Defines the scene to register the component in
  122117. */
  122118. constructor(scene: Scene);
  122119. /**
  122120. * Registers the component in a given scene
  122121. */
  122122. register(): void;
  122123. /**
  122124. * Rebuilds the elements related to this component in case of
  122125. * context lost for instance.
  122126. */
  122127. rebuild(): void;
  122128. /**
  122129. * Disposes the component and the associated ressources
  122130. */
  122131. dispose(): void;
  122132. private _beforeCameraUpdate;
  122133. }
  122134. }
  122135. declare module BABYLON {
  122136. /**
  122137. * Navigation plugin interface to add navigation constrained by a navigation mesh
  122138. */
  122139. export interface INavigationEnginePlugin {
  122140. /**
  122141. * plugin name
  122142. */
  122143. name: string;
  122144. /**
  122145. * Creates a navigation mesh
  122146. * @param meshes array of all the geometry used to compute the navigatio mesh
  122147. * @param parameters bunch of parameters used to filter geometry
  122148. */
  122149. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122150. /**
  122151. * Create a navigation mesh debug mesh
  122152. * @param scene is where the mesh will be added
  122153. * @returns debug display mesh
  122154. */
  122155. createDebugNavMesh(scene: Scene): Mesh;
  122156. /**
  122157. * Get a navigation mesh constrained position, closest to the parameter position
  122158. * @param position world position
  122159. * @returns the closest point to position constrained by the navigation mesh
  122160. */
  122161. getClosestPoint(position: Vector3): Vector3;
  122162. /**
  122163. * Get a navigation mesh constrained position, within a particular radius
  122164. * @param position world position
  122165. * @param maxRadius the maximum distance to the constrained world position
  122166. * @returns the closest point to position constrained by the navigation mesh
  122167. */
  122168. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122169. /**
  122170. * Compute the final position from a segment made of destination-position
  122171. * @param position world position
  122172. * @param destination world position
  122173. * @returns the resulting point along the navmesh
  122174. */
  122175. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122176. /**
  122177. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122178. * @param start world position
  122179. * @param end world position
  122180. * @returns array containing world position composing the path
  122181. */
  122182. computePath(start: Vector3, end: Vector3): Vector3[];
  122183. /**
  122184. * If this plugin is supported
  122185. * @returns true if plugin is supported
  122186. */
  122187. isSupported(): boolean;
  122188. /**
  122189. * Create a new Crowd so you can add agents
  122190. * @param maxAgents the maximum agent count in the crowd
  122191. * @param maxAgentRadius the maximum radius an agent can have
  122192. * @param scene to attach the crowd to
  122193. * @returns the crowd you can add agents to
  122194. */
  122195. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122196. /**
  122197. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122198. * The queries will try to find a solution within those bounds
  122199. * default is (1,1,1)
  122200. * @param extent x,y,z value that define the extent around the queries point of reference
  122201. */
  122202. setDefaultQueryExtent(extent: Vector3): void;
  122203. /**
  122204. * Get the Bounding box extent specified by setDefaultQueryExtent
  122205. * @returns the box extent values
  122206. */
  122207. getDefaultQueryExtent(): Vector3;
  122208. /**
  122209. * Release all resources
  122210. */
  122211. dispose(): void;
  122212. }
  122213. /**
  122214. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  122215. */
  122216. export interface ICrowd {
  122217. /**
  122218. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122219. * You can attach anything to that node. The node position is updated in the scene update tick.
  122220. * @param pos world position that will be constrained by the navigation mesh
  122221. * @param parameters agent parameters
  122222. * @param transform hooked to the agent that will be update by the scene
  122223. * @returns agent index
  122224. */
  122225. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122226. /**
  122227. * Returns the agent position in world space
  122228. * @param index agent index returned by addAgent
  122229. * @returns world space position
  122230. */
  122231. getAgentPosition(index: number): Vector3;
  122232. /**
  122233. * Gets the agent velocity in world space
  122234. * @param index agent index returned by addAgent
  122235. * @returns world space velocity
  122236. */
  122237. getAgentVelocity(index: number): Vector3;
  122238. /**
  122239. * remove a particular agent previously created
  122240. * @param index agent index returned by addAgent
  122241. */
  122242. removeAgent(index: number): void;
  122243. /**
  122244. * get the list of all agents attached to this crowd
  122245. * @returns list of agent indices
  122246. */
  122247. getAgents(): number[];
  122248. /**
  122249. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122250. * @param deltaTime in seconds
  122251. */
  122252. update(deltaTime: number): void;
  122253. /**
  122254. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122255. * @param index agent index returned by addAgent
  122256. * @param destination targeted world position
  122257. */
  122258. agentGoto(index: number, destination: Vector3): void;
  122259. /**
  122260. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122261. * The queries will try to find a solution within those bounds
  122262. * default is (1,1,1)
  122263. * @param extent x,y,z value that define the extent around the queries point of reference
  122264. */
  122265. setDefaultQueryExtent(extent: Vector3): void;
  122266. /**
  122267. * Get the Bounding box extent specified by setDefaultQueryExtent
  122268. * @returns the box extent values
  122269. */
  122270. getDefaultQueryExtent(): Vector3;
  122271. /**
  122272. * Release all resources
  122273. */
  122274. dispose(): void;
  122275. }
  122276. /**
  122277. * Configures an agent
  122278. */
  122279. export interface IAgentParameters {
  122280. /**
  122281. * Agent radius. [Limit: >= 0]
  122282. */
  122283. radius: number;
  122284. /**
  122285. * Agent height. [Limit: > 0]
  122286. */
  122287. height: number;
  122288. /**
  122289. * Maximum allowed acceleration. [Limit: >= 0]
  122290. */
  122291. maxAcceleration: number;
  122292. /**
  122293. * Maximum allowed speed. [Limit: >= 0]
  122294. */
  122295. maxSpeed: number;
  122296. /**
  122297. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  122298. */
  122299. collisionQueryRange: number;
  122300. /**
  122301. * The path visibility optimization range. [Limit: > 0]
  122302. */
  122303. pathOptimizationRange: number;
  122304. /**
  122305. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  122306. */
  122307. separationWeight: number;
  122308. }
  122309. /**
  122310. * Configures the navigation mesh creation
  122311. */
  122312. export interface INavMeshParameters {
  122313. /**
  122314. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  122315. */
  122316. cs: number;
  122317. /**
  122318. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  122319. */
  122320. ch: number;
  122321. /**
  122322. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  122323. */
  122324. walkableSlopeAngle: number;
  122325. /**
  122326. * Minimum floor to 'ceiling' height that will still allow the floor area to
  122327. * be considered walkable. [Limit: >= 3] [Units: vx]
  122328. */
  122329. walkableHeight: number;
  122330. /**
  122331. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  122332. */
  122333. walkableClimb: number;
  122334. /**
  122335. * The distance to erode/shrink the walkable area of the heightfield away from
  122336. * obstructions. [Limit: >=0] [Units: vx]
  122337. */
  122338. walkableRadius: number;
  122339. /**
  122340. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  122341. */
  122342. maxEdgeLen: number;
  122343. /**
  122344. * The maximum distance a simplfied contour's border edges should deviate
  122345. * the original raw contour. [Limit: >=0] [Units: vx]
  122346. */
  122347. maxSimplificationError: number;
  122348. /**
  122349. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  122350. */
  122351. minRegionArea: number;
  122352. /**
  122353. * Any regions with a span count smaller than this value will, if possible,
  122354. * be merged with larger regions. [Limit: >=0] [Units: vx]
  122355. */
  122356. mergeRegionArea: number;
  122357. /**
  122358. * The maximum number of vertices allowed for polygons generated during the
  122359. * contour to polygon conversion process. [Limit: >= 3]
  122360. */
  122361. maxVertsPerPoly: number;
  122362. /**
  122363. * Sets the sampling distance to use when generating the detail mesh.
  122364. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  122365. */
  122366. detailSampleDist: number;
  122367. /**
  122368. * The maximum distance the detail mesh surface should deviate from heightfield
  122369. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  122370. */
  122371. detailSampleMaxError: number;
  122372. }
  122373. }
  122374. declare module BABYLON {
  122375. /**
  122376. * RecastJS navigation plugin
  122377. */
  122378. export class RecastJSPlugin implements INavigationEnginePlugin {
  122379. /**
  122380. * Reference to the Recast library
  122381. */
  122382. bjsRECAST: any;
  122383. /**
  122384. * plugin name
  122385. */
  122386. name: string;
  122387. /**
  122388. * the first navmesh created. We might extend this to support multiple navmeshes
  122389. */
  122390. navMesh: any;
  122391. /**
  122392. * Initializes the recastJS plugin
  122393. * @param recastInjection can be used to inject your own recast reference
  122394. */
  122395. constructor(recastInjection?: any);
  122396. /**
  122397. * Creates a navigation mesh
  122398. * @param meshes array of all the geometry used to compute the navigatio mesh
  122399. * @param parameters bunch of parameters used to filter geometry
  122400. */
  122401. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122402. /**
  122403. * Create a navigation mesh debug mesh
  122404. * @param scene is where the mesh will be added
  122405. * @returns debug display mesh
  122406. */
  122407. createDebugNavMesh(scene: Scene): Mesh;
  122408. /**
  122409. * Get a navigation mesh constrained position, closest to the parameter position
  122410. * @param position world position
  122411. * @returns the closest point to position constrained by the navigation mesh
  122412. */
  122413. getClosestPoint(position: Vector3): Vector3;
  122414. /**
  122415. * Get a navigation mesh constrained position, within a particular radius
  122416. * @param position world position
  122417. * @param maxRadius the maximum distance to the constrained world position
  122418. * @returns the closest point to position constrained by the navigation mesh
  122419. */
  122420. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122421. /**
  122422. * Compute the final position from a segment made of destination-position
  122423. * @param position world position
  122424. * @param destination world position
  122425. * @returns the resulting point along the navmesh
  122426. */
  122427. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122428. /**
  122429. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122430. * @param start world position
  122431. * @param end world position
  122432. * @returns array containing world position composing the path
  122433. */
  122434. computePath(start: Vector3, end: Vector3): Vector3[];
  122435. /**
  122436. * Create a new Crowd so you can add agents
  122437. * @param maxAgents the maximum agent count in the crowd
  122438. * @param maxAgentRadius the maximum radius an agent can have
  122439. * @param scene to attach the crowd to
  122440. * @returns the crowd you can add agents to
  122441. */
  122442. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122443. /**
  122444. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122445. * The queries will try to find a solution within those bounds
  122446. * default is (1,1,1)
  122447. * @param extent x,y,z value that define the extent around the queries point of reference
  122448. */
  122449. setDefaultQueryExtent(extent: Vector3): void;
  122450. /**
  122451. * Get the Bounding box extent specified by setDefaultQueryExtent
  122452. * @returns the box extent values
  122453. */
  122454. getDefaultQueryExtent(): Vector3;
  122455. /**
  122456. * Disposes
  122457. */
  122458. dispose(): void;
  122459. /**
  122460. * If this plugin is supported
  122461. * @returns true if plugin is supported
  122462. */
  122463. isSupported(): boolean;
  122464. }
  122465. /**
  122466. * Recast detour crowd implementation
  122467. */
  122468. export class RecastJSCrowd implements ICrowd {
  122469. /**
  122470. * Recast/detour plugin
  122471. */
  122472. bjsRECASTPlugin: RecastJSPlugin;
  122473. /**
  122474. * Link to the detour crowd
  122475. */
  122476. recastCrowd: any;
  122477. /**
  122478. * One transform per agent
  122479. */
  122480. transforms: TransformNode[];
  122481. /**
  122482. * All agents created
  122483. */
  122484. agents: number[];
  122485. /**
  122486. * Link to the scene is kept to unregister the crowd from the scene
  122487. */
  122488. private _scene;
  122489. /**
  122490. * Observer for crowd updates
  122491. */
  122492. private _onBeforeAnimationsObserver;
  122493. /**
  122494. * Constructor
  122495. * @param plugin recastJS plugin
  122496. * @param maxAgents the maximum agent count in the crowd
  122497. * @param maxAgentRadius the maximum radius an agent can have
  122498. * @param scene to attach the crowd to
  122499. * @returns the crowd you can add agents to
  122500. */
  122501. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  122502. /**
  122503. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122504. * You can attach anything to that node. The node position is updated in the scene update tick.
  122505. * @param pos world position that will be constrained by the navigation mesh
  122506. * @param parameters agent parameters
  122507. * @param transform hooked to the agent that will be update by the scene
  122508. * @returns agent index
  122509. */
  122510. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122511. /**
  122512. * Returns the agent position in world space
  122513. * @param index agent index returned by addAgent
  122514. * @returns world space position
  122515. */
  122516. getAgentPosition(index: number): Vector3;
  122517. /**
  122518. * Returns the agent velocity in world space
  122519. * @param index agent index returned by addAgent
  122520. * @returns world space velocity
  122521. */
  122522. getAgentVelocity(index: number): Vector3;
  122523. /**
  122524. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122525. * @param index agent index returned by addAgent
  122526. * @param destination targeted world position
  122527. */
  122528. agentGoto(index: number, destination: Vector3): void;
  122529. /**
  122530. * remove a particular agent previously created
  122531. * @param index agent index returned by addAgent
  122532. */
  122533. removeAgent(index: number): void;
  122534. /**
  122535. * get the list of all agents attached to this crowd
  122536. * @returns list of agent indices
  122537. */
  122538. getAgents(): number[];
  122539. /**
  122540. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122541. * @param deltaTime in seconds
  122542. */
  122543. update(deltaTime: number): void;
  122544. /**
  122545. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122546. * The queries will try to find a solution within those bounds
  122547. * default is (1,1,1)
  122548. * @param extent x,y,z value that define the extent around the queries point of reference
  122549. */
  122550. setDefaultQueryExtent(extent: Vector3): void;
  122551. /**
  122552. * Get the Bounding box extent specified by setDefaultQueryExtent
  122553. * @returns the box extent values
  122554. */
  122555. getDefaultQueryExtent(): Vector3;
  122556. /**
  122557. * Release all resources
  122558. */
  122559. dispose(): void;
  122560. }
  122561. }
  122562. declare module BABYLON {
  122563. /**
  122564. * Class used to enable access to IndexedDB
  122565. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  122566. */
  122567. export class Database implements IOfflineProvider {
  122568. private _callbackManifestChecked;
  122569. private _currentSceneUrl;
  122570. private _db;
  122571. private _enableSceneOffline;
  122572. private _enableTexturesOffline;
  122573. private _manifestVersionFound;
  122574. private _mustUpdateRessources;
  122575. private _hasReachedQuota;
  122576. private _isSupported;
  122577. private _idbFactory;
  122578. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122579. private static IsUASupportingBlobStorage;
  122580. /**
  122581. * Gets a boolean indicating if Database storate is enabled (off by default)
  122582. */
  122583. static IDBStorageEnabled: boolean;
  122584. /**
  122585. * Gets a boolean indicating if scene must be saved in the database
  122586. */
  122587. readonly enableSceneOffline: boolean;
  122588. /**
  122589. * Gets a boolean indicating if textures must be saved in the database
  122590. */
  122591. readonly enableTexturesOffline: boolean;
  122592. /**
  122593. * Creates a new Database
  122594. * @param urlToScene defines the url to load the scene
  122595. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122596. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122597. */
  122598. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122599. private static _ParseURL;
  122600. private static _ReturnFullUrlLocation;
  122601. private _checkManifestFile;
  122602. /**
  122603. * Open the database and make it available
  122604. * @param successCallback defines the callback to call on success
  122605. * @param errorCallback defines the callback to call on error
  122606. */
  122607. open(successCallback: () => void, errorCallback: () => void): void;
  122608. /**
  122609. * Loads an image from the database
  122610. * @param url defines the url to load from
  122611. * @param image defines the target DOM image
  122612. */
  122613. loadImage(url: string, image: HTMLImageElement): void;
  122614. private _loadImageFromDBAsync;
  122615. private _saveImageIntoDBAsync;
  122616. private _checkVersionFromDB;
  122617. private _loadVersionFromDBAsync;
  122618. private _saveVersionIntoDBAsync;
  122619. /**
  122620. * Loads a file from database
  122621. * @param url defines the URL to load from
  122622. * @param sceneLoaded defines a callback to call on success
  122623. * @param progressCallBack defines a callback to call when progress changed
  122624. * @param errorCallback defines a callback to call on error
  122625. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122626. */
  122627. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122628. private _loadFileAsync;
  122629. private _saveFileAsync;
  122630. /**
  122631. * Validates if xhr data is correct
  122632. * @param xhr defines the request to validate
  122633. * @param dataType defines the expected data type
  122634. * @returns true if data is correct
  122635. */
  122636. private static _ValidateXHRData;
  122637. }
  122638. }
  122639. declare module BABYLON {
  122640. /** @hidden */
  122641. export var gpuUpdateParticlesPixelShader: {
  122642. name: string;
  122643. shader: string;
  122644. };
  122645. }
  122646. declare module BABYLON {
  122647. /** @hidden */
  122648. export var gpuUpdateParticlesVertexShader: {
  122649. name: string;
  122650. shader: string;
  122651. };
  122652. }
  122653. declare module BABYLON {
  122654. /** @hidden */
  122655. export var clipPlaneFragmentDeclaration2: {
  122656. name: string;
  122657. shader: string;
  122658. };
  122659. }
  122660. declare module BABYLON {
  122661. /** @hidden */
  122662. export var gpuRenderParticlesPixelShader: {
  122663. name: string;
  122664. shader: string;
  122665. };
  122666. }
  122667. declare module BABYLON {
  122668. /** @hidden */
  122669. export var clipPlaneVertexDeclaration2: {
  122670. name: string;
  122671. shader: string;
  122672. };
  122673. }
  122674. declare module BABYLON {
  122675. /** @hidden */
  122676. export var gpuRenderParticlesVertexShader: {
  122677. name: string;
  122678. shader: string;
  122679. };
  122680. }
  122681. declare module BABYLON {
  122682. /**
  122683. * This represents a GPU particle system in Babylon
  122684. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122685. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122686. */
  122687. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122688. /**
  122689. * The layer mask we are rendering the particles through.
  122690. */
  122691. layerMask: number;
  122692. private _capacity;
  122693. private _activeCount;
  122694. private _currentActiveCount;
  122695. private _accumulatedCount;
  122696. private _renderEffect;
  122697. private _updateEffect;
  122698. private _buffer0;
  122699. private _buffer1;
  122700. private _spriteBuffer;
  122701. private _updateVAO;
  122702. private _renderVAO;
  122703. private _targetIndex;
  122704. private _sourceBuffer;
  122705. private _targetBuffer;
  122706. private _engine;
  122707. private _currentRenderId;
  122708. private _started;
  122709. private _stopped;
  122710. private _timeDelta;
  122711. private _randomTexture;
  122712. private _randomTexture2;
  122713. private _attributesStrideSize;
  122714. private _updateEffectOptions;
  122715. private _randomTextureSize;
  122716. private _actualFrame;
  122717. private readonly _rawTextureWidth;
  122718. /**
  122719. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122720. */
  122721. static readonly IsSupported: boolean;
  122722. /**
  122723. * An event triggered when the system is disposed.
  122724. */
  122725. onDisposeObservable: Observable<GPUParticleSystem>;
  122726. /**
  122727. * Gets the maximum number of particles active at the same time.
  122728. * @returns The max number of active particles.
  122729. */
  122730. getCapacity(): number;
  122731. /**
  122732. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122733. * to override the particles.
  122734. */
  122735. forceDepthWrite: boolean;
  122736. /**
  122737. * Gets or set the number of active particles
  122738. */
  122739. activeParticleCount: number;
  122740. private _preWarmDone;
  122741. /**
  122742. * Is this system ready to be used/rendered
  122743. * @return true if the system is ready
  122744. */
  122745. isReady(): boolean;
  122746. /**
  122747. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122748. * @returns True if it has been started, otherwise false.
  122749. */
  122750. isStarted(): boolean;
  122751. /**
  122752. * Starts the particle system and begins to emit
  122753. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122754. */
  122755. start(delay?: number): void;
  122756. /**
  122757. * Stops the particle system.
  122758. */
  122759. stop(): void;
  122760. /**
  122761. * Remove all active particles
  122762. */
  122763. reset(): void;
  122764. /**
  122765. * Returns the string "GPUParticleSystem"
  122766. * @returns a string containing the class name
  122767. */
  122768. getClassName(): string;
  122769. private _colorGradientsTexture;
  122770. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122771. /**
  122772. * Adds a new color gradient
  122773. * @param gradient defines the gradient to use (between 0 and 1)
  122774. * @param color1 defines the color to affect to the specified gradient
  122775. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122776. * @returns the current particle system
  122777. */
  122778. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122779. /**
  122780. * Remove a specific color gradient
  122781. * @param gradient defines the gradient to remove
  122782. * @returns the current particle system
  122783. */
  122784. removeColorGradient(gradient: number): GPUParticleSystem;
  122785. private _angularSpeedGradientsTexture;
  122786. private _sizeGradientsTexture;
  122787. private _velocityGradientsTexture;
  122788. private _limitVelocityGradientsTexture;
  122789. private _dragGradientsTexture;
  122790. private _addFactorGradient;
  122791. /**
  122792. * Adds a new size gradient
  122793. * @param gradient defines the gradient to use (between 0 and 1)
  122794. * @param factor defines the size factor to affect to the specified gradient
  122795. * @returns the current particle system
  122796. */
  122797. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122798. /**
  122799. * Remove a specific size gradient
  122800. * @param gradient defines the gradient to remove
  122801. * @returns the current particle system
  122802. */
  122803. removeSizeGradient(gradient: number): GPUParticleSystem;
  122804. /**
  122805. * Adds a new angular speed gradient
  122806. * @param gradient defines the gradient to use (between 0 and 1)
  122807. * @param factor defines the angular speed to affect to the specified gradient
  122808. * @returns the current particle system
  122809. */
  122810. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122811. /**
  122812. * Remove a specific angular speed gradient
  122813. * @param gradient defines the gradient to remove
  122814. * @returns the current particle system
  122815. */
  122816. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  122817. /**
  122818. * Adds a new velocity gradient
  122819. * @param gradient defines the gradient to use (between 0 and 1)
  122820. * @param factor defines the velocity to affect to the specified gradient
  122821. * @returns the current particle system
  122822. */
  122823. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122824. /**
  122825. * Remove a specific velocity gradient
  122826. * @param gradient defines the gradient to remove
  122827. * @returns the current particle system
  122828. */
  122829. removeVelocityGradient(gradient: number): GPUParticleSystem;
  122830. /**
  122831. * Adds a new limit velocity gradient
  122832. * @param gradient defines the gradient to use (between 0 and 1)
  122833. * @param factor defines the limit velocity value to affect to the specified gradient
  122834. * @returns the current particle system
  122835. */
  122836. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122837. /**
  122838. * Remove a specific limit velocity gradient
  122839. * @param gradient defines the gradient to remove
  122840. * @returns the current particle system
  122841. */
  122842. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  122843. /**
  122844. * Adds a new drag gradient
  122845. * @param gradient defines the gradient to use (between 0 and 1)
  122846. * @param factor defines the drag value to affect to the specified gradient
  122847. * @returns the current particle system
  122848. */
  122849. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  122850. /**
  122851. * Remove a specific drag gradient
  122852. * @param gradient defines the gradient to remove
  122853. * @returns the current particle system
  122854. */
  122855. removeDragGradient(gradient: number): GPUParticleSystem;
  122856. /**
  122857. * Not supported by GPUParticleSystem
  122858. * @param gradient defines the gradient to use (between 0 and 1)
  122859. * @param factor defines the emit rate value to affect to the specified gradient
  122860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122861. * @returns the current particle system
  122862. */
  122863. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122864. /**
  122865. * Not supported by GPUParticleSystem
  122866. * @param gradient defines the gradient to remove
  122867. * @returns the current particle system
  122868. */
  122869. removeEmitRateGradient(gradient: number): IParticleSystem;
  122870. /**
  122871. * Not supported by GPUParticleSystem
  122872. * @param gradient defines the gradient to use (between 0 and 1)
  122873. * @param factor defines the start size value to affect to the specified gradient
  122874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122875. * @returns the current particle system
  122876. */
  122877. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122878. /**
  122879. * Not supported by GPUParticleSystem
  122880. * @param gradient defines the gradient to remove
  122881. * @returns the current particle system
  122882. */
  122883. removeStartSizeGradient(gradient: number): IParticleSystem;
  122884. /**
  122885. * Not supported by GPUParticleSystem
  122886. * @param gradient defines the gradient to use (between 0 and 1)
  122887. * @param min defines the color remap minimal range
  122888. * @param max defines the color remap maximal range
  122889. * @returns the current particle system
  122890. */
  122891. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122892. /**
  122893. * Not supported by GPUParticleSystem
  122894. * @param gradient defines the gradient to remove
  122895. * @returns the current particle system
  122896. */
  122897. removeColorRemapGradient(): IParticleSystem;
  122898. /**
  122899. * Not supported by GPUParticleSystem
  122900. * @param gradient defines the gradient to use (between 0 and 1)
  122901. * @param min defines the alpha remap minimal range
  122902. * @param max defines the alpha remap maximal range
  122903. * @returns the current particle system
  122904. */
  122905. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122906. /**
  122907. * Not supported by GPUParticleSystem
  122908. * @param gradient defines the gradient to remove
  122909. * @returns the current particle system
  122910. */
  122911. removeAlphaRemapGradient(): IParticleSystem;
  122912. /**
  122913. * Not supported by GPUParticleSystem
  122914. * @param gradient defines the gradient to use (between 0 and 1)
  122915. * @param color defines the color to affect to the specified gradient
  122916. * @returns the current particle system
  122917. */
  122918. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  122919. /**
  122920. * Not supported by GPUParticleSystem
  122921. * @param gradient defines the gradient to remove
  122922. * @returns the current particle system
  122923. */
  122924. removeRampGradient(): IParticleSystem;
  122925. /**
  122926. * Not supported by GPUParticleSystem
  122927. * @returns the list of ramp gradients
  122928. */
  122929. getRampGradients(): Nullable<Array<Color3Gradient>>;
  122930. /**
  122931. * Not supported by GPUParticleSystem
  122932. * Gets or sets a boolean indicating that ramp gradients must be used
  122933. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  122934. */
  122935. useRampGradients: boolean;
  122936. /**
  122937. * Not supported by GPUParticleSystem
  122938. * @param gradient defines the gradient to use (between 0 and 1)
  122939. * @param factor defines the life time factor to affect to the specified gradient
  122940. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122941. * @returns the current particle system
  122942. */
  122943. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122944. /**
  122945. * Not supported by GPUParticleSystem
  122946. * @param gradient defines the gradient to remove
  122947. * @returns the current particle system
  122948. */
  122949. removeLifeTimeGradient(gradient: number): IParticleSystem;
  122950. /**
  122951. * Instantiates a GPU particle system.
  122952. * 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.
  122953. * @param name The name of the particle system
  122954. * @param options The options used to create the system
  122955. * @param scene The scene the particle system belongs to
  122956. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  122957. */
  122958. constructor(name: string, options: Partial<{
  122959. capacity: number;
  122960. randomTextureSize: number;
  122961. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  122962. protected _reset(): void;
  122963. private _createUpdateVAO;
  122964. private _createRenderVAO;
  122965. private _initialize;
  122966. /** @hidden */
  122967. _recreateUpdateEffect(): void;
  122968. /** @hidden */
  122969. _recreateRenderEffect(): void;
  122970. /**
  122971. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  122972. * @param preWarm defines if we are in the pre-warmimg phase
  122973. */
  122974. animate(preWarm?: boolean): void;
  122975. private _createFactorGradientTexture;
  122976. private _createSizeGradientTexture;
  122977. private _createAngularSpeedGradientTexture;
  122978. private _createVelocityGradientTexture;
  122979. private _createLimitVelocityGradientTexture;
  122980. private _createDragGradientTexture;
  122981. private _createColorGradientTexture;
  122982. /**
  122983. * Renders the particle system in its current state
  122984. * @param preWarm defines if the system should only update the particles but not render them
  122985. * @returns the current number of particles
  122986. */
  122987. render(preWarm?: boolean): number;
  122988. /**
  122989. * Rebuilds the particle system
  122990. */
  122991. rebuild(): void;
  122992. private _releaseBuffers;
  122993. private _releaseVAOs;
  122994. /**
  122995. * Disposes the particle system and free the associated resources
  122996. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  122997. */
  122998. dispose(disposeTexture?: boolean): void;
  122999. /**
  123000. * Clones the particle system.
  123001. * @param name The name of the cloned object
  123002. * @param newEmitter The new emitter to use
  123003. * @returns the cloned particle system
  123004. */
  123005. clone(name: string, newEmitter: any): GPUParticleSystem;
  123006. /**
  123007. * Serializes the particle system to a JSON object.
  123008. * @returns the JSON object
  123009. */
  123010. serialize(): any;
  123011. /**
  123012. * Parses a JSON object to create a GPU particle system.
  123013. * @param parsedParticleSystem The JSON object to parse
  123014. * @param scene The scene to create the particle system in
  123015. * @param rootUrl The root url to use to load external dependencies like texture
  123016. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  123017. * @returns the parsed GPU particle system
  123018. */
  123019. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  123020. }
  123021. }
  123022. declare module BABYLON {
  123023. /**
  123024. * Represents a set of particle systems working together to create a specific effect
  123025. */
  123026. export class ParticleSystemSet implements IDisposable {
  123027. private _emitterCreationOptions;
  123028. private _emitterNode;
  123029. /**
  123030. * Gets the particle system list
  123031. */
  123032. systems: IParticleSystem[];
  123033. /**
  123034. * Gets the emitter node used with this set
  123035. */
  123036. readonly emitterNode: Nullable<TransformNode>;
  123037. /**
  123038. * Creates a new emitter mesh as a sphere
  123039. * @param options defines the options used to create the sphere
  123040. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  123041. * @param scene defines the hosting scene
  123042. */
  123043. setEmitterAsSphere(options: {
  123044. diameter: number;
  123045. segments: number;
  123046. color: Color3;
  123047. }, renderingGroupId: number, scene: Scene): void;
  123048. /**
  123049. * Starts all particle systems of the set
  123050. * @param emitter defines an optional mesh to use as emitter for the particle systems
  123051. */
  123052. start(emitter?: AbstractMesh): void;
  123053. /**
  123054. * Release all associated resources
  123055. */
  123056. dispose(): void;
  123057. /**
  123058. * Serialize the set into a JSON compatible object
  123059. * @returns a JSON compatible representation of the set
  123060. */
  123061. serialize(): any;
  123062. /**
  123063. * Parse a new ParticleSystemSet from a serialized source
  123064. * @param data defines a JSON compatible representation of the set
  123065. * @param scene defines the hosting scene
  123066. * @param gpu defines if we want GPU particles or CPU particles
  123067. * @returns a new ParticleSystemSet
  123068. */
  123069. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  123070. }
  123071. }
  123072. declare module BABYLON {
  123073. /**
  123074. * This class is made for on one-liner static method to help creating particle system set.
  123075. */
  123076. export class ParticleHelper {
  123077. /**
  123078. * Gets or sets base Assets URL
  123079. */
  123080. static BaseAssetsUrl: string;
  123081. /**
  123082. * Create a default particle system that you can tweak
  123083. * @param emitter defines the emitter to use
  123084. * @param capacity defines the system capacity (default is 500 particles)
  123085. * @param scene defines the hosting scene
  123086. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  123087. * @returns the new Particle system
  123088. */
  123089. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  123090. /**
  123091. * This is the main static method (one-liner) of this helper to create different particle systems
  123092. * @param type This string represents the type to the particle system to create
  123093. * @param scene The scene where the particle system should live
  123094. * @param gpu If the system will use gpu
  123095. * @returns the ParticleSystemSet created
  123096. */
  123097. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  123098. /**
  123099. * Static function used to export a particle system to a ParticleSystemSet variable.
  123100. * Please note that the emitter shape is not exported
  123101. * @param systems defines the particle systems to export
  123102. * @returns the created particle system set
  123103. */
  123104. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  123105. }
  123106. }
  123107. declare module BABYLON {
  123108. interface Engine {
  123109. /**
  123110. * Create an effect to use with particle systems.
  123111. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  123112. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  123113. * @param uniformsNames defines a list of attribute names
  123114. * @param samplers defines an array of string used to represent textures
  123115. * @param defines defines the string containing the defines to use to compile the shaders
  123116. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  123117. * @param onCompiled defines a function to call when the effect creation is successful
  123118. * @param onError defines a function to call when the effect creation has failed
  123119. * @returns the new Effect
  123120. */
  123121. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  123122. }
  123123. interface Mesh {
  123124. /**
  123125. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  123126. * @returns an array of IParticleSystem
  123127. */
  123128. getEmittedParticleSystems(): IParticleSystem[];
  123129. /**
  123130. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  123131. * @returns an array of IParticleSystem
  123132. */
  123133. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  123134. }
  123135. /**
  123136. * @hidden
  123137. */
  123138. export var _IDoNeedToBeInTheBuild: number;
  123139. }
  123140. declare module BABYLON {
  123141. interface Scene {
  123142. /** @hidden (Backing field) */
  123143. _physicsEngine: Nullable<IPhysicsEngine>;
  123144. /**
  123145. * Gets the current physics engine
  123146. * @returns a IPhysicsEngine or null if none attached
  123147. */
  123148. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  123149. /**
  123150. * Enables physics to the current scene
  123151. * @param gravity defines the scene's gravity for the physics engine
  123152. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  123153. * @return a boolean indicating if the physics engine was initialized
  123154. */
  123155. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  123156. /**
  123157. * Disables and disposes the physics engine associated with the scene
  123158. */
  123159. disablePhysicsEngine(): void;
  123160. /**
  123161. * Gets a boolean indicating if there is an active physics engine
  123162. * @returns a boolean indicating if there is an active physics engine
  123163. */
  123164. isPhysicsEnabled(): boolean;
  123165. /**
  123166. * Deletes a physics compound impostor
  123167. * @param compound defines the compound to delete
  123168. */
  123169. deleteCompoundImpostor(compound: any): void;
  123170. /**
  123171. * An event triggered when physic simulation is about to be run
  123172. */
  123173. onBeforePhysicsObservable: Observable<Scene>;
  123174. /**
  123175. * An event triggered when physic simulation has been done
  123176. */
  123177. onAfterPhysicsObservable: Observable<Scene>;
  123178. }
  123179. interface AbstractMesh {
  123180. /** @hidden */
  123181. _physicsImpostor: Nullable<PhysicsImpostor>;
  123182. /**
  123183. * Gets or sets impostor used for physic simulation
  123184. * @see http://doc.babylonjs.com/features/physics_engine
  123185. */
  123186. physicsImpostor: Nullable<PhysicsImpostor>;
  123187. /**
  123188. * Gets the current physics impostor
  123189. * @see http://doc.babylonjs.com/features/physics_engine
  123190. * @returns a physics impostor or null
  123191. */
  123192. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  123193. /** Apply a physic impulse to the mesh
  123194. * @param force defines the force to apply
  123195. * @param contactPoint defines where to apply the force
  123196. * @returns the current mesh
  123197. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123198. */
  123199. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  123200. /**
  123201. * Creates a physic joint between two meshes
  123202. * @param otherMesh defines the other mesh to use
  123203. * @param pivot1 defines the pivot to use on this mesh
  123204. * @param pivot2 defines the pivot to use on the other mesh
  123205. * @param options defines additional options (can be plugin dependent)
  123206. * @returns the current mesh
  123207. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  123208. */
  123209. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  123210. /** @hidden */
  123211. _disposePhysicsObserver: Nullable<Observer<Node>>;
  123212. }
  123213. /**
  123214. * Defines the physics engine scene component responsible to manage a physics engine
  123215. */
  123216. export class PhysicsEngineSceneComponent implements ISceneComponent {
  123217. /**
  123218. * The component name helpful to identify the component in the list of scene components.
  123219. */
  123220. readonly name: string;
  123221. /**
  123222. * The scene the component belongs to.
  123223. */
  123224. scene: Scene;
  123225. /**
  123226. * Creates a new instance of the component for the given scene
  123227. * @param scene Defines the scene to register the component in
  123228. */
  123229. constructor(scene: Scene);
  123230. /**
  123231. * Registers the component in a given scene
  123232. */
  123233. register(): void;
  123234. /**
  123235. * Rebuilds the elements related to this component in case of
  123236. * context lost for instance.
  123237. */
  123238. rebuild(): void;
  123239. /**
  123240. * Disposes the component and the associated ressources
  123241. */
  123242. dispose(): void;
  123243. }
  123244. }
  123245. declare module BABYLON {
  123246. /**
  123247. * A helper for physics simulations
  123248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123249. */
  123250. export class PhysicsHelper {
  123251. private _scene;
  123252. private _physicsEngine;
  123253. /**
  123254. * Initializes the Physics helper
  123255. * @param scene Babylon.js scene
  123256. */
  123257. constructor(scene: Scene);
  123258. /**
  123259. * Applies a radial explosion impulse
  123260. * @param origin the origin of the explosion
  123261. * @param radiusOrEventOptions the radius or the options of radial explosion
  123262. * @param strength the explosion strength
  123263. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123264. * @returns A physics radial explosion event, or null
  123265. */
  123266. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123267. /**
  123268. * Applies a radial explosion force
  123269. * @param origin the origin of the explosion
  123270. * @param radiusOrEventOptions the radius or the options of radial explosion
  123271. * @param strength the explosion strength
  123272. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123273. * @returns A physics radial explosion event, or null
  123274. */
  123275. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123276. /**
  123277. * Creates a gravitational field
  123278. * @param origin the origin of the explosion
  123279. * @param radiusOrEventOptions the radius or the options of radial explosion
  123280. * @param strength the explosion strength
  123281. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123282. * @returns A physics gravitational field event, or null
  123283. */
  123284. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  123285. /**
  123286. * Creates a physics updraft event
  123287. * @param origin the origin of the updraft
  123288. * @param radiusOrEventOptions the radius or the options of the updraft
  123289. * @param strength the strength of the updraft
  123290. * @param height the height of the updraft
  123291. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  123292. * @returns A physics updraft event, or null
  123293. */
  123294. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  123295. /**
  123296. * Creates a physics vortex event
  123297. * @param origin the of the vortex
  123298. * @param radiusOrEventOptions the radius or the options of the vortex
  123299. * @param strength the strength of the vortex
  123300. * @param height the height of the vortex
  123301. * @returns a Physics vortex event, or null
  123302. * A physics vortex event or null
  123303. */
  123304. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  123305. }
  123306. /**
  123307. * Represents a physics radial explosion event
  123308. */
  123309. class PhysicsRadialExplosionEvent {
  123310. private _scene;
  123311. private _options;
  123312. private _sphere;
  123313. private _dataFetched;
  123314. /**
  123315. * Initializes a radial explosioin event
  123316. * @param _scene BabylonJS scene
  123317. * @param _options The options for the vortex event
  123318. */
  123319. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  123320. /**
  123321. * Returns the data related to the radial explosion event (sphere).
  123322. * @returns The radial explosion event data
  123323. */
  123324. getData(): PhysicsRadialExplosionEventData;
  123325. /**
  123326. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  123327. * @param impostor A physics imposter
  123328. * @param origin the origin of the explosion
  123329. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  123330. */
  123331. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  123332. /**
  123333. * Triggers affecterd impostors callbacks
  123334. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  123335. */
  123336. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  123337. /**
  123338. * Disposes the sphere.
  123339. * @param force Specifies if the sphere should be disposed by force
  123340. */
  123341. dispose(force?: boolean): void;
  123342. /*** Helpers ***/
  123343. private _prepareSphere;
  123344. private _intersectsWithSphere;
  123345. }
  123346. /**
  123347. * Represents a gravitational field event
  123348. */
  123349. class PhysicsGravitationalFieldEvent {
  123350. private _physicsHelper;
  123351. private _scene;
  123352. private _origin;
  123353. private _options;
  123354. private _tickCallback;
  123355. private _sphere;
  123356. private _dataFetched;
  123357. /**
  123358. * Initializes the physics gravitational field event
  123359. * @param _physicsHelper A physics helper
  123360. * @param _scene BabylonJS scene
  123361. * @param _origin The origin position of the gravitational field event
  123362. * @param _options The options for the vortex event
  123363. */
  123364. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  123365. /**
  123366. * Returns the data related to the gravitational field event (sphere).
  123367. * @returns A gravitational field event
  123368. */
  123369. getData(): PhysicsGravitationalFieldEventData;
  123370. /**
  123371. * Enables the gravitational field.
  123372. */
  123373. enable(): void;
  123374. /**
  123375. * Disables the gravitational field.
  123376. */
  123377. disable(): void;
  123378. /**
  123379. * Disposes the sphere.
  123380. * @param force The force to dispose from the gravitational field event
  123381. */
  123382. dispose(force?: boolean): void;
  123383. private _tick;
  123384. }
  123385. /**
  123386. * Represents a physics updraft event
  123387. */
  123388. class PhysicsUpdraftEvent {
  123389. private _scene;
  123390. private _origin;
  123391. private _options;
  123392. private _physicsEngine;
  123393. private _originTop;
  123394. private _originDirection;
  123395. private _tickCallback;
  123396. private _cylinder;
  123397. private _cylinderPosition;
  123398. private _dataFetched;
  123399. /**
  123400. * Initializes the physics updraft event
  123401. * @param _scene BabylonJS scene
  123402. * @param _origin The origin position of the updraft
  123403. * @param _options The options for the updraft event
  123404. */
  123405. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  123406. /**
  123407. * Returns the data related to the updraft event (cylinder).
  123408. * @returns A physics updraft event
  123409. */
  123410. getData(): PhysicsUpdraftEventData;
  123411. /**
  123412. * Enables the updraft.
  123413. */
  123414. enable(): void;
  123415. /**
  123416. * Disables the updraft.
  123417. */
  123418. disable(): void;
  123419. /**
  123420. * Disposes the cylinder.
  123421. * @param force Specifies if the updraft should be disposed by force
  123422. */
  123423. dispose(force?: boolean): void;
  123424. private getImpostorHitData;
  123425. private _tick;
  123426. /*** Helpers ***/
  123427. private _prepareCylinder;
  123428. private _intersectsWithCylinder;
  123429. }
  123430. /**
  123431. * Represents a physics vortex event
  123432. */
  123433. class PhysicsVortexEvent {
  123434. private _scene;
  123435. private _origin;
  123436. private _options;
  123437. private _physicsEngine;
  123438. private _originTop;
  123439. private _tickCallback;
  123440. private _cylinder;
  123441. private _cylinderPosition;
  123442. private _dataFetched;
  123443. /**
  123444. * Initializes the physics vortex event
  123445. * @param _scene The BabylonJS scene
  123446. * @param _origin The origin position of the vortex
  123447. * @param _options The options for the vortex event
  123448. */
  123449. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  123450. /**
  123451. * Returns the data related to the vortex event (cylinder).
  123452. * @returns The physics vortex event data
  123453. */
  123454. getData(): PhysicsVortexEventData;
  123455. /**
  123456. * Enables the vortex.
  123457. */
  123458. enable(): void;
  123459. /**
  123460. * Disables the cortex.
  123461. */
  123462. disable(): void;
  123463. /**
  123464. * Disposes the sphere.
  123465. * @param force
  123466. */
  123467. dispose(force?: boolean): void;
  123468. private getImpostorHitData;
  123469. private _tick;
  123470. /*** Helpers ***/
  123471. private _prepareCylinder;
  123472. private _intersectsWithCylinder;
  123473. }
  123474. /**
  123475. * Options fot the radial explosion event
  123476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123477. */
  123478. export class PhysicsRadialExplosionEventOptions {
  123479. /**
  123480. * The radius of the sphere for the radial explosion.
  123481. */
  123482. radius: number;
  123483. /**
  123484. * The strenth of the explosion.
  123485. */
  123486. strength: number;
  123487. /**
  123488. * The strenght of the force in correspondence to the distance of the affected object
  123489. */
  123490. falloff: PhysicsRadialImpulseFalloff;
  123491. /**
  123492. * Sphere options for the radial explosion.
  123493. */
  123494. sphere: {
  123495. segments: number;
  123496. diameter: number;
  123497. };
  123498. /**
  123499. * Sphere options for the radial explosion.
  123500. */
  123501. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  123502. }
  123503. /**
  123504. * Options fot the updraft event
  123505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123506. */
  123507. export class PhysicsUpdraftEventOptions {
  123508. /**
  123509. * The radius of the cylinder for the vortex
  123510. */
  123511. radius: number;
  123512. /**
  123513. * The strenth of the updraft.
  123514. */
  123515. strength: number;
  123516. /**
  123517. * The height of the cylinder for the updraft.
  123518. */
  123519. height: number;
  123520. /**
  123521. * The mode for the the updraft.
  123522. */
  123523. updraftMode: PhysicsUpdraftMode;
  123524. }
  123525. /**
  123526. * Options fot the vortex event
  123527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123528. */
  123529. export class PhysicsVortexEventOptions {
  123530. /**
  123531. * The radius of the cylinder for the vortex
  123532. */
  123533. radius: number;
  123534. /**
  123535. * The strenth of the vortex.
  123536. */
  123537. strength: number;
  123538. /**
  123539. * The height of the cylinder for the vortex.
  123540. */
  123541. height: number;
  123542. /**
  123543. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  123544. */
  123545. centripetalForceThreshold: number;
  123546. /**
  123547. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  123548. */
  123549. centripetalForceMultiplier: number;
  123550. /**
  123551. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  123552. */
  123553. centrifugalForceMultiplier: number;
  123554. /**
  123555. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  123556. */
  123557. updraftForceMultiplier: number;
  123558. }
  123559. /**
  123560. * The strenght of the force in correspondence to the distance of the affected object
  123561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123562. */
  123563. export enum PhysicsRadialImpulseFalloff {
  123564. /** Defines that impulse is constant in strength across it's whole radius */
  123565. Constant = 0,
  123566. /** Defines that impulse gets weaker if it's further from the origin */
  123567. Linear = 1
  123568. }
  123569. /**
  123570. * The strength of the force in correspondence to the distance of the affected object
  123571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123572. */
  123573. export enum PhysicsUpdraftMode {
  123574. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  123575. Center = 0,
  123576. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123577. Perpendicular = 1
  123578. }
  123579. /**
  123580. * Interface for a physics hit data
  123581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123582. */
  123583. export interface PhysicsHitData {
  123584. /**
  123585. * The force applied at the contact point
  123586. */
  123587. force: Vector3;
  123588. /**
  123589. * The contact point
  123590. */
  123591. contactPoint: Vector3;
  123592. /**
  123593. * The distance from the origin to the contact point
  123594. */
  123595. distanceFromOrigin: number;
  123596. }
  123597. /**
  123598. * Interface for radial explosion event data
  123599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123600. */
  123601. export interface PhysicsRadialExplosionEventData {
  123602. /**
  123603. * A sphere used for the radial explosion event
  123604. */
  123605. sphere: Mesh;
  123606. }
  123607. /**
  123608. * Interface for gravitational field event data
  123609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123610. */
  123611. export interface PhysicsGravitationalFieldEventData {
  123612. /**
  123613. * A sphere mesh used for the gravitational field event
  123614. */
  123615. sphere: Mesh;
  123616. }
  123617. /**
  123618. * Interface for updraft event data
  123619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123620. */
  123621. export interface PhysicsUpdraftEventData {
  123622. /**
  123623. * A cylinder used for the updraft event
  123624. */
  123625. cylinder: Mesh;
  123626. }
  123627. /**
  123628. * Interface for vortex event data
  123629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123630. */
  123631. export interface PhysicsVortexEventData {
  123632. /**
  123633. * A cylinder used for the vortex event
  123634. */
  123635. cylinder: Mesh;
  123636. }
  123637. /**
  123638. * Interface for an affected physics impostor
  123639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123640. */
  123641. export interface PhysicsAffectedImpostorWithData {
  123642. /**
  123643. * The impostor affected by the effect
  123644. */
  123645. impostor: PhysicsImpostor;
  123646. /**
  123647. * The data about the hit/horce from the explosion
  123648. */
  123649. hitData: PhysicsHitData;
  123650. }
  123651. }
  123652. declare module BABYLON {
  123653. /** @hidden */
  123654. export var blackAndWhitePixelShader: {
  123655. name: string;
  123656. shader: string;
  123657. };
  123658. }
  123659. declare module BABYLON {
  123660. /**
  123661. * Post process used to render in black and white
  123662. */
  123663. export class BlackAndWhitePostProcess extends PostProcess {
  123664. /**
  123665. * Linear about to convert he result to black and white (default: 1)
  123666. */
  123667. degree: number;
  123668. /**
  123669. * Creates a black and white post process
  123670. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123671. * @param name The name of the effect.
  123672. * @param options The required width/height ratio to downsize to before computing the render pass.
  123673. * @param camera The camera to apply the render pass to.
  123674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123675. * @param engine The engine which the post process will be applied. (default: current engine)
  123676. * @param reusable If the post process can be reused on the same frame. (default: false)
  123677. */
  123678. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123679. }
  123680. }
  123681. declare module BABYLON {
  123682. /**
  123683. * This represents a set of one or more post processes in Babylon.
  123684. * A post process can be used to apply a shader to a texture after it is rendered.
  123685. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123686. */
  123687. export class PostProcessRenderEffect {
  123688. private _postProcesses;
  123689. private _getPostProcesses;
  123690. private _singleInstance;
  123691. private _cameras;
  123692. private _indicesForCamera;
  123693. /**
  123694. * Name of the effect
  123695. * @hidden
  123696. */
  123697. _name: string;
  123698. /**
  123699. * Instantiates a post process render effect.
  123700. * A post process can be used to apply a shader to a texture after it is rendered.
  123701. * @param engine The engine the effect is tied to
  123702. * @param name The name of the effect
  123703. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123704. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123705. */
  123706. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123707. /**
  123708. * Checks if all the post processes in the effect are supported.
  123709. */
  123710. readonly isSupported: boolean;
  123711. /**
  123712. * Updates the current state of the effect
  123713. * @hidden
  123714. */
  123715. _update(): void;
  123716. /**
  123717. * Attaches the effect on cameras
  123718. * @param cameras The camera to attach to.
  123719. * @hidden
  123720. */
  123721. _attachCameras(cameras: Camera): void;
  123722. /**
  123723. * Attaches the effect on cameras
  123724. * @param cameras The camera to attach to.
  123725. * @hidden
  123726. */
  123727. _attachCameras(cameras: Camera[]): void;
  123728. /**
  123729. * Detaches the effect on cameras
  123730. * @param cameras The camera to detatch from.
  123731. * @hidden
  123732. */
  123733. _detachCameras(cameras: Camera): void;
  123734. /**
  123735. * Detatches the effect on cameras
  123736. * @param cameras The camera to detatch from.
  123737. * @hidden
  123738. */
  123739. _detachCameras(cameras: Camera[]): void;
  123740. /**
  123741. * Enables the effect on given cameras
  123742. * @param cameras The camera to enable.
  123743. * @hidden
  123744. */
  123745. _enable(cameras: Camera): void;
  123746. /**
  123747. * Enables the effect on given cameras
  123748. * @param cameras The camera to enable.
  123749. * @hidden
  123750. */
  123751. _enable(cameras: Nullable<Camera[]>): void;
  123752. /**
  123753. * Disables the effect on the given cameras
  123754. * @param cameras The camera to disable.
  123755. * @hidden
  123756. */
  123757. _disable(cameras: Camera): void;
  123758. /**
  123759. * Disables the effect on the given cameras
  123760. * @param cameras The camera to disable.
  123761. * @hidden
  123762. */
  123763. _disable(cameras: Nullable<Camera[]>): void;
  123764. /**
  123765. * Gets a list of the post processes contained in the effect.
  123766. * @param camera The camera to get the post processes on.
  123767. * @returns The list of the post processes in the effect.
  123768. */
  123769. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123770. }
  123771. }
  123772. declare module BABYLON {
  123773. /** @hidden */
  123774. export var extractHighlightsPixelShader: {
  123775. name: string;
  123776. shader: string;
  123777. };
  123778. }
  123779. declare module BABYLON {
  123780. /**
  123781. * 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.
  123782. */
  123783. export class ExtractHighlightsPostProcess extends PostProcess {
  123784. /**
  123785. * The luminance threshold, pixels below this value will be set to black.
  123786. */
  123787. threshold: number;
  123788. /** @hidden */
  123789. _exposure: number;
  123790. /**
  123791. * Post process which has the input texture to be used when performing highlight extraction
  123792. * @hidden
  123793. */
  123794. _inputPostProcess: Nullable<PostProcess>;
  123795. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123796. }
  123797. }
  123798. declare module BABYLON {
  123799. /** @hidden */
  123800. export var bloomMergePixelShader: {
  123801. name: string;
  123802. shader: string;
  123803. };
  123804. }
  123805. declare module BABYLON {
  123806. /**
  123807. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123808. */
  123809. export class BloomMergePostProcess extends PostProcess {
  123810. /** Weight of the bloom to be added to the original input. */
  123811. weight: number;
  123812. /**
  123813. * Creates a new instance of @see BloomMergePostProcess
  123814. * @param name The name of the effect.
  123815. * @param originalFromInput Post process which's input will be used for the merge.
  123816. * @param blurred Blurred highlights post process which's output will be used.
  123817. * @param weight Weight of the bloom to be added to the original input.
  123818. * @param options The required width/height ratio to downsize to before computing the render pass.
  123819. * @param camera The camera to apply the render pass to.
  123820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123821. * @param engine The engine which the post process will be applied. (default: current engine)
  123822. * @param reusable If the post process can be reused on the same frame. (default: false)
  123823. * @param textureType Type of textures used when performing the post process. (default: 0)
  123824. * @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)
  123825. */
  123826. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  123827. /** Weight of the bloom to be added to the original input. */
  123828. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123829. }
  123830. }
  123831. declare module BABYLON {
  123832. /**
  123833. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  123834. */
  123835. export class BloomEffect extends PostProcessRenderEffect {
  123836. private bloomScale;
  123837. /**
  123838. * @hidden Internal
  123839. */
  123840. _effects: Array<PostProcess>;
  123841. /**
  123842. * @hidden Internal
  123843. */
  123844. _downscale: ExtractHighlightsPostProcess;
  123845. private _blurX;
  123846. private _blurY;
  123847. private _merge;
  123848. /**
  123849. * The luminance threshold to find bright areas of the image to bloom.
  123850. */
  123851. threshold: number;
  123852. /**
  123853. * The strength of the bloom.
  123854. */
  123855. weight: number;
  123856. /**
  123857. * Specifies the size of the bloom blur kernel, relative to the final output size
  123858. */
  123859. kernel: number;
  123860. /**
  123861. * Creates a new instance of @see BloomEffect
  123862. * @param scene The scene the effect belongs to.
  123863. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  123864. * @param bloomKernel The size of the kernel to be used when applying the blur.
  123865. * @param bloomWeight The the strength of bloom.
  123866. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123867. * @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)
  123868. */
  123869. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  123870. /**
  123871. * Disposes each of the internal effects for a given camera.
  123872. * @param camera The camera to dispose the effect on.
  123873. */
  123874. disposeEffects(camera: Camera): void;
  123875. /**
  123876. * @hidden Internal
  123877. */
  123878. _updateEffects(): void;
  123879. /**
  123880. * Internal
  123881. * @returns if all the contained post processes are ready.
  123882. * @hidden
  123883. */
  123884. _isReady(): boolean;
  123885. }
  123886. }
  123887. declare module BABYLON {
  123888. /** @hidden */
  123889. export var chromaticAberrationPixelShader: {
  123890. name: string;
  123891. shader: string;
  123892. };
  123893. }
  123894. declare module BABYLON {
  123895. /**
  123896. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  123897. */
  123898. export class ChromaticAberrationPostProcess extends PostProcess {
  123899. /**
  123900. * The amount of seperation of rgb channels (default: 30)
  123901. */
  123902. aberrationAmount: number;
  123903. /**
  123904. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  123905. */
  123906. radialIntensity: number;
  123907. /**
  123908. * 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))
  123909. */
  123910. direction: Vector2;
  123911. /**
  123912. * 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))
  123913. */
  123914. centerPosition: Vector2;
  123915. /**
  123916. * Creates a new instance ChromaticAberrationPostProcess
  123917. * @param name The name of the effect.
  123918. * @param screenWidth The width of the screen to apply the effect on.
  123919. * @param screenHeight The height of the screen to apply the effect on.
  123920. * @param options The required width/height ratio to downsize to before computing the render pass.
  123921. * @param camera The camera to apply the render pass to.
  123922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123923. * @param engine The engine which the post process will be applied. (default: current engine)
  123924. * @param reusable If the post process can be reused on the same frame. (default: false)
  123925. * @param textureType Type of textures used when performing the post process. (default: 0)
  123926. * @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)
  123927. */
  123928. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123929. }
  123930. }
  123931. declare module BABYLON {
  123932. /** @hidden */
  123933. export var circleOfConfusionPixelShader: {
  123934. name: string;
  123935. shader: string;
  123936. };
  123937. }
  123938. declare module BABYLON {
  123939. /**
  123940. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  123941. */
  123942. export class CircleOfConfusionPostProcess extends PostProcess {
  123943. /**
  123944. * 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.
  123945. */
  123946. lensSize: number;
  123947. /**
  123948. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123949. */
  123950. fStop: number;
  123951. /**
  123952. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123953. */
  123954. focusDistance: number;
  123955. /**
  123956. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  123957. */
  123958. focalLength: number;
  123959. private _depthTexture;
  123960. /**
  123961. * Creates a new instance CircleOfConfusionPostProcess
  123962. * @param name The name of the effect.
  123963. * @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.
  123964. * @param options The required width/height ratio to downsize to before computing the render pass.
  123965. * @param camera The camera to apply the render pass to.
  123966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123967. * @param engine The engine which the post process will be applied. (default: current engine)
  123968. * @param reusable If the post process can be reused on the same frame. (default: false)
  123969. * @param textureType Type of textures used when performing the post process. (default: 0)
  123970. * @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)
  123971. */
  123972. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123973. /**
  123974. * 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.
  123975. */
  123976. depthTexture: RenderTargetTexture;
  123977. }
  123978. }
  123979. declare module BABYLON {
  123980. /** @hidden */
  123981. export var colorCorrectionPixelShader: {
  123982. name: string;
  123983. shader: string;
  123984. };
  123985. }
  123986. declare module BABYLON {
  123987. /**
  123988. *
  123989. * This post-process allows the modification of rendered colors by using
  123990. * a 'look-up table' (LUT). This effect is also called Color Grading.
  123991. *
  123992. * The object needs to be provided an url to a texture containing the color
  123993. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  123994. * Use an image editing software to tweak the LUT to match your needs.
  123995. *
  123996. * For an example of a color LUT, see here:
  123997. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  123998. * For explanations on color grading, see here:
  123999. * @see http://udn.epicgames.com/Three/ColorGrading.html
  124000. *
  124001. */
  124002. export class ColorCorrectionPostProcess extends PostProcess {
  124003. private _colorTableTexture;
  124004. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124005. }
  124006. }
  124007. declare module BABYLON {
  124008. /** @hidden */
  124009. export var convolutionPixelShader: {
  124010. name: string;
  124011. shader: string;
  124012. };
  124013. }
  124014. declare module BABYLON {
  124015. /**
  124016. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  124017. * input texture to perform effects such as edge detection or sharpening
  124018. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124019. */
  124020. export class ConvolutionPostProcess extends PostProcess {
  124021. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124022. kernel: number[];
  124023. /**
  124024. * Creates a new instance ConvolutionPostProcess
  124025. * @param name The name of the effect.
  124026. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  124027. * @param options The required width/height ratio to downsize to before computing the render pass.
  124028. * @param camera The camera to apply the render pass to.
  124029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124030. * @param engine The engine which the post process will be applied. (default: current engine)
  124031. * @param reusable If the post process can be reused on the same frame. (default: false)
  124032. * @param textureType Type of textures used when performing the post process. (default: 0)
  124033. */
  124034. constructor(name: string,
  124035. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124036. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124037. /**
  124038. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124039. */
  124040. static EdgeDetect0Kernel: number[];
  124041. /**
  124042. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124043. */
  124044. static EdgeDetect1Kernel: number[];
  124045. /**
  124046. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124047. */
  124048. static EdgeDetect2Kernel: number[];
  124049. /**
  124050. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124051. */
  124052. static SharpenKernel: number[];
  124053. /**
  124054. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124055. */
  124056. static EmbossKernel: number[];
  124057. /**
  124058. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124059. */
  124060. static GaussianKernel: number[];
  124061. }
  124062. }
  124063. declare module BABYLON {
  124064. /**
  124065. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  124066. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  124067. * based on samples that have a large difference in distance than the center pixel.
  124068. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  124069. */
  124070. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  124071. direction: Vector2;
  124072. /**
  124073. * Creates a new instance CircleOfConfusionPostProcess
  124074. * @param name The name of the effect.
  124075. * @param scene The scene the effect belongs to.
  124076. * @param direction The direction the blur should be applied.
  124077. * @param kernel The size of the kernel used to blur.
  124078. * @param options The required width/height ratio to downsize to before computing the render pass.
  124079. * @param camera The camera to apply the render pass to.
  124080. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  124081. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  124082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124083. * @param engine The engine which the post process will be applied. (default: current engine)
  124084. * @param reusable If the post process can be reused on the same frame. (default: false)
  124085. * @param textureType Type of textures used when performing the post process. (default: 0)
  124086. * @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)
  124087. */
  124088. 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);
  124089. }
  124090. }
  124091. declare module BABYLON {
  124092. /** @hidden */
  124093. export var depthOfFieldMergePixelShader: {
  124094. name: string;
  124095. shader: string;
  124096. };
  124097. }
  124098. declare module BABYLON {
  124099. /**
  124100. * Options to be set when merging outputs from the default pipeline.
  124101. */
  124102. export class DepthOfFieldMergePostProcessOptions {
  124103. /**
  124104. * The original image to merge on top of
  124105. */
  124106. originalFromInput: PostProcess;
  124107. /**
  124108. * Parameters to perform the merge of the depth of field effect
  124109. */
  124110. depthOfField?: {
  124111. circleOfConfusion: PostProcess;
  124112. blurSteps: Array<PostProcess>;
  124113. };
  124114. /**
  124115. * Parameters to perform the merge of bloom effect
  124116. */
  124117. bloom?: {
  124118. blurred: PostProcess;
  124119. weight: number;
  124120. };
  124121. }
  124122. /**
  124123. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124124. */
  124125. export class DepthOfFieldMergePostProcess extends PostProcess {
  124126. private blurSteps;
  124127. /**
  124128. * Creates a new instance of DepthOfFieldMergePostProcess
  124129. * @param name The name of the effect.
  124130. * @param originalFromInput Post process which's input will be used for the merge.
  124131. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  124132. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  124133. * @param options The required width/height ratio to downsize to before computing the render pass.
  124134. * @param camera The camera to apply the render pass to.
  124135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124136. * @param engine The engine which the post process will be applied. (default: current engine)
  124137. * @param reusable If the post process can be reused on the same frame. (default: false)
  124138. * @param textureType Type of textures used when performing the post process. (default: 0)
  124139. * @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)
  124140. */
  124141. 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);
  124142. /**
  124143. * Updates the effect with the current post process compile time values and recompiles the shader.
  124144. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124145. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124146. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124147. * @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
  124148. * @param onCompiled Called when the shader has been compiled.
  124149. * @param onError Called if there is an error when compiling a shader.
  124150. */
  124151. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  124152. }
  124153. }
  124154. declare module BABYLON {
  124155. /**
  124156. * Specifies the level of max blur that should be applied when using the depth of field effect
  124157. */
  124158. export enum DepthOfFieldEffectBlurLevel {
  124159. /**
  124160. * Subtle blur
  124161. */
  124162. Low = 0,
  124163. /**
  124164. * Medium blur
  124165. */
  124166. Medium = 1,
  124167. /**
  124168. * Large blur
  124169. */
  124170. High = 2
  124171. }
  124172. /**
  124173. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  124174. */
  124175. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  124176. private _circleOfConfusion;
  124177. /**
  124178. * @hidden Internal, blurs from high to low
  124179. */
  124180. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  124181. private _depthOfFieldBlurY;
  124182. private _dofMerge;
  124183. /**
  124184. * @hidden Internal post processes in depth of field effect
  124185. */
  124186. _effects: Array<PostProcess>;
  124187. /**
  124188. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  124189. */
  124190. focalLength: number;
  124191. /**
  124192. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124193. */
  124194. fStop: number;
  124195. /**
  124196. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124197. */
  124198. focusDistance: number;
  124199. /**
  124200. * 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.
  124201. */
  124202. lensSize: number;
  124203. /**
  124204. * Creates a new instance DepthOfFieldEffect
  124205. * @param scene The scene the effect belongs to.
  124206. * @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.
  124207. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124208. * @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)
  124209. */
  124210. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  124211. /**
  124212. * Get the current class name of the current effet
  124213. * @returns "DepthOfFieldEffect"
  124214. */
  124215. getClassName(): string;
  124216. /**
  124217. * 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.
  124218. */
  124219. depthTexture: RenderTargetTexture;
  124220. /**
  124221. * Disposes each of the internal effects for a given camera.
  124222. * @param camera The camera to dispose the effect on.
  124223. */
  124224. disposeEffects(camera: Camera): void;
  124225. /**
  124226. * @hidden Internal
  124227. */
  124228. _updateEffects(): void;
  124229. /**
  124230. * Internal
  124231. * @returns if all the contained post processes are ready.
  124232. * @hidden
  124233. */
  124234. _isReady(): boolean;
  124235. }
  124236. }
  124237. declare module BABYLON {
  124238. /** @hidden */
  124239. export var displayPassPixelShader: {
  124240. name: string;
  124241. shader: string;
  124242. };
  124243. }
  124244. declare module BABYLON {
  124245. /**
  124246. * DisplayPassPostProcess which produces an output the same as it's input
  124247. */
  124248. export class DisplayPassPostProcess extends PostProcess {
  124249. /**
  124250. * Creates the DisplayPassPostProcess
  124251. * @param name The name of the effect.
  124252. * @param options The required width/height ratio to downsize to before computing the render pass.
  124253. * @param camera The camera to apply the render pass to.
  124254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124255. * @param engine The engine which the post process will be applied. (default: current engine)
  124256. * @param reusable If the post process can be reused on the same frame. (default: false)
  124257. */
  124258. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124259. }
  124260. }
  124261. declare module BABYLON {
  124262. /** @hidden */
  124263. export var filterPixelShader: {
  124264. name: string;
  124265. shader: string;
  124266. };
  124267. }
  124268. declare module BABYLON {
  124269. /**
  124270. * Applies a kernel filter to the image
  124271. */
  124272. export class FilterPostProcess extends PostProcess {
  124273. /** The matrix to be applied to the image */
  124274. kernelMatrix: Matrix;
  124275. /**
  124276. *
  124277. * @param name The name of the effect.
  124278. * @param kernelMatrix The matrix to be applied to the image
  124279. * @param options The required width/height ratio to downsize to before computing the render pass.
  124280. * @param camera The camera to apply the render pass to.
  124281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124282. * @param engine The engine which the post process will be applied. (default: current engine)
  124283. * @param reusable If the post process can be reused on the same frame. (default: false)
  124284. */
  124285. constructor(name: string,
  124286. /** The matrix to be applied to the image */
  124287. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124288. }
  124289. }
  124290. declare module BABYLON {
  124291. /** @hidden */
  124292. export var fxaaPixelShader: {
  124293. name: string;
  124294. shader: string;
  124295. };
  124296. }
  124297. declare module BABYLON {
  124298. /** @hidden */
  124299. export var fxaaVertexShader: {
  124300. name: string;
  124301. shader: string;
  124302. };
  124303. }
  124304. declare module BABYLON {
  124305. /**
  124306. * Fxaa post process
  124307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  124308. */
  124309. export class FxaaPostProcess extends PostProcess {
  124310. /** @hidden */
  124311. texelWidth: number;
  124312. /** @hidden */
  124313. texelHeight: number;
  124314. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124315. private _getDefines;
  124316. }
  124317. }
  124318. declare module BABYLON {
  124319. /** @hidden */
  124320. export var grainPixelShader: {
  124321. name: string;
  124322. shader: string;
  124323. };
  124324. }
  124325. declare module BABYLON {
  124326. /**
  124327. * The GrainPostProcess adds noise to the image at mid luminance levels
  124328. */
  124329. export class GrainPostProcess extends PostProcess {
  124330. /**
  124331. * The intensity of the grain added (default: 30)
  124332. */
  124333. intensity: number;
  124334. /**
  124335. * If the grain should be randomized on every frame
  124336. */
  124337. animated: boolean;
  124338. /**
  124339. * Creates a new instance of @see GrainPostProcess
  124340. * @param name The name of the effect.
  124341. * @param options The required width/height ratio to downsize to before computing the render pass.
  124342. * @param camera The camera to apply the render pass to.
  124343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124344. * @param engine The engine which the post process will be applied. (default: current engine)
  124345. * @param reusable If the post process can be reused on the same frame. (default: false)
  124346. * @param textureType Type of textures used when performing the post process. (default: 0)
  124347. * @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)
  124348. */
  124349. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124350. }
  124351. }
  124352. declare module BABYLON {
  124353. /** @hidden */
  124354. export var highlightsPixelShader: {
  124355. name: string;
  124356. shader: string;
  124357. };
  124358. }
  124359. declare module BABYLON {
  124360. /**
  124361. * Extracts highlights from the image
  124362. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124363. */
  124364. export class HighlightsPostProcess extends PostProcess {
  124365. /**
  124366. * Extracts highlights from the image
  124367. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124368. * @param name The name of the effect.
  124369. * @param options The required width/height ratio to downsize to before computing the render pass.
  124370. * @param camera The camera to apply the render pass to.
  124371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124372. * @param engine The engine which the post process will be applied. (default: current engine)
  124373. * @param reusable If the post process can be reused on the same frame. (default: false)
  124374. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124375. */
  124376. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124377. }
  124378. }
  124379. declare module BABYLON {
  124380. /** @hidden */
  124381. export var mrtFragmentDeclaration: {
  124382. name: string;
  124383. shader: string;
  124384. };
  124385. }
  124386. declare module BABYLON {
  124387. /** @hidden */
  124388. export var geometryPixelShader: {
  124389. name: string;
  124390. shader: string;
  124391. };
  124392. }
  124393. declare module BABYLON {
  124394. /** @hidden */
  124395. export var geometryVertexShader: {
  124396. name: string;
  124397. shader: string;
  124398. };
  124399. }
  124400. declare module BABYLON {
  124401. /** @hidden */
  124402. interface ISavedTransformationMatrix {
  124403. world: Matrix;
  124404. viewProjection: Matrix;
  124405. }
  124406. /**
  124407. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  124408. */
  124409. export class GeometryBufferRenderer {
  124410. /**
  124411. * Constant used to retrieve the position texture index in the G-Buffer textures array
  124412. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  124413. */
  124414. static readonly POSITION_TEXTURE_TYPE: number;
  124415. /**
  124416. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  124417. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  124418. */
  124419. static readonly VELOCITY_TEXTURE_TYPE: number;
  124420. /**
  124421. * Dictionary used to store the previous transformation matrices of each rendered mesh
  124422. * in order to compute objects velocities when enableVelocity is set to "true"
  124423. * @hidden
  124424. */
  124425. _previousTransformationMatrices: {
  124426. [index: number]: ISavedTransformationMatrix;
  124427. };
  124428. /**
  124429. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  124430. * in order to compute objects velocities when enableVelocity is set to "true"
  124431. * @hidden
  124432. */
  124433. _previousBonesTransformationMatrices: {
  124434. [index: number]: Float32Array;
  124435. };
  124436. /**
  124437. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  124438. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  124439. */
  124440. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  124441. private _scene;
  124442. private _multiRenderTarget;
  124443. private _ratio;
  124444. private _enablePosition;
  124445. private _enableVelocity;
  124446. private _positionIndex;
  124447. private _velocityIndex;
  124448. protected _effect: Effect;
  124449. protected _cachedDefines: string;
  124450. /**
  124451. * Set the render list (meshes to be rendered) used in the G buffer.
  124452. */
  124453. renderList: Mesh[];
  124454. /**
  124455. * Gets wether or not G buffer are supported by the running hardware.
  124456. * This requires draw buffer supports
  124457. */
  124458. readonly isSupported: boolean;
  124459. /**
  124460. * Returns the index of the given texture type in the G-Buffer textures array
  124461. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  124462. * @returns the index of the given texture type in the G-Buffer textures array
  124463. */
  124464. getTextureIndex(textureType: number): number;
  124465. /**
  124466. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  124467. */
  124468. /**
  124469. * Sets whether or not objects positions are enabled for the G buffer.
  124470. */
  124471. enablePosition: boolean;
  124472. /**
  124473. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  124474. */
  124475. /**
  124476. * Sets wether or not objects velocities are enabled for the G buffer.
  124477. */
  124478. enableVelocity: boolean;
  124479. /**
  124480. * Gets the scene associated with the buffer.
  124481. */
  124482. readonly scene: Scene;
  124483. /**
  124484. * Gets the ratio used by the buffer during its creation.
  124485. * How big is the buffer related to the main canvas.
  124486. */
  124487. readonly ratio: number;
  124488. /** @hidden */
  124489. static _SceneComponentInitialization: (scene: Scene) => void;
  124490. /**
  124491. * Creates a new G Buffer for the scene
  124492. * @param scene The scene the buffer belongs to
  124493. * @param ratio How big is the buffer related to the main canvas.
  124494. */
  124495. constructor(scene: Scene, ratio?: number);
  124496. /**
  124497. * Checks wether everything is ready to render a submesh to the G buffer.
  124498. * @param subMesh the submesh to check readiness for
  124499. * @param useInstances is the mesh drawn using instance or not
  124500. * @returns true if ready otherwise false
  124501. */
  124502. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124503. /**
  124504. * Gets the current underlying G Buffer.
  124505. * @returns the buffer
  124506. */
  124507. getGBuffer(): MultiRenderTarget;
  124508. /**
  124509. * Gets the number of samples used to render the buffer (anti aliasing).
  124510. */
  124511. /**
  124512. * Sets the number of samples used to render the buffer (anti aliasing).
  124513. */
  124514. samples: number;
  124515. /**
  124516. * Disposes the renderer and frees up associated resources.
  124517. */
  124518. dispose(): void;
  124519. protected _createRenderTargets(): void;
  124520. private _copyBonesTransformationMatrices;
  124521. }
  124522. }
  124523. declare module BABYLON {
  124524. interface Scene {
  124525. /** @hidden (Backing field) */
  124526. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124527. /**
  124528. * Gets or Sets the current geometry buffer associated to the scene.
  124529. */
  124530. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124531. /**
  124532. * Enables a GeometryBufferRender and associates it with the scene
  124533. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  124534. * @returns the GeometryBufferRenderer
  124535. */
  124536. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  124537. /**
  124538. * Disables the GeometryBufferRender associated with the scene
  124539. */
  124540. disableGeometryBufferRenderer(): void;
  124541. }
  124542. /**
  124543. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  124544. * in several rendering techniques.
  124545. */
  124546. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  124547. /**
  124548. * The component name helpful to identify the component in the list of scene components.
  124549. */
  124550. readonly name: string;
  124551. /**
  124552. * The scene the component belongs to.
  124553. */
  124554. scene: Scene;
  124555. /**
  124556. * Creates a new instance of the component for the given scene
  124557. * @param scene Defines the scene to register the component in
  124558. */
  124559. constructor(scene: Scene);
  124560. /**
  124561. * Registers the component in a given scene
  124562. */
  124563. register(): void;
  124564. /**
  124565. * Rebuilds the elements related to this component in case of
  124566. * context lost for instance.
  124567. */
  124568. rebuild(): void;
  124569. /**
  124570. * Disposes the component and the associated ressources
  124571. */
  124572. dispose(): void;
  124573. private _gatherRenderTargets;
  124574. }
  124575. }
  124576. declare module BABYLON {
  124577. /** @hidden */
  124578. export var motionBlurPixelShader: {
  124579. name: string;
  124580. shader: string;
  124581. };
  124582. }
  124583. declare module BABYLON {
  124584. /**
  124585. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124586. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124587. * As an example, all you have to do is to create the post-process:
  124588. * var mb = new BABYLON.MotionBlurPostProcess(
  124589. * 'mb', // The name of the effect.
  124590. * scene, // The scene containing the objects to blur according to their velocity.
  124591. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124592. * camera // The camera to apply the render pass to.
  124593. * );
  124594. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124595. */
  124596. export class MotionBlurPostProcess extends PostProcess {
  124597. /**
  124598. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124599. */
  124600. motionStrength: number;
  124601. /**
  124602. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124603. */
  124604. /**
  124605. * Sets the number of iterations to be used for motion blur quality
  124606. */
  124607. motionBlurSamples: number;
  124608. private _motionBlurSamples;
  124609. private _geometryBufferRenderer;
  124610. /**
  124611. * Creates a new instance MotionBlurPostProcess
  124612. * @param name The name of the effect.
  124613. * @param scene The scene containing the objects to blur according to their velocity.
  124614. * @param options The required width/height ratio to downsize to before computing the render pass.
  124615. * @param camera The camera to apply the render pass to.
  124616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124617. * @param engine The engine which the post process will be applied. (default: current engine)
  124618. * @param reusable If the post process can be reused on the same frame. (default: false)
  124619. * @param textureType Type of textures used when performing the post process. (default: 0)
  124620. * @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)
  124621. */
  124622. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124623. /**
  124624. * Excludes the given skinned mesh from computing bones velocities.
  124625. * 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.
  124626. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124627. */
  124628. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124629. /**
  124630. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124631. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124632. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124633. */
  124634. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124635. /**
  124636. * Disposes the post process.
  124637. * @param camera The camera to dispose the post process on.
  124638. */
  124639. dispose(camera?: Camera): void;
  124640. }
  124641. }
  124642. declare module BABYLON {
  124643. /** @hidden */
  124644. export var refractionPixelShader: {
  124645. name: string;
  124646. shader: string;
  124647. };
  124648. }
  124649. declare module BABYLON {
  124650. /**
  124651. * Post process which applies a refractin texture
  124652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124653. */
  124654. export class RefractionPostProcess extends PostProcess {
  124655. /** the base color of the refraction (used to taint the rendering) */
  124656. color: Color3;
  124657. /** simulated refraction depth */
  124658. depth: number;
  124659. /** the coefficient of the base color (0 to remove base color tainting) */
  124660. colorLevel: number;
  124661. private _refTexture;
  124662. private _ownRefractionTexture;
  124663. /**
  124664. * Gets or sets the refraction texture
  124665. * Please note that you are responsible for disposing the texture if you set it manually
  124666. */
  124667. refractionTexture: Texture;
  124668. /**
  124669. * Initializes the RefractionPostProcess
  124670. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124671. * @param name The name of the effect.
  124672. * @param refractionTextureUrl Url of the refraction texture to use
  124673. * @param color the base color of the refraction (used to taint the rendering)
  124674. * @param depth simulated refraction depth
  124675. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124676. * @param camera The camera to apply the render pass to.
  124677. * @param options The required width/height ratio to downsize to before computing the render pass.
  124678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124679. * @param engine The engine which the post process will be applied. (default: current engine)
  124680. * @param reusable If the post process can be reused on the same frame. (default: false)
  124681. */
  124682. constructor(name: string, refractionTextureUrl: string,
  124683. /** the base color of the refraction (used to taint the rendering) */
  124684. color: Color3,
  124685. /** simulated refraction depth */
  124686. depth: number,
  124687. /** the coefficient of the base color (0 to remove base color tainting) */
  124688. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124689. /**
  124690. * Disposes of the post process
  124691. * @param camera Camera to dispose post process on
  124692. */
  124693. dispose(camera: Camera): void;
  124694. }
  124695. }
  124696. declare module BABYLON {
  124697. /** @hidden */
  124698. export var sharpenPixelShader: {
  124699. name: string;
  124700. shader: string;
  124701. };
  124702. }
  124703. declare module BABYLON {
  124704. /**
  124705. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124706. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124707. */
  124708. export class SharpenPostProcess extends PostProcess {
  124709. /**
  124710. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124711. */
  124712. colorAmount: number;
  124713. /**
  124714. * How much sharpness should be applied (default: 0.3)
  124715. */
  124716. edgeAmount: number;
  124717. /**
  124718. * Creates a new instance ConvolutionPostProcess
  124719. * @param name The name of the effect.
  124720. * @param options The required width/height ratio to downsize to before computing the render pass.
  124721. * @param camera The camera to apply the render pass to.
  124722. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124723. * @param engine The engine which the post process will be applied. (default: current engine)
  124724. * @param reusable If the post process can be reused on the same frame. (default: false)
  124725. * @param textureType Type of textures used when performing the post process. (default: 0)
  124726. * @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)
  124727. */
  124728. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124729. }
  124730. }
  124731. declare module BABYLON {
  124732. /**
  124733. * PostProcessRenderPipeline
  124734. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124735. */
  124736. export class PostProcessRenderPipeline {
  124737. private engine;
  124738. private _renderEffects;
  124739. private _renderEffectsForIsolatedPass;
  124740. /**
  124741. * List of inspectable custom properties (used by the Inspector)
  124742. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124743. */
  124744. inspectableCustomProperties: IInspectable[];
  124745. /**
  124746. * @hidden
  124747. */
  124748. protected _cameras: Camera[];
  124749. /** @hidden */
  124750. _name: string;
  124751. /**
  124752. * Gets pipeline name
  124753. */
  124754. readonly name: string;
  124755. /**
  124756. * Initializes a PostProcessRenderPipeline
  124757. * @param engine engine to add the pipeline to
  124758. * @param name name of the pipeline
  124759. */
  124760. constructor(engine: Engine, name: string);
  124761. /**
  124762. * Gets the class name
  124763. * @returns "PostProcessRenderPipeline"
  124764. */
  124765. getClassName(): string;
  124766. /**
  124767. * If all the render effects in the pipeline are supported
  124768. */
  124769. readonly isSupported: boolean;
  124770. /**
  124771. * Adds an effect to the pipeline
  124772. * @param renderEffect the effect to add
  124773. */
  124774. addEffect(renderEffect: PostProcessRenderEffect): void;
  124775. /** @hidden */
  124776. _rebuild(): void;
  124777. /** @hidden */
  124778. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124779. /** @hidden */
  124780. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124781. /** @hidden */
  124782. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124783. /** @hidden */
  124784. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124785. /** @hidden */
  124786. _attachCameras(cameras: Camera, unique: boolean): void;
  124787. /** @hidden */
  124788. _attachCameras(cameras: Camera[], unique: boolean): void;
  124789. /** @hidden */
  124790. _detachCameras(cameras: Camera): void;
  124791. /** @hidden */
  124792. _detachCameras(cameras: Nullable<Camera[]>): void;
  124793. /** @hidden */
  124794. _update(): void;
  124795. /** @hidden */
  124796. _reset(): void;
  124797. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124798. /**
  124799. * Disposes of the pipeline
  124800. */
  124801. dispose(): void;
  124802. }
  124803. }
  124804. declare module BABYLON {
  124805. /**
  124806. * PostProcessRenderPipelineManager class
  124807. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124808. */
  124809. export class PostProcessRenderPipelineManager {
  124810. private _renderPipelines;
  124811. /**
  124812. * Initializes a PostProcessRenderPipelineManager
  124813. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124814. */
  124815. constructor();
  124816. /**
  124817. * Gets the list of supported render pipelines
  124818. */
  124819. readonly supportedPipelines: PostProcessRenderPipeline[];
  124820. /**
  124821. * Adds a pipeline to the manager
  124822. * @param renderPipeline The pipeline to add
  124823. */
  124824. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  124825. /**
  124826. * Attaches a camera to the pipeline
  124827. * @param renderPipelineName The name of the pipeline to attach to
  124828. * @param cameras the camera to attach
  124829. * @param unique if the camera can be attached multiple times to the pipeline
  124830. */
  124831. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  124832. /**
  124833. * Detaches a camera from the pipeline
  124834. * @param renderPipelineName The name of the pipeline to detach from
  124835. * @param cameras the camera to detach
  124836. */
  124837. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  124838. /**
  124839. * Enables an effect by name on a pipeline
  124840. * @param renderPipelineName the name of the pipeline to enable the effect in
  124841. * @param renderEffectName the name of the effect to enable
  124842. * @param cameras the cameras that the effect should be enabled on
  124843. */
  124844. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124845. /**
  124846. * Disables an effect by name on a pipeline
  124847. * @param renderPipelineName the name of the pipeline to disable the effect in
  124848. * @param renderEffectName the name of the effect to disable
  124849. * @param cameras the cameras that the effect should be disabled on
  124850. */
  124851. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124852. /**
  124853. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  124854. */
  124855. update(): void;
  124856. /** @hidden */
  124857. _rebuild(): void;
  124858. /**
  124859. * Disposes of the manager and pipelines
  124860. */
  124861. dispose(): void;
  124862. }
  124863. }
  124864. declare module BABYLON {
  124865. interface Scene {
  124866. /** @hidden (Backing field) */
  124867. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124868. /**
  124869. * Gets the postprocess render pipeline manager
  124870. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124871. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124872. */
  124873. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124874. }
  124875. /**
  124876. * Defines the Render Pipeline scene component responsible to rendering pipelines
  124877. */
  124878. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  124879. /**
  124880. * The component name helpfull to identify the component in the list of scene components.
  124881. */
  124882. readonly name: string;
  124883. /**
  124884. * The scene the component belongs to.
  124885. */
  124886. scene: Scene;
  124887. /**
  124888. * Creates a new instance of the component for the given scene
  124889. * @param scene Defines the scene to register the component in
  124890. */
  124891. constructor(scene: Scene);
  124892. /**
  124893. * Registers the component in a given scene
  124894. */
  124895. register(): void;
  124896. /**
  124897. * Rebuilds the elements related to this component in case of
  124898. * context lost for instance.
  124899. */
  124900. rebuild(): void;
  124901. /**
  124902. * Disposes the component and the associated ressources
  124903. */
  124904. dispose(): void;
  124905. private _gatherRenderTargets;
  124906. }
  124907. }
  124908. declare module BABYLON {
  124909. /**
  124910. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  124911. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124912. */
  124913. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  124914. private _scene;
  124915. private _camerasToBeAttached;
  124916. /**
  124917. * ID of the sharpen post process,
  124918. */
  124919. private readonly SharpenPostProcessId;
  124920. /**
  124921. * @ignore
  124922. * ID of the image processing post process;
  124923. */
  124924. readonly ImageProcessingPostProcessId: string;
  124925. /**
  124926. * @ignore
  124927. * ID of the Fast Approximate Anti-Aliasing post process;
  124928. */
  124929. readonly FxaaPostProcessId: string;
  124930. /**
  124931. * ID of the chromatic aberration post process,
  124932. */
  124933. private readonly ChromaticAberrationPostProcessId;
  124934. /**
  124935. * ID of the grain post process
  124936. */
  124937. private readonly GrainPostProcessId;
  124938. /**
  124939. * Sharpen post process which will apply a sharpen convolution to enhance edges
  124940. */
  124941. sharpen: SharpenPostProcess;
  124942. private _sharpenEffect;
  124943. private bloom;
  124944. /**
  124945. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  124946. */
  124947. depthOfField: DepthOfFieldEffect;
  124948. /**
  124949. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124950. */
  124951. fxaa: FxaaPostProcess;
  124952. /**
  124953. * Image post processing pass used to perform operations such as tone mapping or color grading.
  124954. */
  124955. imageProcessing: ImageProcessingPostProcess;
  124956. /**
  124957. * Chromatic aberration post process which will shift rgb colors in the image
  124958. */
  124959. chromaticAberration: ChromaticAberrationPostProcess;
  124960. private _chromaticAberrationEffect;
  124961. /**
  124962. * Grain post process which add noise to the image
  124963. */
  124964. grain: GrainPostProcess;
  124965. private _grainEffect;
  124966. /**
  124967. * Glow post process which adds a glow to emissive areas of the image
  124968. */
  124969. private _glowLayer;
  124970. /**
  124971. * Animations which can be used to tweak settings over a period of time
  124972. */
  124973. animations: Animation[];
  124974. private _imageProcessingConfigurationObserver;
  124975. private _sharpenEnabled;
  124976. private _bloomEnabled;
  124977. private _depthOfFieldEnabled;
  124978. private _depthOfFieldBlurLevel;
  124979. private _fxaaEnabled;
  124980. private _imageProcessingEnabled;
  124981. private _defaultPipelineTextureType;
  124982. private _bloomScale;
  124983. private _chromaticAberrationEnabled;
  124984. private _grainEnabled;
  124985. private _buildAllowed;
  124986. /**
  124987. * Gets active scene
  124988. */
  124989. readonly scene: Scene;
  124990. /**
  124991. * Enable or disable the sharpen process from the pipeline
  124992. */
  124993. sharpenEnabled: boolean;
  124994. private _resizeObserver;
  124995. private _hardwareScaleLevel;
  124996. private _bloomKernel;
  124997. /**
  124998. * Specifies the size of the bloom blur kernel, relative to the final output size
  124999. */
  125000. bloomKernel: number;
  125001. /**
  125002. * Specifies the weight of the bloom in the final rendering
  125003. */
  125004. private _bloomWeight;
  125005. /**
  125006. * Specifies the luma threshold for the area that will be blurred by the bloom
  125007. */
  125008. private _bloomThreshold;
  125009. private _hdr;
  125010. /**
  125011. * The strength of the bloom.
  125012. */
  125013. bloomWeight: number;
  125014. /**
  125015. * The strength of the bloom.
  125016. */
  125017. bloomThreshold: number;
  125018. /**
  125019. * The scale of the bloom, lower value will provide better performance.
  125020. */
  125021. bloomScale: number;
  125022. /**
  125023. * Enable or disable the bloom from the pipeline
  125024. */
  125025. bloomEnabled: boolean;
  125026. private _rebuildBloom;
  125027. /**
  125028. * If the depth of field is enabled.
  125029. */
  125030. depthOfFieldEnabled: boolean;
  125031. /**
  125032. * Blur level of the depth of field effect. (Higher blur will effect performance)
  125033. */
  125034. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  125035. /**
  125036. * If the anti aliasing is enabled.
  125037. */
  125038. fxaaEnabled: boolean;
  125039. private _samples;
  125040. /**
  125041. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125042. */
  125043. samples: number;
  125044. /**
  125045. * If image processing is enabled.
  125046. */
  125047. imageProcessingEnabled: boolean;
  125048. /**
  125049. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  125050. */
  125051. glowLayerEnabled: boolean;
  125052. /**
  125053. * Gets the glow layer (or null if not defined)
  125054. */
  125055. readonly glowLayer: Nullable<GlowLayer>;
  125056. /**
  125057. * Enable or disable the chromaticAberration process from the pipeline
  125058. */
  125059. chromaticAberrationEnabled: boolean;
  125060. /**
  125061. * Enable or disable the grain process from the pipeline
  125062. */
  125063. grainEnabled: boolean;
  125064. /**
  125065. * @constructor
  125066. * @param name - The rendering pipeline name (default: "")
  125067. * @param hdr - If high dynamic range textures should be used (default: true)
  125068. * @param scene - The scene linked to this pipeline (default: the last created scene)
  125069. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  125070. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  125071. */
  125072. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  125073. /**
  125074. * Get the class name
  125075. * @returns "DefaultRenderingPipeline"
  125076. */
  125077. getClassName(): string;
  125078. /**
  125079. * Force the compilation of the entire pipeline.
  125080. */
  125081. prepare(): void;
  125082. private _hasCleared;
  125083. private _prevPostProcess;
  125084. private _prevPrevPostProcess;
  125085. private _setAutoClearAndTextureSharing;
  125086. private _depthOfFieldSceneObserver;
  125087. private _buildPipeline;
  125088. private _disposePostProcesses;
  125089. /**
  125090. * Adds a camera to the pipeline
  125091. * @param camera the camera to be added
  125092. */
  125093. addCamera(camera: Camera): void;
  125094. /**
  125095. * Removes a camera from the pipeline
  125096. * @param camera the camera to remove
  125097. */
  125098. removeCamera(camera: Camera): void;
  125099. /**
  125100. * Dispose of the pipeline and stop all post processes
  125101. */
  125102. dispose(): void;
  125103. /**
  125104. * Serialize the rendering pipeline (Used when exporting)
  125105. * @returns the serialized object
  125106. */
  125107. serialize(): any;
  125108. /**
  125109. * Parse the serialized pipeline
  125110. * @param source Source pipeline.
  125111. * @param scene The scene to load the pipeline to.
  125112. * @param rootUrl The URL of the serialized pipeline.
  125113. * @returns An instantiated pipeline from the serialized object.
  125114. */
  125115. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  125116. }
  125117. }
  125118. declare module BABYLON {
  125119. /** @hidden */
  125120. export var lensHighlightsPixelShader: {
  125121. name: string;
  125122. shader: string;
  125123. };
  125124. }
  125125. declare module BABYLON {
  125126. /** @hidden */
  125127. export var depthOfFieldPixelShader: {
  125128. name: string;
  125129. shader: string;
  125130. };
  125131. }
  125132. declare module BABYLON {
  125133. /**
  125134. * BABYLON.JS Chromatic Aberration GLSL Shader
  125135. * Author: Olivier Guyot
  125136. * Separates very slightly R, G and B colors on the edges of the screen
  125137. * Inspired by Francois Tarlier & Martins Upitis
  125138. */
  125139. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  125140. /**
  125141. * @ignore
  125142. * The chromatic aberration PostProcess id in the pipeline
  125143. */
  125144. LensChromaticAberrationEffect: string;
  125145. /**
  125146. * @ignore
  125147. * The highlights enhancing PostProcess id in the pipeline
  125148. */
  125149. HighlightsEnhancingEffect: string;
  125150. /**
  125151. * @ignore
  125152. * The depth-of-field PostProcess id in the pipeline
  125153. */
  125154. LensDepthOfFieldEffect: string;
  125155. private _scene;
  125156. private _depthTexture;
  125157. private _grainTexture;
  125158. private _chromaticAberrationPostProcess;
  125159. private _highlightsPostProcess;
  125160. private _depthOfFieldPostProcess;
  125161. private _edgeBlur;
  125162. private _grainAmount;
  125163. private _chromaticAberration;
  125164. private _distortion;
  125165. private _highlightsGain;
  125166. private _highlightsThreshold;
  125167. private _dofDistance;
  125168. private _dofAperture;
  125169. private _dofDarken;
  125170. private _dofPentagon;
  125171. private _blurNoise;
  125172. /**
  125173. * @constructor
  125174. *
  125175. * Effect parameters are as follow:
  125176. * {
  125177. * chromatic_aberration: number; // from 0 to x (1 for realism)
  125178. * edge_blur: number; // from 0 to x (1 for realism)
  125179. * distortion: number; // from 0 to x (1 for realism)
  125180. * grain_amount: number; // from 0 to 1
  125181. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  125182. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  125183. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  125184. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  125185. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  125186. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  125187. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  125188. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  125189. * }
  125190. * Note: if an effect parameter is unset, effect is disabled
  125191. *
  125192. * @param name The rendering pipeline name
  125193. * @param parameters - An object containing all parameters (see above)
  125194. * @param scene The scene linked to this pipeline
  125195. * @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)
  125196. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125197. */
  125198. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  125199. /**
  125200. * Get the class name
  125201. * @returns "LensRenderingPipeline"
  125202. */
  125203. getClassName(): string;
  125204. /**
  125205. * Gets associated scene
  125206. */
  125207. readonly scene: Scene;
  125208. /**
  125209. * Gets or sets the edge blur
  125210. */
  125211. edgeBlur: number;
  125212. /**
  125213. * Gets or sets the grain amount
  125214. */
  125215. grainAmount: number;
  125216. /**
  125217. * Gets or sets the chromatic aberration amount
  125218. */
  125219. chromaticAberration: number;
  125220. /**
  125221. * Gets or sets the depth of field aperture
  125222. */
  125223. dofAperture: number;
  125224. /**
  125225. * Gets or sets the edge distortion
  125226. */
  125227. edgeDistortion: number;
  125228. /**
  125229. * Gets or sets the depth of field distortion
  125230. */
  125231. dofDistortion: number;
  125232. /**
  125233. * Gets or sets the darken out of focus amount
  125234. */
  125235. darkenOutOfFocus: number;
  125236. /**
  125237. * Gets or sets a boolean indicating if blur noise is enabled
  125238. */
  125239. blurNoise: boolean;
  125240. /**
  125241. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  125242. */
  125243. pentagonBokeh: boolean;
  125244. /**
  125245. * Gets or sets the highlight grain amount
  125246. */
  125247. highlightsGain: number;
  125248. /**
  125249. * Gets or sets the highlight threshold
  125250. */
  125251. highlightsThreshold: number;
  125252. /**
  125253. * Sets the amount of blur at the edges
  125254. * @param amount blur amount
  125255. */
  125256. setEdgeBlur(amount: number): void;
  125257. /**
  125258. * Sets edge blur to 0
  125259. */
  125260. disableEdgeBlur(): void;
  125261. /**
  125262. * Sets the amout of grain
  125263. * @param amount Amount of grain
  125264. */
  125265. setGrainAmount(amount: number): void;
  125266. /**
  125267. * Set grain amount to 0
  125268. */
  125269. disableGrain(): void;
  125270. /**
  125271. * Sets the chromatic aberration amount
  125272. * @param amount amount of chromatic aberration
  125273. */
  125274. setChromaticAberration(amount: number): void;
  125275. /**
  125276. * Sets chromatic aberration amount to 0
  125277. */
  125278. disableChromaticAberration(): void;
  125279. /**
  125280. * Sets the EdgeDistortion amount
  125281. * @param amount amount of EdgeDistortion
  125282. */
  125283. setEdgeDistortion(amount: number): void;
  125284. /**
  125285. * Sets edge distortion to 0
  125286. */
  125287. disableEdgeDistortion(): void;
  125288. /**
  125289. * Sets the FocusDistance amount
  125290. * @param amount amount of FocusDistance
  125291. */
  125292. setFocusDistance(amount: number): void;
  125293. /**
  125294. * Disables depth of field
  125295. */
  125296. disableDepthOfField(): void;
  125297. /**
  125298. * Sets the Aperture amount
  125299. * @param amount amount of Aperture
  125300. */
  125301. setAperture(amount: number): void;
  125302. /**
  125303. * Sets the DarkenOutOfFocus amount
  125304. * @param amount amount of DarkenOutOfFocus
  125305. */
  125306. setDarkenOutOfFocus(amount: number): void;
  125307. private _pentagonBokehIsEnabled;
  125308. /**
  125309. * Creates a pentagon bokeh effect
  125310. */
  125311. enablePentagonBokeh(): void;
  125312. /**
  125313. * Disables the pentagon bokeh effect
  125314. */
  125315. disablePentagonBokeh(): void;
  125316. /**
  125317. * Enables noise blur
  125318. */
  125319. enableNoiseBlur(): void;
  125320. /**
  125321. * Disables noise blur
  125322. */
  125323. disableNoiseBlur(): void;
  125324. /**
  125325. * Sets the HighlightsGain amount
  125326. * @param amount amount of HighlightsGain
  125327. */
  125328. setHighlightsGain(amount: number): void;
  125329. /**
  125330. * Sets the HighlightsThreshold amount
  125331. * @param amount amount of HighlightsThreshold
  125332. */
  125333. setHighlightsThreshold(amount: number): void;
  125334. /**
  125335. * Disables highlights
  125336. */
  125337. disableHighlights(): void;
  125338. /**
  125339. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  125340. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  125341. */
  125342. dispose(disableDepthRender?: boolean): void;
  125343. private _createChromaticAberrationPostProcess;
  125344. private _createHighlightsPostProcess;
  125345. private _createDepthOfFieldPostProcess;
  125346. private _createGrainTexture;
  125347. }
  125348. }
  125349. declare module BABYLON {
  125350. /** @hidden */
  125351. export var ssao2PixelShader: {
  125352. name: string;
  125353. shader: string;
  125354. };
  125355. }
  125356. declare module BABYLON {
  125357. /** @hidden */
  125358. export var ssaoCombinePixelShader: {
  125359. name: string;
  125360. shader: string;
  125361. };
  125362. }
  125363. declare module BABYLON {
  125364. /**
  125365. * Render pipeline to produce ssao effect
  125366. */
  125367. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  125368. /**
  125369. * @ignore
  125370. * The PassPostProcess id in the pipeline that contains the original scene color
  125371. */
  125372. SSAOOriginalSceneColorEffect: string;
  125373. /**
  125374. * @ignore
  125375. * The SSAO PostProcess id in the pipeline
  125376. */
  125377. SSAORenderEffect: string;
  125378. /**
  125379. * @ignore
  125380. * The horizontal blur PostProcess id in the pipeline
  125381. */
  125382. SSAOBlurHRenderEffect: string;
  125383. /**
  125384. * @ignore
  125385. * The vertical blur PostProcess id in the pipeline
  125386. */
  125387. SSAOBlurVRenderEffect: string;
  125388. /**
  125389. * @ignore
  125390. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125391. */
  125392. SSAOCombineRenderEffect: string;
  125393. /**
  125394. * The output strength of the SSAO post-process. Default value is 1.0.
  125395. */
  125396. totalStrength: number;
  125397. /**
  125398. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  125399. */
  125400. maxZ: number;
  125401. /**
  125402. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  125403. */
  125404. minZAspect: number;
  125405. private _samples;
  125406. /**
  125407. * Number of samples used for the SSAO calculations. Default value is 8
  125408. */
  125409. samples: number;
  125410. private _textureSamples;
  125411. /**
  125412. * Number of samples to use for antialiasing
  125413. */
  125414. textureSamples: number;
  125415. /**
  125416. * Ratio object used for SSAO ratio and blur ratio
  125417. */
  125418. private _ratio;
  125419. /**
  125420. * Dynamically generated sphere sampler.
  125421. */
  125422. private _sampleSphere;
  125423. /**
  125424. * Blur filter offsets
  125425. */
  125426. private _samplerOffsets;
  125427. private _expensiveBlur;
  125428. /**
  125429. * If bilateral blur should be used
  125430. */
  125431. expensiveBlur: boolean;
  125432. /**
  125433. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  125434. */
  125435. radius: number;
  125436. /**
  125437. * The base color of the SSAO post-process
  125438. * The final result is "base + ssao" between [0, 1]
  125439. */
  125440. base: number;
  125441. /**
  125442. * Support test.
  125443. */
  125444. static readonly IsSupported: boolean;
  125445. private _scene;
  125446. private _depthTexture;
  125447. private _normalTexture;
  125448. private _randomTexture;
  125449. private _originalColorPostProcess;
  125450. private _ssaoPostProcess;
  125451. private _blurHPostProcess;
  125452. private _blurVPostProcess;
  125453. private _ssaoCombinePostProcess;
  125454. private _firstUpdate;
  125455. /**
  125456. * Gets active scene
  125457. */
  125458. readonly scene: Scene;
  125459. /**
  125460. * @constructor
  125461. * @param name The rendering pipeline name
  125462. * @param scene The scene linked to this pipeline
  125463. * @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 }
  125464. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125465. */
  125466. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125467. /**
  125468. * Get the class name
  125469. * @returns "SSAO2RenderingPipeline"
  125470. */
  125471. getClassName(): string;
  125472. /**
  125473. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125474. */
  125475. dispose(disableGeometryBufferRenderer?: boolean): void;
  125476. private _createBlurPostProcess;
  125477. /** @hidden */
  125478. _rebuild(): void;
  125479. private _bits;
  125480. private _radicalInverse_VdC;
  125481. private _hammersley;
  125482. private _hemisphereSample_uniform;
  125483. private _generateHemisphere;
  125484. private _createSSAOPostProcess;
  125485. private _createSSAOCombinePostProcess;
  125486. private _createRandomTexture;
  125487. /**
  125488. * Serialize the rendering pipeline (Used when exporting)
  125489. * @returns the serialized object
  125490. */
  125491. serialize(): any;
  125492. /**
  125493. * Parse the serialized pipeline
  125494. * @param source Source pipeline.
  125495. * @param scene The scene to load the pipeline to.
  125496. * @param rootUrl The URL of the serialized pipeline.
  125497. * @returns An instantiated pipeline from the serialized object.
  125498. */
  125499. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  125500. }
  125501. }
  125502. declare module BABYLON {
  125503. /** @hidden */
  125504. export var ssaoPixelShader: {
  125505. name: string;
  125506. shader: string;
  125507. };
  125508. }
  125509. declare module BABYLON {
  125510. /**
  125511. * Render pipeline to produce ssao effect
  125512. */
  125513. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  125514. /**
  125515. * @ignore
  125516. * The PassPostProcess id in the pipeline that contains the original scene color
  125517. */
  125518. SSAOOriginalSceneColorEffect: string;
  125519. /**
  125520. * @ignore
  125521. * The SSAO PostProcess id in the pipeline
  125522. */
  125523. SSAORenderEffect: string;
  125524. /**
  125525. * @ignore
  125526. * The horizontal blur PostProcess id in the pipeline
  125527. */
  125528. SSAOBlurHRenderEffect: string;
  125529. /**
  125530. * @ignore
  125531. * The vertical blur PostProcess id in the pipeline
  125532. */
  125533. SSAOBlurVRenderEffect: string;
  125534. /**
  125535. * @ignore
  125536. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125537. */
  125538. SSAOCombineRenderEffect: string;
  125539. /**
  125540. * The output strength of the SSAO post-process. Default value is 1.0.
  125541. */
  125542. totalStrength: number;
  125543. /**
  125544. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  125545. */
  125546. radius: number;
  125547. /**
  125548. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  125549. * Must not be equal to fallOff and superior to fallOff.
  125550. * Default value is 0.0075
  125551. */
  125552. area: number;
  125553. /**
  125554. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  125555. * Must not be equal to area and inferior to area.
  125556. * Default value is 0.000001
  125557. */
  125558. fallOff: number;
  125559. /**
  125560. * The base color of the SSAO post-process
  125561. * The final result is "base + ssao" between [0, 1]
  125562. */
  125563. base: number;
  125564. private _scene;
  125565. private _depthTexture;
  125566. private _randomTexture;
  125567. private _originalColorPostProcess;
  125568. private _ssaoPostProcess;
  125569. private _blurHPostProcess;
  125570. private _blurVPostProcess;
  125571. private _ssaoCombinePostProcess;
  125572. private _firstUpdate;
  125573. /**
  125574. * Gets active scene
  125575. */
  125576. readonly scene: Scene;
  125577. /**
  125578. * @constructor
  125579. * @param name - The rendering pipeline name
  125580. * @param scene - The scene linked to this pipeline
  125581. * @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 }
  125582. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125583. */
  125584. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125585. /**
  125586. * Get the class name
  125587. * @returns "SSAORenderingPipeline"
  125588. */
  125589. getClassName(): string;
  125590. /**
  125591. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125592. */
  125593. dispose(disableDepthRender?: boolean): void;
  125594. private _createBlurPostProcess;
  125595. /** @hidden */
  125596. _rebuild(): void;
  125597. private _createSSAOPostProcess;
  125598. private _createSSAOCombinePostProcess;
  125599. private _createRandomTexture;
  125600. }
  125601. }
  125602. declare module BABYLON {
  125603. /** @hidden */
  125604. export var standardPixelShader: {
  125605. name: string;
  125606. shader: string;
  125607. };
  125608. }
  125609. declare module BABYLON {
  125610. /**
  125611. * Standard rendering pipeline
  125612. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125613. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125614. */
  125615. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125616. /**
  125617. * Public members
  125618. */
  125619. /**
  125620. * Post-process which contains the original scene color before the pipeline applies all the effects
  125621. */
  125622. originalPostProcess: Nullable<PostProcess>;
  125623. /**
  125624. * Post-process used to down scale an image x4
  125625. */
  125626. downSampleX4PostProcess: Nullable<PostProcess>;
  125627. /**
  125628. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125629. */
  125630. brightPassPostProcess: Nullable<PostProcess>;
  125631. /**
  125632. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125633. */
  125634. blurHPostProcesses: PostProcess[];
  125635. /**
  125636. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125637. */
  125638. blurVPostProcesses: PostProcess[];
  125639. /**
  125640. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125641. */
  125642. textureAdderPostProcess: Nullable<PostProcess>;
  125643. /**
  125644. * Post-process used to create volumetric lighting effect
  125645. */
  125646. volumetricLightPostProcess: Nullable<PostProcess>;
  125647. /**
  125648. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125649. */
  125650. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125651. /**
  125652. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125653. */
  125654. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125655. /**
  125656. * Post-process used to merge the volumetric light effect and the real scene color
  125657. */
  125658. volumetricLightMergePostProces: Nullable<PostProcess>;
  125659. /**
  125660. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125661. */
  125662. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125663. /**
  125664. * Base post-process used to calculate the average luminance of the final image for HDR
  125665. */
  125666. luminancePostProcess: Nullable<PostProcess>;
  125667. /**
  125668. * Post-processes used to create down sample post-processes in order to get
  125669. * the average luminance of the final image for HDR
  125670. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125671. */
  125672. luminanceDownSamplePostProcesses: PostProcess[];
  125673. /**
  125674. * Post-process used to create a HDR effect (light adaptation)
  125675. */
  125676. hdrPostProcess: Nullable<PostProcess>;
  125677. /**
  125678. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125679. */
  125680. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125681. /**
  125682. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125683. */
  125684. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125685. /**
  125686. * Post-process used to merge the final HDR post-process and the real scene color
  125687. */
  125688. hdrFinalPostProcess: Nullable<PostProcess>;
  125689. /**
  125690. * Post-process used to create a lens flare effect
  125691. */
  125692. lensFlarePostProcess: Nullable<PostProcess>;
  125693. /**
  125694. * Post-process that merges the result of the lens flare post-process and the real scene color
  125695. */
  125696. lensFlareComposePostProcess: Nullable<PostProcess>;
  125697. /**
  125698. * Post-process used to create a motion blur effect
  125699. */
  125700. motionBlurPostProcess: Nullable<PostProcess>;
  125701. /**
  125702. * Post-process used to create a depth of field effect
  125703. */
  125704. depthOfFieldPostProcess: Nullable<PostProcess>;
  125705. /**
  125706. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125707. */
  125708. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125709. /**
  125710. * Represents the brightness threshold in order to configure the illuminated surfaces
  125711. */
  125712. brightThreshold: number;
  125713. /**
  125714. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125715. */
  125716. blurWidth: number;
  125717. /**
  125718. * Sets if the blur for highlighted surfaces must be only horizontal
  125719. */
  125720. horizontalBlur: boolean;
  125721. /**
  125722. * Gets the overall exposure used by the pipeline
  125723. */
  125724. /**
  125725. * Sets the overall exposure used by the pipeline
  125726. */
  125727. exposure: number;
  125728. /**
  125729. * Texture used typically to simulate "dirty" on camera lens
  125730. */
  125731. lensTexture: Nullable<Texture>;
  125732. /**
  125733. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125734. */
  125735. volumetricLightCoefficient: number;
  125736. /**
  125737. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125738. */
  125739. volumetricLightPower: number;
  125740. /**
  125741. * Used the set the blur intensity to smooth the volumetric lights
  125742. */
  125743. volumetricLightBlurScale: number;
  125744. /**
  125745. * Light (spot or directional) used to generate the volumetric lights rays
  125746. * The source light must have a shadow generate so the pipeline can get its
  125747. * depth map
  125748. */
  125749. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125750. /**
  125751. * For eye adaptation, represents the minimum luminance the eye can see
  125752. */
  125753. hdrMinimumLuminance: number;
  125754. /**
  125755. * For eye adaptation, represents the decrease luminance speed
  125756. */
  125757. hdrDecreaseRate: number;
  125758. /**
  125759. * For eye adaptation, represents the increase luminance speed
  125760. */
  125761. hdrIncreaseRate: number;
  125762. /**
  125763. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125764. */
  125765. /**
  125766. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125767. */
  125768. hdrAutoExposure: boolean;
  125769. /**
  125770. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125771. */
  125772. lensColorTexture: Nullable<Texture>;
  125773. /**
  125774. * The overall strengh for the lens flare effect
  125775. */
  125776. lensFlareStrength: number;
  125777. /**
  125778. * Dispersion coefficient for lens flare ghosts
  125779. */
  125780. lensFlareGhostDispersal: number;
  125781. /**
  125782. * Main lens flare halo width
  125783. */
  125784. lensFlareHaloWidth: number;
  125785. /**
  125786. * Based on the lens distortion effect, defines how much the lens flare result
  125787. * is distorted
  125788. */
  125789. lensFlareDistortionStrength: number;
  125790. /**
  125791. * Configures the blur intensity used for for lens flare (halo)
  125792. */
  125793. lensFlareBlurWidth: number;
  125794. /**
  125795. * Lens star texture must be used to simulate rays on the flares and is available
  125796. * in the documentation
  125797. */
  125798. lensStarTexture: Nullable<Texture>;
  125799. /**
  125800. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125801. * flare effect by taking account of the dirt texture
  125802. */
  125803. lensFlareDirtTexture: Nullable<Texture>;
  125804. /**
  125805. * Represents the focal length for the depth of field effect
  125806. */
  125807. depthOfFieldDistance: number;
  125808. /**
  125809. * Represents the blur intensity for the blurred part of the depth of field effect
  125810. */
  125811. depthOfFieldBlurWidth: number;
  125812. /**
  125813. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125814. */
  125815. /**
  125816. * Sets how much the image is blurred by the movement while using the motion blur post-process
  125817. */
  125818. motionStrength: number;
  125819. /**
  125820. * Gets wether or not the motion blur post-process is object based or screen based.
  125821. */
  125822. /**
  125823. * Sets wether or not the motion blur post-process should be object based or screen based
  125824. */
  125825. objectBasedMotionBlur: boolean;
  125826. /**
  125827. * List of animations for the pipeline (IAnimatable implementation)
  125828. */
  125829. animations: Animation[];
  125830. /**
  125831. * Private members
  125832. */
  125833. private _scene;
  125834. private _currentDepthOfFieldSource;
  125835. private _basePostProcess;
  125836. private _fixedExposure;
  125837. private _currentExposure;
  125838. private _hdrAutoExposure;
  125839. private _hdrCurrentLuminance;
  125840. private _motionStrength;
  125841. private _isObjectBasedMotionBlur;
  125842. private _floatTextureType;
  125843. private _camerasToBeAttached;
  125844. private _ratio;
  125845. private _bloomEnabled;
  125846. private _depthOfFieldEnabled;
  125847. private _vlsEnabled;
  125848. private _lensFlareEnabled;
  125849. private _hdrEnabled;
  125850. private _motionBlurEnabled;
  125851. private _fxaaEnabled;
  125852. private _motionBlurSamples;
  125853. private _volumetricLightStepsCount;
  125854. private _samples;
  125855. /**
  125856. * @ignore
  125857. * Specifies if the bloom pipeline is enabled
  125858. */
  125859. BloomEnabled: boolean;
  125860. /**
  125861. * @ignore
  125862. * Specifies if the depth of field pipeline is enabed
  125863. */
  125864. DepthOfFieldEnabled: boolean;
  125865. /**
  125866. * @ignore
  125867. * Specifies if the lens flare pipeline is enabed
  125868. */
  125869. LensFlareEnabled: boolean;
  125870. /**
  125871. * @ignore
  125872. * Specifies if the HDR pipeline is enabled
  125873. */
  125874. HDREnabled: boolean;
  125875. /**
  125876. * @ignore
  125877. * Specifies if the volumetric lights scattering effect is enabled
  125878. */
  125879. VLSEnabled: boolean;
  125880. /**
  125881. * @ignore
  125882. * Specifies if the motion blur effect is enabled
  125883. */
  125884. MotionBlurEnabled: boolean;
  125885. /**
  125886. * Specifies if anti-aliasing is enabled
  125887. */
  125888. fxaaEnabled: boolean;
  125889. /**
  125890. * Specifies the number of steps used to calculate the volumetric lights
  125891. * Typically in interval [50, 200]
  125892. */
  125893. volumetricLightStepsCount: number;
  125894. /**
  125895. * Specifies the number of samples used for the motion blur effect
  125896. * Typically in interval [16, 64]
  125897. */
  125898. motionBlurSamples: number;
  125899. /**
  125900. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125901. */
  125902. samples: number;
  125903. /**
  125904. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125905. * @constructor
  125906. * @param name The rendering pipeline name
  125907. * @param scene The scene linked to this pipeline
  125908. * @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)
  125909. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  125910. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125911. */
  125912. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  125913. private _buildPipeline;
  125914. private _createDownSampleX4PostProcess;
  125915. private _createBrightPassPostProcess;
  125916. private _createBlurPostProcesses;
  125917. private _createTextureAdderPostProcess;
  125918. private _createVolumetricLightPostProcess;
  125919. private _createLuminancePostProcesses;
  125920. private _createHdrPostProcess;
  125921. private _createLensFlarePostProcess;
  125922. private _createDepthOfFieldPostProcess;
  125923. private _createMotionBlurPostProcess;
  125924. private _getDepthTexture;
  125925. private _disposePostProcesses;
  125926. /**
  125927. * Dispose of the pipeline and stop all post processes
  125928. */
  125929. dispose(): void;
  125930. /**
  125931. * Serialize the rendering pipeline (Used when exporting)
  125932. * @returns the serialized object
  125933. */
  125934. serialize(): any;
  125935. /**
  125936. * Parse the serialized pipeline
  125937. * @param source Source pipeline.
  125938. * @param scene The scene to load the pipeline to.
  125939. * @param rootUrl The URL of the serialized pipeline.
  125940. * @returns An instantiated pipeline from the serialized object.
  125941. */
  125942. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  125943. /**
  125944. * Luminance steps
  125945. */
  125946. static LuminanceSteps: number;
  125947. }
  125948. }
  125949. declare module BABYLON {
  125950. /** @hidden */
  125951. export var tonemapPixelShader: {
  125952. name: string;
  125953. shader: string;
  125954. };
  125955. }
  125956. declare module BABYLON {
  125957. /** Defines operator used for tonemapping */
  125958. export enum TonemappingOperator {
  125959. /** Hable */
  125960. Hable = 0,
  125961. /** Reinhard */
  125962. Reinhard = 1,
  125963. /** HejiDawson */
  125964. HejiDawson = 2,
  125965. /** Photographic */
  125966. Photographic = 3
  125967. }
  125968. /**
  125969. * Defines a post process to apply tone mapping
  125970. */
  125971. export class TonemapPostProcess extends PostProcess {
  125972. private _operator;
  125973. /** Defines the required exposure adjustement */
  125974. exposureAdjustment: number;
  125975. /**
  125976. * Creates a new TonemapPostProcess
  125977. * @param name defines the name of the postprocess
  125978. * @param _operator defines the operator to use
  125979. * @param exposureAdjustment defines the required exposure adjustement
  125980. * @param camera defines the camera to use (can be null)
  125981. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  125982. * @param engine defines the hosting engine (can be ignore if camera is set)
  125983. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125984. */
  125985. constructor(name: string, _operator: TonemappingOperator,
  125986. /** Defines the required exposure adjustement */
  125987. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  125988. }
  125989. }
  125990. declare module BABYLON {
  125991. /** @hidden */
  125992. export var depthVertexShader: {
  125993. name: string;
  125994. shader: string;
  125995. };
  125996. }
  125997. declare module BABYLON {
  125998. /** @hidden */
  125999. export var volumetricLightScatteringPixelShader: {
  126000. name: string;
  126001. shader: string;
  126002. };
  126003. }
  126004. declare module BABYLON {
  126005. /** @hidden */
  126006. export var volumetricLightScatteringPassVertexShader: {
  126007. name: string;
  126008. shader: string;
  126009. };
  126010. }
  126011. declare module BABYLON {
  126012. /** @hidden */
  126013. export var volumetricLightScatteringPassPixelShader: {
  126014. name: string;
  126015. shader: string;
  126016. };
  126017. }
  126018. declare module BABYLON {
  126019. /**
  126020. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  126021. */
  126022. export class VolumetricLightScatteringPostProcess extends PostProcess {
  126023. private _volumetricLightScatteringPass;
  126024. private _volumetricLightScatteringRTT;
  126025. private _viewPort;
  126026. private _screenCoordinates;
  126027. private _cachedDefines;
  126028. /**
  126029. * If not undefined, the mesh position is computed from the attached node position
  126030. */
  126031. attachedNode: {
  126032. position: Vector3;
  126033. };
  126034. /**
  126035. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  126036. */
  126037. customMeshPosition: Vector3;
  126038. /**
  126039. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  126040. */
  126041. useCustomMeshPosition: boolean;
  126042. /**
  126043. * If the post-process should inverse the light scattering direction
  126044. */
  126045. invert: boolean;
  126046. /**
  126047. * The internal mesh used by the post-process
  126048. */
  126049. mesh: Mesh;
  126050. /**
  126051. * @hidden
  126052. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  126053. */
  126054. useDiffuseColor: boolean;
  126055. /**
  126056. * Array containing the excluded meshes not rendered in the internal pass
  126057. */
  126058. excludedMeshes: AbstractMesh[];
  126059. /**
  126060. * Controls the overall intensity of the post-process
  126061. */
  126062. exposure: number;
  126063. /**
  126064. * Dissipates each sample's contribution in range [0, 1]
  126065. */
  126066. decay: number;
  126067. /**
  126068. * Controls the overall intensity of each sample
  126069. */
  126070. weight: number;
  126071. /**
  126072. * Controls the density of each sample
  126073. */
  126074. density: number;
  126075. /**
  126076. * @constructor
  126077. * @param name The post-process name
  126078. * @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)
  126079. * @param camera The camera that the post-process will be attached to
  126080. * @param mesh The mesh used to create the light scattering
  126081. * @param samples The post-process quality, default 100
  126082. * @param samplingModeThe post-process filtering mode
  126083. * @param engine The babylon engine
  126084. * @param reusable If the post-process is reusable
  126085. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  126086. */
  126087. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  126088. /**
  126089. * Returns the string "VolumetricLightScatteringPostProcess"
  126090. * @returns "VolumetricLightScatteringPostProcess"
  126091. */
  126092. getClassName(): string;
  126093. private _isReady;
  126094. /**
  126095. * Sets the new light position for light scattering effect
  126096. * @param position The new custom light position
  126097. */
  126098. setCustomMeshPosition(position: Vector3): void;
  126099. /**
  126100. * Returns the light position for light scattering effect
  126101. * @return Vector3 The custom light position
  126102. */
  126103. getCustomMeshPosition(): Vector3;
  126104. /**
  126105. * Disposes the internal assets and detaches the post-process from the camera
  126106. */
  126107. dispose(camera: Camera): void;
  126108. /**
  126109. * Returns the render target texture used by the post-process
  126110. * @return the render target texture used by the post-process
  126111. */
  126112. getPass(): RenderTargetTexture;
  126113. private _meshExcluded;
  126114. private _createPass;
  126115. private _updateMeshScreenCoordinates;
  126116. /**
  126117. * Creates a default mesh for the Volumeric Light Scattering post-process
  126118. * @param name The mesh name
  126119. * @param scene The scene where to create the mesh
  126120. * @return the default mesh
  126121. */
  126122. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  126123. }
  126124. }
  126125. declare module BABYLON {
  126126. interface Scene {
  126127. /** @hidden (Backing field) */
  126128. _boundingBoxRenderer: BoundingBoxRenderer;
  126129. /** @hidden (Backing field) */
  126130. _forceShowBoundingBoxes: boolean;
  126131. /**
  126132. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  126133. */
  126134. forceShowBoundingBoxes: boolean;
  126135. /**
  126136. * Gets the bounding box renderer associated with the scene
  126137. * @returns a BoundingBoxRenderer
  126138. */
  126139. getBoundingBoxRenderer(): BoundingBoxRenderer;
  126140. }
  126141. interface AbstractMesh {
  126142. /** @hidden (Backing field) */
  126143. _showBoundingBox: boolean;
  126144. /**
  126145. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  126146. */
  126147. showBoundingBox: boolean;
  126148. }
  126149. /**
  126150. * Component responsible of rendering the bounding box of the meshes in a scene.
  126151. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126152. */
  126153. export class BoundingBoxRenderer implements ISceneComponent {
  126154. /**
  126155. * The component name helpfull to identify the component in the list of scene components.
  126156. */
  126157. readonly name: string;
  126158. /**
  126159. * The scene the component belongs to.
  126160. */
  126161. scene: Scene;
  126162. /**
  126163. * Color of the bounding box lines placed in front of an object
  126164. */
  126165. frontColor: Color3;
  126166. /**
  126167. * Color of the bounding box lines placed behind an object
  126168. */
  126169. backColor: Color3;
  126170. /**
  126171. * Defines if the renderer should show the back lines or not
  126172. */
  126173. showBackLines: boolean;
  126174. /**
  126175. * @hidden
  126176. */
  126177. renderList: SmartArray<BoundingBox>;
  126178. private _colorShader;
  126179. private _vertexBuffers;
  126180. private _indexBuffer;
  126181. private _fillIndexBuffer;
  126182. private _fillIndexData;
  126183. /**
  126184. * Instantiates a new bounding box renderer in a scene.
  126185. * @param scene the scene the renderer renders in
  126186. */
  126187. constructor(scene: Scene);
  126188. /**
  126189. * Registers the component in a given scene
  126190. */
  126191. register(): void;
  126192. private _evaluateSubMesh;
  126193. private _activeMesh;
  126194. private _prepareRessources;
  126195. private _createIndexBuffer;
  126196. /**
  126197. * Rebuilds the elements related to this component in case of
  126198. * context lost for instance.
  126199. */
  126200. rebuild(): void;
  126201. /**
  126202. * @hidden
  126203. */
  126204. reset(): void;
  126205. /**
  126206. * Render the bounding boxes of a specific rendering group
  126207. * @param renderingGroupId defines the rendering group to render
  126208. */
  126209. render(renderingGroupId: number): void;
  126210. /**
  126211. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126212. * @param mesh Define the mesh to render the occlusion bounding box for
  126213. */
  126214. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  126215. /**
  126216. * Dispose and release the resources attached to this renderer.
  126217. */
  126218. dispose(): void;
  126219. }
  126220. }
  126221. declare module BABYLON {
  126222. /** @hidden */
  126223. export var depthPixelShader: {
  126224. name: string;
  126225. shader: string;
  126226. };
  126227. }
  126228. declare module BABYLON {
  126229. /**
  126230. * This represents a depth renderer in Babylon.
  126231. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126232. */
  126233. export class DepthRenderer {
  126234. private _scene;
  126235. private _depthMap;
  126236. private _effect;
  126237. private readonly _storeNonLinearDepth;
  126238. private readonly _clearColor;
  126239. /** Get if the depth renderer is using packed depth or not */
  126240. readonly isPacked: boolean;
  126241. private _cachedDefines;
  126242. private _camera;
  126243. /**
  126244. * Specifiess that the depth renderer will only be used within
  126245. * the camera it is created for.
  126246. * This can help forcing its rendering during the camera processing.
  126247. */
  126248. useOnlyInActiveCamera: boolean;
  126249. /** @hidden */
  126250. static _SceneComponentInitialization: (scene: Scene) => void;
  126251. /**
  126252. * Instantiates a depth renderer
  126253. * @param scene The scene the renderer belongs to
  126254. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126255. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126256. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126257. */
  126258. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126259. /**
  126260. * Creates the depth rendering effect and checks if the effect is ready.
  126261. * @param subMesh The submesh to be used to render the depth map of
  126262. * @param useInstances If multiple world instances should be used
  126263. * @returns if the depth renderer is ready to render the depth map
  126264. */
  126265. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126266. /**
  126267. * Gets the texture which the depth map will be written to.
  126268. * @returns The depth map texture
  126269. */
  126270. getDepthMap(): RenderTargetTexture;
  126271. /**
  126272. * Disposes of the depth renderer.
  126273. */
  126274. dispose(): void;
  126275. }
  126276. }
  126277. declare module BABYLON {
  126278. interface Scene {
  126279. /** @hidden (Backing field) */
  126280. _depthRenderer: {
  126281. [id: string]: DepthRenderer;
  126282. };
  126283. /**
  126284. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  126285. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  126286. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126287. * @returns the created depth renderer
  126288. */
  126289. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  126290. /**
  126291. * Disables a depth renderer for a given camera
  126292. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  126293. */
  126294. disableDepthRenderer(camera?: Nullable<Camera>): void;
  126295. }
  126296. /**
  126297. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126298. * in several rendering techniques.
  126299. */
  126300. export class DepthRendererSceneComponent implements ISceneComponent {
  126301. /**
  126302. * The component name helpfull to identify the component in the list of scene components.
  126303. */
  126304. readonly name: string;
  126305. /**
  126306. * The scene the component belongs to.
  126307. */
  126308. scene: Scene;
  126309. /**
  126310. * Creates a new instance of the component for the given scene
  126311. * @param scene Defines the scene to register the component in
  126312. */
  126313. constructor(scene: Scene);
  126314. /**
  126315. * Registers the component in a given scene
  126316. */
  126317. register(): void;
  126318. /**
  126319. * Rebuilds the elements related to this component in case of
  126320. * context lost for instance.
  126321. */
  126322. rebuild(): void;
  126323. /**
  126324. * Disposes the component and the associated ressources
  126325. */
  126326. dispose(): void;
  126327. private _gatherRenderTargets;
  126328. private _gatherActiveCameraRenderTargets;
  126329. }
  126330. }
  126331. declare module BABYLON {
  126332. /** @hidden */
  126333. export var outlinePixelShader: {
  126334. name: string;
  126335. shader: string;
  126336. };
  126337. }
  126338. declare module BABYLON {
  126339. /** @hidden */
  126340. export var outlineVertexShader: {
  126341. name: string;
  126342. shader: string;
  126343. };
  126344. }
  126345. declare module BABYLON {
  126346. interface Scene {
  126347. /** @hidden */
  126348. _outlineRenderer: OutlineRenderer;
  126349. /**
  126350. * Gets the outline renderer associated with the scene
  126351. * @returns a OutlineRenderer
  126352. */
  126353. getOutlineRenderer(): OutlineRenderer;
  126354. }
  126355. interface AbstractMesh {
  126356. /** @hidden (Backing field) */
  126357. _renderOutline: boolean;
  126358. /**
  126359. * Gets or sets a boolean indicating if the outline must be rendered as well
  126360. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  126361. */
  126362. renderOutline: boolean;
  126363. /** @hidden (Backing field) */
  126364. _renderOverlay: boolean;
  126365. /**
  126366. * Gets or sets a boolean indicating if the overlay must be rendered as well
  126367. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  126368. */
  126369. renderOverlay: boolean;
  126370. }
  126371. /**
  126372. * This class is responsible to draw bothe outline/overlay of meshes.
  126373. * It should not be used directly but through the available method on mesh.
  126374. */
  126375. export class OutlineRenderer implements ISceneComponent {
  126376. /**
  126377. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126378. */
  126379. private static _StencilReference;
  126380. /**
  126381. * The name of the component. Each component must have a unique name.
  126382. */
  126383. name: string;
  126384. /**
  126385. * The scene the component belongs to.
  126386. */
  126387. scene: Scene;
  126388. /**
  126389. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126390. */
  126391. zOffset: number;
  126392. private _engine;
  126393. private _effect;
  126394. private _cachedDefines;
  126395. private _savedDepthWrite;
  126396. /**
  126397. * Instantiates a new outline renderer. (There could be only one per scene).
  126398. * @param scene Defines the scene it belongs to
  126399. */
  126400. constructor(scene: Scene);
  126401. /**
  126402. * Register the component to one instance of a scene.
  126403. */
  126404. register(): void;
  126405. /**
  126406. * Rebuilds the elements related to this component in case of
  126407. * context lost for instance.
  126408. */
  126409. rebuild(): void;
  126410. /**
  126411. * Disposes the component and the associated ressources.
  126412. */
  126413. dispose(): void;
  126414. /**
  126415. * Renders the outline in the canvas.
  126416. * @param subMesh Defines the sumesh to render
  126417. * @param batch Defines the batch of meshes in case of instances
  126418. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126419. */
  126420. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  126421. /**
  126422. * Returns whether or not the outline renderer is ready for a given submesh.
  126423. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126424. * @param subMesh Defines the submesh to check readyness for
  126425. * @param useInstances Defines wheter wee are trying to render instances or not
  126426. * @returns true if ready otherwise false
  126427. */
  126428. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126429. private _beforeRenderingMesh;
  126430. private _afterRenderingMesh;
  126431. }
  126432. }
  126433. declare module BABYLON {
  126434. /**
  126435. * Class used to manage multiple sprites of different sizes on the same spritesheet
  126436. * @see http://doc.babylonjs.com/babylon101/sprites
  126437. */
  126438. export class SpritePackedManager extends SpriteManager {
  126439. /** defines the packed manager's name */
  126440. name: string;
  126441. /**
  126442. * Creates a new sprite manager from a packed sprite sheet
  126443. * @param name defines the manager's name
  126444. * @param imgUrl defines the sprite sheet url
  126445. * @param capacity defines the maximum allowed number of sprites
  126446. * @param scene defines the hosting scene
  126447. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  126448. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126449. * @param samplingMode defines the smapling mode to use with spritesheet
  126450. * @param fromPacked set to true; do not alter
  126451. */
  126452. constructor(
  126453. /** defines the packed manager's name */
  126454. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  126455. }
  126456. }
  126457. declare module BABYLON {
  126458. /**
  126459. * Defines the list of states available for a task inside a AssetsManager
  126460. */
  126461. export enum AssetTaskState {
  126462. /**
  126463. * Initialization
  126464. */
  126465. INIT = 0,
  126466. /**
  126467. * Running
  126468. */
  126469. RUNNING = 1,
  126470. /**
  126471. * Done
  126472. */
  126473. DONE = 2,
  126474. /**
  126475. * Error
  126476. */
  126477. ERROR = 3
  126478. }
  126479. /**
  126480. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  126481. */
  126482. export abstract class AbstractAssetTask {
  126483. /**
  126484. * Task name
  126485. */ name: string;
  126486. /**
  126487. * Callback called when the task is successful
  126488. */
  126489. onSuccess: (task: any) => void;
  126490. /**
  126491. * Callback called when the task is not successful
  126492. */
  126493. onError: (task: any, message?: string, exception?: any) => void;
  126494. /**
  126495. * Creates a new AssetsManager
  126496. * @param name defines the name of the task
  126497. */
  126498. constructor(
  126499. /**
  126500. * Task name
  126501. */ name: string);
  126502. private _isCompleted;
  126503. private _taskState;
  126504. private _errorObject;
  126505. /**
  126506. * Get if the task is completed
  126507. */
  126508. readonly isCompleted: boolean;
  126509. /**
  126510. * Gets the current state of the task
  126511. */
  126512. readonly taskState: AssetTaskState;
  126513. /**
  126514. * Gets the current error object (if task is in error)
  126515. */
  126516. readonly errorObject: {
  126517. message?: string;
  126518. exception?: any;
  126519. };
  126520. /**
  126521. * Internal only
  126522. * @hidden
  126523. */
  126524. _setErrorObject(message?: string, exception?: any): void;
  126525. /**
  126526. * Execute the current task
  126527. * @param scene defines the scene where you want your assets to be loaded
  126528. * @param onSuccess is a callback called when the task is successfully executed
  126529. * @param onError is a callback called if an error occurs
  126530. */
  126531. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126532. /**
  126533. * Execute the current task
  126534. * @param scene defines the scene where you want your assets to be loaded
  126535. * @param onSuccess is a callback called when the task is successfully executed
  126536. * @param onError is a callback called if an error occurs
  126537. */
  126538. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126539. /**
  126540. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  126541. * This can be used with failed tasks that have the reason for failure fixed.
  126542. */
  126543. reset(): void;
  126544. private onErrorCallback;
  126545. private onDoneCallback;
  126546. }
  126547. /**
  126548. * Define the interface used by progress events raised during assets loading
  126549. */
  126550. export interface IAssetsProgressEvent {
  126551. /**
  126552. * Defines the number of remaining tasks to process
  126553. */
  126554. remainingCount: number;
  126555. /**
  126556. * Defines the total number of tasks
  126557. */
  126558. totalCount: number;
  126559. /**
  126560. * Defines the task that was just processed
  126561. */
  126562. task: AbstractAssetTask;
  126563. }
  126564. /**
  126565. * Class used to share progress information about assets loading
  126566. */
  126567. export class AssetsProgressEvent implements IAssetsProgressEvent {
  126568. /**
  126569. * Defines the number of remaining tasks to process
  126570. */
  126571. remainingCount: number;
  126572. /**
  126573. * Defines the total number of tasks
  126574. */
  126575. totalCount: number;
  126576. /**
  126577. * Defines the task that was just processed
  126578. */
  126579. task: AbstractAssetTask;
  126580. /**
  126581. * Creates a AssetsProgressEvent
  126582. * @param remainingCount defines the number of remaining tasks to process
  126583. * @param totalCount defines the total number of tasks
  126584. * @param task defines the task that was just processed
  126585. */
  126586. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126587. }
  126588. /**
  126589. * Define a task used by AssetsManager to load meshes
  126590. */
  126591. export class MeshAssetTask extends AbstractAssetTask {
  126592. /**
  126593. * Defines the name of the task
  126594. */
  126595. name: string;
  126596. /**
  126597. * Defines the list of mesh's names you want to load
  126598. */
  126599. meshesNames: any;
  126600. /**
  126601. * Defines the root url to use as a base to load your meshes and associated resources
  126602. */
  126603. rootUrl: string;
  126604. /**
  126605. * Defines the filename of the scene to load from
  126606. */
  126607. sceneFilename: string;
  126608. /**
  126609. * Gets the list of loaded meshes
  126610. */
  126611. loadedMeshes: Array<AbstractMesh>;
  126612. /**
  126613. * Gets the list of loaded particle systems
  126614. */
  126615. loadedParticleSystems: Array<IParticleSystem>;
  126616. /**
  126617. * Gets the list of loaded skeletons
  126618. */
  126619. loadedSkeletons: Array<Skeleton>;
  126620. /**
  126621. * Gets the list of loaded animation groups
  126622. */
  126623. loadedAnimationGroups: Array<AnimationGroup>;
  126624. /**
  126625. * Callback called when the task is successful
  126626. */
  126627. onSuccess: (task: MeshAssetTask) => void;
  126628. /**
  126629. * Callback called when the task is successful
  126630. */
  126631. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126632. /**
  126633. * Creates a new MeshAssetTask
  126634. * @param name defines the name of the task
  126635. * @param meshesNames defines the list of mesh's names you want to load
  126636. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126637. * @param sceneFilename defines the filename of the scene to load from
  126638. */
  126639. constructor(
  126640. /**
  126641. * Defines the name of the task
  126642. */
  126643. name: string,
  126644. /**
  126645. * Defines the list of mesh's names you want to load
  126646. */
  126647. meshesNames: any,
  126648. /**
  126649. * Defines the root url to use as a base to load your meshes and associated resources
  126650. */
  126651. rootUrl: string,
  126652. /**
  126653. * Defines the filename of the scene to load from
  126654. */
  126655. sceneFilename: string);
  126656. /**
  126657. * Execute the current task
  126658. * @param scene defines the scene where you want your assets to be loaded
  126659. * @param onSuccess is a callback called when the task is successfully executed
  126660. * @param onError is a callback called if an error occurs
  126661. */
  126662. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126663. }
  126664. /**
  126665. * Define a task used by AssetsManager to load text content
  126666. */
  126667. export class TextFileAssetTask extends AbstractAssetTask {
  126668. /**
  126669. * Defines the name of the task
  126670. */
  126671. name: string;
  126672. /**
  126673. * Defines the location of the file to load
  126674. */
  126675. url: string;
  126676. /**
  126677. * Gets the loaded text string
  126678. */
  126679. text: string;
  126680. /**
  126681. * Callback called when the task is successful
  126682. */
  126683. onSuccess: (task: TextFileAssetTask) => void;
  126684. /**
  126685. * Callback called when the task is successful
  126686. */
  126687. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126688. /**
  126689. * Creates a new TextFileAssetTask object
  126690. * @param name defines the name of the task
  126691. * @param url defines the location of the file to load
  126692. */
  126693. constructor(
  126694. /**
  126695. * Defines the name of the task
  126696. */
  126697. name: string,
  126698. /**
  126699. * Defines the location of the file to load
  126700. */
  126701. url: string);
  126702. /**
  126703. * Execute the current task
  126704. * @param scene defines the scene where you want your assets to be loaded
  126705. * @param onSuccess is a callback called when the task is successfully executed
  126706. * @param onError is a callback called if an error occurs
  126707. */
  126708. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126709. }
  126710. /**
  126711. * Define a task used by AssetsManager to load binary data
  126712. */
  126713. export class BinaryFileAssetTask extends AbstractAssetTask {
  126714. /**
  126715. * Defines the name of the task
  126716. */
  126717. name: string;
  126718. /**
  126719. * Defines the location of the file to load
  126720. */
  126721. url: string;
  126722. /**
  126723. * Gets the lodaded data (as an array buffer)
  126724. */
  126725. data: ArrayBuffer;
  126726. /**
  126727. * Callback called when the task is successful
  126728. */
  126729. onSuccess: (task: BinaryFileAssetTask) => void;
  126730. /**
  126731. * Callback called when the task is successful
  126732. */
  126733. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126734. /**
  126735. * Creates a new BinaryFileAssetTask object
  126736. * @param name defines the name of the new task
  126737. * @param url defines the location of the file to load
  126738. */
  126739. constructor(
  126740. /**
  126741. * Defines the name of the task
  126742. */
  126743. name: string,
  126744. /**
  126745. * Defines the location of the file to load
  126746. */
  126747. url: string);
  126748. /**
  126749. * Execute the current task
  126750. * @param scene defines the scene where you want your assets to be loaded
  126751. * @param onSuccess is a callback called when the task is successfully executed
  126752. * @param onError is a callback called if an error occurs
  126753. */
  126754. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126755. }
  126756. /**
  126757. * Define a task used by AssetsManager to load images
  126758. */
  126759. export class ImageAssetTask extends AbstractAssetTask {
  126760. /**
  126761. * Defines the name of the task
  126762. */
  126763. name: string;
  126764. /**
  126765. * Defines the location of the image to load
  126766. */
  126767. url: string;
  126768. /**
  126769. * Gets the loaded images
  126770. */
  126771. image: HTMLImageElement;
  126772. /**
  126773. * Callback called when the task is successful
  126774. */
  126775. onSuccess: (task: ImageAssetTask) => void;
  126776. /**
  126777. * Callback called when the task is successful
  126778. */
  126779. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126780. /**
  126781. * Creates a new ImageAssetTask
  126782. * @param name defines the name of the task
  126783. * @param url defines the location of the image to load
  126784. */
  126785. constructor(
  126786. /**
  126787. * Defines the name of the task
  126788. */
  126789. name: string,
  126790. /**
  126791. * Defines the location of the image to load
  126792. */
  126793. url: string);
  126794. /**
  126795. * Execute the current task
  126796. * @param scene defines the scene where you want your assets to be loaded
  126797. * @param onSuccess is a callback called when the task is successfully executed
  126798. * @param onError is a callback called if an error occurs
  126799. */
  126800. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126801. }
  126802. /**
  126803. * Defines the interface used by texture loading tasks
  126804. */
  126805. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126806. /**
  126807. * Gets the loaded texture
  126808. */
  126809. texture: TEX;
  126810. }
  126811. /**
  126812. * Define a task used by AssetsManager to load 2D textures
  126813. */
  126814. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126815. /**
  126816. * Defines the name of the task
  126817. */
  126818. name: string;
  126819. /**
  126820. * Defines the location of the file to load
  126821. */
  126822. url: string;
  126823. /**
  126824. * Defines if mipmap should not be generated (default is false)
  126825. */
  126826. noMipmap?: boolean | undefined;
  126827. /**
  126828. * Defines if texture must be inverted on Y axis (default is false)
  126829. */
  126830. invertY?: boolean | undefined;
  126831. /**
  126832. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126833. */
  126834. samplingMode: number;
  126835. /**
  126836. * Gets the loaded texture
  126837. */
  126838. texture: Texture;
  126839. /**
  126840. * Callback called when the task is successful
  126841. */
  126842. onSuccess: (task: TextureAssetTask) => void;
  126843. /**
  126844. * Callback called when the task is successful
  126845. */
  126846. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  126847. /**
  126848. * Creates a new TextureAssetTask object
  126849. * @param name defines the name of the task
  126850. * @param url defines the location of the file to load
  126851. * @param noMipmap defines if mipmap should not be generated (default is false)
  126852. * @param invertY defines if texture must be inverted on Y axis (default is false)
  126853. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126854. */
  126855. constructor(
  126856. /**
  126857. * Defines the name of the task
  126858. */
  126859. name: string,
  126860. /**
  126861. * Defines the location of the file to load
  126862. */
  126863. url: string,
  126864. /**
  126865. * Defines if mipmap should not be generated (default is false)
  126866. */
  126867. noMipmap?: boolean | undefined,
  126868. /**
  126869. * Defines if texture must be inverted on Y axis (default is false)
  126870. */
  126871. invertY?: boolean | undefined,
  126872. /**
  126873. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126874. */
  126875. samplingMode?: number);
  126876. /**
  126877. * Execute the current task
  126878. * @param scene defines the scene where you want your assets to be loaded
  126879. * @param onSuccess is a callback called when the task is successfully executed
  126880. * @param onError is a callback called if an error occurs
  126881. */
  126882. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126883. }
  126884. /**
  126885. * Define a task used by AssetsManager to load cube textures
  126886. */
  126887. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  126888. /**
  126889. * Defines the name of the task
  126890. */
  126891. name: string;
  126892. /**
  126893. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126894. */
  126895. url: string;
  126896. /**
  126897. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126898. */
  126899. extensions?: string[] | undefined;
  126900. /**
  126901. * Defines if mipmaps should not be generated (default is false)
  126902. */
  126903. noMipmap?: boolean | undefined;
  126904. /**
  126905. * Defines the explicit list of files (undefined by default)
  126906. */
  126907. files?: string[] | undefined;
  126908. /**
  126909. * Gets the loaded texture
  126910. */
  126911. texture: CubeTexture;
  126912. /**
  126913. * Callback called when the task is successful
  126914. */
  126915. onSuccess: (task: CubeTextureAssetTask) => void;
  126916. /**
  126917. * Callback called when the task is successful
  126918. */
  126919. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  126920. /**
  126921. * Creates a new CubeTextureAssetTask
  126922. * @param name defines the name of the task
  126923. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126924. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126925. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126926. * @param files defines the explicit list of files (undefined by default)
  126927. */
  126928. constructor(
  126929. /**
  126930. * Defines the name of the task
  126931. */
  126932. name: string,
  126933. /**
  126934. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126935. */
  126936. url: string,
  126937. /**
  126938. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126939. */
  126940. extensions?: string[] | undefined,
  126941. /**
  126942. * Defines if mipmaps should not be generated (default is false)
  126943. */
  126944. noMipmap?: boolean | undefined,
  126945. /**
  126946. * Defines the explicit list of files (undefined by default)
  126947. */
  126948. files?: string[] | undefined);
  126949. /**
  126950. * Execute the current task
  126951. * @param scene defines the scene where you want your assets to be loaded
  126952. * @param onSuccess is a callback called when the task is successfully executed
  126953. * @param onError is a callback called if an error occurs
  126954. */
  126955. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126956. }
  126957. /**
  126958. * Define a task used by AssetsManager to load HDR cube textures
  126959. */
  126960. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  126961. /**
  126962. * Defines the name of the task
  126963. */
  126964. name: string;
  126965. /**
  126966. * Defines the location of the file to load
  126967. */
  126968. url: string;
  126969. /**
  126970. * Defines the desired size (the more it increases the longer the generation will be)
  126971. */
  126972. size: number;
  126973. /**
  126974. * Defines if mipmaps should not be generated (default is false)
  126975. */
  126976. noMipmap: boolean;
  126977. /**
  126978. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126979. */
  126980. generateHarmonics: boolean;
  126981. /**
  126982. * 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)
  126983. */
  126984. gammaSpace: boolean;
  126985. /**
  126986. * Internal Use Only
  126987. */
  126988. reserved: boolean;
  126989. /**
  126990. * Gets the loaded texture
  126991. */
  126992. texture: HDRCubeTexture;
  126993. /**
  126994. * Callback called when the task is successful
  126995. */
  126996. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  126997. /**
  126998. * Callback called when the task is successful
  126999. */
  127000. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  127001. /**
  127002. * Creates a new HDRCubeTextureAssetTask object
  127003. * @param name defines the name of the task
  127004. * @param url defines the location of the file to load
  127005. * @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.
  127006. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127007. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127008. * @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)
  127009. * @param reserved Internal use only
  127010. */
  127011. constructor(
  127012. /**
  127013. * Defines the name of the task
  127014. */
  127015. name: string,
  127016. /**
  127017. * Defines the location of the file to load
  127018. */
  127019. url: string,
  127020. /**
  127021. * Defines the desired size (the more it increases the longer the generation will be)
  127022. */
  127023. size: number,
  127024. /**
  127025. * Defines if mipmaps should not be generated (default is false)
  127026. */
  127027. noMipmap?: boolean,
  127028. /**
  127029. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127030. */
  127031. generateHarmonics?: boolean,
  127032. /**
  127033. * 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)
  127034. */
  127035. gammaSpace?: boolean,
  127036. /**
  127037. * Internal Use Only
  127038. */
  127039. reserved?: boolean);
  127040. /**
  127041. * Execute the current task
  127042. * @param scene defines the scene where you want your assets to be loaded
  127043. * @param onSuccess is a callback called when the task is successfully executed
  127044. * @param onError is a callback called if an error occurs
  127045. */
  127046. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127047. }
  127048. /**
  127049. * Define a task used by AssetsManager to load Equirectangular cube textures
  127050. */
  127051. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  127052. /**
  127053. * Defines the name of the task
  127054. */
  127055. name: string;
  127056. /**
  127057. * Defines the location of the file to load
  127058. */
  127059. url: string;
  127060. /**
  127061. * Defines the desired size (the more it increases the longer the generation will be)
  127062. */
  127063. size: number;
  127064. /**
  127065. * Defines if mipmaps should not be generated (default is false)
  127066. */
  127067. noMipmap: boolean;
  127068. /**
  127069. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127070. * but the standard material would require them in Gamma space) (default is true)
  127071. */
  127072. gammaSpace: boolean;
  127073. /**
  127074. * Gets the loaded texture
  127075. */
  127076. texture: EquiRectangularCubeTexture;
  127077. /**
  127078. * Callback called when the task is successful
  127079. */
  127080. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  127081. /**
  127082. * Callback called when the task is successful
  127083. */
  127084. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  127085. /**
  127086. * Creates a new EquiRectangularCubeTextureAssetTask object
  127087. * @param name defines the name of the task
  127088. * @param url defines the location of the file to load
  127089. * @param size defines the desired size (the more it increases the longer the generation will be)
  127090. * If the size is omitted this implies you are using a preprocessed cubemap.
  127091. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127092. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  127093. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  127094. * (default is true)
  127095. */
  127096. constructor(
  127097. /**
  127098. * Defines the name of the task
  127099. */
  127100. name: string,
  127101. /**
  127102. * Defines the location of the file to load
  127103. */
  127104. url: string,
  127105. /**
  127106. * Defines the desired size (the more it increases the longer the generation will be)
  127107. */
  127108. size: number,
  127109. /**
  127110. * Defines if mipmaps should not be generated (default is false)
  127111. */
  127112. noMipmap?: boolean,
  127113. /**
  127114. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127115. * but the standard material would require them in Gamma space) (default is true)
  127116. */
  127117. gammaSpace?: boolean);
  127118. /**
  127119. * Execute the current task
  127120. * @param scene defines the scene where you want your assets to be loaded
  127121. * @param onSuccess is a callback called when the task is successfully executed
  127122. * @param onError is a callback called if an error occurs
  127123. */
  127124. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127125. }
  127126. /**
  127127. * This class can be used to easily import assets into a scene
  127128. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  127129. */
  127130. export class AssetsManager {
  127131. private _scene;
  127132. private _isLoading;
  127133. protected _tasks: AbstractAssetTask[];
  127134. protected _waitingTasksCount: number;
  127135. protected _totalTasksCount: number;
  127136. /**
  127137. * Callback called when all tasks are processed
  127138. */
  127139. onFinish: (tasks: AbstractAssetTask[]) => void;
  127140. /**
  127141. * Callback called when a task is successful
  127142. */
  127143. onTaskSuccess: (task: AbstractAssetTask) => void;
  127144. /**
  127145. * Callback called when a task had an error
  127146. */
  127147. onTaskError: (task: AbstractAssetTask) => void;
  127148. /**
  127149. * Callback called when a task is done (whatever the result is)
  127150. */
  127151. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  127152. /**
  127153. * Observable called when all tasks are processed
  127154. */
  127155. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  127156. /**
  127157. * Observable called when a task had an error
  127158. */
  127159. onTaskErrorObservable: Observable<AbstractAssetTask>;
  127160. /**
  127161. * Observable called when all tasks were executed
  127162. */
  127163. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  127164. /**
  127165. * Observable called when a task is done (whatever the result is)
  127166. */
  127167. onProgressObservable: Observable<IAssetsProgressEvent>;
  127168. /**
  127169. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  127170. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127171. */
  127172. useDefaultLoadingScreen: boolean;
  127173. /**
  127174. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  127175. * when all assets have been downloaded.
  127176. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  127177. */
  127178. autoHideLoadingUI: boolean;
  127179. /**
  127180. * Creates a new AssetsManager
  127181. * @param scene defines the scene to work on
  127182. */
  127183. constructor(scene: Scene);
  127184. /**
  127185. * Add a MeshAssetTask to the list of active tasks
  127186. * @param taskName defines the name of the new task
  127187. * @param meshesNames defines the name of meshes to load
  127188. * @param rootUrl defines the root url to use to locate files
  127189. * @param sceneFilename defines the filename of the scene file
  127190. * @returns a new MeshAssetTask object
  127191. */
  127192. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  127193. /**
  127194. * Add a TextFileAssetTask to the list of active tasks
  127195. * @param taskName defines the name of the new task
  127196. * @param url defines the url of the file to load
  127197. * @returns a new TextFileAssetTask object
  127198. */
  127199. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  127200. /**
  127201. * Add a BinaryFileAssetTask to the list of active tasks
  127202. * @param taskName defines the name of the new task
  127203. * @param url defines the url of the file to load
  127204. * @returns a new BinaryFileAssetTask object
  127205. */
  127206. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  127207. /**
  127208. * Add a ImageAssetTask to the list of active tasks
  127209. * @param taskName defines the name of the new task
  127210. * @param url defines the url of the file to load
  127211. * @returns a new ImageAssetTask object
  127212. */
  127213. addImageTask(taskName: string, url: string): ImageAssetTask;
  127214. /**
  127215. * Add a TextureAssetTask to the list of active tasks
  127216. * @param taskName defines the name of the new task
  127217. * @param url defines the url of the file to load
  127218. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127219. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  127220. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127221. * @returns a new TextureAssetTask object
  127222. */
  127223. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  127224. /**
  127225. * Add a CubeTextureAssetTask to the list of active tasks
  127226. * @param taskName defines the name of the new task
  127227. * @param url defines the url of the file to load
  127228. * @param extensions defines the extension to use to load the cube map (can be null)
  127229. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127230. * @param files defines the list of files to load (can be null)
  127231. * @returns a new CubeTextureAssetTask object
  127232. */
  127233. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  127234. /**
  127235. *
  127236. * Add a HDRCubeTextureAssetTask to the list of active tasks
  127237. * @param taskName defines the name of the new task
  127238. * @param url defines the url of the file to load
  127239. * @param size defines the size you want for the cubemap (can be null)
  127240. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127241. * @param generateHarmonics defines if you want to automatically generate (true by default)
  127242. * @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)
  127243. * @param reserved Internal use only
  127244. * @returns a new HDRCubeTextureAssetTask object
  127245. */
  127246. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  127247. /**
  127248. *
  127249. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  127250. * @param taskName defines the name of the new task
  127251. * @param url defines the url of the file to load
  127252. * @param size defines the size you want for the cubemap (can be null)
  127253. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127254. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  127255. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  127256. * @returns a new EquiRectangularCubeTextureAssetTask object
  127257. */
  127258. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  127259. /**
  127260. * Remove a task from the assets manager.
  127261. * @param task the task to remove
  127262. */
  127263. removeTask(task: AbstractAssetTask): void;
  127264. private _decreaseWaitingTasksCount;
  127265. private _runTask;
  127266. /**
  127267. * Reset the AssetsManager and remove all tasks
  127268. * @return the current instance of the AssetsManager
  127269. */
  127270. reset(): AssetsManager;
  127271. /**
  127272. * Start the loading process
  127273. * @return the current instance of the AssetsManager
  127274. */
  127275. load(): AssetsManager;
  127276. /**
  127277. * Start the loading process as an async operation
  127278. * @return a promise returning the list of failed tasks
  127279. */
  127280. loadAsync(): Promise<void>;
  127281. }
  127282. }
  127283. declare module BABYLON {
  127284. /**
  127285. * Wrapper class for promise with external resolve and reject.
  127286. */
  127287. export class Deferred<T> {
  127288. /**
  127289. * The promise associated with this deferred object.
  127290. */
  127291. readonly promise: Promise<T>;
  127292. private _resolve;
  127293. private _reject;
  127294. /**
  127295. * The resolve method of the promise associated with this deferred object.
  127296. */
  127297. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  127298. /**
  127299. * The reject method of the promise associated with this deferred object.
  127300. */
  127301. readonly reject: (reason?: any) => void;
  127302. /**
  127303. * Constructor for this deferred object.
  127304. */
  127305. constructor();
  127306. }
  127307. }
  127308. declare module BABYLON {
  127309. /**
  127310. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  127311. */
  127312. export class MeshExploder {
  127313. private _centerMesh;
  127314. private _meshes;
  127315. private _meshesOrigins;
  127316. private _toCenterVectors;
  127317. private _scaledDirection;
  127318. private _newPosition;
  127319. private _centerPosition;
  127320. /**
  127321. * Explodes meshes from a center mesh.
  127322. * @param meshes The meshes to explode.
  127323. * @param centerMesh The mesh to be center of explosion.
  127324. */
  127325. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  127326. private _setCenterMesh;
  127327. /**
  127328. * Get class name
  127329. * @returns "MeshExploder"
  127330. */
  127331. getClassName(): string;
  127332. /**
  127333. * "Exploded meshes"
  127334. * @returns Array of meshes with the centerMesh at index 0.
  127335. */
  127336. getMeshes(): Array<Mesh>;
  127337. /**
  127338. * Explodes meshes giving a specific direction
  127339. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  127340. */
  127341. explode(direction?: number): void;
  127342. }
  127343. }
  127344. declare module BABYLON {
  127345. /**
  127346. * Class used to help managing file picking and drag'n'drop
  127347. */
  127348. export class FilesInput {
  127349. /**
  127350. * List of files ready to be loaded
  127351. */
  127352. static readonly FilesToLoad: {
  127353. [key: string]: File;
  127354. };
  127355. /**
  127356. * Callback called when a file is processed
  127357. */
  127358. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  127359. private _engine;
  127360. private _currentScene;
  127361. private _sceneLoadedCallback;
  127362. private _progressCallback;
  127363. private _additionalRenderLoopLogicCallback;
  127364. private _textureLoadingCallback;
  127365. private _startingProcessingFilesCallback;
  127366. private _onReloadCallback;
  127367. private _errorCallback;
  127368. private _elementToMonitor;
  127369. private _sceneFileToLoad;
  127370. private _filesToLoad;
  127371. /**
  127372. * Creates a new FilesInput
  127373. * @param engine defines the rendering engine
  127374. * @param scene defines the hosting scene
  127375. * @param sceneLoadedCallback callback called when scene is loaded
  127376. * @param progressCallback callback called to track progress
  127377. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  127378. * @param textureLoadingCallback callback called when a texture is loading
  127379. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  127380. * @param onReloadCallback callback called when a reload is requested
  127381. * @param errorCallback callback call if an error occurs
  127382. */
  127383. 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);
  127384. private _dragEnterHandler;
  127385. private _dragOverHandler;
  127386. private _dropHandler;
  127387. /**
  127388. * Calls this function to listen to drag'n'drop events on a specific DOM element
  127389. * @param elementToMonitor defines the DOM element to track
  127390. */
  127391. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  127392. /**
  127393. * Release all associated resources
  127394. */
  127395. dispose(): void;
  127396. private renderFunction;
  127397. private drag;
  127398. private drop;
  127399. private _traverseFolder;
  127400. private _processFiles;
  127401. /**
  127402. * Load files from a drop event
  127403. * @param event defines the drop event to use as source
  127404. */
  127405. loadFiles(event: any): void;
  127406. private _processReload;
  127407. /**
  127408. * Reload the current scene from the loaded files
  127409. */
  127410. reload(): void;
  127411. }
  127412. }
  127413. declare module BABYLON {
  127414. /**
  127415. * Defines the root class used to create scene optimization to use with SceneOptimizer
  127416. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127417. */
  127418. export class SceneOptimization {
  127419. /**
  127420. * Defines the priority of this optimization (0 by default which means first in the list)
  127421. */
  127422. priority: number;
  127423. /**
  127424. * Gets a string describing the action executed by the current optimization
  127425. * @returns description string
  127426. */
  127427. getDescription(): string;
  127428. /**
  127429. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127430. * @param scene defines the current scene where to apply this optimization
  127431. * @param optimizer defines the current optimizer
  127432. * @returns true if everything that can be done was applied
  127433. */
  127434. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127435. /**
  127436. * Creates the SceneOptimization object
  127437. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127438. * @param desc defines the description associated with the optimization
  127439. */
  127440. constructor(
  127441. /**
  127442. * Defines the priority of this optimization (0 by default which means first in the list)
  127443. */
  127444. priority?: number);
  127445. }
  127446. /**
  127447. * Defines an optimization used to reduce the size of render target textures
  127448. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127449. */
  127450. export class TextureOptimization extends SceneOptimization {
  127451. /**
  127452. * Defines the priority of this optimization (0 by default which means first in the list)
  127453. */
  127454. priority: number;
  127455. /**
  127456. * 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
  127457. */
  127458. maximumSize: number;
  127459. /**
  127460. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127461. */
  127462. step: number;
  127463. /**
  127464. * Gets a string describing the action executed by the current optimization
  127465. * @returns description string
  127466. */
  127467. getDescription(): string;
  127468. /**
  127469. * Creates the TextureOptimization object
  127470. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127471. * @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
  127472. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127473. */
  127474. constructor(
  127475. /**
  127476. * Defines the priority of this optimization (0 by default which means first in the list)
  127477. */
  127478. priority?: number,
  127479. /**
  127480. * 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
  127481. */
  127482. maximumSize?: number,
  127483. /**
  127484. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127485. */
  127486. step?: number);
  127487. /**
  127488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127489. * @param scene defines the current scene where to apply this optimization
  127490. * @param optimizer defines the current optimizer
  127491. * @returns true if everything that can be done was applied
  127492. */
  127493. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127494. }
  127495. /**
  127496. * Defines an optimization used to increase or decrease the rendering resolution
  127497. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127498. */
  127499. export class HardwareScalingOptimization extends SceneOptimization {
  127500. /**
  127501. * Defines the priority of this optimization (0 by default which means first in the list)
  127502. */
  127503. priority: number;
  127504. /**
  127505. * Defines the maximum scale to use (2 by default)
  127506. */
  127507. maximumScale: number;
  127508. /**
  127509. * Defines the step to use between two passes (0.5 by default)
  127510. */
  127511. step: number;
  127512. private _currentScale;
  127513. private _directionOffset;
  127514. /**
  127515. * Gets a string describing the action executed by the current optimization
  127516. * @return description string
  127517. */
  127518. getDescription(): string;
  127519. /**
  127520. * Creates the HardwareScalingOptimization object
  127521. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127522. * @param maximumScale defines the maximum scale to use (2 by default)
  127523. * @param step defines the step to use between two passes (0.5 by default)
  127524. */
  127525. constructor(
  127526. /**
  127527. * Defines the priority of this optimization (0 by default which means first in the list)
  127528. */
  127529. priority?: number,
  127530. /**
  127531. * Defines the maximum scale to use (2 by default)
  127532. */
  127533. maximumScale?: number,
  127534. /**
  127535. * Defines the step to use between two passes (0.5 by default)
  127536. */
  127537. step?: number);
  127538. /**
  127539. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127540. * @param scene defines the current scene where to apply this optimization
  127541. * @param optimizer defines the current optimizer
  127542. * @returns true if everything that can be done was applied
  127543. */
  127544. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127545. }
  127546. /**
  127547. * Defines an optimization used to remove shadows
  127548. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127549. */
  127550. export class ShadowsOptimization extends SceneOptimization {
  127551. /**
  127552. * Gets a string describing the action executed by the current optimization
  127553. * @return description string
  127554. */
  127555. getDescription(): string;
  127556. /**
  127557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127558. * @param scene defines the current scene where to apply this optimization
  127559. * @param optimizer defines the current optimizer
  127560. * @returns true if everything that can be done was applied
  127561. */
  127562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127563. }
  127564. /**
  127565. * Defines an optimization used to turn post-processes off
  127566. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127567. */
  127568. export class PostProcessesOptimization extends SceneOptimization {
  127569. /**
  127570. * Gets a string describing the action executed by the current optimization
  127571. * @return description string
  127572. */
  127573. getDescription(): string;
  127574. /**
  127575. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127576. * @param scene defines the current scene where to apply this optimization
  127577. * @param optimizer defines the current optimizer
  127578. * @returns true if everything that can be done was applied
  127579. */
  127580. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127581. }
  127582. /**
  127583. * Defines an optimization used to turn lens flares off
  127584. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127585. */
  127586. export class LensFlaresOptimization extends SceneOptimization {
  127587. /**
  127588. * Gets a string describing the action executed by the current optimization
  127589. * @return description string
  127590. */
  127591. getDescription(): string;
  127592. /**
  127593. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127594. * @param scene defines the current scene where to apply this optimization
  127595. * @param optimizer defines the current optimizer
  127596. * @returns true if everything that can be done was applied
  127597. */
  127598. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127599. }
  127600. /**
  127601. * Defines an optimization based on user defined callback.
  127602. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127603. */
  127604. export class CustomOptimization extends SceneOptimization {
  127605. /**
  127606. * Callback called to apply the custom optimization.
  127607. */
  127608. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127609. /**
  127610. * Callback called to get custom description
  127611. */
  127612. onGetDescription: () => string;
  127613. /**
  127614. * Gets a string describing the action executed by the current optimization
  127615. * @returns description string
  127616. */
  127617. getDescription(): string;
  127618. /**
  127619. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127620. * @param scene defines the current scene where to apply this optimization
  127621. * @param optimizer defines the current optimizer
  127622. * @returns true if everything that can be done was applied
  127623. */
  127624. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127625. }
  127626. /**
  127627. * Defines an optimization used to turn particles off
  127628. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127629. */
  127630. export class ParticlesOptimization extends SceneOptimization {
  127631. /**
  127632. * Gets a string describing the action executed by the current optimization
  127633. * @return description string
  127634. */
  127635. getDescription(): string;
  127636. /**
  127637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127638. * @param scene defines the current scene where to apply this optimization
  127639. * @param optimizer defines the current optimizer
  127640. * @returns true if everything that can be done was applied
  127641. */
  127642. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127643. }
  127644. /**
  127645. * Defines an optimization used to turn render targets off
  127646. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127647. */
  127648. export class RenderTargetsOptimization extends SceneOptimization {
  127649. /**
  127650. * Gets a string describing the action executed by the current optimization
  127651. * @return description string
  127652. */
  127653. getDescription(): string;
  127654. /**
  127655. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127656. * @param scene defines the current scene where to apply this optimization
  127657. * @param optimizer defines the current optimizer
  127658. * @returns true if everything that can be done was applied
  127659. */
  127660. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127661. }
  127662. /**
  127663. * Defines an optimization used to merge meshes with compatible materials
  127664. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127665. */
  127666. export class MergeMeshesOptimization extends SceneOptimization {
  127667. private static _UpdateSelectionTree;
  127668. /**
  127669. * Gets or sets a boolean which defines if optimization octree has to be updated
  127670. */
  127671. /**
  127672. * Gets or sets a boolean which defines if optimization octree has to be updated
  127673. */
  127674. static UpdateSelectionTree: boolean;
  127675. /**
  127676. * Gets a string describing the action executed by the current optimization
  127677. * @return description string
  127678. */
  127679. getDescription(): string;
  127680. private _canBeMerged;
  127681. /**
  127682. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127683. * @param scene defines the current scene where to apply this optimization
  127684. * @param optimizer defines the current optimizer
  127685. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127686. * @returns true if everything that can be done was applied
  127687. */
  127688. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127689. }
  127690. /**
  127691. * Defines a list of options used by SceneOptimizer
  127692. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127693. */
  127694. export class SceneOptimizerOptions {
  127695. /**
  127696. * Defines the target frame rate to reach (60 by default)
  127697. */
  127698. targetFrameRate: number;
  127699. /**
  127700. * Defines the interval between two checkes (2000ms by default)
  127701. */
  127702. trackerDuration: number;
  127703. /**
  127704. * Gets the list of optimizations to apply
  127705. */
  127706. optimizations: SceneOptimization[];
  127707. /**
  127708. * Creates a new list of options used by SceneOptimizer
  127709. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127710. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127711. */
  127712. constructor(
  127713. /**
  127714. * Defines the target frame rate to reach (60 by default)
  127715. */
  127716. targetFrameRate?: number,
  127717. /**
  127718. * Defines the interval between two checkes (2000ms by default)
  127719. */
  127720. trackerDuration?: number);
  127721. /**
  127722. * Add a new optimization
  127723. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127724. * @returns the current SceneOptimizerOptions
  127725. */
  127726. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127727. /**
  127728. * Add a new custom optimization
  127729. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127730. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127731. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127732. * @returns the current SceneOptimizerOptions
  127733. */
  127734. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127735. /**
  127736. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127737. * @param targetFrameRate defines the target frame rate (60 by default)
  127738. * @returns a SceneOptimizerOptions object
  127739. */
  127740. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127741. /**
  127742. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127743. * @param targetFrameRate defines the target frame rate (60 by default)
  127744. * @returns a SceneOptimizerOptions object
  127745. */
  127746. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127747. /**
  127748. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127749. * @param targetFrameRate defines the target frame rate (60 by default)
  127750. * @returns a SceneOptimizerOptions object
  127751. */
  127752. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127753. }
  127754. /**
  127755. * Class used to run optimizations in order to reach a target frame rate
  127756. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127757. */
  127758. export class SceneOptimizer implements IDisposable {
  127759. private _isRunning;
  127760. private _options;
  127761. private _scene;
  127762. private _currentPriorityLevel;
  127763. private _targetFrameRate;
  127764. private _trackerDuration;
  127765. private _currentFrameRate;
  127766. private _sceneDisposeObserver;
  127767. private _improvementMode;
  127768. /**
  127769. * Defines an observable called when the optimizer reaches the target frame rate
  127770. */
  127771. onSuccessObservable: Observable<SceneOptimizer>;
  127772. /**
  127773. * Defines an observable called when the optimizer enables an optimization
  127774. */
  127775. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127776. /**
  127777. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127778. */
  127779. onFailureObservable: Observable<SceneOptimizer>;
  127780. /**
  127781. * Gets a boolean indicating if the optimizer is in improvement mode
  127782. */
  127783. readonly isInImprovementMode: boolean;
  127784. /**
  127785. * Gets the current priority level (0 at start)
  127786. */
  127787. readonly currentPriorityLevel: number;
  127788. /**
  127789. * Gets the current frame rate checked by the SceneOptimizer
  127790. */
  127791. readonly currentFrameRate: number;
  127792. /**
  127793. * Gets or sets the current target frame rate (60 by default)
  127794. */
  127795. /**
  127796. * Gets or sets the current target frame rate (60 by default)
  127797. */
  127798. targetFrameRate: number;
  127799. /**
  127800. * Gets or sets the current interval between two checks (every 2000ms by default)
  127801. */
  127802. /**
  127803. * Gets or sets the current interval between two checks (every 2000ms by default)
  127804. */
  127805. trackerDuration: number;
  127806. /**
  127807. * Gets the list of active optimizations
  127808. */
  127809. readonly optimizations: SceneOptimization[];
  127810. /**
  127811. * Creates a new SceneOptimizer
  127812. * @param scene defines the scene to work on
  127813. * @param options defines the options to use with the SceneOptimizer
  127814. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127815. * @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)
  127816. */
  127817. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  127818. /**
  127819. * Stops the current optimizer
  127820. */
  127821. stop(): void;
  127822. /**
  127823. * Reset the optimizer to initial step (current priority level = 0)
  127824. */
  127825. reset(): void;
  127826. /**
  127827. * Start the optimizer. By default it will try to reach a specific framerate
  127828. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  127829. */
  127830. start(): void;
  127831. private _checkCurrentState;
  127832. /**
  127833. * Release all resources
  127834. */
  127835. dispose(): void;
  127836. /**
  127837. * Helper function to create a SceneOptimizer with one single line of code
  127838. * @param scene defines the scene to work on
  127839. * @param options defines the options to use with the SceneOptimizer
  127840. * @param onSuccess defines a callback to call on success
  127841. * @param onFailure defines a callback to call on failure
  127842. * @returns the new SceneOptimizer object
  127843. */
  127844. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  127845. }
  127846. }
  127847. declare module BABYLON {
  127848. /**
  127849. * Class used to serialize a scene into a string
  127850. */
  127851. export class SceneSerializer {
  127852. /**
  127853. * Clear cache used by a previous serialization
  127854. */
  127855. static ClearCache(): void;
  127856. /**
  127857. * Serialize a scene into a JSON compatible object
  127858. * @param scene defines the scene to serialize
  127859. * @returns a JSON compatible object
  127860. */
  127861. static Serialize(scene: Scene): any;
  127862. /**
  127863. * Serialize a mesh into a JSON compatible object
  127864. * @param toSerialize defines the mesh to serialize
  127865. * @param withParents defines if parents must be serialized as well
  127866. * @param withChildren defines if children must be serialized as well
  127867. * @returns a JSON compatible object
  127868. */
  127869. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  127870. }
  127871. }
  127872. declare module BABYLON {
  127873. /**
  127874. * Class used to host texture specific utilities
  127875. */
  127876. export class TextureTools {
  127877. /**
  127878. * Uses the GPU to create a copy texture rescaled at a given size
  127879. * @param texture Texture to copy from
  127880. * @param width defines the desired width
  127881. * @param height defines the desired height
  127882. * @param useBilinearMode defines if bilinear mode has to be used
  127883. * @return the generated texture
  127884. */
  127885. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  127886. }
  127887. }
  127888. declare module BABYLON {
  127889. /**
  127890. * This represents the different options available for the video capture.
  127891. */
  127892. export interface VideoRecorderOptions {
  127893. /** Defines the mime type of the video. */
  127894. mimeType: string;
  127895. /** Defines the FPS the video should be recorded at. */
  127896. fps: number;
  127897. /** Defines the chunk size for the recording data. */
  127898. recordChunckSize: number;
  127899. /** The audio tracks to attach to the recording. */
  127900. audioTracks?: MediaStreamTrack[];
  127901. }
  127902. /**
  127903. * This can help with recording videos from BabylonJS.
  127904. * This is based on the available WebRTC functionalities of the browser.
  127905. *
  127906. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  127907. */
  127908. export class VideoRecorder {
  127909. private static readonly _defaultOptions;
  127910. /**
  127911. * Returns whether or not the VideoRecorder is available in your browser.
  127912. * @param engine Defines the Babylon Engine.
  127913. * @returns true if supported otherwise false.
  127914. */
  127915. static IsSupported(engine: Engine): boolean;
  127916. private readonly _options;
  127917. private _canvas;
  127918. private _mediaRecorder;
  127919. private _recordedChunks;
  127920. private _fileName;
  127921. private _resolve;
  127922. private _reject;
  127923. /**
  127924. * True when a recording is already in progress.
  127925. */
  127926. readonly isRecording: boolean;
  127927. /**
  127928. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  127929. * @param engine Defines the BabylonJS Engine you wish to record.
  127930. * @param options Defines options that can be used to customize the capture.
  127931. */
  127932. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  127933. /**
  127934. * Stops the current recording before the default capture timeout passed in the startRecording function.
  127935. */
  127936. stopRecording(): void;
  127937. /**
  127938. * Starts recording the canvas for a max duration specified in parameters.
  127939. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  127940. * If null no automatic download will start and you can rely on the promise to get the data back.
  127941. * @param maxDuration Defines the maximum recording time in seconds.
  127942. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  127943. * @return A promise callback at the end of the recording with the video data in Blob.
  127944. */
  127945. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  127946. /**
  127947. * Releases internal resources used during the recording.
  127948. */
  127949. dispose(): void;
  127950. private _handleDataAvailable;
  127951. private _handleError;
  127952. private _handleStop;
  127953. }
  127954. }
  127955. declare module BABYLON {
  127956. /**
  127957. * Class containing a set of static utilities functions for screenshots
  127958. */
  127959. export class ScreenshotTools {
  127960. /**
  127961. * Captures a screenshot of the current rendering
  127962. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127963. * @param engine defines the rendering engine
  127964. * @param camera defines the source camera
  127965. * @param size This parameter can be set to a single number or to an object with the
  127966. * following (optional) properties: precision, width, height. If a single number is passed,
  127967. * it will be used for both width and height. If an object is passed, the screenshot size
  127968. * will be derived from the parameters. The precision property is a multiplier allowing
  127969. * rendering at a higher or lower resolution
  127970. * @param successCallback defines the callback receives a single parameter which contains the
  127971. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127972. * src parameter of an <img> to display it
  127973. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127974. * Check your browser for supported MIME types
  127975. */
  127976. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  127977. /**
  127978. * Captures a screenshot of the current rendering
  127979. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127980. * @param engine defines the rendering engine
  127981. * @param camera defines the source camera
  127982. * @param size This parameter can be set to a single number or to an object with the
  127983. * following (optional) properties: precision, width, height. If a single number is passed,
  127984. * it will be used for both width and height. If an object is passed, the screenshot size
  127985. * will be derived from the parameters. The precision property is a multiplier allowing
  127986. * rendering at a higher or lower resolution
  127987. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127988. * Check your browser for supported MIME types
  127989. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127990. * to the src parameter of an <img> to display it
  127991. */
  127992. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  127993. /**
  127994. * Generates an image screenshot from the specified camera.
  127995. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127996. * @param engine The engine to use for rendering
  127997. * @param camera The camera to use for rendering
  127998. * @param size This parameter can be set to a single number or to an object with the
  127999. * following (optional) properties: precision, width, height. If a single number is passed,
  128000. * it will be used for both width and height. If an object is passed, the screenshot size
  128001. * will be derived from the parameters. The precision property is a multiplier allowing
  128002. * rendering at a higher or lower resolution
  128003. * @param successCallback The callback receives a single parameter which contains the
  128004. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128005. * src parameter of an <img> to display it
  128006. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128007. * Check your browser for supported MIME types
  128008. * @param samples Texture samples (default: 1)
  128009. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128010. * @param fileName A name for for the downloaded file.
  128011. */
  128012. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128013. /**
  128014. * Generates an image screenshot from the specified camera.
  128015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128016. * @param engine The engine to use for rendering
  128017. * @param camera The camera to use for rendering
  128018. * @param size This parameter can be set to a single number or to an object with the
  128019. * following (optional) properties: precision, width, height. If a single number is passed,
  128020. * it will be used for both width and height. If an object is passed, the screenshot size
  128021. * will be derived from the parameters. The precision property is a multiplier allowing
  128022. * rendering at a higher or lower resolution
  128023. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128024. * Check your browser for supported MIME types
  128025. * @param samples Texture samples (default: 1)
  128026. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128027. * @param fileName A name for for the downloaded file.
  128028. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128029. * to the src parameter of an <img> to display it
  128030. */
  128031. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128032. /**
  128033. * Gets height and width for screenshot size
  128034. * @private
  128035. */
  128036. private static _getScreenshotSize;
  128037. }
  128038. }
  128039. declare module BABYLON {
  128040. /**
  128041. * A cursor which tracks a point on a path
  128042. */
  128043. export class PathCursor {
  128044. private path;
  128045. /**
  128046. * Stores path cursor callbacks for when an onchange event is triggered
  128047. */
  128048. private _onchange;
  128049. /**
  128050. * The value of the path cursor
  128051. */
  128052. value: number;
  128053. /**
  128054. * The animation array of the path cursor
  128055. */
  128056. animations: Animation[];
  128057. /**
  128058. * Initializes the path cursor
  128059. * @param path The path to track
  128060. */
  128061. constructor(path: Path2);
  128062. /**
  128063. * Gets the cursor point on the path
  128064. * @returns A point on the path cursor at the cursor location
  128065. */
  128066. getPoint(): Vector3;
  128067. /**
  128068. * Moves the cursor ahead by the step amount
  128069. * @param step The amount to move the cursor forward
  128070. * @returns This path cursor
  128071. */
  128072. moveAhead(step?: number): PathCursor;
  128073. /**
  128074. * Moves the cursor behind by the step amount
  128075. * @param step The amount to move the cursor back
  128076. * @returns This path cursor
  128077. */
  128078. moveBack(step?: number): PathCursor;
  128079. /**
  128080. * Moves the cursor by the step amount
  128081. * If the step amount is greater than one, an exception is thrown
  128082. * @param step The amount to move the cursor
  128083. * @returns This path cursor
  128084. */
  128085. move(step: number): PathCursor;
  128086. /**
  128087. * Ensures that the value is limited between zero and one
  128088. * @returns This path cursor
  128089. */
  128090. private ensureLimits;
  128091. /**
  128092. * Runs onchange callbacks on change (used by the animation engine)
  128093. * @returns This path cursor
  128094. */
  128095. private raiseOnChange;
  128096. /**
  128097. * Executes a function on change
  128098. * @param f A path cursor onchange callback
  128099. * @returns This path cursor
  128100. */
  128101. onchange(f: (cursor: PathCursor) => void): PathCursor;
  128102. }
  128103. }
  128104. declare module BABYLON {
  128105. /** @hidden */
  128106. export var blurPixelShader: {
  128107. name: string;
  128108. shader: string;
  128109. };
  128110. }
  128111. declare module BABYLON {
  128112. /** @hidden */
  128113. export var pointCloudVertexDeclaration: {
  128114. name: string;
  128115. shader: string;
  128116. };
  128117. }
  128118. // Mixins
  128119. interface Window {
  128120. mozIndexedDB: IDBFactory;
  128121. webkitIndexedDB: IDBFactory;
  128122. msIndexedDB: IDBFactory;
  128123. webkitURL: typeof URL;
  128124. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  128125. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  128126. WebGLRenderingContext: WebGLRenderingContext;
  128127. MSGesture: MSGesture;
  128128. CANNON: any;
  128129. AudioContext: AudioContext;
  128130. webkitAudioContext: AudioContext;
  128131. PointerEvent: any;
  128132. Math: Math;
  128133. Uint8Array: Uint8ArrayConstructor;
  128134. Float32Array: Float32ArrayConstructor;
  128135. mozURL: typeof URL;
  128136. msURL: typeof URL;
  128137. VRFrameData: any; // WebVR, from specs 1.1
  128138. DracoDecoderModule: any;
  128139. setImmediate(handler: (...args: any[]) => void): number;
  128140. }
  128141. interface HTMLCanvasElement {
  128142. requestPointerLock(): void;
  128143. msRequestPointerLock?(): void;
  128144. mozRequestPointerLock?(): void;
  128145. webkitRequestPointerLock?(): void;
  128146. /** Track wether a record is in progress */
  128147. isRecording: boolean;
  128148. /** Capture Stream method defined by some browsers */
  128149. captureStream(fps?: number): MediaStream;
  128150. }
  128151. interface CanvasRenderingContext2D {
  128152. msImageSmoothingEnabled: boolean;
  128153. }
  128154. interface MouseEvent {
  128155. mozMovementX: number;
  128156. mozMovementY: number;
  128157. webkitMovementX: number;
  128158. webkitMovementY: number;
  128159. msMovementX: number;
  128160. msMovementY: number;
  128161. }
  128162. interface Navigator {
  128163. mozGetVRDevices: (any: any) => any;
  128164. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128165. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128166. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128167. webkitGetGamepads(): Gamepad[];
  128168. msGetGamepads(): Gamepad[];
  128169. webkitGamepads(): Gamepad[];
  128170. }
  128171. interface HTMLVideoElement {
  128172. mozSrcObject: any;
  128173. }
  128174. interface Math {
  128175. fround(x: number): number;
  128176. imul(a: number, b: number): number;
  128177. }
  128178. interface WebGLRenderingContext {
  128179. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  128180. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  128181. vertexAttribDivisor(index: number, divisor: number): void;
  128182. createVertexArray(): any;
  128183. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  128184. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  128185. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  128186. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  128187. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  128188. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  128189. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  128190. // Queries
  128191. createQuery(): WebGLQuery;
  128192. deleteQuery(query: WebGLQuery): void;
  128193. beginQuery(target: number, query: WebGLQuery): void;
  128194. endQuery(target: number): void;
  128195. getQueryParameter(query: WebGLQuery, pname: number): any;
  128196. getQuery(target: number, pname: number): any;
  128197. MAX_SAMPLES: number;
  128198. RGBA8: number;
  128199. READ_FRAMEBUFFER: number;
  128200. DRAW_FRAMEBUFFER: number;
  128201. UNIFORM_BUFFER: number;
  128202. HALF_FLOAT_OES: number;
  128203. RGBA16F: number;
  128204. RGBA32F: number;
  128205. R32F: number;
  128206. RG32F: number;
  128207. RGB32F: number;
  128208. R16F: number;
  128209. RG16F: number;
  128210. RGB16F: number;
  128211. RED: number;
  128212. RG: number;
  128213. R8: number;
  128214. RG8: number;
  128215. UNSIGNED_INT_24_8: number;
  128216. DEPTH24_STENCIL8: number;
  128217. /* Multiple Render Targets */
  128218. drawBuffers(buffers: number[]): void;
  128219. readBuffer(src: number): void;
  128220. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  128221. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  128222. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  128223. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  128224. // Occlusion Query
  128225. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  128226. ANY_SAMPLES_PASSED: number;
  128227. QUERY_RESULT_AVAILABLE: number;
  128228. QUERY_RESULT: number;
  128229. }
  128230. interface WebGLProgram {
  128231. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  128232. }
  128233. interface EXT_disjoint_timer_query {
  128234. QUERY_COUNTER_BITS_EXT: number;
  128235. TIME_ELAPSED_EXT: number;
  128236. TIMESTAMP_EXT: number;
  128237. GPU_DISJOINT_EXT: number;
  128238. QUERY_RESULT_EXT: number;
  128239. QUERY_RESULT_AVAILABLE_EXT: number;
  128240. queryCounterEXT(query: WebGLQuery, target: number): void;
  128241. createQueryEXT(): WebGLQuery;
  128242. beginQueryEXT(target: number, query: WebGLQuery): void;
  128243. endQueryEXT(target: number): void;
  128244. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  128245. deleteQueryEXT(query: WebGLQuery): void;
  128246. }
  128247. interface WebGLUniformLocation {
  128248. _currentState: any;
  128249. }
  128250. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  128251. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  128252. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  128253. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128254. interface WebGLRenderingContext {
  128255. readonly RASTERIZER_DISCARD: number;
  128256. readonly DEPTH_COMPONENT24: number;
  128257. readonly TEXTURE_3D: number;
  128258. readonly TEXTURE_2D_ARRAY: number;
  128259. readonly TEXTURE_COMPARE_FUNC: number;
  128260. readonly TEXTURE_COMPARE_MODE: number;
  128261. readonly COMPARE_REF_TO_TEXTURE: number;
  128262. readonly TEXTURE_WRAP_R: number;
  128263. readonly HALF_FLOAT: number;
  128264. readonly RGB8: number;
  128265. readonly RED_INTEGER: number;
  128266. readonly RG_INTEGER: number;
  128267. readonly RGB_INTEGER: number;
  128268. readonly RGBA_INTEGER: number;
  128269. readonly R8_SNORM: number;
  128270. readonly RG8_SNORM: number;
  128271. readonly RGB8_SNORM: number;
  128272. readonly RGBA8_SNORM: number;
  128273. readonly R8I: number;
  128274. readonly RG8I: number;
  128275. readonly RGB8I: number;
  128276. readonly RGBA8I: number;
  128277. readonly R8UI: number;
  128278. readonly RG8UI: number;
  128279. readonly RGB8UI: number;
  128280. readonly RGBA8UI: number;
  128281. readonly R16I: number;
  128282. readonly RG16I: number;
  128283. readonly RGB16I: number;
  128284. readonly RGBA16I: number;
  128285. readonly R16UI: number;
  128286. readonly RG16UI: number;
  128287. readonly RGB16UI: number;
  128288. readonly RGBA16UI: number;
  128289. readonly R32I: number;
  128290. readonly RG32I: number;
  128291. readonly RGB32I: number;
  128292. readonly RGBA32I: number;
  128293. readonly R32UI: number;
  128294. readonly RG32UI: number;
  128295. readonly RGB32UI: number;
  128296. readonly RGBA32UI: number;
  128297. readonly RGB10_A2UI: number;
  128298. readonly R11F_G11F_B10F: number;
  128299. readonly RGB9_E5: number;
  128300. readonly RGB10_A2: number;
  128301. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  128302. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  128303. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  128304. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  128305. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  128306. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  128307. 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;
  128308. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  128309. readonly TRANSFORM_FEEDBACK: number;
  128310. readonly INTERLEAVED_ATTRIBS: number;
  128311. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  128312. createTransformFeedback(): WebGLTransformFeedback;
  128313. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  128314. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  128315. beginTransformFeedback(primitiveMode: number): void;
  128316. endTransformFeedback(): void;
  128317. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  128318. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128319. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128320. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128321. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  128322. }
  128323. interface ImageBitmap {
  128324. readonly width: number;
  128325. readonly height: number;
  128326. close(): void;
  128327. }
  128328. interface WebGLQuery extends WebGLObject {
  128329. }
  128330. declare var WebGLQuery: {
  128331. prototype: WebGLQuery;
  128332. new(): WebGLQuery;
  128333. };
  128334. interface WebGLSampler extends WebGLObject {
  128335. }
  128336. declare var WebGLSampler: {
  128337. prototype: WebGLSampler;
  128338. new(): WebGLSampler;
  128339. };
  128340. interface WebGLSync extends WebGLObject {
  128341. }
  128342. declare var WebGLSync: {
  128343. prototype: WebGLSync;
  128344. new(): WebGLSync;
  128345. };
  128346. interface WebGLTransformFeedback extends WebGLObject {
  128347. }
  128348. declare var WebGLTransformFeedback: {
  128349. prototype: WebGLTransformFeedback;
  128350. new(): WebGLTransformFeedback;
  128351. };
  128352. interface WebGLVertexArrayObject extends WebGLObject {
  128353. }
  128354. declare var WebGLVertexArrayObject: {
  128355. prototype: WebGLVertexArrayObject;
  128356. new(): WebGLVertexArrayObject;
  128357. };
  128358. // Type definitions for WebVR API
  128359. // Project: https://w3c.github.io/webvr/
  128360. // Definitions by: six a <https://github.com/lostfictions>
  128361. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128362. interface VRDisplay extends EventTarget {
  128363. /**
  128364. * Dictionary of capabilities describing the VRDisplay.
  128365. */
  128366. readonly capabilities: VRDisplayCapabilities;
  128367. /**
  128368. * z-depth defining the far plane of the eye view frustum
  128369. * enables mapping of values in the render target depth
  128370. * attachment to scene coordinates. Initially set to 10000.0.
  128371. */
  128372. depthFar: number;
  128373. /**
  128374. * z-depth defining the near plane of the eye view frustum
  128375. * enables mapping of values in the render target depth
  128376. * attachment to scene coordinates. Initially set to 0.01.
  128377. */
  128378. depthNear: number;
  128379. /**
  128380. * An identifier for this distinct VRDisplay. Used as an
  128381. * association point in the Gamepad API.
  128382. */
  128383. readonly displayId: number;
  128384. /**
  128385. * A display name, a user-readable name identifying it.
  128386. */
  128387. readonly displayName: string;
  128388. readonly isConnected: boolean;
  128389. readonly isPresenting: boolean;
  128390. /**
  128391. * If this VRDisplay supports room-scale experiences, the optional
  128392. * stage attribute contains details on the room-scale parameters.
  128393. */
  128394. readonly stageParameters: VRStageParameters | null;
  128395. /**
  128396. * Passing the value returned by `requestAnimationFrame` to
  128397. * `cancelAnimationFrame` will unregister the callback.
  128398. * @param handle Define the hanle of the request to cancel
  128399. */
  128400. cancelAnimationFrame(handle: number): void;
  128401. /**
  128402. * Stops presenting to the VRDisplay.
  128403. * @returns a promise to know when it stopped
  128404. */
  128405. exitPresent(): Promise<void>;
  128406. /**
  128407. * Return the current VREyeParameters for the given eye.
  128408. * @param whichEye Define the eye we want the parameter for
  128409. * @returns the eye parameters
  128410. */
  128411. getEyeParameters(whichEye: string): VREyeParameters;
  128412. /**
  128413. * Populates the passed VRFrameData with the information required to render
  128414. * the current frame.
  128415. * @param frameData Define the data structure to populate
  128416. * @returns true if ok otherwise false
  128417. */
  128418. getFrameData(frameData: VRFrameData): boolean;
  128419. /**
  128420. * Get the layers currently being presented.
  128421. * @returns the list of VR layers
  128422. */
  128423. getLayers(): VRLayer[];
  128424. /**
  128425. * Return a VRPose containing the future predicted pose of the VRDisplay
  128426. * when the current frame will be presented. The value returned will not
  128427. * change until JavaScript has returned control to the browser.
  128428. *
  128429. * The VRPose will contain the position, orientation, velocity,
  128430. * and acceleration of each of these properties.
  128431. * @returns the pose object
  128432. */
  128433. getPose(): VRPose;
  128434. /**
  128435. * Return the current instantaneous pose of the VRDisplay, with no
  128436. * prediction applied.
  128437. * @returns the current instantaneous pose
  128438. */
  128439. getImmediatePose(): VRPose;
  128440. /**
  128441. * The callback passed to `requestAnimationFrame` will be called
  128442. * any time a new frame should be rendered. When the VRDisplay is
  128443. * presenting the callback will be called at the native refresh
  128444. * rate of the HMD. When not presenting this function acts
  128445. * identically to how window.requestAnimationFrame acts. Content should
  128446. * make no assumptions of frame rate or vsync behavior as the HMD runs
  128447. * asynchronously from other displays and at differing refresh rates.
  128448. * @param callback Define the eaction to run next frame
  128449. * @returns the request handle it
  128450. */
  128451. requestAnimationFrame(callback: FrameRequestCallback): number;
  128452. /**
  128453. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  128454. * Repeat calls while already presenting will update the VRLayers being displayed.
  128455. * @param layers Define the list of layer to present
  128456. * @returns a promise to know when the request has been fulfilled
  128457. */
  128458. requestPresent(layers: VRLayer[]): Promise<void>;
  128459. /**
  128460. * Reset the pose for this display, treating its current position and
  128461. * orientation as the "origin/zero" values. VRPose.position,
  128462. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  128463. * updated when calling resetPose(). This should be called in only
  128464. * sitting-space experiences.
  128465. */
  128466. resetPose(): void;
  128467. /**
  128468. * The VRLayer provided to the VRDisplay will be captured and presented
  128469. * in the HMD. Calling this function has the same effect on the source
  128470. * canvas as any other operation that uses its source image, and canvases
  128471. * created without preserveDrawingBuffer set to true will be cleared.
  128472. * @param pose Define the pose to submit
  128473. */
  128474. submitFrame(pose?: VRPose): void;
  128475. }
  128476. declare var VRDisplay: {
  128477. prototype: VRDisplay;
  128478. new(): VRDisplay;
  128479. };
  128480. interface VRLayer {
  128481. leftBounds?: number[] | Float32Array | null;
  128482. rightBounds?: number[] | Float32Array | null;
  128483. source?: HTMLCanvasElement | null;
  128484. }
  128485. interface VRDisplayCapabilities {
  128486. readonly canPresent: boolean;
  128487. readonly hasExternalDisplay: boolean;
  128488. readonly hasOrientation: boolean;
  128489. readonly hasPosition: boolean;
  128490. readonly maxLayers: number;
  128491. }
  128492. interface VREyeParameters {
  128493. /** @deprecated */
  128494. readonly fieldOfView: VRFieldOfView;
  128495. readonly offset: Float32Array;
  128496. readonly renderHeight: number;
  128497. readonly renderWidth: number;
  128498. }
  128499. interface VRFieldOfView {
  128500. readonly downDegrees: number;
  128501. readonly leftDegrees: number;
  128502. readonly rightDegrees: number;
  128503. readonly upDegrees: number;
  128504. }
  128505. interface VRFrameData {
  128506. readonly leftProjectionMatrix: Float32Array;
  128507. readonly leftViewMatrix: Float32Array;
  128508. readonly pose: VRPose;
  128509. readonly rightProjectionMatrix: Float32Array;
  128510. readonly rightViewMatrix: Float32Array;
  128511. readonly timestamp: number;
  128512. }
  128513. interface VRPose {
  128514. readonly angularAcceleration: Float32Array | null;
  128515. readonly angularVelocity: Float32Array | null;
  128516. readonly linearAcceleration: Float32Array | null;
  128517. readonly linearVelocity: Float32Array | null;
  128518. readonly orientation: Float32Array | null;
  128519. readonly position: Float32Array | null;
  128520. readonly timestamp: number;
  128521. }
  128522. interface VRStageParameters {
  128523. sittingToStandingTransform?: Float32Array;
  128524. sizeX?: number;
  128525. sizeY?: number;
  128526. }
  128527. interface Navigator {
  128528. getVRDisplays(): Promise<VRDisplay[]>;
  128529. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  128530. }
  128531. interface Window {
  128532. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  128533. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  128534. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  128535. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128536. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128537. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  128538. }
  128539. interface Gamepad {
  128540. readonly displayId: number;
  128541. }
  128542. type XRSessionMode =
  128543. | "inline"
  128544. | "immersive-vr"
  128545. | "immersive-ar";
  128546. type XRReferenceSpaceType =
  128547. | "viewer"
  128548. | "local"
  128549. | "local-floor"
  128550. | "bounded-floor"
  128551. | "unbounded";
  128552. type XREnvironmentBlendMode =
  128553. | "opaque"
  128554. | "additive"
  128555. | "alpha-blend";
  128556. type XRVisibilityState =
  128557. | "visible"
  128558. | "visible-blurred"
  128559. | "hidden";
  128560. type XRHandedness =
  128561. | "none"
  128562. | "left"
  128563. | "right";
  128564. type XRTargetRayMode =
  128565. | "gaze"
  128566. | "tracked-pointer"
  128567. | "screen";
  128568. type XREye =
  128569. | "none"
  128570. | "left"
  128571. | "right";
  128572. interface XRSpace extends EventTarget {
  128573. }
  128574. interface XRRenderState {
  128575. depthNear?: number;
  128576. depthFar?: number;
  128577. inlineVerticalFieldOfView?: number;
  128578. baseLayer?: XRWebGLLayer;
  128579. }
  128580. interface XRInputSource {
  128581. handedness: XRHandedness;
  128582. targetRayMode: XRTargetRayMode;
  128583. targetRaySpace: XRSpace;
  128584. gripSpace: XRSpace | undefined;
  128585. gamepad: Gamepad | undefined;
  128586. profiles: Array<string>;
  128587. }
  128588. interface XRSession {
  128589. addEventListener: Function;
  128590. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128591. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128592. requestAnimationFrame: Function;
  128593. end(): Promise<void>;
  128594. renderState: XRRenderState;
  128595. inputSources: Array<XRInputSource>;
  128596. }
  128597. interface XRReferenceSpace extends XRSpace {
  128598. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128599. onreset: any;
  128600. }
  128601. interface XRFrame {
  128602. session: XRSession;
  128603. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128604. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128605. }
  128606. interface XRViewerPose extends XRPose {
  128607. views: Array<XRView>;
  128608. }
  128609. interface XRPose {
  128610. transform: XRRigidTransform;
  128611. emulatedPosition: boolean;
  128612. }
  128613. declare var XRWebGLLayer: {
  128614. prototype: XRWebGLLayer;
  128615. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128616. };
  128617. interface XRWebGLLayer {
  128618. framebuffer: WebGLFramebuffer;
  128619. framebufferWidth: number;
  128620. framebufferHeight: number;
  128621. getViewport: Function;
  128622. }
  128623. interface XRRigidTransform {
  128624. position: DOMPointReadOnly;
  128625. orientation: DOMPointReadOnly;
  128626. matrix: Float32Array;
  128627. inverse: XRRigidTransform;
  128628. }
  128629. interface XRView {
  128630. eye: XREye;
  128631. projectionMatrix: Float32Array;
  128632. transform: XRRigidTransform;
  128633. }
  128634. interface XRInputSourceChangeEvent {
  128635. session: XRSession;
  128636. removed: Array<XRInputSource>;
  128637. added: Array<XRInputSource>;
  128638. }